01: /*
02: * $Id: ThisNode.java,v 1.12 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.AnyClass;
14: import anvil.codec.Code;
15: import anvil.script.compiler.ByteCompiler;
16: import anvil.script.Context;
17: import anvil.script.ClassType;
18: import java.io.IOException;
19:
20: /**
21: * class ThisNode
22: *
23: * @author: Jani Lehtimäki
24: */
25: public class ThisNode extends Node {
26:
27: public static final ThisNode INSTANCE = new ThisNode(null, null);
28:
29: protected ClassType _context;
30: protected ClassType _class;
31:
32: public ThisNode(ClassType context, ClassType classtype) {
33: super ();
34: _context = context;
35: _class = classtype;
36: }
37:
38: public int typeOf() {
39: return Node.EXPR_THIS;
40: }
41:
42: public boolean isConstant() {
43: return false;
44: }
45:
46: public Node optimize() {
47: return this ;
48: }
49:
50: public void compile(ByteCompiler context, int operation) {
51: context.accessInstance(_context, _class);
52: //context.getCode().self();
53: if (operation == GET_BOOLEAN) {
54: context.any2boolean();
55: }
56: }
57:
58: }
|