entities
Class Expression

java.lang.Object
  extended byentities.Expression
All Implemented Interfaces:
ScopeManager
Direct Known Subclasses:
Allocation, Assignment, BreakExpression, Call, CaseExpression, CatchExpression, CompositeExpression, ConstantExpression, ContinueExpression, DeleteExpression, ElseExpression, ForExpression, GotoExpression, IfExpression, ReturnExpression, SimpleVariable, SizeOfExpression, SwitchExpression, ThenExpression, ThrowExpression, TryExpression, WhileExpression

public class Expression
extends java.lang.Object
implements ScopeManager

Represent a generic C++ statement


Field Summary
protected  java.lang.String fCast
          Represents the type to which the expression is cast.
protected  java.lang.String fFile
          The string corresponding to the name of file containing the statement
protected  int fLBracketPosition
          Represent the position of "{" if present
protected  java.lang.String fOperator
          Contains the operators associated with the expression.
protected  ScopeManager fParentScope
          The entity in which the expression is.
protected  int fPosition
          The line corresponding to the statement
protected  Expression fPreviousExpression
          Given an expression A with attribute "fField" not null, the attribute fPreviousExpression of the fField expression is the expression A.
protected  int fRBracketPosition
          Represent the position of "}" if present
protected  boolean fToTrace
          Temporary field to trace the expressions
protected  java.lang.String fTypeOfCast
          If a cast is present fTypeOfCast contains information about the type of cast (dynamic_cast, static_cast, reinterpret_cast, const_cast, typeid, normal)
protected static java.lang.String SEPARATORS
           
 
Constructor Summary
Expression()
           
 
Method Summary
 void addClass(ClassEntity cl)
          Empty
 void addClassHeaderFile(java.lang.String className, java.lang.String headerFileName)
          Empty
 void addEnumerator(Enumerator en)
          Empty
 void addExpression(Expression expr, ScopeManager wrapper)
          Empty
 void addExternalField(Variable variable)
          Empty
 void addExternalMethod(Method method)
          Empty
 void addField(Variable variable)
          Empty
 void addFriendClass(Variable variable)
          Empty
 void addFriendFunction(Function function)
          Empty
 void addFriendMethod(Method method)
          Empty
 void addFunction(Function function)
          Empty
 void addGeneralization(SuperClass superClass)
          Empty
 void addMethod(Method method)
          Empty
 void addNameSpace(NameSpace namespace)
          Empty
 void addType(java.lang.String name, java.lang.String type)
          Empty
 void addUserType(java.lang.String name, java.lang.String type)
          Empty
 void addVariable(Variable var)
          Empty
protected  java.lang.String cleanType(java.lang.String type)
          Remove from "type" the symbols "*", "&", "const"....
 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
 void fillName(java.lang.StringBuffer fullName, java.lang.String type)
          Compute the complete name to be associated to a SimpleVariable or to a Call expression.
 void fillNameNew(java.lang.StringBuffer fullName, java.lang.String type)
          Compute the complete name to be associated to a SimpleVariable or to a Call expression.
 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.lang.String getAllocationType()
           
 java.lang.String getCast()
           
 java.lang.String getCastType()
           
protected  java.lang.String getClassContext(ScopeManager parent)
           
 Method getContainingMethod()
           
protected  java.lang.String getContext(ScopeManager parent)
           
 java.lang.String getContextNew()
           
 Method getCurrentMethod(java.lang.String methodName, java.util.Vector parameters)
           
 java.lang.String getFile()
           
 int getLBracketPosition()
           
 java.lang.String getName()
           
 java.lang.String getOperator()
           
 java.util.Vector getOperators()
           
 ScopeManager getParent()
           
 ScopeManager getParentScope()
           
 int getPosition()
           
 Expression getPreviousExpression()
           
 int getRBracketPosition()
           
 java.lang.String getString()
           
 java.lang.String getType()
          For expressions that have a field corresponding to the type, it returns the type or null
 java.lang.String getTypeOfCast()
           
 void print(java.lang.String indentation)
          Empty
 void propagateParentScope(ScopeManager scope)
          Propagate the scope to related expressions (it is properly overwritten in the subclasses).
 java.lang.String resolveType()
           
 void setCast(java.lang.String cast)
           
 void setFile(java.lang.String file)
           
 void setLBracketPosition(int position)
          Empty
 void setOperator(java.lang.String operator)
           
 void setParentScope(ScopeManager parentScope)
           
 void setPosition(int position)
           
 void setPreviousExpression(Expression expr)
           
 void setRBracketPosition(int position)
          Empty
 void setTypeOfCast(java.lang.String typeOfCast)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fFile

