gov.llnl.babel.symbols
Class AssertionExpression

java.lang.Object
  extended by gov.llnl.babel.symbols.AssertionExpression
Direct Known Subclasses:
BinaryExpression, Literal, MethodCall, UnaryExpression

public abstract class AssertionExpression
extends java.lang.Object


Field Summary
protected  Context d_context
           
static java.lang.String ERROR_SEMANTIC_VALIDATION
           
 
Constructor Summary
AssertionExpression(boolean valid, Context context)
          Used to initialize the basic expression attributes.
 
Method Summary
abstract  java.lang.Object accept(ExprVisitor ev, java.lang.Object data)
          Implement the "visitor pattern".
abstract  java.lang.String cExpression(java.lang.String epvVar, int[] startInd)
          Return the C version of the expression.
abstract  java.util.ArrayList getArrayIterMacros(java.lang.String epvVar, int[] startInd)
          Return the list of array iteration macro messages, if any.
abstract  int getDefaultComplexity()
          Return the default complexity of the expression.
protected  java.lang.String getExceptionPrefix(Extendable ext)
          Return the prefix for exception messages based on the specified extendable.
protected  java.lang.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.
 java.lang.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 hasBuiltinMethod(int type)
          Return TRUE if the expression is, or has, the specified built-in method call; otherwise, return FALSE.
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 hasResult()
          Return TRUE if the expression contains RESULT; otherwise, return FALSE.
abstract  boolean hasResultOrArg()
          Return TRUE if a result clause or method argument is found within the expression; otherwise, return FALSE.
abstract  boolean hasResultOrOutArg(boolean outOnly)
          Return TRUE if a result clause or output argument is found within the expression; otherwise, return FALSE.
abstract  boolean hasUserDefinedMethod(boolean any)
          Return TRUE if the expression has a method AND the method is any user-defined method (when any is TRUE) or it is an user-defined 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 returnIsClass()
          Return TRUE if the return type is a class; 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 returnIsEnum()
          Return TRUE if the return type is an enumeration; 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 returnIsInterface()
          Return TRUE if the return type is an interface; 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 setReturnToClass()
          Set the return type to class.
protected  void setReturnToDComplex()
          Set the return type to double complex.
protected  void setReturnToDouble()
          Set the return type to double.
protected  void setReturnToEnum()
          Set the return type to enumeration.
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 setReturnToInterface()
          Set the return type to interface.
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(int return_type)
          Set the return type associated with the expression based on the specified type value.
protected  void setReturnType(Type return_type)
          Set the return type associated with the expression based on the value associated with the specified return type.
abstract  java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

d_context

protected Context d_context

ERROR_SEMANTIC_VALIDATION

public static final java.lang.String ERROR_SEMANTIC_VALIDATION
See Also:
Constant Field Values
Constructor Detail

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 Detail

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.

hasParens

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


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.

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.

getReturnType

public Type getReturnType()
Return the return type.


getReturnTypeName

public java.lang.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.


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.


returnIsEnum

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


returnIsClass

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


returnIsInterface

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


setReturnToBoolean

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

Throws:
AssertionException

setReturnToCharacter

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

Throws:
AssertionException

setReturnToDComplex

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

Throws:
AssertionException

setReturnToDouble

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

Throws:
AssertionException

setReturnToFComplex

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

Throws:
AssertionException

setReturnToFloat

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

Throws:
AssertionException

setReturnToInteger

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

Throws:
AssertionException

setReturnToLong

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

Throws:
AssertionException

setReturnToOpaque

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

Throws:
AssertionException

setReturnToString

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

Throws:
AssertionException

setReturnToEnum

protected void setReturnToEnum()
                        throws AssertionException
Set the return type to enumeration.

Throws:
AssertionException

setReturnToClass

protected void setReturnToClass()
                         throws AssertionException
Set the return type to class.

Throws:
AssertionException

setReturnToInterface

protected void setReturnToInterface()
                             throws AssertionException
Set the return type to interface.

Throws:
AssertionException

isValid

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


hasPure

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


hasResult

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


hasResultOrArg

public abstract boolean hasResultOrArg()
Return TRUE if a result clause or method argument is found within the expression; otherwise, return FALSE.


hasResultOrOutArg

public abstract boolean hasResultOrOutArg(boolean outOnly)
Return TRUE if a result clause or output argument is found within the expression; otherwise, return FALSE.

Parameters:
outOnly - TRUE if only concerned with output arguments that are out only; FALSE otherwise.

hasMethodCall

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


getDefaultComplexity

public abstract int getDefaultComplexity()
Return the default complexity of the expression.


hasBuiltinMethod

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


hasUserDefinedMethod

public abstract boolean hasUserDefinedMethod(boolean any)
Return TRUE if the expression has a method AND the method is any user-defined method (when any is TRUE) or it is an user-defined method with a throws clause (if any is FALSE); otherwise, return FALSE.


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.


getExceptionPrefix

protected java.lang.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.

getExceptionPrefix

protected java.lang.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.

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.

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.

getArrayIterMacros

public abstract java.util.ArrayList getArrayIterMacros(java.lang.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.


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.


cExpression

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

Throws:
AssertionException - this indicates that the expression contained unsupported node types.

leftAssociative

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


toString

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

Overrides:
toString in class java.lang.Object

accept

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