public class Method extends ASTNode implements java.lang.Cloneable, Attributes, IMetadata
Method
class defines a SIDL method, including modifiers,
return type, name, arguments, and exceptions. Methods may have one of
three definition modifiers: final, static, or abstract. They may also
have one of two communication modifiers: local or oneway. The return type
is either a type or null (which indicates void). The method name is a
simple identifier string. The optional arguments are an ordered collecton
or arguments. The method may throw any number of exceptions.Modifier and Type | Class and Description |
---|---|
static class |
Method.RarrayInfo |
Modifier and Type | Field and Description |
---|---|
static int |
ABSTRACT |
static int |
FINAL |
static int |
LOCAL |
static int |
NONBLOCKING |
static int |
NONBLOCKING_RECV |
static int |
NONBLOCKING_SEND |
static int |
NORMAL |
static int |
ONEWAY |
static java.lang.String[] |
s_comm_mod |
static java.lang.String[] |
s_def_mod |
static int |
STATIC |
Constructor and Description |
---|
Method(Context context)
Create an empty
Method object that will be built by
calls to other member functions. |
Modifier and Type | Method and Description |
---|---|
void |
addArgument(Argument arg)
Add another argument to the end of the list of method arguments.
|
void |
addClauseAssertion(Assertion assertion)
Add the specified assertion to the proper contract clause for this method.
|
void |
addImplicitThrows(SymbolID id)
Add a symbol identifier to the list of exceptions thrown, but
do not treat it as an explicit throw.
|
void |
addMetadata(java.lang.String keyword,
java.lang.String value)
Add a (keyword, value) pair to the metadata for this object.
|
void |
addRarrayIndex(java.util.Collection new_indices)
add a set of required rarray indices to the set of indices
|
void |
addRarrayIndex(java.lang.String s)
add a required rarray index to the set of indices
|
void |
addSplicerContents(java.lang.String location,
java.lang.String name,
java.lang.String impl)
Add the specified contents to the splicer block identified by the
location and name.
|
void |
addThrows(SymbolID id)
Add a symbol identifier to the list of explicit supported exceptions
for this method.
|
Method |
cloneMethod()
Return a shallow copy of this method object.
|
boolean |
contractHasBuiltinMethod(int type)
Returns TRUE if the a built-in assertion method call of the specified type
is included in either contract clause; returns FALSE otherwise.
|
boolean |
contractHasUserDefinedMethod(boolean any)
Returns TRUE if the contract calls any user-defined methods (when any is
TRUE) or has a user-defined method with a throws clause (if any is FALSE)
in either of its contract clauses; otherwise, returns FALSE.
|
boolean |
equals(java.lang.Object o) |
void |
freeze() |
Argument |
getArgumentByName(java.lang.String s)
Return an the argument whose formal name matches the passed in string.
|
java.util.List |
getArgumentList()
Return the array of arguments in an
List , where each
element is an Argument . |
java.util.List |
getArgumentListWithIndices()
Return the array of arguments in an
List container. |
java.util.List |
getArgumentListWithOutIndices()
Return the array of arguments in an
List container. |
int |
getArgumentMode(java.lang.String name)
Return the mode of the argument with the specified formal name, if any;
otherwise, return -1.
|
Type |
getArgumentType(java.lang.String name)
Return the
Type of the argument with the specified formal
name, if any; otherwise, return null. |
java.lang.String |
getAttribute(java.lang.String key) |
java.util.Set |
getAttributes() |
java.util.Set |
getBasicArrays()
Return the
Set of basic array references including
arrays of fundamental types such as double, int, etc. |
java.lang.String |
getBlockingMethodName()
Return the nonblocking method name (if NONBLOCKING), else return long name
|
Comment |
getComment()
Return the comment for the method.
|
int |
getCommunicationModifier()
Return the communication modifier for this method.
|
java.lang.String |
getCommunicationModifierString()
Return the communication modifier string for this method.
|
java.lang.String |
getCorrectMethodName()
This method is used for language bindings that support overloading.
|
int |
getDefinitionModifier()
Return the definition modifier for the method.
|
java.lang.String |
getDefinitionModifier(boolean is_interface)
Return the explicit definition modifier string for the method based
on the type of extendable in which it belongs.
|
java.util.Set |
getExplicitThrows()
Return the
Set of explicit exceptions that may be thrown
by this method. |
java.util.Set |
getImplicitThrows()
Return the
Set of implicit exceptions that may be thrown
by this method. |
java.lang.String |
getLongMethodName()
Return the long method name (a standard SIDL identifier).
|
int |
getMaxArrayIterMacros(char type)
Return the number of array iteration macros --- contained in the contract
--- that return the specified type.
|
Metadata |
getMetadata()
Return the metadata associated with this object.
|
java.lang.String |
getNameExtension()
Return the method name extension (a standard SIDL identifier).
|
java.util.List |
getPostClause()
Return an
List of Assertion s that make up
the postcondition clause. |
int |
getPostDefaultComplexity()
Returns the default complexity of the postcondition clause; returns 0
(for constant-time) if none.
|
java.util.List |
getPreClause()
Return an
List of Assertion s that make up
the precondition clause. |
int |
getPreDefaultComplexity()
Returns the default complexity of the precondition clause; returns 0
(for constant-time) if none.
|
java.util.Set |
getRarrayIndices()
Return the set of rarray indices required in the arg list.
|
java.util.Map |
getRarrayInfo()
This returns an array list of RarrayInfo objects that contains the info
for every rarray index used in this method.
|
Type |
getReturnType()
Return the return type for the method or throw NullPointerException
|
java.lang.String |
getReturnType(java.lang.String parent_pkg)
Return the string corresponding to the return type for this method.
|
java.lang.String |
getShortMethodName()
Return the short method name (a standard SIDL identifier).
|
java.lang.String |
getSignature()
Return the signature of the method.
|
java.lang.String |
getSignature(boolean is_interface,
java.lang.String parent_pkg)
Return the signature of the method, including the definition modifier
based on the extendable type.
|
java.lang.String |
getSignaturePreface(boolean is_interface,
java.lang.String parent_pkg)
Return the concatenation of the explicit definition modifier, copy,
return type, name and extension.
|
java.util.ArrayList |
getSplicerBlocks(java.lang.String location)
Return splicer blocks for the specified location.
|
java.util.ArrayList |
getSplicerContents(java.lang.String location,
java.lang.String name)
Return splicer contents for the specified location and splicer name.
|
java.util.Set |
getSymbolReferences()
Return the
Set of symbols referred to by this method. |
java.util.Set |
getSymbolReferencesWithoutExceptions()
Return the
Set of symbols referred to by this method,
except for the exceptions it throws. |
java.util.Set |
getThrows()
Return the
Set of exceptions that may be thrown by this
method. |
boolean |
hasArrayOrderSpec()
Return TRUE if and only if at least one argument of this method is an
array with an ordering specification.
|
boolean |
hasAttribute(java.lang.String key) |
boolean |
hasExplicitExceptions() |
int |
hashCode() |
boolean |
hasPostClause()
Returns TRUE if the method has assertions within its postcondition clause;
otherwise, returns FALSE.
|
boolean |
hasPreClause()
Returns TRUE if the method has assertions within its precondition clause;
otherwise, returns FALSE.
|
boolean |
hasPureAssertion()
Return TRUE if PURE clause appears in the assertions associated
with this method; otherwise, return FALSE.
|
boolean |
hasRarray()
Returns true if this method has an rarray in it's signature
|
boolean |
isAbstract()
Return TRUE if the method is abstract; otherwise, return FALSE.
|
boolean |
isBuiltIn()
Return the built-in attribute for the method.
|
boolean |
isFinal()
Return TRUE if the method is final; otherwise, return FALSE.
|
boolean |
isImplicitException(SymbolID id) |
boolean |
isReturnCopy()
Return the copy mode for the return type.
|
boolean |
isStatic()
Return TRUE if the method is static; otherwise, return FALSE.
|
int |
numRarray()
Returns the number of rarray arguments in the method's argument list.
|
boolean |
overloadCollision(Method m) |
boolean |
postHasMethodCall()
Returns TRUE if the postcondition clause includes at least one method
call; returns FALSE otherwise.
|
boolean |
postHasResult()
Returns TRUE if the postcondition clause includes a result argument;
returns FALSE otherwise.
|
boolean |
postHasResultOrOutArg()
Returns TRUE if the postcondition clause includes at least one result
or output argument; returns FALSE otherwise.
|
boolean |
preHasMethodCall()
Returns TRUE if the precondition clause includes at least one method
call; returns FALSE otherwise.
|
boolean |
preHasResultOrOutArg()
/**
Returns TRUE if the precondition clause includes at least one result
or output argument; returns FALSE otherwise.
|
void |
removeAttribute(java.lang.String key) |
boolean |
sameBaseSignature(Method m)
Return TRUE if the base signature of the specified method matches
that of this method; otherwise, return FALSE.
|
boolean |
sameSignature(Method m)
Return TRUE if the signature of the specified method matches that of
this method; otherwise, return FALSE.
|
boolean |
sameSignature(Method m,
boolean compExt)
Return TRUE if the signature of the specified method matches that of
this method; otherwise, return FALSE.
|
void |
setAttribute(java.lang.String key) |
void |
setAttribute(java.lang.String key,
java.lang.String value) |
void |
setBuiltIn(boolean is_builtin)
Set the built-in attribute.
|
void |
setComment(Comment comment)
Set the comment for the method.
|
void |
setCommunicationModifier(int modifier)
Set the communication modifier for the method.
|
void |
setDefinitionModifier(int modifier)
Set the definition modifier for the method.
|
void |
setMethodName(java.lang.String shortName)
Set the names of the method (a standard SIDL identifier).
|
void |
setMethodName(java.lang.String shortName,
java.lang.String extension)
Set the names of the method (a standard SIDL identifier).
|
void |
setReturnCopy(boolean copy)
Set the copy mode for the return type.
|
void |
setReturnType(Type type)
Set the return type for the method.
|
Method |
spawnNonblockingRecv()
Create the non-blocking recv variant iff method is nonblocking
|
Method |
spawnNonblockingSend()
Create the non-blocking send variant iff method is nonblocking
|
Method |
spawnPostHook() |
Method |
spawnPostHook(boolean useCReturn,
boolean without)
Create the post hook variant iff hooks are turned on.
|
Method |
spawnPreHook() |
Method |
spawnPreHook(boolean withinout)
Create the pre hook variant iff hooks are turned on.
|
checkFrozen, clone, protectCollection, protectList, protectMap, protectSet
public static final int NORMAL
public static final int ABSTRACT
public static final int FINAL
public static final int STATIC
public static final int LOCAL
public static final int ONEWAY
public static final int NONBLOCKING
public static final int NONBLOCKING_SEND
public static final int NONBLOCKING_RECV
public static final java.lang.String[] s_def_mod
public static final java.lang.String[] s_comm_mod
public Method(Context context)
Method
object that will be built by
calls to other member functions.public Method cloneMethod()
public Method spawnPreHook(boolean withinout) throws CodeGenerationException
withinout
- If false, all in and inout args are converted to in
args only. If true, inouts remain inout. out args are always removed.CodeGenerationException
spawnNonblockingRecv()
public Method spawnPreHook() throws CodeGenerationException
CodeGenerationException
public Method spawnPostHook(boolean useCReturn, boolean without) throws CodeGenerationException
useCReturn
- if true, uses the return name given in C.java. If
false, uses the Fortran variant namewithout
- If false, all out and inout args are converted to in
args only. If true, inouts and outs remain such.CodeGenerationException
spawnNonblockingRecv()
public Method spawnPostHook() throws CodeGenerationException
CodeGenerationException
public Method spawnNonblockingSend() throws CodeGenerationException
CodeGenerationException
spawnNonblockingRecv()
public Method spawnNonblockingRecv() throws CodeGenerationException
CodeGenerationException
spawnNonblockingSend()
public void addArgument(Argument arg)
arg
- The argument to be appended to the object's argument listpublic java.util.List getArgumentList()
List
, where each
element is an Argument
.public java.util.List getArgumentListWithOutIndices()
List
container.
This method returns only arguments that are not used as indices to
an Rarraypublic java.util.List getArgumentListWithIndices()
List
container.
This returns all the arguments in the argument list, including those
that are indices to an Rarray.public void addRarrayIndex(java.lang.String s)
public void addRarrayIndex(java.util.Collection new_indices)
public java.util.Set getRarrayIndices()
public boolean hasRarray()
public int numRarray()
public Type getArgumentType(java.lang.String name)
Type
of the argument with the specified formal
name, if any; otherwise, return null.name
- The formal argument name whose type is to be returned.public int getArgumentMode(java.lang.String name)
name
- The formal argument name whose type is to be returned.public void setBuiltIn(boolean is_builtin)
is_builtin
- TRUE if the method is/should be built-in; otherwise,
false.public boolean isBuiltIn()
public void setComment(Comment comment)
comment
- The comment associated with the method. May be null.public Comment getComment()
public void setCommunicationModifier(int modifier)
modifier
- The method's communication modifier. Valid values
are NORMAL, LOCAL, and ONEWAY.public int getCommunicationModifier()
public java.lang.String getCommunicationModifierString()
public void setDefinitionModifier(int modifier)
modifier
- The method's definnition modifier. Valid values are
NORMAL, ABSTRACT, FINAL, and STATIC.public int getDefinitionModifier()
public java.lang.String getDefinitionModifier(boolean is_interface)
is_interface
- If TRUE, then the extendable is an interface so
do NOT include ABSTRACT since it is implicit.public boolean isAbstract()
public boolean isFinal()
public boolean isStatic()
public boolean hasArrayOrderSpec()
void doIt(in array<int, 2, row-major> x);
will return TRUE.public void setMethodName(java.lang.String shortName, java.lang.String extension)
shortName
- The short name of the methodextension
- The method name extension used in combination
with the short name to uniquely identify this
methodpublic void setMethodName(java.lang.String shortName)
shortName
- The short name of the methodpublic java.lang.String getCorrectMethodName()
public java.lang.String getShortMethodName()
public java.lang.String getNameExtension()
public java.lang.String getLongMethodName()
public java.lang.String getBlockingMethodName()
public void setReturnCopy(boolean copy)
copy
- If TRUE then the return interface/class is to be copied
to the caller; otherwise, it is not.public boolean isReturnCopy()
public void setReturnType(Type type)
type
- The return type to be used. Note that a void return
type must be represented by a Type.VOID
NOT a null Type reference.public Type getReturnType()
public void addThrows(SymbolID id)
id
- The symbol identifier to be addedpublic void addImplicitThrows(SymbolID id)
public boolean isImplicitException(SymbolID id)
public boolean hasExplicitExceptions()
public java.util.Set getThrows()
Set
of exceptions that may be thrown by this
method. Each element of the set is a SymbolID
.public java.util.Set getExplicitThrows()
Set
of explicit exceptions that may be thrown
by this method. Each element of the set is a SymbolID
.public java.util.Set getImplicitThrows()
Set
of implicit exceptions that may be thrown
by this method. Each element of the set is a SymbolID
.public java.util.Set getSymbolReferences()
Set
of symbols referred to by this method.
Each element of the set is a SymbolID
.public java.util.Set getSymbolReferencesWithoutExceptions()
Set
of symbols referred to by this method,
except for the exceptions it throws.
Each element of the set is a SymbolID
.public java.util.Set getBasicArrays()
Set
of basic array references including
arrays of fundamental types such as double, int, etc. Each element
of the set is a SymbolID
.public java.lang.String getReturnType(java.lang.String parent_pkg)
parent_pkg
- The string containing the parent package. When not
null, it is used to strip the package from the return
string if it is in the specified package.public java.lang.String getSignaturePreface(boolean is_interface, java.lang.String parent_pkg)
is_interface
- TRUE if an interface and want the implicit
definition modifier excluded from the result;
otherwise, FALSE.parent_pkg
- The string containing the parent package. When not
null, it is used to strip the package from the return
string if it is in the specified package.public java.lang.String getSignature(boolean is_interface, java.lang.String parent_pkg)
is_interface
- TRUE if interface and want the implicit definition
modifier excluded from the result; otherwise, FALSEparent_pkg
- The string containing the parent package. When not
null, it is used to strip the package from the return
string if it is in the specified package.public java.lang.String getSignature()
public boolean sameSignature(Method m)
m
- The method whose signature is being compared with.public boolean sameSignature(Method m, boolean compExt)
m
- The method whose signature is being compared with.compExt
- True if the comparision should compare method
extensions. (False for from clauses)public boolean sameBaseSignature(Method m)
m
- The method whose base signature is being compared.public boolean overloadCollision(Method m)
public Argument getArgumentByName(java.lang.String s)
public void addClauseAssertion(Assertion assertion) throws AssertionException
assertion
- The assertion to be added.AssertionException
- The exception thrown if the assertion is not valid.public java.util.List getPreClause()
List
of Assertion
s that make up
the precondition clause.public boolean hasPreClause()
public java.util.List getPostClause()
List
of Assertion
s that make up
the postcondition clause.public boolean hasPostClause()
public boolean preHasMethodCall()
public boolean postHasMethodCall()
public boolean preHasResultOrOutArg()
public boolean postHasResultOrOutArg()
public boolean postHasResult()
public boolean hasPureAssertion()
public int getPreDefaultComplexity()
public int getPostDefaultComplexity()
public boolean contractHasBuiltinMethod(int type)
public boolean contractHasUserDefinedMethod(boolean any)
public int getMaxArrayIterMacros(char type)
public java.util.Map getRarrayInfo()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean hasAttribute(java.lang.String key)
hasAttribute
in interface Attributes
public java.lang.String getAttribute(java.lang.String key)
getAttribute
in interface Attributes
public void setAttribute(java.lang.String key)
setAttribute
in interface Attributes
public void setAttribute(java.lang.String key, java.lang.String value)
setAttribute
in interface Attributes
public void removeAttribute(java.lang.String key) throws UnknownAttributeException
removeAttribute
in interface Attributes
UnknownAttributeException
public java.util.Set getAttributes()
getAttributes
in interface Attributes
public Metadata getMetadata()
IMetadata
getMetadata
in interface IMetadata
public void addMetadata(java.lang.String keyword, java.lang.String value)
IMetadata
addMetadata
in interface IMetadata
public void addSplicerContents(java.lang.String location, java.lang.String name, java.lang.String impl)
public java.util.ArrayList getSplicerBlocks(java.lang.String location)
public java.util.ArrayList getSplicerContents(java.lang.String location, java.lang.String name)