The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
ThetaStatement.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: ThetaStatement.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a Theta function to use in SSA algorithm. //
9 // Inheritance: Statement. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 06-04-2007 //
14 // Modification date: 10-05-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 ThetaStatement : Statement
35  {
36  #region Fields
37 
41  private List<SingleIdentifierExpression> thetaList;
42 
46  private SingleIdentifierExpression thetaId;
47 
48  #endregion
49 
50  #region Properties
51 
55  public List<SingleIdentifierExpression> ThetaList
56  {
57  get { return this.thetaList; }
58  }
59 
64  {
65  get { return this.thetaId; }
66  }
67 
68  #endregion
69 
70  #region Constructor
71 
79  public ThetaStatement(SingleIdentifierExpression id, List<SingleIdentifierExpression> list, Location location)
80  : base(location)
81  {
82  this.thetaId = id;
83  this.thetaList = new List<SingleIdentifierExpression>();
84  if (list.Count != 0)
85  insertElements(list);
86  }
87 
88  #endregion
89 
90  #region containsValue
91 
98  private bool containsValue(string id, int index)
99  {
100  for (int i = 0; i < this.thetaList.Count; i++)
101  {
102  if (thetaList[i].Identifier.Equals(id))
103  if (thetaList[i].IndexOfSSA == index)
104  return true;
105  }
106  return false;
107  }
108 
109  #endregion
110 
111  #region insertElements
112 
117  private void insertElements(List<SingleIdentifierExpression> list)
118  {
119  for (int i = 0; i < list.Count; i++)
120  {
121  if (!(containsValue(list[i].Identifier, list[i].IndexOfSSA)))
122  this.thetaList.Add(list[i]);
123  }
124  }
125 
126  #endregion
127 
128  #region Accept()
129 
136  public override Object Accept(Visitor v, Object o)
137  {
138  return v.Visit(this, o);
139  }
140 
141  #endregion
142  }
143 }
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
Encapsulates a identifier expression of our programming language.
Encapsulates a Theta function to use in SSA algorithm.
SingleIdentifierExpression ThetaId
Gets the expression
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
List< SingleIdentifierExpression > ThetaList
Gets the parameter of theta funcion
ThetaStatement(SingleIdentifierExpression id, List< SingleIdentifierExpression > list, Location location)
Constructor of ThetaStatement