gov.llnl.babel.symbols

Class UnaryExpression


public class UnaryExpression
extends AssertionExpression

Field Summary

static int
COMPLEMENT
static int
IS
static int
MINUS
static int
NOOP
static int
NOT
static int
PLUS

Fields inherited from class gov.llnl.babel.symbols.AssertionExpression

ERROR_SEMANTIC_VALIDATION, d_context

Constructor Summary

UnaryExpression(int op, AssertionExpression expr, Context context)
Construct a new object.

Method Summary

Object
accept(ExprVisitor ev, Object data)
String
cExpression(String epvVar, int[] startInd)
Return the C version of the expression.
ArrayList
getArrayIterMacros(String epvVar, int[] startInd)
Return the list of array iteration macro messages, if any.
AssertionExpression
getExpression()
Return the expression.
int
getNumArrayIterMacrosByType(char type)
Returns the number of macros supported by this assertion of the specified type.
int
getOp()
Return the unary operator.
String
getOpSymbol()
Return the symbol associated with the operator.
boolean
hasMethodCall()
Return TRUE if the expression has at least one method call; otherwise, return FALSE.
boolean
hasPure()
Return TRUE if the expression is PURE clause; otherwise, return FALSE.
boolean
hasReservedMethod(int type)
Return TRUE if the expression is, or has, the specified reserved method call; otherwise, return FALSE.
boolean
hasResult()
Return TRUE if the expression contains RESULT; otherwise, return FALSE.
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
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.
String
toString()
Return the stringified version of the expression (in SIDL form).
protected void
validateSemantics(Extendable ext, Method m)
Validate the expression semantics, if necessary, within the context of the extendable and optional method.

Methods inherited from class gov.llnl.babel.symbols.AssertionExpression

accept, cExpression, getArrayIterMacros, getExceptionPrefix, getExceptionPrefix, getNumArrayIterMacrosByType, getReturnType, getReturnTypeName, getReturnTypeValue, hasMethodCall, hasParens, hasPure, hasReservedMethod, hasResult, hasUnreservedMethod, isValid, leftAssociative, requiresExtendableContext, requiresMethodContext, returnIsArray, returnIsBoolean, returnIsCharacter, returnIsDComplex, returnIsDouble, returnIsFComplex, returnIsFloat, returnIsInteger, returnIsLong, returnIsNumericArray, returnIsOpaque, returnIsString, setParens, setReturnToBoolean, setReturnToCharacter, setReturnToDComplex, setReturnToDouble, setReturnToFComplex, setReturnToFloat, setReturnToInteger, setReturnToLong, setReturnToOpaque, setReturnToString, setReturnType, setReturnType, toString, validateExpression, validateSemantics

Field Details

COMPLEMENT

public static final int COMPLEMENT
Field Value:
1

IS

public static final int IS
Field Value:
2

MINUS

public static final int MINUS
Field Value:
3

NOOP

public static final int NOOP
Field Value:
0

NOT

public static final int NOT
Field Value:
4

PLUS

public static final int PLUS
Field Value:
5

Constructor Details

UnaryExpression

public UnaryExpression(int op,
                       AssertionExpression expr,
                       Context context)
            throws AssertionException
Construct a new object.
Parameters:
op - The operator associated with this unary expression.
expr - The expression being paired with the operator.
Throws:
AssertionException - The exception raised if the operator does not fall within the range of supported operators OR if the expression is null.

Method Details

accept

public Object accept(ExprVisitor ev,
                     Object data)
Overrides:
accept in interface AssertionExpression

cExpression

public String cExpression(String epvVar,
                          int[] startInd)
Return the C version of the expression.
Overrides:
cExpression in interface AssertionExpression

getArrayIterMacros

public 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.
Overrides:
getArrayIterMacros in interface AssertionExpression

getExpression

public AssertionExpression getExpression()
Return the expression.

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.
Overrides:
getNumArrayIterMacrosByType in interface AssertionExpression

getOp

public int getOp()
Return the unary operator.

getOpSymbol

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

hasMethodCall

public boolean hasMethodCall()
Return TRUE if the expression has at least one method call; otherwise, return FALSE. Clearly this expression isn't a method call BUT the expression may be or contain one.
Overrides:
hasMethodCall in interface AssertionExpression

hasPure

public boolean hasPure()
Return TRUE if the expression is PURE clause; otherwise, return FALSE.
Overrides:
hasPure in interface AssertionExpression

hasReservedMethod

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

hasResult

public boolean hasResult()
Return TRUE if the expression contains RESULT; otherwise, return FALSE.
Overrides:
hasResult in interface AssertionExpression

hasUnreservedMethod

public 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.
Overrides:
hasUnreservedMethod in interface AssertionExpression

requiresExtendableContext

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

requiresMethodContext

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

toString

public String toString()
Return the stringified version of the expression (in SIDL form).
Overrides:
toString in interface AssertionExpression

validateSemantics

protected void validateSemantics(Extendable ext,
                                 Method m)
            throws AssertionException
Validate the expression semantics, if necessary, within the context of the extendable and optional method.
Overrides:
validateSemantics in interface 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 validation.