|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.millscript.millscript.expr.Expr<ForAction>
org.millscript.millscript.expr.ForExpr
public final class ForExpr
This class represents a For loop expression. A for loop expression may contain multiple condition/binding expressions, a single body expression and a single termination expression.
ForSyntax,
ForAction| Constructor Summary | |
|---|---|
ForExpr(org.millscript.commons.util.IList<ForConditionExpr> a,
Expr<?> b,
Expr<?> t)
Construct a new For Expression with the supplied conditions/bindings, body and normal termination expression. |
|
| Method Summary | |
|---|---|
int |
arity()
Returns the arity of this expression. |
ForAction |
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 |
|---|
public ForExpr(org.millscript.commons.util.IList<ForConditionExpr> a,
Expr<?> b,
Expr<?> t)
a - list of conditions and bindingsb - body Exprt - normal termination Expr| Method Detail |
|---|
public int arity()
If the for loop body has an arity of zero, the for loops arity is zero, otherwise the for loop arity is unknown. The for loop arity would depend on the number of iterations, etc.
arity in class Expr<ForAction>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.public ForAction compileIt()
Expr
compileIt in class Expr<ForAction>Action for this expressionExpr.compileIt()public void resolve(CompilerState state)
ExprNameExpr 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.
resolve in class Expr<ForAction>state - the compiler state we are resolving in
In a for expression, the renaming process is slightly more compilcated
than usual. The renaming uses the following sequence:
- binding expressions children are pushed onto the stack
- binding expressions are renamed
- the termination expression is renamed
- a new scope is declared
- any bound variables are pushed onto the stack
- remaining for conditions are renamed
- for loop body is renamed
Which ensures that the relevant bindings are available within the
condition and body expression.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||