entities
Class Function

java.lang.Object
  extended byentities.Function
All Implemented Interfaces:
ScopeManager

public class Function
extends java.lang.Object
implements ScopeManager

The Function class represents the information regarding a function.


Field Summary
protected  ScopeManager fParentScope
           
protected  java.util.Hashtable fTypeTable
           
protected  java.util.Hashtable fUserTypeTable
           
 
Constructor Summary
Function(ScopeManager parentScope, java.lang.String name, java.lang.String file, int position, boolean staticFlag, boolean inlineFlag, boolean externFlag, boolean returnedValueConst, java.lang.String returnedType, java.util.Vector parameters)
          Construct a new Function object
 
Method Summary
 void addClass(ClassEntity cl)
          Empty
 void addClassHeaderFile(java.lang.String className, java.lang.String headerFileName)
          Empty
 void addEnumerator(Enumerator en)
          Add an Enumerator object to the function
 void addExpression(Expression expr, ScopeManager wrapper)
          Add an Expression object associated with a statement of the function to the current Function
 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)
          Add a new type defined with typedef to the user types.
 void addVariable(Variable var)
          Add a Variable object (corresponding to a local variable) to the Function
 boolean areExceptionUsed()
          Deprecated.  
static void createTable(java.sql.Connection dbConnection)
           
static void delete(java.sql.Connection dbConnection, int id)
           
 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 variable type.
 java.util.Vector getBody()
           
 Method getCurrentMethod(java.lang.String methodName, java.util.Vector parameters)
           
 int getEndLine()
           
 java.util.Vector getEnumerators()
           
 java.lang.String getFile()
           
 int getInitLine()
           
 java.util.Vector getLocalVariables()
           
 java.lang.String getName()
           
 Parameter getParameter(java.lang.String parameterName)
           
 java.util.Vector getParameters()
           
 java.lang.String getParameterTypesAsString()
           
 ScopeManager getParent()
           
 int getPosition()
           
 java.lang.String getReturnedType()
           
 java.lang.String getSignature()
           
 java.util.Vector getThrownExceptions()
           
 java.util.Hashtable getTypeTable()
           
 java.util.Hashtable getUserTypeTable()
           
 void insert(java.sql.Connection dbConnection, int sourceId, int sourceType)
           
 boolean isATemplate()
           
 boolean isExtern()
           
 boolean isStatic()
           
 void print(java.lang.String indentation)
          Print all information contained in a Function object
 void setEndLine(int end)
          The parameter "end" represents the line corresponding to the last "}"
 void setExceptionFlag(boolean exceptionFlag)
          "exceptionFlag" is true if exceptions are used inside the function
 void setInitLine(int init)
          The parameter "init" represents the line corresponding to the first "{"
 void setTemplateFlag(boolean templateFlag)
          "templateFlag" is true if the function is a template function
 void setThrownExceptions(java.util.Vector thrownExceptions)
          The parameter "thrownExceptions" contains the strings (of type String) corresponding to the names of exceptions thrown by the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fParentScope

protected ScopeManager fParentScope

fTypeTable

protected java.util.Hashtable fTypeTable

fUserTypeTable

protected java.util.Hashtable fUserTypeTable
Constructor Detail

Function

public Function(ScopeManager parentScope,
                java.lang.String name,
                java.lang.String file,
                int position,
                boolean staticFlag,
                boolean inlineFlag,
                boolean externFlag,
                boolean returnedValueConst,
                java.lang.String returnedType,
                java.util.Vector parameters)
Construct a new Function object

Parameters:
parentScope - The entity containing the function
name - Name of the function
file - Name of the file in which the function is defined
staticFlag - Flag that states if the function is static
inlineFlag - Flag that states if the function has the keyword inline
externFlag - Flag that states if the function is extern
returnedValueConst - Flag that states if the returned value is constant
returnedType - Type returned by the function
parameters - Vector of Parameter objects corresponding to the function parameters
Method Detail

getName

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

getFile

public java.lang.String getFile()
Returns:
the string corresponding to the file in which the function is defined

getPosition

public int getPosition()
Returns:
an integer corresponding to the position (of the name) in the file

getReturnedType

public java.lang.String getReturnedType()
Returns:
the string containing the type returned by the function

