18 using System.Collections.Generic;
23 using ErrorManagement;
25 namespace Semantic.SSAAlgorithm
50 #region Visit(Definition node, Object obj)
54 node.Init.Accept(
this, obj);
60 #region Visit(ConstantDefinition node, Object obj)
64 node.Init.Accept(
this, obj);
70 #region Visit(FieldDefinition node, Object obj)
74 node.Init.Accept(
this, obj);
80 #region Visit(ConstantFieldDefinition node, Object obj)
84 node.Init.Accept(
this, obj);
92 #region createMoveStatement
97 left.IndexOfSSA = mapY.Search(id) + 1;
99 right.IndexOfSSA = mapX.Search(id);
103 private MoveStatement createMoveStatement(
string id, SSAMap mapX,
string filename,
int line)
106 left.IndexOfSSA = mapX.Search(id);
108 right.IndexOfSSA = mapX.Search(id) - 1;
114 #region Visit(AssignmentExpression node, Object obj)
125 if ((mapX = ((SSAInfo)obj).FirstOperandToMove) != null)
129 if ((mapY = ((SSAInfo)obj).SecondOperandToMove) != null)
131 if (((SingleIdentifierExpression)node.
FirstOperand).IndexOfSSA == mapX.Search(((SingleIdentifierExpression)node.
FirstOperand).Identifier))
137 node.
MoveStat = createMoveStatement(((SingleIdentifierExpression)node.
FirstOperand).Identifier, mapX, node.Location.FileName, node.Location.Line);
143 node.FirstOperand.Accept(
this, obj);
144 node.SecondOperand.Accept(
this, obj);
147 node.MoveStat.Accept(
this, obj);
153 #region Visit(MoveStatement node, Object obj)
162 if ((mapX = ((SSAInfo)obj).FirstOperandToMove) != null)
166 if ((mapY = ((SSAInfo)obj).SecondOperandToMove) != null)
179 node.RightExp.Accept(
this, obj);
182 node.MoveStat.Accept(
this, obj);
189 #region Visit(SingleIdentifierExpression node, Object obj)
198 if (((mapX = ((SSAInfo)obj).FirstOperandToUpdateId) != null) && ((mapY = ((SSAInfo)obj).SecondOperandToUpdateId) != null))
205 if (((iValueX = mapX.
Search(node.
Identifier)) != -1) && ((iValueY = mapY.Search(node.Identifier)) != -1))
209 if (iValueX != iValueY)
211 node.IndexOfSSA = iValueY;
This class stores the information to use in SSA algorithm
Encapsulates a definition of a concrete field.
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.
MoveStatement MoveStat
Gets or sets a move statement associated to the assignment expression.
Encapsulates a constant field definition.
Encapsulates a definition.
Encapsulates a identifier expression of our programming language.
override Object Visit(Definition node, Object obj)
int Line
Gets line where the item is located
This class makes the second part of static single assignment algorithm in which every variable is ass...
bool LeftExpression
Gets or sets true if the expression is allocated in the left part of an assignment, false otherwise.
Encapsulates assignment binary expressions.
override Object Visit(FieldDefinition node, Object obj)
MoveStatement MoveStat
Gets or sets a move statement associated to the current move statement.
SingleIdentifierExpression LeftExp
Gets the left expression
int IndexOfSSA
Gets or sets the index associated with SSA algorithm
VisitorSSA2()
Constructor of VisitorSSA2
override Object Visit(ConstantFieldDefinition node, Object obj)
Encapsulates a constant definition.
override Object Visit(MoveStatement node, Object obj)
Encapsulates a Move instruction to use in SSA algorithm
override Object Visit(AssignmentExpression node, Object obj)
override Object Visit(SingleIdentifierExpression node, Object obj)
Expression FirstOperand
Gets the first operand of the binary expression
string Identifier
Gets the name name.
Implementation of a map to use in static single assignment algorithm.
string FileName
Gets de name of the file
override Object Visit(ConstantDefinition node, Object obj)
int Search(string id)
Searches the variable specified and returns its associated number.