01: /*
02: * $Id: ConstructorInvokeNode.java,v 1.15 2002/09/16 08:05:04 jkl Exp $
03: *
04: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
05: *
06: * Use is subject to license terms, as defined in
07: * Anvil Sofware License, Version 1.1. See LICENSE
08: * file, or http://njet.org/license-1.1.txt
09: */
10: package anvil.script.expression;
11:
12: import anvil.core.Any;
13: import anvil.core.AnyClass;
14: import anvil.ErrorListener;
15: import anvil.script.ClassType;
16: import anvil.script.ClassRef;
17: import anvil.script.CompilableFunction;
18: import anvil.codec.Code;
19: import anvil.script.compiler.ByteCompiler;
20: import anvil.script.Context;
21: import anvil.script.Function;
22: import java.io.IOException;
23:
24: /**
25: * class ConstructorInvokeNode
26: *
27: * @author: Jani Lehtimäki
28: */
29: public class ConstructorInvokeNode extends MultiParent {
30:
31: private ClassType _classtype;
32:
33: public ConstructorInvokeNode(ClassType classtype, Parent parameters) {
34: super (parameters);
35: _classtype = classtype;
36: }
37:
38: public int typeOf() {
39: return Node.EXPR_INVOKE;
40: }
41:
42: public boolean isConstant() {
43: return false;
44: }
45:
46: public void compile(ByteCompiler context, int operation) {
47: ClassType base = _classtype.getBaseClass();
48: if (base != null) {
49: Code code = context.getCode();
50: CompilableFunction ctor = base.getConstructor();
51: code.self();
52: context.compileArgumentList(ctor, getChilds(0));
53: code.invokespecial(ctor.getTypeRef(code.getPool()));
54: }
55: }
56:
57: }
|