scale.clef.decl
Class VariableDecl

java.lang.Object
  |
  +--scale.common.Root
        |
        +--scale.clef.Node
              |
              +--scale.clef.decl.Declaration
                    |
                    +--scale.clef.decl.ValueDecl
                          |
                          +--scale.clef.decl.VariableDecl
All Implemented Interfaces:
AnnotationInterface, DisplayNode, java.io.Serializable
Direct Known Subclasses:
EquivalenceDecl, FormalDecl, RenamedVariableDecl, VirtualVar

public class VariableDecl
extends ValueDecl

This class declares a variable.

$Id: VariableDecl.java,v 1.47 2002/01/03 21:42:46 burrill Exp $

Copyright 2002 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

See Also:
Serialized Form

Fields inherited from class scale.clef.decl.Declaration
accessibilities, cAuto, cExtern, cFile, cGlobal, cLocal, cMemory, cPrivate, cProtected, cPublic, cRegister, residencies, visibilitys
 
Fields inherited from interface scale.common.DisplayNode
ANNO, CLEF, DD, DEFUSE, DOM, EXPR, MAYUSE, TYPE
 
Constructor Summary
VariableDecl(java.lang.String name, Type type)
          Create a variable declaration which doesn't have a default value.
VariableDecl(java.lang.String name, Type type, Expression initialValue)
           
VariableDecl(Type type)
          Create a variable declaration for a temporary variable.
 
Method Summary
 boolean addressTaken()
          Return true if the address of this Declaration has been taken.
 int alignment()
           
static int created()
          Return the number of instances of this class created.
 void declareFtnResultVar()
          Specify that the variable is declared as the result variable of a function.
protected  void finalize()
          Keep the count of instances up-to-date.
 java.lang.Object getConstantValue()
          Return the constant value of the expression.
 Expression getInitialValue()
           
 VariableDecl getOriginal()
          Return the variable that this variable was renamed from.
 boolean inMemory()
          Return true if this declaration is to be allocated to memory.
 boolean isConst()
          Return true if the declaration is a const variable.
 boolean isFormalArg()
          Return true if this variable is an argument to the routine
 boolean isFtnResultVar()
          Return true if the declaration is declared as the result variable of a function.
 boolean isReferenced()
          Return true if the declaration is referenced somewhere in the Clef AST.
 boolean isStatic()
          Return true if this declaration is static.
 boolean isTemporary()
          Return true if the declaration is a temporary variable.
 boolean isVariable()
          Return true if the declaration is a variable.
 boolean isVolatile()
          Return true if the type specifies volatile.
static int number()
          Return the current number of instances of this class.
 int residency()
          Return the declaration residency.
 void setAddressTaken()
          Record that the address is used.
 void setAlignment(int alignment)
          Specify the alignment of the declaration.
 void setInitialValue(Expression i)
           
 void setReferenced()
          Specify that the variable is referenced somewhere in the Clef AST.
 void setResidency(int residency)
          Specify the residency of the declaration.
 void setTemporary()
          Specify that the variable is a temporary variable.
 boolean shouldBeInRegister()
          Return true if this variable should be allocated to a register.
 java.lang.String toStringSpecial()
          Return any special information of a node that is not a child or annotation.
 void visit(Predicate p)
          The visit() method is used to implement a visit 'pattern'.
 
Methods inherited from class scale.clef.decl.ValueDecl
createChildren, getValue, setValue
 
Methods inherited from class scale.clef.decl.Declaration
accessibility, DDname, getCoreType, getDecl, getDisplayColorHint, getDisplayShapeHint, getDisplayText, getName, getParent, getScope, getScopeNode, getTag, getType, hashCode, isGlobal, isPure, isVirtual, setAccessibility, setChildParent, setName, setParent, setScope, setTag, setType, setVisibility, visibility
 
Methods inherited from class scale.clef.Node
getChildren, setAnnotationLevel, setReportLevel, toString, toString, toStringChildren
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VariableDecl

public VariableDecl(java.lang.String name,
                    Type type,
                    Expression initialValue)

