gov.llnl.babel.symbols
Class BinaryExpression

java.lang.Object
  extended by gov.llnl.babel.symbols.AssertionExpression
      extended by gov.llnl.babel.symbols.BinaryExpression

public class BinaryExpression
extends AssertionExpression


Field Summary
static int BITWISE_AND
           
static int BITWISE_OR
           
static int BITWISE_XOR
           
static int DIVIDE
           
static int EQUALS
           
static int GREATER_EQUAL
           
static int GREATER_THAN
           
static int IF_AND_ONLY_IF
           
static int IMPLIES
           
static int LESS_EQUAL
           
static int LESS_THAN
           
static int LOGICAL_AND
           
static int LOGICAL_OR
           
static int LOGICAL_XOR
           
static int MAX_OP_VALUE
           
static int MIN_OP_VALUE
           
static int MINUS
           
static int MODULUS
           
static int MULTIPLY
           
static int NOOP
           
static int NOT_EQUAL
           
static int PLUS
           
static int POWER
           
static int REMAINDER
           
static int SHIFT_LEFT
           
static int SHIFT_RIGHT
           
 
Fields inherited from class gov.llnl.babel.symbols.AssertionExpression
d_context, ERROR_SEMANTIC_VALIDATION
 
Constructor Summary
BinaryExpression(AssertionExpression lhs, int op, AssertionExpression rhs, Context context)
          Construct a new object.
 
Method Summary
 java.lang.Object accept(ExprVisitor ev, java.lang.Object data)
          Implement the "visitor pattern".
 boolean arrayOnLeft()
          Return TRUE if an array appears on the LHS; otherwise, FALSE.
 boolean arrayOnRight()
          Return TRUE if an array appears on the RHS; otherwise, FALSE.
 java.lang.String cExpression(java.lang.String epvVar, int[] startInd)
          Return the C version of the expression.
 java.util.ArrayList getArrayIterMacros(java.lang.String epvVar, int[] startInd)
          Return the list of array iteration macro messages, if any.
 java.lang.String getArrayRelation()
          Return the array relation only.
 java.lang.String getArrayRelationVariable(boolean onLeft)
          Return the specified array relation's array variable.
 int getDefaultComplexity()
          Return the default complexity of the expression (0 = constant, 1 = linear, etc.).
 AssertionExpression getLeftExpression()
          Return the left-hand expression.
 int getNumArrayIterMacrosByType(char type)
          Returns the number of macros supported by this assertion of the specified type.
 int getOp()
          Return the binary operator.
 java.lang.String getOpSymbol()
          Return the symbol associated with the operator.
 AssertionExpression getRightExpression()
          Return the right-hand expression.
 boolean hasBuiltinMethod(int type)
          Return TRUE if the expression is, or has, the specified built-in method call; otherwise, return FALSE.
 boolean hasMethodCall()
          Return TRUE if the expression has at least one method call; otherwise, return FALSE.
 boolean hasPure()
          Return TRUE if the expression has an "is pure" clause; otherwise, return FALSE.
 boolean hasResult()
          Return TRUE if the expression uses the "result" keyword; otherwise, return FALSE.
 boolean hasResultOrArg()
          Return TRUE if a result clause or method argument is found within the expression; otherwise, return FALSE.
 boolean hasResultOrOutArg(boolean outOnly)
          Return TRUE if a result clause or output argument is found within the expression; otherwise, return FALSE.
 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 isArrayRelationRequired()
          Return TRUE if the array relation is required (during validation); otherwise, return FALSE.
 boolean requiresExtendableContext()
          Return TRUE if extendable context is required to validate the expression; otherwise, return FALSE.
 boolean requiresMethodContext()
          Return TRUE if method context is required to validate the expression; otherwise, return FALSE.
 void setArrayRelationRequired(boolean isReq)
          Set the array relation required attribute.
 java.lang.String toString()
          Return the stringified version of the expression (in SIDL form).
protected  void validateSemantics(Extendable ext, Method m)
          Validate the expression semantics, first ensuring both subexpressions are valid then that the binary expression is valid for the specified operator.
 
Methods inherited from class gov.llnl.babel.symbols.AssertionExpression
getExceptionPrefix, getExceptionPrefix, getReturnType, getReturnTypeName, getReturnTypeValue, hasParens, isValid, leftAssociative, returnIsArray, returnIsBoolean, returnIsCharacter, returnIsClass, returnIsDComplex, returnIsDouble, returnIsEnum, returnIsFComplex, returnIsFloat, returnIsInteger, returnIsInterface, returnIsLong, returnIsNumericArray, returnIsOpaque, returnIsString, setParens, setReturnToBoolean, setReturnToCharacter, setReturnToClass, setReturnToDComplex, setReturnToDouble, setReturnToEnum, setReturnToFComplex, setReturnToFloat, setReturnToInteger, setReturnToInterface, setReturnToLong, setReturnToOpaque, setReturnToString, setReturnType, setReturnType, validateExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOOP

public static final int NOOP
See Also:
Constant Field Values

LOGICAL_AND

public static final int LOGICAL_AND
See Also:
Constant Field Values

DIVIDE

public static final int DIVIDE
See Also:
Constant Field Values

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

GREATER_EQUAL

public static final int GREATER_EQUAL
See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
See Also:
Constant Field Values

IF_AND_ONLY_IF

public static final int IF_AND_ONLY_IF
See Also:
Constant Field Values

IMPLIES

