ast
Class UnaryExpr

java.lang.Object
  extended by ast.ASTNode
      extended by ast.Expr
          extended by ast.UnaryExpr
Direct Known Subclasses:
UnaryDecrExpr, UnaryIncrExpr, UnaryNegExpr, UnaryNotExpr

public abstract class UnaryExpr
extends Expr

The abstract UnaryExpr class represents unary expressions whose operand is an expression (i.e., this does not include new constructions). It can be either a negation expression ('-'), a complement expression ('!'), an increment expression ('++'), or a decrement expression ('--'). It contains an expression. Subclasses of this class can be handled similarly within the compiler, so most functionality can be implemented in the visitor method for this class.

See Also:
ASTNode, Expr

Field Summary
protected  Expr expr
          The expression
 
Fields inherited from class ast.ASTNode
charNum, lineNum, lineStr
 
Constructor Summary
UnaryExpr(int lineNum, Expr expr)
          UnaryExpr constructor
 
Method Summary
abstract  java.lang.Object accept(visitor.Visitor v, java.lang.Object o)
          Visitor method
 Expr getExpr()
          Get the expression
abstract  java.lang.String getOperandType()
          Get the operand type (e.g., "boolean") (must be defined by each subclass)
abstract  java.lang.String getOpName()
          Get the operation name (e.g., "!") (must be defined by each subclass)
abstract  java.lang.String getOpType()
          Get the operation type (e.g., "boolean") (must be defined by each subclass)
abstract  boolean isPostfix()
          Is this a postfix operator (as opposed to prefix)?
 
Methods inherited from class ast.Expr
getExprType, setExprType
 
Methods inherited from class ast.ASTNode
getLineNum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expr

protected Expr expr
The expression

Constructor Detail

UnaryExpr

public UnaryExpr(int lineNum,
                 Expr expr)
UnaryExpr constructor

Parameters:
lineNum - source line number corresponding to this AST node
expr - expression
Method Detail

getExpr

public Expr getExpr()
Get the expression

Returns:
expression

getOpName

public abstract java.lang.String getOpName()
Get the operation name (e.g., "!") (must be defined by each subclass)

Returns:
op name

getOpType

public abstract java.lang.String getOpType()
Get the operation type (e.g., "boolean") (must be defined by each subclass)

Returns:
op type

getOperandType

public abstract java.lang.String getOperandType()
Get the operand type (e.g., "boolean") (must be defined by each subclass)

Returns:
operand type

isPostfix

public abstract boolean isPostfix()
Is this a postfix operator (as opposed to prefix)?

Returns:
boolean indicating whether postfix operator

accept

public abstract java.lang.Object accept(visitor.Visitor v,
                                        java.lang.Object o)
Visitor method

Specified by:
accept in class Expr
Parameters:
v - visitor object
o - object to pass down
Returns:
result of visiting this node
See Also:
Visitor