scale.clef.decl
Class EquivalenceDecl

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

public class EquivalenceDecl
extends VariableDecl

This class declares a variable that is equivalenced to an offset in another variable.

$Id: EquivalenceDecl.java,v 1.19 2002/01/03 21:42:43 burrill Exp $

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

This class declares a variable that is equivalenced to an offset in another variable. An equivalence relationship is generated for Fortran EQUIVALENCE statements and COMMON statements. For the statement

 EQUIVALENCE A, B
 
the base variable would be A with a offset of zero. For the statement
 EQUIVALENCE A(20), B
 
the base variable would be A with a offset of 20*sizeof(double).

Note - an EquivalenceDecl specifies an implied equivalence for COMMON variables.

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
EquivalenceDecl(java.lang.String name, Type type, VariableDecl base, long offset)
           
 
Method Summary
 VariableDecl copy(java.lang.String name)
          Make a copy of this VariableDecl using a new name.
protected  Vector createChildren()
          Create the list of children for the node - each node that has children must implement this method.
 long getBaseOffset()
          Return the offset from the base (i.e.
 VariableDecl getBaseVariable()
          Return the base variable (i.e.
 java.lang.Object getConstantValue()
          Return the constant value of the expression.
 Expression getValue()
          Return null - initializers are specified only for the base VariableDecl.
 boolean inMemory()
          Return true if this declaration is to be allocated to memory.
 boolean isGlobal()
          Return true if this declaration is globally visible.
 int residency()
          Return the declaration residency.
 void setBaseOffset(long offset)
           
 void setBaseVariable(VariableDecl base)
           
 void setInitialValue(Expression i)
           
 void setResidency(int residency)
          Generate an error - residency is specified only for the base VariableDecl.
 void setValue(Expression value)
          Generate an error if the value is not null - initializers are specified only for the base VariableDecl.
 void setVisibility(int visibility)
          Generate an error - visibility is specified only for the base VariableDecl.
 int visibility()
          Return the declaration visibility.
 void visit(Predicate p)
          The visit() method is used to implement a visit 'pattern'.
 
Methods inherited from class scale.clef.decl.VariableDecl
addressTaken, alignment, created, declareFtnResultVar, finalize, getInitialValue, getOriginal, isConst, isFormalArg, isFtnResultVar, isReferenced, isStatic, isTemporary, isVariable, isVolatile, number, setAddressTaken, setAlignment, setReferenced, setTemporary, shouldBeInRegister, toStringSpecial
 
Methods inherited from class scale.clef.decl.Declaration
accessibility, DDname, getCoreType, getDecl, getDisplayColorHint, getDisplayShapeHint, getDisplayText, getName, getParent, getScope, getScopeNode, getTag, getType, hashCode, isPure, isVirtual, setAccessibility, setChildParent, setName, setParent, setScope, setTag, setType
 
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

EquivalenceDecl

public EquivalenceDecl(java.lang.String name,
                       Type type,
                       VariableDecl base,
                       long offset)
Parameters:
name - - name of the variable
type - - type of the variable
base - - VariableDecl representing the base variable (COMMONM area) in the equivalence relationship
offset - - offset of this variable in bytes into the base variable
Method Detail

copy

public VariableDecl copy(java.lang.String name)
Make a copy of this VariableDecl using a new name.

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 VariableDecl

setInitialValue

public final void setInitialValue(Expression i)
Overrides:
setInitialValue in class VariableDecl

getBaseVariable

public final VariableDecl getBaseVariable()
Return the base variable (i.e. COMMON area).

setBaseVariable

public final void setBaseVariable(VariableDecl base)

getBaseOffset

public final long getBaseOffset()
Return the offset from the base (i.e. COMMON area).

setBaseOffset

public final void setBaseOffset(long offset)

setResidency

public void setResidency(int residency)
Generate an error - residency is specified only for the base VariableDecl.
Overrides:
setResidency in class VariableDecl
Parameters:
residency - is the residency of the declaration
See Also:
Declaration.cAuto, Declaration.cRegister, Declaration.cMemory

residency

public int residency()
Return the declaration residency. The residency of an EquivalenceDecl is the residency of the base VariableDecl.
Overrides:
residency in class VariableDecl
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 VariableDecl

getValue

public final Expression getValue()
Return null - initializers are specified only for the base VariableDecl.
Overrides:
getValue in class ValueDecl

setValue

public void setValue(Expression value)
Generate an error if the value is not null - initializers are specified only for the base VariableDecl.
Overrides:
setValue in class ValueDecl

setVisibility

public void setVisibility(int visibility)
Generate an error - visibility is specified only for the base VariableDecl.
Overrides:
setVisibility in class Declaration
Parameters:
visibility - is the visibility of the declaration
See Also:
Declaration.cLocal, Declaration.cFile, Declaration.cGlobal, Declaration.cExtern

visibility

public int visibility()
Return the declaration visibility. The visibility of an EquivalenceDecl is the visibility of the base VariableDecl.
Overrides:
visibility in class Declaration
See Also:
Declaration.cLocal, Declaration.cFile, Declaration.cGlobal, Declaration.cExtern

isGlobal

public boolean isGlobal()
Return true if this declaration is globally visible.
Overrides:
isGlobal in class Declaration

getConstantValue

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

createChildren

protected Vector createChildren()
Description copied from class: Node
Create the list of children for the node - each node that has children must implement this method. However, use getChildren() to actually get the children.
Overrides:
createChildren in class ValueDecl
Following copied from class: scale.clef.Node
Returns:
the list of children