VariableDecl

public VariableDecl(java.lang.String name,
                    Type type)
Create a variable declaration which doesn't have a default value.

VariableDecl

public VariableDecl(Type type)
Create a variable declaration for a temporary variable. It doesn't have a default value.
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Keep the count of instances up-to-date.
Overrides:
finalize in class Declaration
Throws:
java.lang.Throwable - [needs description]

number

public static int number()
Return the current number of instances of this class.

created

public static int created()
Return the number of instances of this class created.

setResidency

public void setResidency(int residency)
Specify the residency of the declaration.
Overrides:
setResidency in class Declaration
Parameters:
residency - is the residency of the declaration
See Also:
Declaration.cAuto, Declaration.cRegister, Declaration.cMemory

setAlignment

public void setAlignment(int alignment)
Specify the alignment of the declaration. Zero means that alignment is not needed. The value specifies the boundary required such that (address % alignment) == 0.
Parameters:
alignment - is the alignment of the declaration

alignment

public int alignment()

residency

public int residency()
Return the declaration residency.
Overrides:
residency in class Declaration
See Also:
Declaration.cAuto, Declaration.cRegister, Declaration.cMemory

inMemory

public boolean inMemory()
Return true if this declaration is to be allocated to memory.
Overrides:
inMemory in class Declaration

isReferenced

public boolean isReferenced()
Return true if the declaration is referenced somewhere in the Clef AST.
Overrides:
isReferenced in class Declaration
Following copied from class: scale.clef.decl.Declaration
See Also:
VariableDecl, RoutineDecl

setReferenced

public void setReferenced()
Specify that the variable is referenced somewhere in the Clef AST.
Overrides:
setReferenced in class Declaration
Following copied from class: scale.clef.decl.Declaration
See Also:
VariableDecl, RoutineDecl

isConst

public boolean isConst()
Return true if the declaration is a const variable.
Overrides:
isConst in class ValueDecl
Following copied from class: scale.clef.decl.ValueDecl
Returns:
true if the declaration is constant.

isVariable

public boolean isVariable()
Return true if the declaration is a variable.
Overrides:
isVariable in class Declaration

isFormalArg

public boolean isFormalArg()
Return true if this variable is an argument to the routine

isTemporary

public boolean isTemporary()
Return true if the declaration is a temporary variable.
Overrides:
isTemporary in class Declaration

setTemporary

public void setTemporary()
Specify that the variable is a temporary variable.

isFtnResultVar

public boolean isFtnResultVar()
Return true if the declaration is declared as the result variable of a function.
Overrides:
isFtnResultVar in class Declaration

declareFtnResultVar

public void declareFtnResultVar()
Specify that the variable is declared as the result variable of a function.

setAddressTaken

public void setAddressTaken()
Record that the address is used.
Overrides:
setAddressTaken in class Declaration

addressTaken

public boolean addressTaken()
Return true if the address of this Declaration has been taken.
Overrides:
addressTaken in class Declaration

shouldBeInRegister

public boolean shouldBeInRegister()
Return true if this variable should be allocated to a register.

isVolatile

public boolean isVolatile()
Return true if the type specifies volatile.

visit

public void visit(Predicate p)
Description copied from class: Node
The visit() method is used to implement a visit 'pattern'.
Overrides:
visit in class ValueDecl

getInitialValue

public final Expression getInitialValue()

setInitialValue

public void setInitialValue(Expression i)

getConstantValue

public java.lang.Object getConstantValue()
Return the constant value of the expression.
Overrides:
getConstantValue in class ValueDecl
See Also:
Lattice

isStatic

public boolean isStatic()
Return true if this declaration is static.

getOriginal

public VariableDecl getOriginal()
Return the variable that this variable was renamed from.

toStringSpecial

public java.lang.String toStringSpecial()
Description copied from class: Root
Return any special information of a node that is not a child or annotation. This method is meant to be overridden by nodes that need to provide special output.
Overrides:
toStringSpecial in class Declaration