Source code: openjava/ptree/ExpressionObject.java
1 /*
2 * ExpressionObject.java 1.0
3 *
4 *
5 * June 23, 2000
6 *
7 * @see openjava.ptree.ParseTree
8 * @version 1.0 last updated: June 23, 2000
9 * @author Michiaki Tatsubori
10 */
11 package openjava.ptree;
12
13
14 import openjava.mop.Environment;
15 import openjava.mop.OJClass;
16
17
18
19 /**
20 * The Expression interface presents common interface
21 * to access Expression node of parse tree
22 *
23 * this interface is implements by
24 * <pre>
25 * UnaryExpression
26 * BinaryExpression
27 * ConditionalExpression
28 * AssignmentExpression
29 * CastExpression
30 * AllocationExpression
31 * ArrayAllocationExpression
32 * Variable
33 * MethodCall
34 * SpecialName
35 * Literal
36 * ClassLiteral
37 * ArrayAccess
38 * FieldAccess
39 * </pre>
40 *
41 * @see openjava.ptree.ParseTree
42 * @see openjava.ptree.NonLeaf
43 */
44 public abstract class ExpressionObject extends NonLeaf
45 implements Expression
46 {
47 private OJClass cachedType = null;
48
49 void soilCache() {
50 cachedType = null;
51 ParseTree parent = getParent();
52 if (parent instanceof ExpressionObject) {
53 ExpressionObject pexp = (ExpressionObject) parent;
54 pexp.soilCache();
55 }
56 }
57
58 /**
59 * dirty implementation
60 */
61 public OJClass getCachedType(Environment env) throws Exception {
62 if (cachedType == null) cachedType = getType(env);
63 return cachedType;
64 }
65
66 public abstract OJClass getType(Environment env, boolean using_cache)
67 throws Exception;
68
69 public abstract OJClass getType(Environment env)
70 throws Exception;
71
72 /**
73 * Makes this ptree a list presenting for
74 * [ p ]
75 *
76 * @param p list's element
77 */
78 protected void set( Object[] ptrees ) {
79 soilCache();
80 super.set(ptrees);
81 }
82
83 }