protected java.lang.String fFile
The string corresponding to the name of file containing the statement


fPosition

protected int fPosition
The line corresponding to the statement


fParentScope

protected ScopeManager fParentScope
The entity in which the expression is.

Ex: A a; for(...) {a->b();... }

Both the Expression objects corresponding to a and b have the expression corresponding to the for as parent scope.


fCast

protected java.lang.String fCast
Represents the type to which the expression is cast.

Ex: (A) x; fCast contains A.


fTypeOfCast

protected java.lang.String fTypeOfCast
If a cast is present fTypeOfCast contains information about the type of cast (dynamic_cast, static_cast, reinterpret_cast, const_cast, typeid, normal)


fOperator

protected java.lang.String fOperator
Contains the operators associated with the expression.

Ex: the expression "a + b - c + d" is represented with a CompositeExpression expression with fOperator equals to "+ - +")


fPreviousExpression

protected Expression fPreviousExpression
Given an expression A with attribute "fField" not null, the attribute fPreviousExpression of the fField expression is the expression A.

Ex: a->b(); a->f;

On the Expression object representing the call b() returns the Expression object representing the variable a.

On the Expression object representing the variable f returns the Expression object representing the variable a.


fLBracketPosition

protected int fLBracketPosition
Represent the position of "{" if present


fRBracketPosition

protected int fRBracketPosition
Represent the position of "}" if present


fToTrace

protected boolean fToTrace
Temporary field to trace the expressions


SEPARATORS

protected static final java.lang.String SEPARATORS
See Also:
Constant Field Values
Constructor Detail

Expression

public Expression()
Method Detail

getFile

public java.lang.String getFile()
Returns:
the String corresponding to the name of the file in which the expression has been found

getPosition

public int getPosition()
Returns:
the position (the line) of the statement within the file

getType

public java.lang.String getType()
For expressions that have a field corresponding to the type, it returns the type or null


getCast

public java.lang.String getCast()
Returns:
the String corresponding to the cast

getTypeOfCast

public java.lang.String getTypeOfCast()
Returns:
the String corresponding to the type of cast (dynamic_cast, static_cast, reinterpret_cast, const_cast, typeid, normal)

getParentScope

public ScopeManager getParentScope()
Returns:
the parent scope.
See Also:
fParentScope

getPreviousExpression

public Expression getPreviousExpression()
Returns:
the Expression object having the current Expression object as fField.
See Also:
fPreviousExpression

getString

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

getOperator

public java.lang.String getOperator()
Returns:
the String object associated with the field "fOperator"

See Also:


getOperators

public java.util.Vector getOperators()
Returns:
the Vector containing as elements the operators associated with the expression.

Ex: called on the CompositeExpression representing the expression "a+b-c+d" return the Vector containing the elements "+", "-", "+".


getContext

protected java.lang.String getContext(ScopeManager parent)
Returns:
the String obtained concatenating the name of the entities containing the expression.

getContextNew

public java.lang.String getContextNew()
Returns:
the String obtained concatenating the name of the entities containing the expression.

getClassContext

protected java.lang.String getClassContext(ScopeManager parent)
Returns:
the String obtained concatenating the name of the class entities containing the expression.

getContainingMethod

public Method getContainingMethod()
Returns:
the Method object containing the current expression, if the expression is contained in a method, null otherwise.

getLBracketPosition

public int getLBracketPosition()
Returns:
the position of "{" if it is present, -1 otherwise

getRBracketPosition

public int getRBracketPosition()
Returns:
the position of "}" if it is present, -1 otherwise

setFile

public void setFile(java.lang.String file)
Parameters:
file - represent the name of the file in which the statement has been found

setPosition

public void setPosition(int position)
Parameters:
position - represent the line (the first if it is on more lines) in which the statement has been found

setTypeOfCast

public void setTypeOfCast(java.lang.String typeOfCast)
Parameters:
typeOfCast - represent the type of cast (dynamic_cast, static_cast, reinterpret_cast, const_cast, typeid, normal)

