com.go.tea.parsetree
Class ParenExpression

java.lang.Object
  |
  +--com.go.tea.parsetree.Node
        |
        +--com.go.tea.parsetree.Expression
              |
              +--com.go.tea.parsetree.ParenExpression
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ParenExpression
extends Expression

A ParenExpression is a thin wrapper around an Expression that was delimited by parenthesis in the source code. A parse tree does not necessarily need a ParenExpression, but it is useful when reconstructing something that resembles the source code.

Version:
28 , 01/02/01
Author:
Brian S O'Neill
See Also:
Serialized Form

Inner classes inherited from class com.go.tea.parsetree.Expression
Expression.Conversion
 
Constructor Summary
ParenExpression(SourceInfo info, Expression expr)
           
 
Method Summary
 java.lang.Object accept(NodeVisitor visitor)
          Every subclass of Node must override this method with the following: return visitor.visit(this).
 java.lang.Object clone()
          Returns a clone of this Node and all its children.
 void convertTo(Type toType, boolean preferCast)
          Applies a type conversion to this expression which is chained to all previous conversions.
 java.util.LinkedList getConversionChain()
          Returns a list of Conversion objects representing the all the conversions that have been applied to this Expression.
 Expression getExpression()
           
 Type getInitialType()
          Returns the type of this expression before any conversions were applied, or null if the type isn't set.
 Type getType()
          The type of an expression is not necessarily set by a parser.
 java.lang.Object getValue()
          Most expressions can't generate a value at compile-time, so this method simply returns null.
 boolean isExceptionPossible()
          Returns true if an exception can be thrown while executing this Expression.
 boolean isValueKnown()
          Returns true if the value generated by this expression is known at compile-time.
 void setExpression(Expression expr)
           
 void setInitialType(Type type)
          Sets the intial type in the conversion chain, but does not clear the conversions.
 void setType(Type type)
          Sets the type of this expression, clearing the conversion chain.
 
Methods inherited from class com.go.tea.parsetree.Expression
convertTo
 
Methods inherited from class com.go.tea.parsetree.Node
getSourceInfo, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParenExpression

public ParenExpression(SourceInfo info,
                       Expression expr)
Method Detail

accept

public java.lang.Object accept(NodeVisitor visitor)
Description copied from class: Node
Every subclass of Node must override this method with the following: return visitor.visit(this).
Overrides:
accept in class Expression
Following copied from class: com.go.tea.parsetree.Node
Parameters:
visitor - A visitor of this Node
Returns:
Node The Node returned by the visitor
See Also:
NodeVisitor

clone

public java.lang.Object clone()
Description copied from class: Node
Returns a clone of this Node and all its children. Immutable child objects are not necessarily cloned
Overrides:
clone in class Expression

isExceptionPossible

public boolean isExceptionPossible()
Description copied from class: Expression
Returns true if an exception can be thrown while executing this Expression. By default, returns true only if a type conversion could cause an exception.
Overrides:
isExceptionPossible in class Expression

getType

public Type getType()
Description copied from class: Expression
The type of an expression is not necessarily set by a parser. It is typically set by a type checker. An expression's type may represent its natural type or its coerced type. A code generator is responsible for ensuring that the type it generates correctly matches the type of the expression.
Overrides:
getType in class Expression
Following copied from class: com.go.tea.parsetree.Expression
Returns:
null if type is unknown

getInitialType

public Type getInitialType()
Description copied from class: Expression
Returns the type of this expression before any conversions were applied, or null if the type isn't set.
Overrides:
getInitialType in class Expression

convertTo

public void convertTo(Type toType,
                      boolean preferCast)
Description copied from class: Expression
Applies a type conversion to this expression which is chained to all previous conversions.
Overrides:
convertTo in class Expression
Following copied from class: com.go.tea.parsetree.Expression
Parameters:
toType - the type to convert to.
preferCast - a hint that the conversion should be performed by a type cast operation, by default is true.
Throws:
java.lang.IllegalArgumentException - when the conversion is illegal.

getConversionChain

public java.util.LinkedList getConversionChain()
Description copied from class: Expression
Returns a list of Conversion objects representing the all the conversions that have been applied to this Expression. Unless the type isn't set, the chain contains at least one element. The conversion chain may be reduced or expanded, so its length doesn't necessarily represent the exact sequence of calls to Expression.convertTo(com.go.tea.compiler.Type).
Overrides:
getConversionChain in class Expression

setType

public void setType(Type type)
Description copied from class: Expression
Sets the type of this expression, clearing the conversion chain.
Overrides:
setType in class Expression

setInitialType

public void setInitialType(Type type)
Description copied from class: Expression
Sets the intial type in the conversion chain, but does not clear the conversions.
Overrides:
setInitialType in class Expression

isValueKnown

public boolean isValueKnown()
Description copied from class: Expression
Returns true if the value generated by this expression is known at compile-time. For most expressions, false is returned. Literals always return true.
Overrides:
isValueKnown in class Expression
Following copied from class: com.go.tea.parsetree.Expression
See Also:
Literal

getValue

public java.lang.Object getValue()
Description copied from class: Expression
Most expressions can't generate a value at compile-time, so this method simply returns null. Call isValueKnown to check if the expression's value is known at compile-time.
Overrides:
getValue in class Expression

getExpression

public Expression getExpression()

setExpression

public void setExpression(Expression expr)