entities
Class IfExpression

java.lang.Object
  extended byentities.Expression
      extended byentities.IfExpression
All Implemented Interfaces:
ScopeManager

public class IfExpression
extends Expression

The class IfExpression represents an if-statement


Field Summary
 
Fields inherited from class entities.Expression
fCast, fFile, fLBracketPosition, fOperator, fParentScope, fPosition, fPreviousExpression, fRBracketPosition, fToTrace, fTypeOfCast, SEPARATORS
 
Constructor Summary
IfExpression(ScopeManager parentScope)
           
 
Method Summary
 void computeType(ScopeInfo scopeInfo, java.lang.String indentation)
          This method, properly overwritten in the subclasses, computes recursively the types of variables involved in the expressions
 ScopeManager findVariableType(java.lang.String nameToBeFound, java.lang.StringBuffer typeToBeFound, Expression expr)
          Look for the variable declaration whose name is "nameToBeFound" and return the ScopeManager in which it is defined (if found), filling "typeToBeFound" with the variabl type.
 Expression getCondition()
           
 Expression getElsePart()
           
 java.lang.String getString()
           
 Expression getThenPart()
           
 void print(java.lang.String indentation)
          Print all information
 void setCondition(Expression expr, ScopeManager wrapper)
          The expression "expr" is used to represent the condition after the keyword "if"
 void setElsePart(ElseExpression elseExpr)
          The expression "elsePart" is used to represent all the statements associated with the else
 void setThenPart(ThenExpression thenExpr)
          The expression "thenPart" is used to represent all the statements of the then block
 
Methods inherited from class entities.Expression
addClass, addClassHeaderFile, addEnumerator, addExpression, addExternalField, addExternalMethod, addField, addFriendClass, addFriendFunction, addFriendMethod, addFunction, addGeneralization, addMethod, addNameSpace, addType, addUserType, addVariable, cleanType, fillName, fillNameNew, getAllocationType, getCast, getCastType, getClassContext, getContainingMethod, getContext, getContextNew, getCurrentMethod, getFile, getLBracketPosition, getName, getOperator, getOperators, getParent, getParentScope, getPosition, getPreviousExpression, getRBracketPosition, getType, getTypeOfCast, propagateParentScope, resolveType, setCast, setFile, setLBracketPosition, setOperator, setParentScope, setPosition, setPreviousExpression, setRBracketPosition, setTypeOfCast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IfExpression

public IfExpression(ScopeManager parentScope)
Method Detail

getCondition

public Expression getCondition()
Returns:
the object (of type Expression) corresponding to the condition statement
 
 Ex: if (i>0) {...}
 
In this case it returns the CompositeExpression corresponding to the statement "i>0"

getThenPart

public Expression getThenPart()
Returns:
the object (of type Expression) corresponding to the then block.

getElsePart

public Expression getElsePart()
Returns:
the object (of type Expression) corresponding to the else block.

getString

public java.lang.String getString()
Overrides:
getString in class Expression
Returns:
the representation of the Expression as a String (it is not a thorough reconstruction)

setCondition

public void setCondition(Expression expr,
                         ScopeManager wrapper)
The expression "expr" is used to represent the condition after the keyword "if"
 Ex: if (a>b) {...} 
 
The parameter "expr" represents the expression "a>b"


setThenPart

public void setThenPart(ThenExpression thenExpr)
The expression "thenPart" is used to represent all the statements of the then block

Ex: if (a>b) {...}

In this case "thenPart" represents all the statements inside the "{}"


setElsePart

public void setElsePart(ElseExpression elseExpr)
The expression "elsePart" is used to represent all the statements associated with the else

Ex: if (a>b) {...} else {....}

In this case elsePart represents all the statements inside the "{}" after the keyword else


computeType

public void computeType(ScopeInfo scopeInfo,
                        java.lang.String indentation)
Description copied from class: Expression
This method, properly overwritten in the subclasses, computes recursively the types of variables involved in the expressions

Overrides:
computeType in class Expression

findVariableType

public ScopeManager findVariableType(java.lang.String nameToBeFound,
                                     java.lang.StringBuffer typeToBeFound,
                                     Expression expr)
Description copied from class: Expression
Look for the variable declaration whose name is "nameToBeFound" and return the ScopeManager in which it is defined (if found), filling "typeToBeFound" with the variabl type.

Specified by:
findVariableType in interface ScopeManager
Overrides:
findVariableType in class Expression

print

public void print(java.lang.String indentation)
Print all information

Specified by:
print in interface ScopeManager
Overrides:
print in class Expression