org.millscript.millscript.expr
Class CheckExpr

java.lang.Object
  extended by org.millscript.millscript.expr.Expr<CheckAction>
      extended by org.millscript.millscript.expr.CheckExpr

public final class CheckExpr
extends Expr<CheckAction>

This class implements a check expression. A check expression is guaranteed to return one result.

See Also:
CheckAction

Constructor Summary
CheckExpr(Expr<?> e)
          Creates a new check expression, to check the specified expression returns a single result.
 
Method Summary
 CheckAction compileIt()
          Compiles this expression into an action.
static Expr<?> make(Expr<?> e)
          Returns an expression that is guaranteed to return a single result.
 void resolve(CompilerState state)
          Resolves any NameExpr in the tree so that they refer to the correct ident.
 
Methods inherited from class org.millscript.millscript.expr.Expr
arity, compile, isIntegerExpr, resolveList, setLineNumber, setOrigin, show, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckExpr

public CheckExpr(Expr<?> e)
Creates a new check expression, to check the specified expression returns a single result.

Parameters:
e - the expression which must return a single result
Method Detail

make

public static Expr<?> make(Expr<?> e)
Returns an expression that is guaranteed to return a single result. This method provides some compile-time optimisation, as it avoids creating additional unnecessary objects in the expression tree. If the specified expression already returns a single result, it is simply returned, otherwise if it returns an unknown number of results, a new check expression is created.

Parameters:
e - the expression which must return a single result
Returns:
the specified expression if it already returns a single result, otherwise a new CheckExpr

compileIt

public CheckAction compileIt()
Description copied from class: Expr
Compiles this expression into an action.

Specified by:
compileIt in class Expr<CheckAction>
Returns:
the Action for this expression
See Also:
Expr.compileIt()

resolve

public void resolve(CompilerState state)
Description copied from class: Expr
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.

Specified by:
resolve in class Expr<CheckAction>
Parameters:
state - the compiler state we are resolving in
See Also:
Expr.resolve(org.millscript.millscript.vm.CompilerState)


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