getParameters

public java.util.Vector getParameters()
Returns:
the Vector containing the Parameter objects

getParameter

public Parameter getParameter(java.lang.String parameterName)
Returns:
the Parameter object corresponding to the name whether it exists, null otherwise.

getParameterTypesAsString

public java.lang.String getParameterTypesAsString()
Returns:
a string containing the types of the parameters separated by a ","

getSignature

public java.lang.String getSignature()
Returns:
the string containing the signature of the function in UML format

getEnumerators

public java.util.Vector getEnumerators()
Returns:
a Vector of objects of type Enumerator
See Also:
Enumerator

getLocalVariables

public java.util.Vector getLocalVariables()
Returns:
a Vector of Variable objects that represent the local variables of the function (the variables inside a block are reported a this level too)
See Also:
Variable

getInitLine

public int getInitLine()
Returns:
the line position of the first "{". It is -1 if it has not been set.

getEndLine

public int getEndLine()
Returns:
the line position of the last "}". It is -1 if it has not been set.

getBody

public java.util.Vector getBody()
Returns:
s Vector of objects of type Expression corresponding to the statements of the function.
See Also:
Expression

getTypeTable

public java.util.Hashtable getTypeTable()
Returns:
a Hashtable containing all the new types defined using the typedef statement (the key is the new name)

getUserTypeTable

public java.util.Hashtable getUserTypeTable()
Returns:
a Hashtable containing the new types defined by the user using the typedef statement (the key is the new name)

getParent

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

getThrownExceptions

public java.util.Vector getThrownExceptions()
Returns:
the Vector containing the objects (of type String) corresponding to the exceptions thrown by the function
 Ex: void h () throw (Range_Error) {..}
 
In this case it returns a Vector containing an object (of type String) corresponding to the string "Range_Error".

getCurrentMethod

public Method getCurrentMethod(java.lang.String methodName,
                               java.util.Vector parameters)
Specified by:
getCurrentMethod in interface ScopeManager
Returns:
null

isExtern

public boolean isExtern()
Returns:
true if the function is extern

isStatic

public boolean isStatic()
Returns:
true if the function is static

isATemplate

public boolean isATemplate()
Returns:
true if the function is a template

areExceptionUsed

public boolean areExceptionUsed()
Deprecated.  

Returns:
true if exceptions are used

setInitLine

public void setInitLine(int init)
The parameter "init" represents the line corresponding to the first "{"


setEndLine

public void setEndLine(int end)
The parameter "end" represents the line corresponding to the last "}"


setTemplateFlag

public void setTemplateFlag(boolean templateFlag)
"templateFlag" is true if the function is a template function


setExceptionFlag

public void setExceptionFlag(boolean exceptionFlag)
"exceptionFlag" is true if exceptions are used inside the function


addEnumerator

public void addEnumerator(Enumerator en)
Add an Enumerator object to the function

Specified by:
addEnumerator in interface ScopeManager
See Also:
Enumerator

setThrownExceptions

public void setThrownExceptions(java.util.Vector thrownExceptions)
The parameter "thrownExceptions" contains the strings (of type String) corresponding to the names of exceptions thrown by the function.
 Ex: void h () throw (Range_Error) {..}
 
In this case "thrownExceptions" will contain the string (of type String) corresponding to "Range_Error".


addNameSpace

public void addNameSpace(NameSpace namespace)
Empty

Specified by:
addNameSpace in interface ScopeManager

addExpression

public void addExpression(Expression expr,
                          ScopeManager wrapper)
Add an Expression object associated with a statement of the function to the current Function

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)
Add a Variable object (corresponding to a local variable) to the Function

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)
Add a new type defined with typedef to the user types.

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

print

public void print(java.lang.String indentation)
Print all information contained in a Function object

Specified by:
print in interface ScopeManager

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 variable type.

Specified by:
findVariableType in interface ScopeManager

delete

public static void delete(java.sql.Connection dbConnection,
                          int id)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

createTable

public static void createTable(java.sql.Connection dbConnection)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

insert

public void insert(java.sql.Connection dbConnection,
                   int sourceId,
                   int sourceType)
            throws java.sql.SQLException
Throws:
java.sql.SQLException