1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jexl3.parser;
18
19 import org.apache.commons.jexl3.JexlFeatures;
20 import org.apache.commons.jexl3.internal.Scope;
21 import java.util.Map;
22 import org.apache.commons.jexl3.internal.Frame;
23
24
25
26
27 public class ASTJexlScript extends JexlLexicalNode {
28
29 private static final long serialVersionUID = 202112111533L;
30
31 private Map<String, Object> pragmas = null;
32
33 private transient JexlFeatures features = null;
34
35 private transient Scope scope = null;
36
37 public ASTJexlScript(final int id) {
38 super(id);
39 }
40
41 public ASTJexlScript(final Parser p, final int id) {
42 super(p, id);
43 }
44
45
46
47
48
49 public ASTJexlScript script() {
50 if (scope == null && jjtGetNumChildren() == 1 && jjtGetChild(0) instanceof ASTJexlLambda) {
51 final ASTJexlLambda lambda = (ASTJexlLambda) jjtGetChild(0);
52 lambda.jjtSetParent(null);
53 return lambda;
54 }
55 return this;
56 }
57
58 @Override
59 public Object jjtAccept(final ParserVisitor visitor, final Object data) {
60 return visitor.visit(this, data);
61 }
62
63
64
65
66
67 public void setPragmas(final Map<String, Object> thePragmas) {
68 this.pragmas = thePragmas;
69 }
70
71
72
73
74 public Map<String, Object> getPragmas() {
75 return pragmas;
76 }
77
78
79
80
81
82 public void setFeatures(final JexlFeatures theFeatures) {
83 this.features = theFeatures;
84 }
85
86
87
88
89 public JexlFeatures getFeatures() {
90 return features;
91 }
92
93
94
95
96
97 public void setScope(final Scope theScope) {
98 this.scope = theScope;
99 if (theScope != null) {
100 for(int a = 0; a < theScope.getArgCount(); ++a) {
101 this.declareSymbol(a);
102 }
103 }
104 }
105
106
107
108
109 public Scope getScope() {
110 return scope;
111 }
112
113
114
115
116
117
118
119 public Frame createFrame(final Frame caller, final Object... values) {
120 return scope != null? scope.createFrame(caller, values) : null;
121 }
122
123
124
125
126
127
128 public Frame createFrame(final Object... values) {
129 return createFrame(null, values);
130 }
131
132
133
134
135
136 public int getArgCount() {
137 return scope != null? scope.getArgCount() : 0;
138 }
139
140
141
142
143
144 public String[] getSymbols() {
145 return scope != null? scope.getSymbols() : null;
146 }
147
148
149
150
151
152 public String[] getParameters() {
153 return scope != null? scope.getParameters() : null;
154 }
155
156
157
158
159
160 public String[] getLocalVariables() {
161 return scope != null? scope.getLocalVariables() : null;
162 }
163
164
165
166
167
168
169 public boolean isCapturedSymbol(final int symbol) {
170 return scope != null && scope.isCapturedSymbol(symbol);
171 }
172
173
174
175
176
177 public String[] getCapturedVariables() {
178 return scope != null? scope.getCapturedVariables() : null;
179 }
180 }