scale.clef.decl
Class FormalDecl

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

public class FormalDecl
extends VariableDecl

This class represents a formal parameter to a procedure/function.

$Id: FormalDecl.java,v 1.30 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.

See Also:
Serialized Form

Field Summary
static int cInOut
          Represents Ada's inout keyword, which allows implementations to choose between Reference and ValueResult.
static int cInValue
          Pass-by-value but the formal's value may not be altered.
static int cReadOnly
          Pass-by-reference, but the value cannot be updated.
static int cReference
          Formal parameter is an alias for the argument.
static int cResult
          Represents Ada's out mode, which allows implementations to choose between Reference and ValueResult.
static int cValue
          Pass-by-value but the formal's value may be altered.
static int cValueResult
          Represents copy-in and copy-out semantics.
static java.lang.String[] modeMap
           
 
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
FormalDecl(java.lang.String name, Type type)
           
FormalDecl(java.lang.String name, Type type, int passByMode)
           
FormalDecl(java.lang.String name, Type type, int passByMode, Expression defaultValue)
           
 
Method Summary
 java.lang.Object getConstantValue()
          Return the constant value of the expression.
 Expression getDefaultValue()
           
 int getMode()
           
 boolean isFormalArg()
          Return true if this variable is an argument to the routine
protected  void setDefaultValue(Expression d)
           
protected  void setMode(int passByMode)
           
 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.VariableDecl
addressTaken, alignment, created, declareFtnResultVar, finalize, getInitialValue, getOriginal, inMemory, isConst, isFtnResultVar, isReferenced, isStatic, isTemporary, isVariable, isVolatile, number, residency, setAddressTaken, setAlignment, setInitialValue, setReferenced, setResidency, setTemporary, shouldBeInRegister
 
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
 

Field Detail

cValue

public static final int cValue
Pass-by-value but the formal's value may be altered. This mode is the default for Modula-3 and the only one for C/C++.

cReference

public static final int cReference
Formal parameter is an alias for the argument. Therefore, an update to the formal parameter is a direct update the argument (actual parameter) as well. This mode is the only parameter int for Fortran and represents the var mode for Modula-3.

cInValue

public static final int cInValue
Pass-by-value but the formal's value may not be altered. This mode is used for Ada.

cValueResult

public static final int cValueResult
Represents copy-in and copy-out semantics. This mode is used for Ada's inout mode.

cResult

public static final int cResult
Represents Ada's out mode, which allows implementations to choose between Reference and ValueResult.

cInOut

public static final int cInOut
Represents Ada's inout keyword, which allows implementations to choose between Reference and ValueResult.

cReadOnly

public static final int cReadOnly
Pass-by-reference, but the value cannot be updated. This mode supports Modula-3's readonly mode, and is efficient for large data structures.

modeMap

public static final java.lang.String[] modeMap
Constructor Detail

FormalDecl

public FormalDecl(java.lang.String name,
                  Type type,
                  int passByMode,
                  Expression defaultValue)

FormalDecl

public FormalDecl(java.lang.String name,
                  Type type,
                  int passByMode)

FormalDecl

public FormalDecl(java.lang.String name,
                  Type type)
Method Detail

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 VariableDecl

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

getMode

public final int getMode()

getDefaultValue

public final Expression getDefaultValue()

setMode

protected final void setMode(int passByMode)

setDefaultValue

protected final void setDefaultValue(Expression d)

isFormalArg

public boolean isFormalArg()
Description copied from class: VariableDecl
Return true if this variable is an argument to the routine
Overrides:
isFormalArg in class VariableDecl
Returns:
true if this variable is an argument to the routine

getConstantValue

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