01: /*
02: * $Id: ForeachNode.java,v 1.3 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.ErrorListener;
13: import anvil.Location;
14: import anvil.core.Any;
15: import anvil.codec.Code;
16: import anvil.codec.ConstantPool;
17: import anvil.script.compiler.ByteCompiler;
18: import anvil.script.statements.FunctionStatement;
19: import anvil.script.Context;
20: import anvil.script.Function;
21: import anvil.script.Type;
22: import java.io.IOException;
23:
24: /**
25: * class ForeachNode
26: *
27: * @author: Jani Lehtimäki
28: */
29: public class ForeachNode extends BinaryParent {
30:
31: public ForeachNode(Node self, Node inline) {
32: super (self, inline);
33: }
34:
35: public int typeOf() {
36: return Node.EXPR_FOREACH;
37: }
38:
39: public boolean isConstant() {
40: return false;
41: }
42:
43: public void compile(ByteCompiler context, int operation) {
44: Code code = context.getCode();
45: ConstantPool pool = code.getPool();
46:
47: code.aload_first();
48: _left.compile(context, GET);
49: _right.compile(context, GET);
50: code.invokevirtual(pool.addMethodRef(context.TYPE_CONTEXT,
51: "foreach",
52: "(Lanvil/core/Any;Lanvil/core/Any;)Lanvil/core/Any;"));
53:
54: if (operation == GET_BOOLEAN) {
55: context.any2boolean();
56: }
57: }
58:
59: }
|