KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > quercus > expr > AbstractVarExpr


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.quercus.expr;
31
32 import com.caucho.quercus.Location;
33 import com.caucho.quercus.env.Env;
34 import com.caucho.quercus.env.Value;
35 import com.caucho.quercus.parser.QuercusParser;
36 import com.caucho.quercus.program.Statement;
37
38 /**
39  * Represents an expression that is assignable
40  */

41 abstract public class AbstractVarExpr extends Expr {
42   public AbstractVarExpr(Location location)
43   {
44     super(location);
45   }
46   
47   public AbstractVarExpr()
48   {
49   }
50   /**
51    * Marks the value as assigned
52    */

53   public void assign(QuercusParser parser)
54   {
55     // XXX: used by list, e.g. quercus/03l8. need further tests
56
}
57
58   /**
59    * Creates the assignment.
60    */

61   @Override JavaDoc
62   public Expr createAssign(QuercusParser parser, Expr value)
63   {
64     return parser.getExprFactory().createAssign(this, value);
65   }
66
67   /**
68    * Creates the assignment.
69    */

70   @Override JavaDoc
71   public Expr createAssignRef(QuercusParser parser,
72                               Expr value)
73   {
74     return parser.getExprFactory().createAssignRef(this, value);
75   }
76
77   /**
78    * Creates the reference
79    * @param location
80    */

81   @Override JavaDoc
82   public Expr createRef(QuercusParser parser)
83   {
84     return parser.getExprFactory().createRef(this);
85   }
86
87   /**
88    * Creates the copy.
89    * @param location
90    */

91   @Override JavaDoc
92   public Expr createCopy(ExprFactory factory)
93   {
94     return factory.createCopy(this);
95   }
96
97   /**
98    * Creates the assignment.
99    */

100   @Override JavaDoc
101   public Statement createUnset(ExprFactory factory, Location location)
102   {
103     return factory.createExpr(location, factory.createUnsetVar(this));
104   }
105
106   /**
107    * Evaluates the expression.
108    *
109    * @param env the calling environment.
110    *
111    * @return the expression value.
112    */

113   abstract public Value eval(Env env);
114
115   /**
116    * Evaluates the expression as a reference (by RefExpr).
117    *
118    * @param env the calling environment.
119    *
120    * @return the expression value.
121    */

122   abstract public Value evalRef(Env env);
123
124   /**
125    * Evaluates the expression as an argument.
126    *
127    * @param env the calling environment.
128    *
129    * @return the expression value.
130    */

131   abstract public Value evalArg(Env env);
132
133   /**
134    * Evaluates the expression as an argument.
135    *
136    * @param env the calling environment.
137    *
138    * @return the expression value.
139    */

140   abstract public void evalUnset(Env env);
141
142   /**
143    * Evaluates the expression.
144    *
145    * @param env the calling environment.
146    *
147    * @return the expression value.
148    */

149   abstract public void evalAssign(Env env, Value value);
150 }
151
152
Popular Tags