org.millscript.millscript.expr
Class SwitchExpr

java.lang.Object
  extended by org.millscript.millscript.expr.Expr<SwitchAction>
      extended by org.millscript.millscript.expr.SwitchExpr

public final class SwitchExpr
extends Expr<SwitchAction>

This class implements a switch expression.

See Also:
SwitchSyntax, SwitchAction

Constructor Summary
SwitchExpr(Expr<?> a, org.millscript.commons.util.IList<CaseExpr> b, Expr<?> c)
          Creates a new switch expression for the specified choice, case and default expressions.
 
Method Summary
 int arity()
          Returns the arity of this expression.
 SwitchAction compileIt()
          Compiles this expression into an action.
 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
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

SwitchExpr

public SwitchExpr(Expr<?> a,
                  org.millscript.commons.util.IList<CaseExpr> b,
                  Expr<?> c)
Creates a new switch expression for the specified choice, case and default expressions.

Parameters:
a - the choice expression
b - the list of case expressions
c - the default expression
Method Detail

arity

public int arity()
Description copied from class: Expr
Returns the arity of this expression. Positive numbers represent exact arity, while negative numbers represent unknown arity.

Overrides:
arity in class Expr<SwitchAction>
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.
See Also:
Expr.arity()

compileIt

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

Specified by:
compileIt in class Expr<SwitchAction>
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<SwitchAction>
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.