The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
Expression.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: Expression.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Abstract class encapsulate a programming language expression. //
9 // Inheritance: Statement. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 04-12-2006 //
14 // Modification date: 09-04-2007 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 
21 using Tools;
22 using TypeSystem;
23 
24 using ErrorManagement;
25 using AST.Operations;
26 
27 namespace AST
28 {
37  public abstract class Expression : Statement
38  {
39  #region Fields
40 
44  private TypeExpression expressionType;
45 
49  private bool lvalue;
50 
54  private bool leftExpression = false;
55 
62 
63  #endregion
64 
65  #region Properties
66 
71  {
72  get { return this.expressionType; }
73  set { this.expressionType = value; }
74  }
75 
79  public bool Lvalue
80  {
81  get { return this.lvalue; }
82  set { this.lvalue = value; }
83  }
84 
88  public bool LeftExpression
89  {
90  get { return this.leftExpression; }
91  set { this.leftExpression = value; }
92  }
93 
97  public virtual TypeExpression ILTypeExpression
98  {
99  get
100  {
101  if (this.frozenTypeExpression != null)
102  return this.frozenTypeExpression;
103  else
104  return this.expressionType;
105  }
106  }
107 
108  #endregion
109 
110  #region Constructor
111 
118  protected Expression(Location location):base(location)
119  {
120  }
121 
122  #endregion
123 
124  #region CloneInit()
125 
131  {
132  return (Expression)this.MemberwiseClone();
133  }
134 
135  #endregion
136 
137  #region Dispatcher AstOperation
138  public override object AcceptOperation(AstOperation op, object arg) {
146  return op.Exec(this, arg);
147  }
148 
149  #endregion
150  }
151 }
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
TypeExpression ExpressionType
Gets or sets the type of the expression.
Definition: Expression.cs:71
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
Abstract class represents a programming language statement.
Definition: Statement.cs:30
bool Lvalue
Gets or sets the lvalue.
Definition: Expression.cs:80
override object AcceptOperation(AstOperation op, object arg)
Dispatches expressions to the operation passed as argument. It provokes the execution of op...
Definition: Expression.cs:145
This class represent the entry wnen sending a message to an operation object. derived from AstNode ...
Abstract class that represents all different types.
Expression CloneInit()
Clones the initialization of the current object.
Definition: Expression.cs:130
bool LeftExpression
Gets or sets true if the expression is allocated in the left part of an assignment, false otherwise.
Definition: Expression.cs:89
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
Expression(Location location)
Protected constructor of Expresion.
Definition: Expression.cs:118
TypeExpression frozenTypeExpression
WriteType variable may change its type's substitution (e.g., field type variables) This attribute sav...
Definition: Expression.cs:61
virtual TypeExpression ILTypeExpression
Gets the type expression to use in code generation.
Definition: Expression.cs:98