|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object minijava.typecheck.Method
public class Method
This class represents a method. It stores type information about its return type, local variables, signature and formal parameters. Note that the signature types must be appended in order since ordering matters. Parameters and local variables are stored as a mapping of identifiers to types.
Symbol
,
Type
Constructor Summary | |
---|---|
Method()
Creates an empty method object. |
Method Summary | |
---|---|
boolean |
addLocalVariable(Type type,
java.lang.String iden)
|
boolean |
addLocalVariable(Type type,
Symbol iden)
|
boolean |
appendParameterSignature(Type type,
Symbol iden)
|
java.util.Set<Symbol> |
getLocalVariableIdentifiers()
|
Type |
getLocalVariableType(java.lang.String sym)
|
Type |
getLocalVariableType(Symbol sym)
|
int |
getParameterCount()
|
Symbol |
getParameterIdentifierAt(int pos)
Pre-condition: pos < getParameterCount() |
Type |
getParameterTypeAt(int pos)
Pre-condition: pos < getParameterCount() |
Type |
getReturnType()
|
void |
setReturnType(Type returnType)
|
java.lang.String |
toString()
A string representation of the method in the form of: method(#param:type)* -> type . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Method()
Method Detail |
---|
public Type getReturnType()
public void setReturnType(Type returnType)
returnType
- the return type to setpublic int getParameterCount()
public Type getParameterTypeAt(int pos)
pos < getParameterCount()
pos
- the index into parameter signature
pos
'th position in the
method signature (list of formal parameters)public Symbol getParameterIdentifierAt(int pos)
pos < getParameterCount()
pos
- the index into parameter signature
pos
'th position in the
method signature (list of formal parameters)public boolean appendParameterSignature(Type type, Symbol iden)
type
- append a parameter type at the end of this method's
signature
true
if the operation succeeds, false
if
a binding of such parameter has already been enteredpublic boolean addLocalVariable(Type type, Symbol iden)
type
- the type of the variableiden
- the identifier of the variable
true
if the operation succeeds, false
if
a binding of such variable has already been entered either
in this method's local variables or its formal parameterspublic boolean addLocalVariable(Type type, java.lang.String iden)
type
- the type of the variableiden
- the identifier of the variable
true
if the operation succeeds, false
if
a binding of such variable has already been entered either
in this method's local variables or its formal parameterspublic Type getLocalVariableType(Symbol sym)
sym
- the local variable identifier
null
if no such identifier existspublic Type getLocalVariableType(java.lang.String sym)
sym
- the local variable identifier
null
if no such identifier existspublic java.util.Set<Symbol> getLocalVariableIdentifiers()
public java.lang.String toString()
method(#param:type)* -> type
.
toString
in class java.lang.Object
method(#param:type)* -> type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |