|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.clef.Node scale.clef.type.Type scale.clef.type.ProcedureType
public class ProcedureType
A ProcedureType represents the type of a procedure.
$Id: ProcedureType.java,v 1.65 2007-08-27 18:13:32 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Constructor Summary | |
---|---|
protected |
ProcedureType(Type returnType,
Vector<FormalDecl> formals,
Vector<Raise> raises)
|
Method Summary | |
---|---|
int |
alignment(Machine machine)
Calculate the alignment needed for this data type. |
static void |
cleanup()
Remove static lists of types. |
boolean |
compareSignatures(ProcedureType s2,
boolean matchUnknowns,
boolean matchFormalNames,
boolean matchFormalModes,
boolean matchExceptions,
boolean exactExceptionMatch)
Return true if the specified procedure type matches this procedure type. |
ProcedureType |
copy(Type returnType)
Create a procedure type with the same parameters but a different return type. |
static ProcedureType |
create(Type returnType,
Vector<FormalDecl> formals,
Vector<Raise> raises)
Re-use an existing instance of a particular procedure type. |
boolean |
equivalent(Type t)
Compares two ProcedureTypes for equivalence as defined by the type equivalence rules specified in ted. |
Node |
getChild(int i)
Return the specified AST child of this node. |
FormalDecl |
getFormal(int i)
Return the specified formal parameter. |
FormalDecl |
getFormal(java.lang.String name)
Return the specified formal parameter. |
Raise |
getRaise(int i)
Return the specified exception. |
Vector<Raise> |
getRaiseVector()
Return a vector of exceptions raised. |
Type |
getReturnType()
Return the return type of the procedure. |
static java.util.Enumeration<ProcedureType> |
getTypes()
Return an enumeration of all the different types. |
boolean |
isFChar()
Return true if this is a Fortran FUNCTION that returns a CHARACTER value via an address passed in as in argument. |
boolean |
isOldStyle()
Return true if this is an old style C procedure type defined with out a prototype. |
boolean |
isProcedureType()
Return true if this type represents a procedure. |
void |
markAsFChar()
Mark this as a Fortran FUNCTION that returns a CHARACTER value via an address passed in as in argument. |
void |
markAsOldStyle()
Mark this as an old style K&R C procedure type. |
long |
memorySize(Machine machine)
Calculate how many addressable memory units are needed to represent the type. |
int |
numChildren()
Return the number of AST children of this node. |
int |
numFormals()
Return the number of formal parameters. |
int |
numRaises()
Return the number of exceptions raised. |
int |
precedence()
Return a precedence value for types. |
ProcedureType |
returnProcedureType()
Return if this is a ProcedureType , return this . |
boolean |
sameFormals(Vector<FormalDecl> formals)
Return true if the formals match. |
boolean |
sameRaises(Vector<Raise> raises)
Return true if the formals match. |
java.lang.String |
toStringSpecial()
This method allows sub-classes to provide class specific stuff to the string. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
void |
visit(TypePredicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.clef.Node |
---|
getDecl, getSourceLineNumber, setAnnotationLevel, setReportLevel, setSourceLineNumber, toString, toStringChildren |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected ProcedureType(Type returnType, Vector<FormalDecl> formals, Vector<Raise> raises)
Method Detail |
---|
public static ProcedureType create(Type returnType, Vector<FormalDecl> formals, Vector<Raise> raises)
returnType
- the return type of the routine.formals
- a vector of FormalDecls. If the vector is empty,
the routine is of the form r(void).raises
- the exceptions raised by the routine or null if none.public ProcedureType copy(Type returnType)
public boolean sameFormals(Vector<FormalDecl> formals)
public boolean sameRaises(Vector<Raise> raises)
public boolean isProcedureType()
isProcedureType
in class Type
public final ProcedureType returnProcedureType()
Type
this
is a ProcedureType
, return this
. Otherwise, return
null
.
returnProcedureType
in class Type
public final boolean isOldStyle()
public final void markAsOldStyle()
public final boolean isFChar()
public final void markAsFChar()
public final Type getReturnType()
public final FormalDecl getFormal(int i)
public final FormalDecl getFormal(java.lang.String name)
public int numFormals()
public final Vector<Raise> getRaiseVector()
public int numRaises()
public final Raise getRaise(int i)
public void visit(Predicate p)
Node
Each class has a visit(Predicate p)
method. For
example, in class ABC
:
public void visit(Predicate p) { p.visitABC(this); }and the class that implements
Predicate
has a method
public void visitABC(Node n) { ABC a = (ABC) n; ... }Thus, the class that implements
Predicate
can call
n.visit(this);where
n
is a Node
sub-class without
determining which specific sub-class n
is.
The visit pattern basically avoids implementing a large
switch
statement or defining different methods
in each class for some purpose.
visit
in class Type
Predicate
public void visit(TypePredicate p)
Type
Each type class has a visit(TypePredicate p)
method.
For example, in class ABC
:
public void visit(Predicate p) { p.visitABC(this); }and the class that implements
Predicate
has a method
public void visitABC(Node n) { ABC a = (ABC) n; ... }Thus, the class that implements
TypePredicate
can call
n.visit(this);where
n
is a Node
sub-class without
determining which specific sub-class n
is.
The visit pattern basically avoids implementing a large
switch
statement or defining different methods
in each class for some purpose.
visit
in class Type
TypePredicate
public Node getChild(int i)
getChild
in class Node
public int numChildren()
numChildren
in class Node
public java.lang.String toStringSpecial()
Node
toStringSpecial
in class Node
public boolean compareSignatures(ProcedureType s2, boolean matchUnknowns, boolean matchFormalNames, boolean matchFormalModes, boolean matchExceptions, boolean exactExceptionMatch)
The criterion for considering two signatures equivalent can be
modified by the boolean
arguments to the method.
If matchUnknowns
is false
then two
parameter lists match if:
UnknownFormals
instances, or
UnknownFormals
instance,
UnknownFormals
instance.
UnknownFormals
instance must always be the last parameter.
s2
- is the other procedure typematchUnknowns
- is true if the signatures don't match when
the position of any UnknownFormals
instances differmatchFormalNames
- is true is the names of the parameters
should be comparedmatchFormalModes
- is true if the parameter modes should be
comparedmatchExceptions
- is true if the exceptions should be
comparedexactExceptionMatch
- is true if the exceptions must match
excatlypublic boolean equivalent(Type t)
equivalent
in class Type
public static java.util.Enumeration<ProcedureType> getTypes()
public long memorySize(Machine machine)
memorySize
in class Type
machine
- is the machine-specific data machine
public int alignment(Machine machine)
alignment
in class Type
public int precedence()
precedence
in class Type
public static void cleanup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |