01: /*
02: * $Id: MutableExpressionList.java,v 1.5 2002/09/16 08:05:05 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.AnyList;
14: import anvil.codec.Code;
15: import anvil.codec.ConstantPool;
16: import anvil.script.compiler.ByteCompiler;
17: import anvil.script.Context;
18: import java.io.IOException;
19:
20: /**
21: * class MutableExpressionList
22: *
23: * @author: Jani Lehtimäki
24: */
25: public class MutableExpressionList extends MultiParent {
26:
27: public MutableExpressionList(int childs) {
28: super (childs);
29: }
30:
31: public int typeOf() {
32: return EXPR_LIST;
33: }
34:
35: public Any eval() {
36: return new AnyList(evalChilds(0));
37: }
38:
39: public void compile(ByteCompiler context, int operation) {
40: Code code = context.getCode();
41: ConstantPool pool = code.getPool();
42: int clazz = pool.addClass("anvil/core/AnyList");
43: int n = childs();
44: code.anew(clazz);
45: code.dup();
46: code.iconst(n);
47: code.anewarray(context.TYPE_ANY);
48: for (int i = 0; i < n; i++) {
49: code.dup();
50: code.iconst(i);
51: getChild(i).compile(context, GET);
52: code.aastore();
53: }
54: code.invokespecial(pool.addMethodRef(clazz, "<init>",
55: "([Lanvil/core/Any;)V"));
56: if (operation == context.GET_BOOLEAN) {
57: context.any2boolean();
58: }
59: }
60:
61: }
|