setCast

public void setCast(java.lang.String cast)
Parameters:
cast - represent the cast before the expression if it is present
See Also:
fCast

setOperator

public void setOperator(java.lang.String operator)
Parameters:
operator - represent the operator before the expression if it is present
See Also:
fOperator

print

public void print(java.lang.String indentation)
Empty

Specified by:
print in interface ScopeManager

setParentScope

public void setParentScope(ScopeManager parentScope)
Parameters:
parentScope - represent the entity in which the expression is found
See Also:
fParentScope

setPreviousExpression

public void setPreviousExpression(Expression expr)
Parameters:
expr - represent the expression found before the "." or "->",
See Also:
fPreviousExpression

setLBracketPosition

public void setLBracketPosition(int position)
Empty


setRBracketPosition

public void setRBracketPosition(int position)
Empty


computeType

public 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


propagateParentScope

public void propagateParentScope(ScopeManager scope)
Propagate the scope to related expressions (it is properly overwritten in the subclasses). It is empty.


cleanType

protected java.lang.String cleanType(java.lang.String type)
Remove from "type" the symbols "*", "&", "const"....


resolveType

public java.lang.String resolveType()

fillName

public void fillName(java.lang.StringBuffer fullName,
                     java.lang.String type)
Compute the complete name to be associated to a SimpleVariable or to a Call expression.


fillNameNew

public void fillNameNew(java.lang.StringBuffer fullName,
                        java.lang.String type)
Compute the complete name to be associated to a SimpleVariable or to a Call expression.


getAllocationType

public java.lang.String getAllocationType()
Returns:
null

getCastType

public java.lang.String getCastType()
Returns:
null

addEnumerator

public void addEnumerator(Enumerator en)
Empty

Specified by:
addEnumerator in interface ScopeManager

addNameSpace

public void addNameSpace(NameSpace namespace)
Empty

Specified by:
addNameSpace in interface ScopeManager

addExpression

public void addExpression(Expression expr,
                          ScopeManager wrapper)
Empty

Specified by:
addExpression in interface ScopeManager

addClass

public void addClass(ClassEntity cl)
Empty

Specified by:
addClass in interface ScopeManager

addFunction

public void addFunction(Function function)
Empty

Specified by:
addFunction in interface ScopeManager

addMethod

public void addMethod(Method method)
Empty

Specified by:
addMethod in interface ScopeManager

addVariable

public void addVariable(Variable var)
Empty

Specified by:
addVariable in interface ScopeManager

addField

public void addField(Variable variable)
Empty

Specified by:
addField in interface ScopeManager

addType

public void addType(java.lang.String name,
                    java.lang.String type)
Empty

Specified by:
addType in interface ScopeManager

addUserType

public void addUserType(java.lang.String name,
                        java.lang.String type)
Empty

Specified by:
addUserType in interface ScopeManager

addGeneralization

public void addGeneralization(SuperClass superClass)
Empty

Specified by:
addGeneralization in interface ScopeManager

addExternalMethod

public void addExternalMethod(Method method)
Empty

Specified by:
addExternalMethod in interface ScopeManager

addExternalField

public void addExternalField(Variable variable)
Empty

Specified by:
addExternalField in interface ScopeManager

addFriendFunction

public void addFriendFunction(Function function)
Empty

Specified by:
addFriendFunction in interface ScopeManager

addFriendMethod

public void addFriendMethod(Method method)
Empty

Specified by:
addFriendMethod in interface ScopeManager

addFriendClass

public void addFriendClass(Variable variable)
Empty

Specified by:
addFriendClass in interface ScopeManager

addClassHeaderFile

public void addClassHeaderFile(java.lang.String className,
                               java.lang.String headerFileName)
Empty

Specified by:
addClassHeaderFile in interface ScopeManager

getCurrentMethod

public Method getCurrentMethod(java.lang.String methodName,
                               java.util.Vector parameters)
Specified by:
getCurrentMethod in interface ScopeManager
Returns:
the Method entity associated with the a Call Expression

getName

public java.lang.String getName()
Specified by:
getName in interface ScopeManager
Returns:
the string corresponding to the name of the object

findVariableType

public 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.

Specified by:
findVariableType in interface ScopeManager

getParent

public ScopeManager getParent()
Specified by:
getParent in interface ScopeManager
Returns:
the parent scope