The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
NewArrayExpression.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: NewArrayExpression.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a new array expression. //
9 // Inheritance: Expression. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 17-01-2007 //
14 // Modification date: 26-03-2007 //
16 
17 using System;
18 using AST.Operations;
19 using ErrorManagement;
20 using Tools;
21 
22 namespace AST
23 {
33  {
34  #region Fields
35 
39  private string typeInfo;
40 
44  private CompoundExpression init;
45 
49  private int rank = 1;
50 
54  private Expression size;
55 
59  private string identifier;
60 
61  #endregion
62 
63  #region Properties
64 
68  public string TypeInfo
69  {
70  get { return this.typeInfo; }
71  }
72 
77  {
78  get { return this.init; }
79  set
80  {
81  this.init = value;
82  if (this.size == null)
83  this.size = new IntLiteralExpression(this.init.ExpressionCount, this.Location);
84  }
85  }
86 
90  public int Rank
91  {
92  get { return this.rank; }
93  set { this.rank = value; }
94  }
95 
99  public Expression Size
100  {
101  get { return this.size; }
102  set { this.size = value; }
103  }
104 
108  public string Identifier
109  {
110  get { return this.identifier; }
111  set { this.identifier = value; }
112  }
113 
114  #endregion
115 
116  #region Constructor
117 
126  public NewArrayExpression(string arrayType, Location location)
127  : base(location)
128  {
129  this.typeInfo = arrayType;
130  }
131 
132  #endregion
133 
134  #region Accept()
135 
142  public override Object Accept(Visitor v, Object o)
143  {
144  return v.Visit(this, o);
145  }
146 
147  #endregion
148 
149  #region Dispatcher AstOperation
150  public override object AcceptOperation(AstOperation op, object arg) {
158  return op.Exec(this, arg);
159  }
160 
161  #endregion
162  }
163 }
string Identifier
Gets or sets the auxiliar variable identifier used to store the new array in code generation...
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
override object AcceptOperation(AstOperation op, object arg)
Dispatches expressions to the operation passed as argument. It provokes the execution of op...
Abstract class to define different visits over the abstract syntax tree.
Definition: Visitor.cs:29
This class encapsulates a location in a specific file. Implements an Inmutable pattern. So it can be used in any context, that is his internal fields never change.
Definition: Location.cs:24
This class represent the entry wnen sending a message to an operation object. derived from AstNode ...
string TypeInfo
Gets the name of the new type
int ExpressionCount
Gets the number of expressions.
Encapsulates a set of expressions.
CompoundExpression Init
Gets or sets the array initialization
Encapsulates a new array expression.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
Expression Size
Gets or sets the array size
Encapsulates a integer literal expression.
NewArrayExpression(string arrayType, Location location)
Constructor of NewArrayExpression
int Rank
Gets or sets the array rank