gov.llnl.babel.symbols

Class AssertionExpression

Known Direct Subclasses:
BinaryExpression, Literal, MethodCall, UnaryExpression

public abstract class AssertionExpression
extends java.lang.Object

Field Summary

static String
ERROR_SEMANTIC_VALIDATION
protected Context
d_context

Constructor Summary

AssertionExpression(boolean valid, Context context)
Used to initialize the basic expression attributes.

Method Summary

abstract Object
accept(ExprVisitor ev, Object data)
Implement the "visitor pattern".
abstract String
cExpression(String epvVar, int[] startInd)
Return the C version of the expression.
abstract ArrayList
getArrayIterMacros(String epvVar, int[] startInd)
Return the list of array iteration macro messages, if any.
protected String
getExceptionPrefix(Extendable ext)
Return the prefix for exception messages based on the specified extendable.
protected String
getExceptionPrefix(Extendable ext, Method m)
Return the prefix for exception messages based on the specified extendable and method.
abstract int
getNumArrayIterMacrosByType(char type)
Returns the number of macros supported by this assertion of the specified type.
Type
getReturnType()
Return the return type.
String
getReturnTypeName()
Return the name of the return type or, if empty, null.
int
getReturnTypeValue()
Return the value of the return type or -1 if no return type.
abstract boolean
hasMethodCall()
Return TRUE if the expression is, or has, at least one method call; otherwise, return FALSE.
boolean
hasParens()
Return TRUE if the original expression had parentheses; otherwise, return FALSE.
abstract boolean
hasPure()
Return TRUE if the expression is, or has, a PURE clause; otherwise, return FALSE.
abstract boolean
hasReservedMethod(int type)
Return TRUE if the expression is, or has, the specified reserved method call; otherwise, return FALSE.
abstract boolean
hasResult()
Return TRUE if the expression contains RESULT; otherwise, return FALSE.
abstract boolean
hasUnreservedMethod(boolean any)
Return TRUE if the method is any unreserved method (when any is TRUE) or it is an unreserved method with a throws clause (if any is FALSE); otherwise, return FALSE.
boolean
isValid()
Return TRUE if the expression has been marked as having passed the validation checks; otherwise, return FALSE.
boolean
leftAssociative()
Return true iff the operator is parsed left to right.
abstract boolean
requiresExtendableContext()
Return TRUE if extendable context is required to validate the expression; otherwise, return FALSE.
abstract boolean
requiresMethodContext()
Return TRUE if method context is required to validate the expression; otherwise, return FALSE.
boolean
returnIsArray()
Return TRUE if the return type is an array; otherwise, return FALSE.
boolean
returnIsBoolean()
Return TRUE if the return type is a boolean; otherwise, return FALSE.
boolean
returnIsCharacter()
Return TRUE if the return type is a character; otherwise, return FALSE.
boolean
returnIsDComplex()
Return TRUE if the return type is a double complex; otherwise, return FALSE.
boolean
returnIsDouble()
Return TRUE if the return type is a double; otherwise, return FALSE.
boolean
returnIsFComplex()
Return TRUE if the return type is a float complex; otherwise, return FALSE.
boolean
returnIsFloat()
Return TRUE if the return type is a float; otherwise, return FALSE.
boolean
returnIsInteger()
Return TRUE if the return type is a integer; otherwise, return FALSE.
boolean
returnIsLong()
Return TRUE if the return type is a long; otherwise, return FALSE.
boolean
returnIsNumericArray()
Return TRUE if the return type is an array; otherwise, return FALSE.
boolean
returnIsOpaque()
Return TRUE if the return type is a opaque; otherwise, return FALSE.
boolean
returnIsString()
Return TRUE if the return type is a string; otherwise, return FALSE.
void
setParens(boolean parens)
Sets the parens attribute to reflect whether or not the expression is specified to be contained within parentheses.
protected void
setReturnToBoolean()
Set the return type to boolean.
protected void
setReturnToCharacter()
Set the return type to character.
protected void
setReturnToDComplex()
Set the return type to double complex.
protected void
setReturnToDouble()
Set the return type to double.
protected void
setReturnToFComplex()
Set the return type to float complex.
protected void
setReturnToFloat()
Set the return type to float.
protected void
setReturnToInteger()
Set the return type to integer.
protected void
setReturnToLong()
Set the return type to long.
protected void
setReturnToOpaque()
Set the return type to opaque.
protected void
setReturnToString()
Set the return type to string.
protected void
setReturnType(Type return_type)
Set the return type associated with the expression based on the value associated with the specified return type.
protected void
setReturnType(int return_type)
Set the return type associated with the expression based on the specified type value.
abstract String
toString()
Return the stringified version of the expression (in SIDL form).
void
validateExpression(Extendable ext, Method m)
Validate this assertion expression within the context of the given extendable and optional method.
protected abstract void
validateSemantics(Extendable ext, Method m)
Validate the expression semantics, if necessary, within the context of the extendable and/or method.

