at.dms.kjc.common
Class ALocalVariable

java.lang.Object
  extended by at.dms.kjc.common.ALocalVariable

public class ALocalVariable
extends Object

Package up declaration statement and use expression for a local variable.

Author:
dimock

Method Summary
 JVariableDeclarationStatement getDecl()
           
 JExpression getInitializer()
          Get the expression for the initial value of the variable.
 String getName()
          Get variable name
 JLocalVariableExpression getRef()
           
 JVariableDefinition getVarDefn()
          Get the definition of the variable (allowing hacking name, type, initializer...).
static ALocalVariable makeTmp(CType typ)
          Create a new local variable, don't care about name so long as it is likely to be unique.
static ALocalVariable makeVar(CType typ, String varName)
          Create a new local variable with a specified name and type.
 void setInitializer(JExpression initExpr)
          Set the initial value of the variable.
 void setName(String varName)
          Change variable name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeTmp

public static ALocalVariable makeTmp(CType typ)
Create a new local variable, don't care about name so long as it is likely to be unique.

Parameters:
typ - type for variable
Returns:
ALocalVariable object with statement for declaration, expression for use.

makeVar

public static ALocalVariable makeVar(CType typ,
                                     String varName)
Create a new local variable with a specified name and type.

Parameters:
typ - type for variable
varName - name for variable
Returns:
ALocalVariable object with statement for declaration, expression for use.

setName

public void setName(String varName)
Change variable name.

Parameters:
varName - the new variable name to set (affects declaration and references)

getName

public String getName()
Get variable name

Returns:
the variable name

setInitializer

public void setInitializer(JExpression initExpr)
Set the initial value of the variable.

Parameters:
initExpr - expression that will be produced for the variable declaration.

getInitializer

public JExpression getInitializer()
Get the expression for the initial value of the variable.

Returns:
expression, will be null unless #setVarInitializer(JExpression) has been called (or equivalent hacking)

getDecl

public JVariableDeclarationStatement getDecl()
Returns:
the variable declaration statement.

getRef

public JLocalVariableExpression getRef()
Returns:
expression referencing the variable.

getVarDefn

public JVariableDefinition getVarDefn()
Get the definition of the variable (allowing hacking name, type, initializer...).

Returns:
definition of variable.