|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSFE.Compiler.Function
public class Function
A class for representing a function that can be defined in the program.
Field Summary | |
---|---|
static Function |
currentFunction
|
LvalExpression |
functionResult
|
static java.util.Vector |
inputFormat
|
java.util.Vector |
parameters
|
Constructor Summary | |
---|---|
Function(java.lang.String name,
Type returnType)
Constructs a new Function from a given name, returned type |
Method Summary | |
---|---|
void |
addInputStatements()
|
void |
addParameter(java.lang.String name,
Type type)
Adds a parameter to this function. |
void |
addStatement(Statement statement)
Adds a statement to this function. |
void |
addStatements(java.util.Vector statements)
Adds statements to this function. |
static LvalExpression |
addTempLocalVar(java.lang.String name,
Type type)
Adds a temporary local varivable as single bit LvalExpression from a given varname and type and returns the LvalExpression that hold the whole (original) variable. |
static void |
addVar(LvalExpression exp)
Adds a local variable that was defined to this functioni, from a given LvalExpression. |
static void |
addVar(java.lang.String name,
Type type)
Adds a local variable that was defined to this function. |
void |
buildUsedStatementsHash()
create the list of all the needed statements to calculate the circuit. |
java.util.Vector |
getArguments()
returns the arguments of this function. |
java.util.Vector |
getBody()
returns the body of this function |
java.lang.String |
getName()
Return the name of the function. |
static LvalExpression |
getVar(LvalExpression lval)
this method is used to get the last referance existing (unique var) |
static LvalExpression |
getVar(java.lang.String name)
Returns the LvalExpression from a given parameter or a local variable name. |
static LvalExpression |
getVarBitAt(LvalExpression exp,
int i)
Returns the bit LvalExpression from a given Lvalexpression and the bit number. |
static UniqueVariables |
getVars()
Returns all variables and their references in all scopes. |
BlockStatement |
multi2SingleBit(java.lang.Object obj)
Transfroms multibit statements in the function into single bit statements. |
void |
optimizePhaseI()
Optimizes this function - phase I. |
void |
optimizePhaseII(java.util.Vector newBody)
creates a list of the needed statements in this functions and removes all unneeded statements according to this list. |
static java.util.HashMap |
popScope()
Called when ending the current scope |
static void |
pushScope()
Called when begining a new scope (for example: if, for) |
int |
size()
Returns the size of the value returned by the function in bits. |
void |
toCircuit(java.io.PrintWriter circuit)
Prints this AssignmentStatement into the circuit. |
java.lang.String |
toFormat()
Returns a String representing this object as it should appear in the format file. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
uniqueVars()
Unique vars transformations. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.util.Vector parameters
public LvalExpression functionResult
public static Function currentFunction
public static final java.util.Vector inputFormat
Constructor Detail |
---|
public Function(java.lang.String name, Type returnType)
name
- the name of this function.returnType
- the type of this function's returned value.Method Detail |
---|
public static UniqueVariables getVars()
public void addParameter(java.lang.String name, Type type)
name
- the name of the new parametertype
- the type of the new parameterpublic static void addVar(java.lang.String name, Type type)
name
- the name of the new local variabletype
- the type of the new local variablepublic static void addVar(LvalExpression exp)
exp
- the given expression.public static LvalExpression addTempLocalVar(java.lang.String name, Type type)
name
- the name of the temp. variable.type
- the type of the temp. variable.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
public void addStatement(Statement statement)
statement
- the new statement.public void addStatements(java.util.Vector statements)
statements
- the new statements.public static LvalExpression getVar(java.lang.String name)
name
- the function, parameter or a local variable name.
public static LvalExpression getVar(LvalExpression lval)
public static LvalExpression getVarBitAt(LvalExpression exp, int i)
exp
- the Lvalexpressioni
- the bit number to be returned.
public BlockStatement multi2SingleBit(java.lang.Object obj)
multi2SingleBit
in interface Multi2SingleBit
obj
- not needed (null).
public void addInputStatements()
public void toCircuit(java.io.PrintWriter circuit)
circuit
- the circuit output file.public java.lang.String toFormat()
public void optimizePhaseI()
public void optimizePhaseII(java.util.Vector newBody)
newBody
- newBody is always null (needed for other classes).public void buildUsedStatementsHash()
public void uniqueVars()
public int size()
public static void pushScope()
public static java.util.HashMap popScope()
public java.util.Vector getArguments()
public java.util.Vector getBody()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |