entities
Class SwitchExpression

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

public class SwitchExpression
extends Expression

The class SwitchExpression represents an switch-statement


Field Summary
 
Fields inherited from class entities.Expression
fCast, fFile, fLBracketPosition, fOperator, fParentScope, fPosition, fPreviousExpression, fRBracketPosition, fToTrace, fTypeOfCast, SEPARATORS
 
Constructor Summary
SwitchExpression(ScopeManager parentScope)
           
 
Method Summary
 void addCase(CaseExpression caseExpr)
           
 void addExpression(Expression expr, ScopeManager wrapper)
          Add an object of type CaseExpression to the switch
 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.
 java.util.Vector getCases()
           
 Expression getSelector()
           
 java.lang.String getString()
           
 void print(java.lang.String indentation)
          Empty
 void setSelector(Expression expr)
          The parameter "expr" represents the expression found after the keyword switch
 
Methods inherited from class entities.Expression
addClass, addClassHeaderFile, addEnumerator, 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

SwitchExpression

public SwitchExpression(ScopeManager parentScope)
Method Detail

getSelector

public Expression getSelector()
Returns:
the object (of type Expression) corresponding to the expression found after the keyword switch
 
 Ex: switch (a) {...}
 
In this case it returns the SimpleVariable corresponding to the variable "a"

getCases

public java.util.Vector getCases()
Returns:
the Vector containing the objects (of type Expression) corresponding to case blocks
 
 Ex: switch (a) {
         case 1:  ... break;
         case 2:  ... break;
         case 3:  ... break;
 }
 
In this case it returns a Vector containing 3 CaseExpression associated to the 3 case statements

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)

addCase

public void addCase(CaseExpression caseExpr)
Parameters:
caseExpr - represents a case statement inside a switch

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

setSelector

public void setSelector(Expression expr)
The parameter "expr" represents the expression found after the keyword switch
 
 Ex: switch (a) {...}
 
In this case "expr" is the SimpleVariable corresponding to the variable "a"


addExpression

public void addExpression(Expression expr,
                          ScopeManager wrapper)
Add an object of type CaseExpression to the switch

Specified by:
addExpression in interface ScopeManager
Overrides:
addExpression 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)
Description copied from class: Expression
Empty

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