The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
WhileStatement.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: WhileStatement.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a While statement of our programming languages. //
9 // Inheritance: Statement. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 05-12-2006 //
14 // Modification date: 25-04-2007 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 
21 using Tools;
22 using ErrorManagement;
23 
24 namespace AST
25 {
34  public class WhileStatement : Statement
35  {
36  #region Fields
37 
41  private Expression condition;
42 
46  private Statement whileStatement;
47 
51  private List<MoveStatement> initWhile;
52 
56  private List<ThetaStatement> beforeCondition;
57 
61  private List<MoveStatement> afterCondition;
62 
63  #endregion
64 
65  #region Properties
66 
70  public Expression Condition
71  {
72  get { return condition; }
73  set { this.condition = value; }
74  }
75 
79  public Statement Statements
80  {
81  get { return whileStatement; }
82  }
83 
87  public List<MoveStatement> InitWhile
88  {
89  get { return this.initWhile; }
90  set { this.initWhile = value; }
91  }
92 
96  public List<MoveStatement> AfterCondition
97  {
98  get { return this.afterCondition; }
99  set { this.afterCondition = value; }
100  }
101 
105  public List<ThetaStatement> BeforeCondition
106  {
107  get { return this.beforeCondition; }
108  set { this.beforeCondition = value; }
109  }
110 
111  #endregion
112 
113  #region Constructor
114 
124  : base(location)
125  {
126  this.condition = cond;
127  this.whileStatement = statements;
128  this.initWhile = new List<MoveStatement>();
129  this.beforeCondition = new List<ThetaStatement>();
130  this.afterCondition = new List<MoveStatement>();
131  }
132 
133  #endregion
134 
135  #region Accept()
136 
143  public override Object Accept(Visitor v, Object o)
144  {
145  return v.Visit(this, o);
146  }
147 
148  #endregion
149  }
150 }
Abstract class encapsulate a programming language expression.
Definition: Expression.cs:37
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Statement Statements
Gets the block executed when the condition is true.
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
Abstract class represents a programming language statement.
Definition: Statement.cs:30
List< MoveStatement > AfterCondition
Gets or sets the statements after condition.
Encapsulates a While statement of our programming languages.
Expression Condition
Gets the condition expression of While Statement.
WhileStatement(Expression cond, Statement statements, Location location)
Constructor of WhileStatement
List< MoveStatement > InitWhile
Gets or sets the statements to use at the init of the while loop.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
List< ThetaStatement > BeforeCondition
Gets or sets the statements before condition.