1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.millscript.expr;
22
23 import org.millscript.millscript.action.ForConditionWhileAction;
24 import org.millscript.millscript.vm.CompilerState;
25
26 /**
27 * This class represents a for loop while condition expression. A while
28 * condition loops while the expression is true, then executes the termination
29 * expression and terminates the loop.
30 */
31 public final class ForConditionWhileExpr extends ForConditionExpr< ForConditionWhileAction > {
32
33 /**
34 * The while expression. While this condition is true, this iterator allows
35 * the for loop to continue. When this condition is false, this iterator
36 * will cause the for loop to terminate.
37 */
38 private final Expr< ? > whileExpr;
39
40 /**
41 * The termination expression. This expression will be executed when this
42 * condition causes the for loop to terminate.
43 */
44 private final Expr< ? > terminateExpr;
45
46 /**
47 * Constructs a new while condition expression, with the supplied while and
48 * terminate expressions.
49 *
50 * @param e the while condition expression
51 * @param t the while condition termination expression
52 */
53 public ForConditionWhileExpr( final Expr< ? > e, final Expr< ? > t ) {
54
55 whileExpr = CheckExpr.make( e );
56 terminateExpr = t;
57 }
58
59 /**
60 * @see org.millscript.millscript.expr.Expr#compileIt()
61 */
62 @Override
63 public ForConditionWhileAction compileIt() {
64 return new ForConditionWhileAction( whileExpr.compile(), terminateExpr.compile() );
65 }
66
67 /**
68 * @see org.millscript.millscript.expr.Expr#resolve(org.millscript.millscript.vm.CompilerState)
69 */
70 @Override
71 public void resolve( final CompilerState state ) {
72 this.whileExpr.resolve( state );
73 this.terminateExpr.resolve( state );
74 }
75
76 /**
77 * @see org.millscript.millscript.expr.Expr#showComponents(int)
78 */
79 @Override
80 void showComponents( final int n ) {
81 this.whileExpr.show( n );
82 this.terminateExpr.show( n );
83 }
84
85 }