org.millscript.millscript.expr
Class Expr<A extends Action>

java.lang.Object
  extended by org.millscript.millscript.expr.Expr<A>
Direct Known Subclasses:
AndAbsentExpr, AndExpr, ApplyExpr, ApplyUpdaterExpr, AssignExpr, BinaryOpExpr, Block, CaseExpr, CheckExpr, CheckNoneExpr, CommaExpr, ConstantExpr, DirectiveExpr, ExplodeExpr, FakeExpr, ForConditionExpr, ForExpr, If2Expr, If3Expr, InitExpr, LambdaExpr, ListExpr, MemoExpr, MethodExpr, MethodOverrideExpr, NameExpr, NoneExpr, NotExpr, OrAbsentExpr, OrExpr, RelationalOperationExpr, SkipExpr, SpiceClassExpr, SpiceClassInitExpr, SpiceClassSlotExpr, SwitchExpr, UnaryOpExpr, VarExpr, WhileExpr, XMLExpr

public abstract class Expr<A extends Action>
extends java.lang.Object

This class represents the base class of all expressions in MillScript. As such any new type of expression must extend this class, or one of it's more specific subclasses. An expression is the result of parsing syntax, and is the middle stage of compiling to actions.

See Also:
Action, Syntax

Constructor Summary
Expr()
           
 
Method Summary
 int arity()
          Returns the arity of this expression.
 A compile()
          Compiles this expression into an action, setting the context of the action.
abstract  A compileIt()
          Compiles this expression into an action.
static java.lang.Integer isIntegerExpr(Expr x)
          Checks if the specified expression is a constant integer and returns it.
abstract  void resolve(CompilerState state)
          Resolves any NameExpr in the tree so that they refer to the correct ident.
static void resolveList(CompilerState state, org.millscript.commons.util.IList<? extends Expr> list)
          Resolves all the expressions in the specified list, by calling the resolve(CompilerState) method on each one in turn.
 void setLineNumber(int n)
          Sets the line number of this expression in the origin.
 void setOrigin(java.lang.String x)
          Sets the origin of this expression.
 void show()
          Displays details about this expression, starting with no indent.
 void show(int n)
          Displays details about this expression, with the specified indent level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expr

public Expr()
Method Detail

isIntegerExpr

public static final java.lang.Integer isIntegerExpr(Expr x)
Checks if the specified expression is a constant integer and returns it.

Parameters:
x - the expression to check
Returns:
null or an Integer if the expression represents a constant integer

resolveList

public static void resolveList(CompilerState state,
                               org.millscript.commons.util.IList<? extends Expr> list)
Resolves all the expressions in the specified list, by calling the resolve(CompilerState) method on each one in turn.

Parameters:
state - the compiler state we are resolving in
list - the list of expressions to resolve

arity

public int arity()
Returns the arity of this expression. Positive numbers represent exact arity, while negative numbers represent unknown arity.

Returns:
0 if the expression returns zero results, 1 if the expression returns one result or -1 if the expression returns an unknown number of results.

compile

public A compile()
Compiles this expression into an action, setting the context of the action. The resulting action will have it's origin and line numbers set to assist with debugging.

Returns:
the Action for this expression, with it's context set.

compileIt

public abstract A compileIt()
Compiles this expression into an action.

Returns:
the Action for this expression

resolve

public abstract void resolve(CompilerState state)
Resolves any NameExpr in the tree so that they refer to the correct ident. e.g. This method is responsible for ensuring that references to a function argument in the body of a function actually refer to the correct value.

Parameters:
state - the compiler state we are resolving in

setLineNumber

public void setLineNumber(int n)
Sets the line number of this expression in the origin.

Parameters:
n - the line number at which this expression appears in the given origin

setOrigin

public void setOrigin(java.lang.String x)
Sets the origin of this expression.

Parameters:
x - a String describing this expressions origin

show

public void show()
Displays details about this expression, starting with no indent.


show

public void show(int n)
Displays details about this expression, with the specified indent level. This expressions class name, origin and, at a new indent level, component expressions.

Parameters:
n - the indent level at which to start displaying


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.