Field Details

ERROR_SEMANTIC_VALIDATION

public static final String ERROR_SEMANTIC_VALIDATION

d_context

protected Context d_context

Constructor Details

AssertionExpression

public AssertionExpression(boolean valid,
                           Context context)
Used to initialize the basic expression attributes.
Parameters:
valid - Use TRUE only if the expression is clearly valid from the start (e.g., most literals).

Method Details

accept

public abstract Object accept(ExprVisitor ev,
                              Object data)
Implement the "visitor pattern".

cExpression

public abstract String cExpression(String epvVar,
                                   int[] startInd)
Return the C version of the expression.

getArrayIterMacros

public abstract ArrayList getArrayIterMacros(String epvVar,
                                             int[] startInd)
Return the list of array iteration macro messages, if any. Each message is a string where the first character indicates the return type associated with the iteration. The remaining characters will be the actual macro invocation.

getExceptionPrefix

protected String getExceptionPrefix(Extendable ext)
Return the prefix for exception messages based on the specified extendable.
Parameters:
ext - The interface or class that owns this expression.

getExceptionPrefix

protected String getExceptionPrefix(Extendable ext,
                                    Method m)
Return the prefix for exception messages based on the specified extendable and method.
Parameters:
ext - The interface or class that owns this expression.
m - The method that owns this expression.

getNumArrayIterMacrosByType

public abstract int getNumArrayIterMacrosByType(char type)
Returns the number of macros supported by this assertion of the specified type. Valid types are given in MethodCall.java.

getReturnType

public Type getReturnType()
Return the return type.

getReturnTypeName

public String getReturnTypeName()
Return the name of the return type or, if empty, null.

getReturnTypeValue

public int getReturnTypeValue()
Return the value of the return type or -1 if no return type. Assumption(s): 1) Value of -1 is not a valid return type value per the Type class.

hasMethodCall

public abstract boolean hasMethodCall()
Return TRUE if the expression is, or has, at least one method call; otherwise, return FALSE.

hasParens

public boolean hasParens()
Return TRUE if the original expression had parentheses; otherwise, return FALSE.

hasPure

public abstract boolean hasPure()
Return TRUE if the expression is, or has, a PURE clause; otherwise, return FALSE.

hasReservedMethod

public abstract boolean hasReservedMethod(int type)
Return TRUE if the expression is, or has, the specified reserved method call; otherwise, return FALSE.

hasResult

public abstract boolean hasResult()
Return TRUE if the expression contains RESULT; otherwise, return FALSE.

hasUnreservedMethod

public abstract boolean hasUnreservedMethod(boolean any)
Return TRUE if the method is any unreserved method (when any is TRUE) or it is an unreserved method with a throws clause (if any is FALSE); otherwise, return FALSE.

isValid

public boolean isValid()
Return TRUE if the expression has been marked as having passed the validation checks; otherwise, return FALSE.

leftAssociative

public boolean leftAssociative()
Return true iff the operator is parsed left to right.

requiresExtendableContext

public abstract boolean requiresExtendableContext()
Return TRUE if extendable context is required to validate the expression; otherwise, return FALSE.

requiresMethodContext

public abstract boolean requiresMethodContext()
Return TRUE if method context is required to validate the expression; otherwise, return FALSE.

returnIsArray

public boolean returnIsArray()
Return TRUE if the return type is an array; otherwise, return FALSE.

