01: package gnu.expr;
02:
03: import gnu.bytecode.*;
04: import gnu.mapping.*;
05:
06: public class ObjectExp extends ClassExp {
07: public ObjectExp() {
08: type = null;
09: // Make sure we actually generate a class.
10: setCanRead(true);
11: }
12:
13: protected Expression walk(ExpWalker walker) {
14: return walker.walkObjectExp(this );
15: }
16:
17: public void compile(Compilation comp, Target target) {
18: ClassType new_class = compile(comp);
19: CodeAttr code = comp.getCode();
20: code.emitNew(type);
21: code.emitDup(1);
22: Method init = comp.getConstructor(type, this );
23: if (closureEnvField != null) {
24: LambdaExp caller = outerLambda();
25: Variable closureEnv = !Compilation.usingTailCalls ? getHeapLambda().heapFrame
26: : caller.heapFrame != null ? caller.heapFrame
27: : caller.closureEnv;
28: code.emitLoad(closureEnv);
29: }
30: code.emitInvokeSpecial(init);
31:
32: target.compileFromStack(comp, getCompiledClassType(comp));
33: }
34:
35: }
|