01: /*
02: * $Id: NamespaceNode.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.runtime.AnyNamespace;
14: import anvil.ErrorListener;
15: import anvil.codec.Code;
16: import anvil.script.compiler.ByteCompiler;
17: import anvil.script.Context;
18: import anvil.script.NamespaceType;
19: import java.io.IOException;
20:
21: /**
22: * class NamespaceNode
23: *
24: * @author: Jani Lehtimäki
25: */
26: public class NamespaceNode extends Node {
27:
28: public NamespaceType _namespace;
29:
30: public NamespaceNode(NamespaceType namespace) {
31: super ();
32: _namespace = namespace;
33: }
34:
35: public int typeOf() {
36: return Node.EXPR_NAMESPACE;
37: }
38:
39: public boolean isConstant() {
40: return false;
41: }
42:
43: public Node optimize() {
44: return this ;
45: }
46:
47: public void compile(ByteCompiler context, int operation) {
48: Code code = context.getCode();
49: code.aload_first();
50: code.astring(_namespace.getName());
51: code.invokevirtual(code.getPool().addMethodRef(
52: context.TYPE_CONTEXT, "getNS",
53: "(Ljava/lang/String;)Lanvil/core/Any;"));
54: if (operation == GET_BOOLEAN) {
55: context.any2boolean();
56: }
57: }
58:
59: }
|