returnIsBoolean

public boolean returnIsBoolean()
Return TRUE if the return type is a boolean; otherwise, return FALSE.

returnIsCharacter

public boolean returnIsCharacter()
Return TRUE if the return type is a character; otherwise, return FALSE.

returnIsDComplex

public boolean returnIsDComplex()
Return TRUE if the return type is a double complex; otherwise, return FALSE.

returnIsDouble

public boolean returnIsDouble()
Return TRUE if the return type is a double; otherwise, return FALSE.

returnIsFComplex

public boolean returnIsFComplex()
Return TRUE if the return type is a float complex; otherwise, return FALSE.

returnIsFloat

public boolean returnIsFloat()
Return TRUE if the return type is a float; otherwise, return FALSE.

returnIsInteger

public boolean returnIsInteger()
Return TRUE if the return type is a integer; otherwise, return FALSE.

returnIsLong

public boolean returnIsLong()
Return TRUE if the return type is a long; otherwise, return FALSE.

returnIsNumericArray

public boolean returnIsNumericArray()
Return TRUE if the return type is an array; otherwise, return FALSE.

returnIsOpaque

public boolean returnIsOpaque()
Return TRUE if the return type is a opaque; otherwise, return FALSE.

returnIsString

public boolean returnIsString()
Return TRUE if the return type is a string; otherwise, return FALSE.

setParens

public void setParens(boolean parens)
Sets the parens attribute to reflect whether or not the expression is specified to be contained within parentheses.
Parameters:
parens - TRUE if the expression is known to be specified to be contained within parentheses; FALSE otherwise.

setReturnToBoolean

protected void setReturnToBoolean()
            throws AssertionException
Set the return type to boolean.

setReturnToCharacter

protected void setReturnToCharacter()
            throws AssertionException
Set the return type to character.

setReturnToDComplex

protected void setReturnToDComplex()
            throws AssertionException
Set the return type to double complex.

setReturnToDouble

protected void setReturnToDouble()
            throws AssertionException
Set the return type to double.

setReturnToFComplex

protected void setReturnToFComplex()
            throws AssertionException
Set the return type to float complex.

setReturnToFloat

protected void setReturnToFloat()
            throws AssertionException
Set the return type to float.

setReturnToInteger

protected void setReturnToInteger()
            throws AssertionException
Set the return type to integer.

setReturnToLong

protected void setReturnToLong()
            throws AssertionException
Set the return type to long.

setReturnToOpaque

protected void setReturnToOpaque()
            throws AssertionException
Set the return type to opaque.

setReturnToString

protected void setReturnToString()
            throws AssertionException
Set the return type to string.

setReturnType

protected void setReturnType(Type return_type)
            throws AssertionException
Set the return type associated with the expression based on the value associated with the specified return type.
Parameters:
return_type - A return type containing the value for this expression.
Throws:
AssertionException - The exception raised if the specified return type is still not determined.

setReturnType

protected void setReturnType(int return_type)
            throws AssertionException
Set the return type associated with the expression based on the specified type value.
Parameters:
return_type - A return type value for this expression.
Throws:
AssertionException - The exception raised if the specified return type is still not determined.

toString

public abstract String toString()
Return the stringified version of the expression (in SIDL form).

validateExpression

public void validateExpression(Extendable ext,
                               Method m)
            throws AssertionException
Validate this assertion expression within the context of the given extendable and optional method. Assumptions: o All methods within the extendable have been populated in the symbol table prior to invocation; Requirements: o This method MUST be invoked and execute successfully before the expression can be marked as valid.
Parameters:
ext - The interface or class that owns this expression.
m - The method that owns this expression.
Throws:
AssertionException - The exception raised if sufficient context is unavailable or that can be propagated by validations.

validateSemantics

protected abstract void validateSemantics(Extendable ext,
                                          Method m)
            throws AssertionException
Validate the expression semantics, if necessary, within the context of the extendable and/or method. If the method does not apply for the context, then the argument can be passed in as null.
Parameters:
ext - The interface or class that owns this expression.
m - The method that owns this expression.
Throws:
AssertionException - The exception that can be raised during the validation.