01: /**
02: * MVEL (The MVFLEX Expression Language)
03: *
04: * Copyright (C) 2007 Christopher Brock, MVFLEX/Valhalla Project and the Codehaus
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: */package org.mvel.ast;
19:
20: import org.mvel.integration.VariableResolverFactory;
21: import static org.mvel.util.ParseTools.checkNameSafety;
22: import org.mvel.compiler.AbstractParser;
23:
24: /**
25: * @author Christopher Brock
26: */
27: public class DeclTypedVarNode extends ASTNode implements Assignment {
28: private String name;
29:
30: public DeclTypedVarNode(String name, Class type, int fields) {
31: this .egressType = type;
32: checkNameSafety(this .name = name);
33:
34: if ((fields & COMPILE_IMMEDIATE) != 0) {
35: AbstractParser.getCurrentThreadParserContext().addVariable(
36: name, egressType, true);
37: }
38: }
39:
40: public Object getReducedValueAccelerated(Object ctx,
41: Object this Value, VariableResolverFactory factory) {
42: factory.createVariable(name, null, egressType);
43: return null;
44: }
45:
46: public Object getReducedValue(Object ctx, Object this Value,
47: VariableResolverFactory factory) {
48: factory.createVariable(name, null, egressType);
49: return null;
50: }
51:
52: public String getName() {
53: return name;
54: }
55:
56: public String getAssignmentVar() {
57: return name;
58: }
59:
60: public char[] getExpression() {
61: return new char[0];
62: }
63:
64: public boolean isAssignment() {
65: return true;
66: }
67:
68: public boolean isNewDeclaration() {
69: return true;
70: }
71: }
|