public static final int IMPLIES
See Also:
Constant Field Values

LESS_EQUAL

public static final int LESS_EQUAL
See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
See Also:
Constant Field Values

MINUS

public static final int MINUS
See Also:
Constant Field Values

MODULUS

public static final int MODULUS
See Also:
Constant Field Values

MULTIPLY

public static final int MULTIPLY
See Also:
Constant Field Values

NOT_EQUAL

public static final int NOT_EQUAL
See Also:
Constant Field Values

LOGICAL_OR

public static final int LOGICAL_OR
See Also:
Constant Field Values

PLUS

public static final int PLUS
See Also:
Constant Field Values

POWER

public static final int POWER
See Also:
Constant Field Values

REMAINDER

public static final int REMAINDER
See Also:
Constant Field Values

SHIFT_LEFT

public static final int SHIFT_LEFT
See Also:
Constant Field Values

SHIFT_RIGHT

public static final int SHIFT_RIGHT
See Also:
Constant Field Values

LOGICAL_XOR

public static final int LOGICAL_XOR
See Also:
Constant Field Values

BITWISE_AND

public static final int BITWISE_AND
See Also:
Constant Field Values

BITWISE_OR

public static final int BITWISE_OR
See Also:
Constant Field Values

BITWISE_XOR

public static final int BITWISE_XOR
See Also:
Constant Field Values

MIN_OP_VALUE

public static final int MIN_OP_VALUE
See Also:
Constant Field Values

MAX_OP_VALUE

public static final int MAX_OP_VALUE
See Also:
Constant Field Values
Constructor Detail

BinaryExpression

public BinaryExpression(AssertionExpression lhs,
                        int op,
                        AssertionExpression rhs,
                        Context context)
                 throws AssertionException
Construct a new object. An exception is thrown if an invalid binary operator is specified.

Parameters:
lhs - The expression on the left side of the operator.
op - The binary operator.
rhs - The expression on the right side of the operator.
Throws:
AssertionException - The exception raised if the specified return type is out of range, the operator invalid, or either the left or right expression is null.
Method Detail

getLeftExpression

public AssertionExpression getLeftExpression()
Return the left-hand expression.


getOp

public int getOp()
Return the binary operator.


getOpSymbol

public java.lang.String getOpSymbol()
Return the symbol associated with the operator. It is assumed the operator is valid thanks to the check in the constructor.


getRightExpression

public AssertionExpression getRightExpression()
Return the right-hand expression.


setArrayRelationRequired

public void setArrayRelationRequired(boolean isReq)
Set the array relation required attribute.


isArrayRelationRequired

public boolean isArrayRelationRequired()
Return TRUE if the array relation is required (during validation); otherwise, return FALSE.


getArrayRelationVariable

public java.lang.String getArrayRelationVariable(boolean onLeft)
Return the specified array relation's array variable.


getArrayRelation

public java.lang.String getArrayRelation()
Return the array relation only. For relations with a single array, this is the operator and value being used for comparison. When both arrays are specified, this is only the operator.


arrayOnLeft

public boolean arrayOnLeft()
Return TRUE if an array appears on the LHS; otherwise, FALSE.


arrayOnRight

public boolean arrayOnRight()
Return TRUE if an array appears on the RHS; otherwise, FALSE.


hasPure

public boolean hasPure()
Return TRUE if the expression has an "is pure" clause; otherwise, return FALSE.

Specified by:
hasPure in class AssertionExpression

hasResult

public boolean hasResult()
Return TRUE if the expression uses the "result" keyword; otherwise, return FALSE.

Specified by:
hasResult in class AssertionExpression

hasResultOrArg

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

Specified by:
hasResultOrArg in class AssertionExpression

hasResultOrOutArg

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

Specified by:
hasResultOrOutArg in class AssertionExpression
Parameters:
outOnly - TRUE if only concerned with output arguments that are out only; FALSE otherwise.

hasMethodCall

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

Specified by:
hasMethodCall in class AssertionExpression

getDefaultComplexity

public int getDefaultComplexity()
Return the default complexity of the expression (0 = constant, 1 = linear, etc.).

Specified by:
getDefaultComplexity in class AssertionExpression

hasBuiltinMethod

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

Specified by:
hasBuiltinMethod in class AssertionExpression

hasUserDefinedMethod

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

Specified by:
hasUserDefinedMethod in class AssertionExpression

requiresExtendableContext

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

Specified by:
requiresExtendableContext in class AssertionExpression

requiresMethodContext

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

Specified by:
requiresMethodContext in class AssertionExpression

validateSemantics

protected void validateSemantics(Extendable ext,
                                 Method m)
                          throws AssertionException
Validate the expression semantics, first ensuring both subexpressions are valid then that the binary expression is valid for the specified operator. Set the return type of this binary expression accordingly.

Specified by:
validateSemantics in class AssertionExpression
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.

getArrayIterMacros

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

Specified by:
getArrayIterMacros in class AssertionExpression

getNumArrayIterMacrosByType

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

Specified by:
getNumArrayIterMacrosByType in class AssertionExpression

cExpression

public java.lang.String cExpression(java.lang.String epvVar,
                                    int[] startInd)
Return the C version of the expression. ToDo...Need to finish this. In particular, need to handle complex subexpressions properly -- at least under the assumption that the relevant complex struct has been declared!

Specified by:
cExpression in class AssertionExpression

toString

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

Specified by:
toString in class AssertionExpression

accept

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

Specified by:
accept in class AssertionExpression