entities
Class SimpleVariable

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

public class SimpleVariable
extends Expression

The class represents a C++ variable


Field Summary
 
Fields inherited from class entities.Expression
fCast, fFile, fLBracketPosition, fOperator, fParentScope, fPosition, fPreviousExpression, fRBracketPosition, fToTrace, fTypeOfCast, SEPARATORS
 
Constructor Summary
SimpleVariable(ScopeManager parentScope)
           
 
Method Summary
 void addIndex(Expression expr)
          Add an Expression object to the index expressions
 void computeType(ScopeInfo inputScopeInfo, java.lang.String indentation)
          This method computes recursively the types on the field and on the elements of index expressions
 void fillName(java.lang.StringBuffer fullName, java.lang.String previousType)
          Compute the complete name to associate to a SimpleVariable
 void fillNameNew(java.lang.StringBuffer fullName, java.lang.String previousType)
          Compute the complete name to associate to a SimpleVariable
 Expression getField()
           
 java.util.Vector getIndex()
           
 java.lang.String getName()
           
 Parameter getRefParameter()
           
 Variable getRefVariable()
           
 java.lang.String getScopedName()
           
 java.lang.String getString()
           
 java.lang.String getType()
          For expressions that have a field corresponding to the type, it returns the type or null
 boolean IsOnRef()
           
 void print(java.lang.String indentation)
          Empty
 java.lang.String resolveType()
           
 void setField(Expression field)
          The parameter "field" represents the expression found after "." or "->"
 void setName(java.lang.String name)
          Set the name of the variable corresponding to the SimpleVariable expression
 void setOnRef(boolean onRef)
           
 void setPreviousExpression(Expression expr)
           
 void setRefParameter(Parameter par)
           
 void setRefVariable(Variable var)
           
 
Methods inherited from class entities.Expression
addClass, addClassHeaderFile, addEnumerator, addExpression, addExternalField, addExternalMethod, addField, addFriendClass, addFriendFunction, addFriendMethod, addFunction, addGeneralization, addMethod, addNameSpace, addType, addUserType, addVariable, cleanType, findVariableType, getAllocationType, getCast, getCastType, getClassContext, getContainingMethod, getContext, getContextNew, getCurrentMethod, getFile, getLBracketPosition, getOperator, getOperators, getParent, getParentScope, getPosition, getPreviousExpression, getRBracketPosition, getTypeOfCast, propagateParentScope, setCast, setFile, setLBracketPosition, setOperator, setParentScope, setPosition, setRBracketPosition, setTypeOfCast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleVariable

public SimpleVariable(ScopeManager parentScope)
Method Detail

getName

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

getScopedName

public java.lang.String getScopedName()
Returns:
the string corresponding to the variable name prefixed by the name of scopes containing it
 Ex:  class A { 
          int p () {
             int j;
             j = 2; 
          }
      };
 
On the SimpleVariable representing the local variable "j" it returns "A::p::j"

getField

public Expression getField()
Returns:
the expression corresponding to the field

Ex: A *a; ...; a->f(); a->g;

On the SimpleVariable object representing the variable "a" returns the Call and the SimpleVariable objects corresponding to the method f() and the field g respectively.


getIndex

public java.util.Vector getIndex()
Returns:
a Vector containing objects of type Expression corresponding to array indeces if present

Ex: a[3][5] = 10;

On the SimpleVariable object representing the variable "a" returns a Vector containing two ConstantExpression associated to the constant 3 and 5.


getRefVariable

public Variable getRefVariable()
Returns:
the variable with which it is associated

getRefParameter

public Parameter getRefParameter()
Returns:
the parameter with which it is associated

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)

IsOnRef

public boolean IsOnRef()
Returns:
true if is a pointer

addIndex

public void addIndex(Expression expr)
Add an Expression object to the index expressions


setName

public void setName(java.lang.String name)
Set the name of the variable corresponding to the SimpleVariable expression


setRefParameter

public void setRefParameter(Parameter par)
Parameters:
par - represents the parameter associated with the SimpleVariable, if it is a parameter

setRefVariable

public void setRefVariable(Variable var)
Parameters:
var - represents the variable (local, field or global) associated with the SimpleVariable if it is not a parameter

fillName

public void fillName(java.lang.StringBuffer fullName,
                     java.lang.String previousType)
Compute the complete name to associate to a SimpleVariable

Overrides:
fillName in class Expression

fillNameNew

public void fillNameNew(java.lang.StringBuffer fullName,
                        java.lang.String previousType)
Compute the complete name to associate to a SimpleVariable

Overrides:
fillNameNew in class Expression

setField

public void setField(Expression field)
The parameter "field" represents the expression found after "." or "->"

Ex: A *a; ... a->f(); a->f;

In the first case "field" is the expression of type Call associated with the method f() and in the second the expression of type SimpleVariable associated with f


setPreviousExpression

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

setOnRef

public void setOnRef(boolean onRef)
Parameters:
onRef - is true if the SimpleVariable is a pointer

computeType

public void computeType(ScopeInfo inputScopeInfo,
                        java.lang.String indentation)
This method computes recursively the types on the field and on the elements of index expressions

Overrides:
computeType in class Expression

getType

public java.lang.String getType()
Description copied from class: Expression
For expressions that have a field corresponding to the type, it returns the type or null

Overrides:
getType in class Expression
Returns:
the type

resolveType

public java.lang.String resolveType()
Overrides:
resolveType in class Expression
Returns:
the type corresonding to the complete expression

Ex: class A { public: int h; }; A a; a.h; On the expression a.h returns "int".


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