01: /*
02: * $Id: StaticVariableNode.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.ErrorListener;
14: import anvil.codec.Code;
15: import anvil.script.compiler.ByteCompiler;
16: import anvil.script.Context;
17: import anvil.script.Type;
18: import anvil.script.StaticVariableType;
19: import anvil.script.statements.ModuleStatement;
20: import java.io.IOException;
21:
22: /**
23: * class StaticVariableNode
24: *
25: * @author: Jani Lehtimäki
26: */
27: public class StaticVariableNode extends Node {
28:
29: private StaticVariableType _var;
30:
31: public StaticVariableNode(StaticVariableType var) {
32: super ();
33: _var = var;
34: }
35:
36: public int typeOf() {
37: return Node.EXPR_VARIABLE;
38: }
39:
40: public boolean isConstant() {
41: return false;
42: }
43:
44: public Node optimize() {
45: return this ;
46: }
47:
48: public void compile(ByteCompiler context, Node child) {
49: child.compile(context, GET);
50: Code code = context.getCode();
51: code.dup();
52: code.putstatic(_var.getTypeRef(code.getPool()));
53: }
54:
55: public void compile(ByteCompiler context, int operation) {
56: int field = _var.getTypeRef(context.getPool());
57: Code code = context.getCode();
58: switch (operation) {
59: case GET:
60: code.getstatic(field);
61: break;
62:
63: case GET_BOOLEAN:
64: code.getstatic(field);
65: context.any2boolean();
66: break;
67:
68: case CHECK:
69: code.getstatic(field);
70: break;
71:
72: case DELETE:
73: code.iconst(false);
74: break;
75: }
76: }
77:
78: }
|