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.SpiceClassInitAction;
24 import org.millscript.millscript.vm.CompilerState;
25
26 /**
27 * This class represents a definition of a <code>class</code> <code>init</code>
28 * procedure.
29 */
30 public final class SpiceClassInitExpr extends Expr< SpiceClassInitAction > implements OneResult {
31
32 /**
33 * The name of the class this method belongs to, for the dispatch
34 * parameter.
35 */
36 private final NameExpr classNameExpr;
37
38 /**
39 * The <code>init</code> procedure.
40 */
41 private final LambdaExpr init;
42
43 /**
44 * Constructs a new init expression for the specified initialiser.
45 *
46 * @param name the name of the class this init constructs
47 * @param lambda the initialiser procedure
48 */
49 public SpiceClassInitExpr( final NameExpr name, final LambdaExpr lambda ) {
50 this.classNameExpr = name;
51 this.init = lambda;
52 }
53
54 /**
55 * @see org.millscript.millscript.expr.Expr#compileIt()
56 */
57 @Override
58 public SpiceClassInitAction compileIt() {
59 return new SpiceClassInitAction( this.classNameExpr.compile(), this.init.compile() );
60 }
61
62 /**
63 * @see org.millscript.millscript.expr.Expr#resolve(org.millscript.millscript.vm.CompilerState)
64 */
65 @Override
66 public void resolve( final CompilerState state ) {
67 this.classNameExpr.resolve( state );
68 this.init.resolve( state );
69 }
70
71 /**
72 * @see org.millscript.millscript.expr.Expr#showComponents(int)
73 */
74 @Override
75 void showComponents( final int n ) {
76 this.classNameExpr.show( n );
77 this.init.show( n );
78 }
79
80 }