| java.lang.Object com.go.tea.parsetree.Node com.go.tea.parsetree.Expression
All known Subclasses: com.go.tea.parsetree.Lookup, com.go.tea.parsetree.Literal, com.go.tea.parsetree.NotExpression, com.go.tea.parsetree.CallExpression, com.go.tea.parsetree.NewArrayExpression, com.go.tea.parsetree.NegateExpression, com.go.tea.parsetree.BinaryExpression, com.go.tea.parsetree.VariableRef, com.go.tea.parsetree.ParenExpression, com.go.tea.parsetree.ArrayLookup,
Expression | public class Expression extends Node (Code) | | An Expression is a piece of code that, when executed, produces a value.
All expressions have a type which represents the type of value is produces.
author: Brian S O'Neill version: 36 , 01/01/25 |
Inner Class :public static class Conversion | |
Method Summary | |
public Object | accept(NodeVisitor visitor) | public Object | clone() | final public void | convertTo(Type toType) Applies a type conversion to this expression which is chained to all
previous conversions. | public void | convertTo(Type toType, boolean preferCast) Applies a type conversion to this expression which is chained to all
previous conversions. | public LinkedList | getConversionChain() Returns a list of Conversion objects representing the all the
conversions that have been applied to this Expression. | public Type | getInitialType() Returns the type of this expression before any conversions were applied,
or null if the type isn't set. | public Type | getType() The type of an expression is not necessarily set by a parser. | public Object | getValue() Most expressions can't generate a value at compile-time, so this
method simply returns null. | public boolean | isExceptionPossible() Returns true if an exception can be thrown while executing this
Expression. | public boolean | isValueKnown() Returns true if the value generated by this expression is known at
compile-time. | public void | setInitialType(Type type) Sets the intial type in the conversion chain, but does not clear the
conversions. | public void | setType(Type type) Sets the type of this expression, clearing the conversion chain. |
convertTo | final public void convertTo(Type toType)(Code) | | Applies a type conversion to this expression which is chained to all
previous conversions.
Parameters: toType - the type to convert to. |
convertTo | public void convertTo(Type toType, boolean preferCast)(Code) | | Applies a type conversion to this expression which is chained to all
previous conversions.
Parameters: toType - the type to convert to. Parameters: preferCast - a hint that the conversion should be performed by atype cast operation, by default is true. throws: IllegalArgumentException - when the conversion is illegal. |
getConversionChain | public LinkedList getConversionChain()(Code) | | 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 .
|
getInitialType | public Type getInitialType()(Code) | | Returns the type of this expression before any conversions were applied,
or null if the type isn't set.
|
getType | public Type getType()(Code) | | 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.
null if type is unknown |
getValue | public Object getValue()(Code) | | 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.
|
isExceptionPossible | public boolean isExceptionPossible()(Code) | | 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.
|
isValueKnown | public boolean isValueKnown()(Code) | | Returns true if the value generated by this expression is known at
compile-time. For most expressions, false is returned. Literals
always return true.
See Also: Literal |
setInitialType | public void setInitialType(Type type)(Code) | | Sets the intial type in the conversion chain, but does not clear the
conversions.
|
setType | public void setType(Type type)(Code) | | Sets the type of this expression, clearing the conversion chain.
|
|
|