1 | /*
|
---|
2 | * Copyright (C) 1999-2000 Harri Porten ([email protected])
|
---|
3 | * Copyright (C) 2001 Peter Kelly ([email protected])
|
---|
4 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
|
---|
5 | * Copyright (C) 2007 Cameron Zwarich ([email protected])
|
---|
6 | * Copyright (C) 2007 Maks Orlovich
|
---|
7 | * Copyright (C) 2007 Eric Seidel <[email protected]>
|
---|
8 | *
|
---|
9 | * This library is free software; you can redistribute it and/or
|
---|
10 | * modify it under the terms of the GNU Library General Public
|
---|
11 | * License as published by the Free Software Foundation; either
|
---|
12 | * version 2 of the License, or (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This library 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. See the GNU
|
---|
17 | * Library General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU Library General Public License
|
---|
20 | * along with this library; see the file COPYING.LIB. If not, write to
|
---|
21 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
---|
22 | * Boston, MA 02110-1301, USA.
|
---|
23 | *
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef NODES_H_
|
---|
27 | #define NODES_H_
|
---|
28 |
|
---|
29 | #include "JSString.h"
|
---|
30 | #include "LabelStack.h"
|
---|
31 | #include "Opcode.h"
|
---|
32 | #include "RegisterID.h"
|
---|
33 | #include "SourceRange.h"
|
---|
34 | #include "SymbolTable.h"
|
---|
35 | #include "regexp.h"
|
---|
36 | #include <wtf/ListRefPtr.h>
|
---|
37 | #include <wtf/MathExtras.h>
|
---|
38 | #include <wtf/OwnPtr.h>
|
---|
39 | #include <wtf/UnusedParam.h>
|
---|
40 | #include <wtf/Vector.h>
|
---|
41 |
|
---|
42 | #if PLATFORM(X86) && COMPILER(GCC)
|
---|
43 | #define KJS_FAST_CALL __attribute__((regparm(3)))
|
---|
44 | #else
|
---|
45 | #define KJS_FAST_CALL
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | namespace KJS {
|
---|
49 |
|
---|
50 | class CodeBlock;
|
---|
51 | class CodeGenerator;
|
---|
52 | class FuncDeclNode;
|
---|
53 | class Node;
|
---|
54 | class EvalCodeBlock;
|
---|
55 | class ProgramCodeBlock;
|
---|
56 | class PropertyListNode;
|
---|
57 | class SourceStream;
|
---|
58 |
|
---|
59 | enum Operator {
|
---|
60 | OpEqual,
|
---|
61 | OpPlusEq,
|
---|
62 | OpMinusEq,
|
---|
63 | OpMultEq,
|
---|
64 | OpDivEq,
|
---|
65 | OpPlusPlus,
|
---|
66 | OpMinusMinus,
|
---|
67 | OpAndEq,
|
---|
68 | OpXOrEq,
|
---|
69 | OpOrEq,
|
---|
70 | OpModEq,
|
---|
71 | OpLShift,
|
---|
72 | OpRShift,
|
---|
73 | OpURShift,
|
---|
74 | };
|
---|
75 |
|
---|
76 | enum Precedence {
|
---|
77 | PrecPrimary,
|
---|
78 | PrecMember,
|
---|
79 | PrecCall,
|
---|
80 | PrecLeftHandSide,
|
---|
81 | PrecPostfix,
|
---|
82 | PrecUnary,
|
---|
83 | PrecMultiplicative,
|
---|
84 | PrecAdditive,
|
---|
85 | PrecShift,
|
---|
86 | PrecRelational,
|
---|
87 | PrecEquality,
|
---|
88 | PrecBitwiseAnd,
|
---|
89 | PrecBitwiseXor,
|
---|
90 | PrecBitwiseOr,
|
---|
91 | PrecLogicalAnd,
|
---|
92 | PrecLogicalOr,
|
---|
93 | PrecConditional,
|
---|
94 | PrecAssignment,
|
---|
95 | PrecExpression
|
---|
96 | };
|
---|
97 |
|
---|
98 | struct DeclarationStacks {
|
---|
99 | typedef Vector<Node*, 16> NodeStack;
|
---|
100 | enum { IsConstant = 1, HasInitializer = 2 } VarAttrs;
|
---|
101 | typedef Vector<std::pair<Identifier, unsigned>, 16> VarStack;
|
---|
102 | typedef Vector<RefPtr<FuncDeclNode>, 16> FunctionStack;
|
---|
103 |
|
---|
104 | DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f)
|
---|
105 | : exec(e)
|
---|
106 | , nodeStack(n)
|
---|
107 | , varStack(v)
|
---|
108 | , functionStack(f)
|
---|
109 | {
|
---|
110 | }
|
---|
111 |
|
---|
112 | ExecState* exec;
|
---|
113 | NodeStack& nodeStack;
|
---|
114 | VarStack& varStack;
|
---|
115 | FunctionStack& functionStack;
|
---|
116 | };
|
---|
117 |
|
---|
118 | class ParserRefCounted : Noncopyable {
|
---|
119 | protected:
|
---|
120 | ParserRefCounted(JSGlobalData*) KJS_FAST_CALL;
|
---|
121 |
|
---|
122 | JSGlobalData* m_globalData;
|
---|
123 |
|
---|
124 | public:
|
---|
125 | void ref() KJS_FAST_CALL;
|
---|
126 | void deref() KJS_FAST_CALL;
|
---|
127 | bool hasOneRef() KJS_FAST_CALL;
|
---|
128 |
|
---|
129 | static void deleteNewObjects(JSGlobalData*) KJS_FAST_CALL;
|
---|
130 |
|
---|
131 | virtual ~ParserRefCounted();
|
---|
132 | };
|
---|
133 |
|
---|
134 | class Node : public ParserRefCounted {
|
---|
135 | public:
|
---|
136 | typedef DeclarationStacks::NodeStack NodeStack;
|
---|
137 | typedef DeclarationStacks::VarStack VarStack;
|
---|
138 | typedef DeclarationStacks::FunctionStack FunctionStack;
|
---|
139 |
|
---|
140 | Node(JSGlobalData*) KJS_FAST_CALL;
|
---|
141 |
|
---|
142 | /*
|
---|
143 | Return value: The register holding the production's value.
|
---|
144 | dst: An optional parameter specifying the most efficient
|
---|
145 | destination at which to store the production's value.
|
---|
146 | The callee must honor dst.
|
---|
147 |
|
---|
148 | dst provides for a crude form of copy propagation. For example,
|
---|
149 |
|
---|
150 | x = 1
|
---|
151 |
|
---|
152 | becomes
|
---|
153 |
|
---|
154 | load r[x], 1
|
---|
155 |
|
---|
156 | instead of
|
---|
157 |
|
---|
158 | load r0, 1
|
---|
159 | mov r[x], r0
|
---|
160 |
|
---|
161 | because the assignment node, "x =", passes r[x] as dst to the number
|
---|
162 | node, "1".
|
---|
163 | */
|
---|
164 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* dst = 0) KJS_FAST_CALL
|
---|
165 | {
|
---|
166 | ASSERT_WITH_MESSAGE(0, "Don't know how to generate code for:\n%s\n", toString().ascii());
|
---|
167 | UNUSED_PARAM(dst);
|
---|
168 | return 0;
|
---|
169 | } // FIXME: Make this pure virtual.
|
---|
170 |
|
---|
171 | UString toString() const KJS_FAST_CALL;
|
---|
172 | int lineNo() const KJS_FAST_CALL { return m_line; }
|
---|
173 |
|
---|
174 | virtual bool isReturnNode() const KJS_FAST_CALL { return false; }
|
---|
175 |
|
---|
176 | // Serialization.
|
---|
177 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL = 0;
|
---|
178 | virtual Precedence precedence() const = 0;
|
---|
179 | virtual bool needsParensIfLeftmost() const { return false; }
|
---|
180 |
|
---|
181 | protected:
|
---|
182 | Node(JSGlobalData*, JSType) KJS_FAST_CALL; // used by ExpressionNode
|
---|
183 |
|
---|
184 | RegisterID* emitThrowError(CodeGenerator&, ErrorType, const char* msg);
|
---|
185 | RegisterID* emitThrowError(CodeGenerator&, ErrorType, const char* msg, const Identifier&);
|
---|
186 |
|
---|
187 | int m_line : 28;
|
---|
188 | unsigned m_expectedReturnType : 3; // JSType
|
---|
189 | };
|
---|
190 |
|
---|
191 | class ExpressionNode : public Node {
|
---|
192 | public:
|
---|
193 | ExpressionNode(JSGlobalData* globalData) KJS_FAST_CALL : Node(globalData) {}
|
---|
194 | ExpressionNode(JSGlobalData* globalData, JSType expectedReturn) KJS_FAST_CALL
|
---|
195 | : Node(globalData, expectedReturn)
|
---|
196 | {
|
---|
197 | }
|
---|
198 |
|
---|
199 | virtual bool isNumber() const KJS_FAST_CALL { return false; }
|
---|
200 | virtual bool isPure(CodeGenerator&) const KJS_FAST_CALL { return false; }
|
---|
201 | virtual bool isLocation() const KJS_FAST_CALL { return false; }
|
---|
202 | virtual bool isResolveNode() const KJS_FAST_CALL { return false; }
|
---|
203 | virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return false; }
|
---|
204 | virtual bool isDotAccessorNode() const KJS_FAST_CALL { return false; }
|
---|
205 |
|
---|
206 | JSType expectedReturnType() const KJS_FAST_CALL { return static_cast<JSType>(m_expectedReturnType); }
|
---|
207 |
|
---|
208 | // This needs to be in public in order to compile using GCC 3.x
|
---|
209 | typedef enum { EvalOperator, FunctionCall } CallerType;
|
---|
210 | };
|
---|
211 |
|
---|
212 | class StatementNode : public Node {
|
---|
213 | public:
|
---|
214 | StatementNode(JSGlobalData*) KJS_FAST_CALL;
|
---|
215 | void setLoc(int line0, int line1) KJS_FAST_CALL;
|
---|
216 | int firstLine() const KJS_FAST_CALL { return lineNo(); }
|
---|
217 | int lastLine() const KJS_FAST_CALL { return m_lastLine; }
|
---|
218 |
|
---|
219 | virtual void pushLabel(const Identifier& ident) KJS_FAST_CALL { m_labelStack.push(ident); }
|
---|
220 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
221 | virtual bool isEmptyStatement() const KJS_FAST_CALL { return false; }
|
---|
222 |
|
---|
223 | protected:
|
---|
224 | LabelStack m_labelStack;
|
---|
225 |
|
---|
226 | private:
|
---|
227 | int m_lastLine;
|
---|
228 | };
|
---|
229 |
|
---|
230 | class NullNode : public ExpressionNode {
|
---|
231 | public:
|
---|
232 | NullNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
233 | : ExpressionNode(globalData, NullType)
|
---|
234 | {
|
---|
235 | }
|
---|
236 |
|
---|
237 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
238 |
|
---|
239 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
240 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
241 | };
|
---|
242 |
|
---|
243 | class BooleanNode : public ExpressionNode {
|
---|
244 | public:
|
---|
245 | BooleanNode(JSGlobalData* globalData, bool value) KJS_FAST_CALL
|
---|
246 | : ExpressionNode(globalData, BooleanType)
|
---|
247 | , m_value(value)
|
---|
248 | {
|
---|
249 | }
|
---|
250 |
|
---|
251 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
252 |
|
---|
253 | virtual bool isPure(CodeGenerator&) const KJS_FAST_CALL { return true; }
|
---|
254 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
255 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
256 |
|
---|
257 | protected:
|
---|
258 | bool m_value;
|
---|
259 | };
|
---|
260 |
|
---|
261 | class NumberNode : public ExpressionNode {
|
---|
262 | public:
|
---|
263 | NumberNode(JSGlobalData* globalData, double v) KJS_FAST_CALL
|
---|
264 | : ExpressionNode(globalData, NumberType)
|
---|
265 | , m_double(v)
|
---|
266 | {
|
---|
267 | }
|
---|
268 |
|
---|
269 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
270 |
|
---|
271 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
272 | virtual Precedence precedence() const { return signbit(m_double) ? PrecUnary : PrecPrimary; }
|
---|
273 |
|
---|
274 | virtual bool isNumber() const KJS_FAST_CALL { return true; }
|
---|
275 | virtual bool isPure(CodeGenerator&) const KJS_FAST_CALL { return true; }
|
---|
276 | double value() const KJS_FAST_CALL { return m_double; }
|
---|
277 | virtual void setValue(double d) KJS_FAST_CALL { m_double = d; }
|
---|
278 |
|
---|
279 | protected:
|
---|
280 | double m_double;
|
---|
281 | };
|
---|
282 |
|
---|
283 | class ImmediateNumberNode : public NumberNode {
|
---|
284 | public:
|
---|
285 | ImmediateNumberNode(JSGlobalData* globalData, JSValue* v, double d) KJS_FAST_CALL
|
---|
286 | : NumberNode(globalData, d)
|
---|
287 | , m_value(v)
|
---|
288 | {
|
---|
289 | ASSERT(v == JSImmediate::from(d));
|
---|
290 | }
|
---|
291 |
|
---|
292 | virtual void setValue(double d) KJS_FAST_CALL { m_double = d; m_value = JSImmediate::from(d); ASSERT(m_value); }
|
---|
293 |
|
---|
294 | private:
|
---|
295 | JSValue* m_value; // This is never a JSCell, only JSImmediate, thus no ProtectedPtr
|
---|
296 | };
|
---|
297 |
|
---|
298 | class StringNode : public ExpressionNode {
|
---|
299 | public:
|
---|
300 | StringNode(JSGlobalData* globalData, const UString* v) KJS_FAST_CALL
|
---|
301 | : ExpressionNode(globalData, StringType)
|
---|
302 | , m_value(*v)
|
---|
303 | {
|
---|
304 | }
|
---|
305 |
|
---|
306 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
307 |
|
---|
308 | virtual bool isPure(CodeGenerator&) const KJS_FAST_CALL { return true; }
|
---|
309 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
310 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
311 |
|
---|
312 | private:
|
---|
313 | UString m_value;
|
---|
314 | };
|
---|
315 |
|
---|
316 | class RegExpNode : public ExpressionNode {
|
---|
317 | public:
|
---|
318 | RegExpNode(JSGlobalData* globalData, const UString& pattern, const UString& flags) KJS_FAST_CALL
|
---|
319 | : ExpressionNode(globalData)
|
---|
320 | , m_regExp(RegExp::create(pattern, flags))
|
---|
321 | {
|
---|
322 | }
|
---|
323 |
|
---|
324 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
325 |
|
---|
326 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
327 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
328 |
|
---|
329 | private:
|
---|
330 | RefPtr<RegExp> m_regExp;
|
---|
331 | };
|
---|
332 |
|
---|
333 | class ThisNode : public ExpressionNode {
|
---|
334 | public:
|
---|
335 | ThisNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
336 | : ExpressionNode(globalData)
|
---|
337 | {
|
---|
338 | }
|
---|
339 |
|
---|
340 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
341 |
|
---|
342 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
343 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
344 | };
|
---|
345 |
|
---|
346 | class ResolveNode : public ExpressionNode {
|
---|
347 | public:
|
---|
348 | ResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
349 | : ExpressionNode(globalData)
|
---|
350 | , m_ident(ident)
|
---|
351 | {
|
---|
352 | }
|
---|
353 |
|
---|
354 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
355 |
|
---|
356 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
357 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
358 |
|
---|
359 | virtual bool isPure(CodeGenerator&) const KJS_FAST_CALL;
|
---|
360 | virtual bool isLocation() const KJS_FAST_CALL { return true; }
|
---|
361 | virtual bool isResolveNode() const KJS_FAST_CALL { return true; }
|
---|
362 | const Identifier& identifier() const KJS_FAST_CALL { return m_ident; }
|
---|
363 |
|
---|
364 | protected:
|
---|
365 | Identifier m_ident;
|
---|
366 | int m_index; // Used by LocalVarAccessNode and ScopedVarAccessNode.
|
---|
367 | size_t m_scopeDepth; // Used by ScopedVarAccessNode
|
---|
368 | };
|
---|
369 |
|
---|
370 | class ElementNode : public Node {
|
---|
371 | public:
|
---|
372 | ElementNode(JSGlobalData* globalData, int elision, ExpressionNode* node) KJS_FAST_CALL
|
---|
373 | : Node(globalData)
|
---|
374 | , m_elision(elision)
|
---|
375 | , m_node(node)
|
---|
376 | {
|
---|
377 | }
|
---|
378 |
|
---|
379 | ElementNode(JSGlobalData* globalData, ElementNode* l, int elision, ExpressionNode* node) KJS_FAST_CALL
|
---|
380 | : Node(globalData)
|
---|
381 | , m_elision(elision)
|
---|
382 | , m_node(node)
|
---|
383 | {
|
---|
384 | l->m_next = this;
|
---|
385 | }
|
---|
386 |
|
---|
387 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
388 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
389 |
|
---|
390 | int elision() const { return m_elision; }
|
---|
391 | ExpressionNode* value() { return m_node.get(); }
|
---|
392 |
|
---|
393 | ElementNode* next() { return m_next.get(); }
|
---|
394 | PassRefPtr<ElementNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }
|
---|
395 |
|
---|
396 | private:
|
---|
397 | ListRefPtr<ElementNode> m_next;
|
---|
398 | int m_elision;
|
---|
399 | RefPtr<ExpressionNode> m_node;
|
---|
400 | };
|
---|
401 |
|
---|
402 | class ArrayNode : public ExpressionNode {
|
---|
403 | public:
|
---|
404 | ArrayNode(JSGlobalData* globalData, int elision) KJS_FAST_CALL
|
---|
405 | : ExpressionNode(globalData)
|
---|
406 | , m_elision(elision)
|
---|
407 | , m_optional(true)
|
---|
408 | {
|
---|
409 | }
|
---|
410 |
|
---|
411 | ArrayNode(JSGlobalData* globalData, ElementNode* element) KJS_FAST_CALL
|
---|
412 | : ExpressionNode(globalData)
|
---|
413 | , m_element(element)
|
---|
414 | , m_elision(0)
|
---|
415 | , m_optional(false)
|
---|
416 | {
|
---|
417 | }
|
---|
418 |
|
---|
419 | ArrayNode(JSGlobalData* globalData, int elision, ElementNode* element) KJS_FAST_CALL
|
---|
420 | : ExpressionNode(globalData)
|
---|
421 | , m_element(element)
|
---|
422 | , m_elision(elision)
|
---|
423 | , m_optional(true)
|
---|
424 | {
|
---|
425 | }
|
---|
426 |
|
---|
427 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
428 |
|
---|
429 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
430 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
431 |
|
---|
432 | private:
|
---|
433 | RefPtr<ElementNode> m_element;
|
---|
434 | int m_elision;
|
---|
435 | bool m_optional;
|
---|
436 | };
|
---|
437 |
|
---|
438 | class PropertyNode : public Node {
|
---|
439 | public:
|
---|
440 | enum Type { Constant, Getter, Setter };
|
---|
441 |
|
---|
442 | PropertyNode(JSGlobalData* globalData, const Identifier& name, ExpressionNode* assign, Type type) KJS_FAST_CALL
|
---|
443 | : Node(globalData)
|
---|
444 | , m_name(name)
|
---|
445 | , m_assign(assign)
|
---|
446 | , m_type(type)
|
---|
447 | {
|
---|
448 | }
|
---|
449 |
|
---|
450 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
451 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
452 |
|
---|
453 | const Identifier& name() const { return m_name; }
|
---|
454 |
|
---|
455 | private:
|
---|
456 | friend class PropertyListNode;
|
---|
457 | Identifier m_name;
|
---|
458 | RefPtr<ExpressionNode> m_assign;
|
---|
459 | Type m_type;
|
---|
460 | };
|
---|
461 |
|
---|
462 | class PropertyListNode : public Node {
|
---|
463 | public:
|
---|
464 | PropertyListNode(JSGlobalData* globalData, PropertyNode* node) KJS_FAST_CALL
|
---|
465 | : Node(globalData)
|
---|
466 | , m_node(node)
|
---|
467 | {
|
---|
468 | }
|
---|
469 |
|
---|
470 | PropertyListNode(JSGlobalData* globalData, PropertyNode* node, PropertyListNode* list) KJS_FAST_CALL
|
---|
471 | : Node(globalData)
|
---|
472 | , m_node(node)
|
---|
473 | {
|
---|
474 | list->m_next = this;
|
---|
475 | }
|
---|
476 |
|
---|
477 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
478 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
479 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
480 |
|
---|
481 | PassRefPtr<PropertyListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }
|
---|
482 |
|
---|
483 | private:
|
---|
484 | friend class ObjectLiteralNode;
|
---|
485 | RefPtr<PropertyNode> m_node;
|
---|
486 | ListRefPtr<PropertyListNode> m_next;
|
---|
487 | };
|
---|
488 |
|
---|
489 | class ObjectLiteralNode : public ExpressionNode {
|
---|
490 | public:
|
---|
491 | ObjectLiteralNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
492 | : ExpressionNode(globalData)
|
---|
493 | {
|
---|
494 | }
|
---|
495 |
|
---|
496 | ObjectLiteralNode(JSGlobalData* globalData, PropertyListNode* list) KJS_FAST_CALL
|
---|
497 | : ExpressionNode(globalData)
|
---|
498 | , m_list(list)
|
---|
499 | {
|
---|
500 | }
|
---|
501 |
|
---|
502 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
503 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
504 | virtual Precedence precedence() const { return PrecPrimary; }
|
---|
505 | virtual bool needsParensIfLeftmost() const { return true; }
|
---|
506 |
|
---|
507 | private:
|
---|
508 | RefPtr<PropertyListNode> m_list;
|
---|
509 | };
|
---|
510 |
|
---|
511 | class BracketAccessorNode : public ExpressionNode {
|
---|
512 | public:
|
---|
513 | BracketAccessorNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments) KJS_FAST_CALL
|
---|
514 | : ExpressionNode(globalData)
|
---|
515 | , m_base(base)
|
---|
516 | , m_subscript(subscript)
|
---|
517 | , m_subscriptHasAssignments(subscriptHasAssignments)
|
---|
518 | {
|
---|
519 | }
|
---|
520 |
|
---|
521 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
522 |
|
---|
523 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
524 | virtual Precedence precedence() const { return PrecMember; }
|
---|
525 |
|
---|
526 | virtual bool isLocation() const KJS_FAST_CALL { return true; }
|
---|
527 | virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return true; }
|
---|
528 | ExpressionNode* base() KJS_FAST_CALL { return m_base.get(); }
|
---|
529 | ExpressionNode* subscript() KJS_FAST_CALL { return m_subscript.get(); }
|
---|
530 |
|
---|
531 | private:
|
---|
532 | RefPtr<ExpressionNode> m_base;
|
---|
533 | RefPtr<ExpressionNode> m_subscript;
|
---|
534 | bool m_subscriptHasAssignments;
|
---|
535 | };
|
---|
536 |
|
---|
537 | class DotAccessorNode : public ExpressionNode {
|
---|
538 | public:
|
---|
539 | DotAccessorNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
540 | : ExpressionNode(globalData)
|
---|
541 | , m_base(base)
|
---|
542 | , m_ident(ident)
|
---|
543 | {
|
---|
544 | }
|
---|
545 |
|
---|
546 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
547 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
548 | virtual Precedence precedence() const { return PrecMember; }
|
---|
549 |
|
---|
550 | virtual bool isLocation() const KJS_FAST_CALL { return true; }
|
---|
551 | virtual bool isDotAccessorNode() const KJS_FAST_CALL { return true; }
|
---|
552 | ExpressionNode* base() const KJS_FAST_CALL { return m_base.get(); }
|
---|
553 | const Identifier& identifier() const KJS_FAST_CALL { return m_ident; }
|
---|
554 |
|
---|
555 | private:
|
---|
556 | RefPtr<ExpressionNode> m_base;
|
---|
557 | Identifier m_ident;
|
---|
558 | };
|
---|
559 |
|
---|
560 | class ArgumentListNode : public Node {
|
---|
561 | public:
|
---|
562 | ArgumentListNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
563 | : Node(globalData)
|
---|
564 | , m_expr(expr)
|
---|
565 | {
|
---|
566 | }
|
---|
567 |
|
---|
568 | ArgumentListNode(JSGlobalData* globalData, ArgumentListNode* listNode, ExpressionNode* expr) KJS_FAST_CALL
|
---|
569 | : Node(globalData)
|
---|
570 | , m_expr(expr)
|
---|
571 | {
|
---|
572 | listNode->m_next = this;
|
---|
573 | }
|
---|
574 |
|
---|
575 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
576 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
577 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
578 |
|
---|
579 | PassRefPtr<ArgumentListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }
|
---|
580 |
|
---|
581 | ListRefPtr<ArgumentListNode> m_next;
|
---|
582 | RefPtr<ExpressionNode> m_expr;
|
---|
583 | };
|
---|
584 |
|
---|
585 | class ArgumentsNode : public Node {
|
---|
586 | public:
|
---|
587 | ArgumentsNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
588 | : Node(globalData)
|
---|
589 | {
|
---|
590 | }
|
---|
591 |
|
---|
592 | ArgumentsNode(JSGlobalData* globalData, ArgumentListNode* listNode) KJS_FAST_CALL
|
---|
593 | : Node(globalData)
|
---|
594 | , m_listNode(listNode)
|
---|
595 | {
|
---|
596 | }
|
---|
597 |
|
---|
598 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
599 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
600 |
|
---|
601 | RefPtr<ArgumentListNode> m_listNode;
|
---|
602 | };
|
---|
603 |
|
---|
604 | class NewExprNode : public ExpressionNode {
|
---|
605 | public:
|
---|
606 | NewExprNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
607 | : ExpressionNode(globalData)
|
---|
608 | , m_expr(expr)
|
---|
609 | {
|
---|
610 | }
|
---|
611 |
|
---|
612 | NewExprNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL
|
---|
613 | : ExpressionNode(globalData)
|
---|
614 | , m_expr(expr)
|
---|
615 | , m_args(args)
|
---|
616 | {
|
---|
617 | }
|
---|
618 |
|
---|
619 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
620 |
|
---|
621 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
622 | virtual Precedence precedence() const { return PrecLeftHandSide; }
|
---|
623 |
|
---|
624 | private:
|
---|
625 | RefPtr<ExpressionNode> m_expr;
|
---|
626 | RefPtr<ArgumentsNode> m_args;
|
---|
627 | };
|
---|
628 |
|
---|
629 | class EvalFunctionCallNode : public ExpressionNode {
|
---|
630 | public:
|
---|
631 | EvalFunctionCallNode(JSGlobalData* globalData, ArgumentsNode* args) KJS_FAST_CALL
|
---|
632 | : ExpressionNode(globalData)
|
---|
633 | , m_args(args)
|
---|
634 | {
|
---|
635 | }
|
---|
636 |
|
---|
637 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
638 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
639 | virtual Precedence precedence() const { return PrecCall; }
|
---|
640 |
|
---|
641 | private:
|
---|
642 | RefPtr<ArgumentsNode> m_args;
|
---|
643 | };
|
---|
644 |
|
---|
645 | class FunctionCallValueNode : public ExpressionNode {
|
---|
646 | public:
|
---|
647 | FunctionCallValueNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL
|
---|
648 | : ExpressionNode(globalData)
|
---|
649 | , m_expr(expr)
|
---|
650 | , m_args(args)
|
---|
651 | {
|
---|
652 | }
|
---|
653 |
|
---|
654 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
655 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
656 | virtual Precedence precedence() const { return PrecCall; }
|
---|
657 |
|
---|
658 | private:
|
---|
659 | RefPtr<ExpressionNode> m_expr;
|
---|
660 | RefPtr<ArgumentsNode> m_args;
|
---|
661 | };
|
---|
662 |
|
---|
663 | class FunctionCallResolveNode : public ExpressionNode {
|
---|
664 | public:
|
---|
665 | FunctionCallResolveNode(JSGlobalData* globalData, const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL
|
---|
666 | : ExpressionNode(globalData)
|
---|
667 | , m_ident(ident)
|
---|
668 | , m_args(args)
|
---|
669 | {
|
---|
670 | }
|
---|
671 |
|
---|
672 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
673 |
|
---|
674 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
675 | virtual Precedence precedence() const { return PrecCall; }
|
---|
676 |
|
---|
677 | protected:
|
---|
678 | Identifier m_ident;
|
---|
679 | RefPtr<ArgumentsNode> m_args;
|
---|
680 | size_t m_index; // Used by LocalVarFunctionCallNode.
|
---|
681 | size_t m_scopeDepth; // Used by ScopedVarFunctionCallNode and NonLocalVarFunctionCallNode
|
---|
682 | };
|
---|
683 |
|
---|
684 | class FunctionCallBracketNode : public ExpressionNode {
|
---|
685 | public:
|
---|
686 | FunctionCallBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args) KJS_FAST_CALL
|
---|
687 | : ExpressionNode(globalData)
|
---|
688 | , m_base(base)
|
---|
689 | , m_subscript(subscript)
|
---|
690 | , m_args(args)
|
---|
691 | {
|
---|
692 | }
|
---|
693 |
|
---|
694 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
695 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
696 | virtual Precedence precedence() const { return PrecCall; }
|
---|
697 |
|
---|
698 | protected:
|
---|
699 | RefPtr<ExpressionNode> m_base;
|
---|
700 | RefPtr<ExpressionNode> m_subscript;
|
---|
701 | RefPtr<ArgumentsNode> m_args;
|
---|
702 | };
|
---|
703 |
|
---|
704 | class FunctionCallDotNode : public ExpressionNode {
|
---|
705 | public:
|
---|
706 | FunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL
|
---|
707 | : ExpressionNode(globalData)
|
---|
708 | , m_base(base)
|
---|
709 | , m_ident(ident)
|
---|
710 | , m_args(args)
|
---|
711 | {
|
---|
712 | }
|
---|
713 |
|
---|
714 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
715 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
716 | virtual Precedence precedence() const { return PrecCall; }
|
---|
717 |
|
---|
718 | private:
|
---|
719 | RefPtr<ExpressionNode> m_base;
|
---|
720 | Identifier m_ident;
|
---|
721 | RefPtr<ArgumentsNode> m_args;
|
---|
722 | };
|
---|
723 |
|
---|
724 | class PrePostResolveNode : public ExpressionNode {
|
---|
725 | public:
|
---|
726 | PrePostResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
727 | : ExpressionNode(globalData, NumberType)
|
---|
728 | , m_ident(ident)
|
---|
729 | {
|
---|
730 | }
|
---|
731 |
|
---|
732 | protected:
|
---|
733 | Identifier m_ident;
|
---|
734 | size_t m_index; // Used by LocalVarPostfixNode.
|
---|
735 | };
|
---|
736 |
|
---|
737 | class PostIncResolveNode : public PrePostResolveNode {
|
---|
738 | public:
|
---|
739 | PostIncResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
740 | : PrePostResolveNode(globalData, ident)
|
---|
741 | {
|
---|
742 | }
|
---|
743 |
|
---|
744 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
745 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
746 | virtual Precedence precedence() const { return PrecPostfix; }
|
---|
747 | };
|
---|
748 |
|
---|
749 | class PostDecResolveNode : public PrePostResolveNode {
|
---|
750 | public:
|
---|
751 | PostDecResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
752 | : PrePostResolveNode(globalData, ident)
|
---|
753 | {
|
---|
754 | }
|
---|
755 |
|
---|
756 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
757 |
|
---|
758 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
759 | virtual Precedence precedence() const { return PrecPostfix; }
|
---|
760 | };
|
---|
761 |
|
---|
762 | class PostfixBracketNode : public ExpressionNode {
|
---|
763 | public:
|
---|
764 | PostfixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
765 | : ExpressionNode(globalData)
|
---|
766 | , m_base(base)
|
---|
767 | , m_subscript(subscript)
|
---|
768 | {
|
---|
769 | }
|
---|
770 |
|
---|
771 | virtual Precedence precedence() const { return PrecPostfix; }
|
---|
772 |
|
---|
773 | protected:
|
---|
774 | RefPtr<ExpressionNode> m_base;
|
---|
775 | RefPtr<ExpressionNode> m_subscript;
|
---|
776 | };
|
---|
777 |
|
---|
778 | class PostIncBracketNode : public PostfixBracketNode {
|
---|
779 | public:
|
---|
780 | PostIncBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
781 | : PostfixBracketNode(globalData, base, subscript)
|
---|
782 | {
|
---|
783 | }
|
---|
784 |
|
---|
785 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
786 |
|
---|
787 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
788 | };
|
---|
789 |
|
---|
790 | class PostDecBracketNode : public PostfixBracketNode {
|
---|
791 | public:
|
---|
792 | PostDecBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
793 | : PostfixBracketNode(globalData, base, subscript)
|
---|
794 | {
|
---|
795 | }
|
---|
796 |
|
---|
797 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
798 |
|
---|
799 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
800 | };
|
---|
801 |
|
---|
802 | class PostfixDotNode : public ExpressionNode {
|
---|
803 | public:
|
---|
804 | PostfixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
805 | : ExpressionNode(globalData)
|
---|
806 | , m_base(base)
|
---|
807 | , m_ident(ident)
|
---|
808 | {
|
---|
809 | }
|
---|
810 |
|
---|
811 | virtual Precedence precedence() const { return PrecPostfix; }
|
---|
812 |
|
---|
813 | protected:
|
---|
814 | RefPtr<ExpressionNode> m_base;
|
---|
815 | Identifier m_ident;
|
---|
816 | };
|
---|
817 |
|
---|
818 | class PostIncDotNode : public PostfixDotNode {
|
---|
819 | public:
|
---|
820 | PostIncDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
821 | : PostfixDotNode(globalData, base, ident)
|
---|
822 | {
|
---|
823 | }
|
---|
824 |
|
---|
825 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
826 |
|
---|
827 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
828 | };
|
---|
829 |
|
---|
830 | class PostDecDotNode : public PostfixDotNode {
|
---|
831 | public:
|
---|
832 | PostDecDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
833 | : PostfixDotNode(globalData, base, ident)
|
---|
834 | {
|
---|
835 | }
|
---|
836 |
|
---|
837 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
838 |
|
---|
839 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
840 | };
|
---|
841 |
|
---|
842 | class PostfixErrorNode : public ExpressionNode {
|
---|
843 | public:
|
---|
844 | PostfixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper) KJS_FAST_CALL
|
---|
845 | : ExpressionNode(globalData)
|
---|
846 | , m_expr(expr)
|
---|
847 | , m_operator(oper)
|
---|
848 | {
|
---|
849 | }
|
---|
850 |
|
---|
851 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
852 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
853 | virtual Precedence precedence() const { return PrecPostfix; }
|
---|
854 |
|
---|
855 | private:
|
---|
856 | RefPtr<ExpressionNode> m_expr;
|
---|
857 | Operator m_operator;
|
---|
858 | };
|
---|
859 |
|
---|
860 | class DeleteResolveNode : public ExpressionNode {
|
---|
861 | public:
|
---|
862 | DeleteResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
863 | : ExpressionNode(globalData)
|
---|
864 | , m_ident(ident)
|
---|
865 | {
|
---|
866 | }
|
---|
867 |
|
---|
868 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
869 |
|
---|
870 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
871 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
872 |
|
---|
873 | private:
|
---|
874 | Identifier m_ident;
|
---|
875 | };
|
---|
876 |
|
---|
877 | class DeleteBracketNode : public ExpressionNode {
|
---|
878 | public:
|
---|
879 | DeleteBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
880 | : ExpressionNode(globalData)
|
---|
881 | , m_base(base)
|
---|
882 | , m_subscript(subscript)
|
---|
883 | {
|
---|
884 | }
|
---|
885 |
|
---|
886 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
887 |
|
---|
888 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
889 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
890 |
|
---|
891 | private:
|
---|
892 | RefPtr<ExpressionNode> m_base;
|
---|
893 | RefPtr<ExpressionNode> m_subscript;
|
---|
894 | };
|
---|
895 |
|
---|
896 | class DeleteDotNode : public ExpressionNode {
|
---|
897 | public:
|
---|
898 | DeleteDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
899 | : ExpressionNode(globalData)
|
---|
900 | , m_base(base)
|
---|
901 | , m_ident(ident)
|
---|
902 | {
|
---|
903 | }
|
---|
904 |
|
---|
905 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
906 |
|
---|
907 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
908 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
909 |
|
---|
910 | private:
|
---|
911 | RefPtr<ExpressionNode> m_base;
|
---|
912 | Identifier m_ident;
|
---|
913 | };
|
---|
914 |
|
---|
915 | class DeleteValueNode : public ExpressionNode {
|
---|
916 | public:
|
---|
917 | DeleteValueNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
918 | : ExpressionNode(globalData)
|
---|
919 | , m_expr(expr)
|
---|
920 | {
|
---|
921 | }
|
---|
922 |
|
---|
923 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
924 |
|
---|
925 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
926 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
927 |
|
---|
928 | private:
|
---|
929 | RefPtr<ExpressionNode> m_expr;
|
---|
930 | };
|
---|
931 |
|
---|
932 | class VoidNode : public ExpressionNode {
|
---|
933 | public:
|
---|
934 | VoidNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
935 | : ExpressionNode(globalData)
|
---|
936 | , m_expr(expr)
|
---|
937 | {
|
---|
938 | }
|
---|
939 |
|
---|
940 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
941 |
|
---|
942 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
943 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
944 |
|
---|
945 | private:
|
---|
946 | RefPtr<ExpressionNode> m_expr;
|
---|
947 | };
|
---|
948 |
|
---|
949 | class TypeOfResolveNode : public ExpressionNode {
|
---|
950 | public:
|
---|
951 | TypeOfResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
952 | : ExpressionNode(globalData, StringType)
|
---|
953 | , m_ident(ident)
|
---|
954 | {
|
---|
955 | }
|
---|
956 |
|
---|
957 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
958 |
|
---|
959 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
960 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
961 |
|
---|
962 | const Identifier& identifier() const KJS_FAST_CALL { return m_ident; }
|
---|
963 |
|
---|
964 | protected:
|
---|
965 | Identifier m_ident;
|
---|
966 | size_t m_index; // Used by LocalTypeOfNode.
|
---|
967 | };
|
---|
968 |
|
---|
969 | class TypeOfValueNode : public ExpressionNode {
|
---|
970 | public:
|
---|
971 | TypeOfValueNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
972 | : ExpressionNode(globalData, StringType)
|
---|
973 | , m_expr(expr)
|
---|
974 | {
|
---|
975 | }
|
---|
976 |
|
---|
977 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
978 |
|
---|
979 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
980 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
981 |
|
---|
982 | private:
|
---|
983 | RefPtr<ExpressionNode> m_expr;
|
---|
984 | };
|
---|
985 |
|
---|
986 | class PreIncResolveNode : public PrePostResolveNode {
|
---|
987 | public:
|
---|
988 | PreIncResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
989 | : PrePostResolveNode(globalData, ident)
|
---|
990 | {
|
---|
991 | }
|
---|
992 |
|
---|
993 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
994 |
|
---|
995 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
996 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
997 | };
|
---|
998 |
|
---|
999 | class PreDecResolveNode : public PrePostResolveNode {
|
---|
1000 | public:
|
---|
1001 | PreDecResolveNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
1002 | : PrePostResolveNode(globalData, ident)
|
---|
1003 | {
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1007 |
|
---|
1008 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1009 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1010 | };
|
---|
1011 |
|
---|
1012 | class PrefixBracketNode : public ExpressionNode {
|
---|
1013 | public:
|
---|
1014 | PrefixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
1015 | : ExpressionNode(globalData)
|
---|
1016 | , m_base(base)
|
---|
1017 | , m_subscript(subscript)
|
---|
1018 | {
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1022 |
|
---|
1023 | protected:
|
---|
1024 | RefPtr<ExpressionNode> m_base;
|
---|
1025 | RefPtr<ExpressionNode> m_subscript;
|
---|
1026 | };
|
---|
1027 |
|
---|
1028 | class PreIncBracketNode : public PrefixBracketNode {
|
---|
1029 | public:
|
---|
1030 | PreIncBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
1031 | : PrefixBracketNode(globalData, base, subscript)
|
---|
1032 | {
|
---|
1033 | }
|
---|
1034 |
|
---|
1035 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1036 |
|
---|
1037 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1038 | };
|
---|
1039 |
|
---|
1040 | class PreDecBracketNode : public PrefixBracketNode {
|
---|
1041 | public:
|
---|
1042 | PreDecBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL
|
---|
1043 | : PrefixBracketNode(globalData, base, subscript)
|
---|
1044 | {
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1048 |
|
---|
1049 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1050 | };
|
---|
1051 |
|
---|
1052 | class PrefixDotNode : public ExpressionNode {
|
---|
1053 | public:
|
---|
1054 | PrefixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
1055 | : ExpressionNode(globalData)
|
---|
1056 | , m_base(base)
|
---|
1057 | , m_ident(ident)
|
---|
1058 | {
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | virtual Precedence precedence() const { return PrecPostfix; }
|
---|
1062 |
|
---|
1063 | protected:
|
---|
1064 | RefPtr<ExpressionNode> m_base;
|
---|
1065 | Identifier m_ident;
|
---|
1066 | };
|
---|
1067 |
|
---|
1068 | class PreIncDotNode : public PrefixDotNode {
|
---|
1069 | public:
|
---|
1070 | PreIncDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
1071 | : PrefixDotNode(globalData, base, ident)
|
---|
1072 | {
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1076 |
|
---|
1077 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1078 | };
|
---|
1079 |
|
---|
1080 | class PreDecDotNode : public PrefixDotNode {
|
---|
1081 | public:
|
---|
1082 | PreDecDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL
|
---|
1083 | : PrefixDotNode(globalData, base, ident)
|
---|
1084 | {
|
---|
1085 | }
|
---|
1086 |
|
---|
1087 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1088 |
|
---|
1089 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1090 | };
|
---|
1091 |
|
---|
1092 | class PrefixErrorNode : public ExpressionNode {
|
---|
1093 | public:
|
---|
1094 | PrefixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper) KJS_FAST_CALL
|
---|
1095 | : ExpressionNode(globalData)
|
---|
1096 | , m_expr(expr)
|
---|
1097 | , m_operator(oper)
|
---|
1098 | {
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1102 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1103 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1104 |
|
---|
1105 | private:
|
---|
1106 | RefPtr<ExpressionNode> m_expr;
|
---|
1107 | Operator m_operator;
|
---|
1108 | };
|
---|
1109 |
|
---|
1110 | class UnaryOpNode : public ExpressionNode {
|
---|
1111 | public:
|
---|
1112 | UnaryOpNode(JSGlobalData* globalData, ExpressionNode* expr)
|
---|
1113 | : ExpressionNode(globalData)
|
---|
1114 | , m_expr(expr)
|
---|
1115 | {
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | UnaryOpNode(JSGlobalData* globalData, JSType type, ExpressionNode* expr)
|
---|
1119 | : ExpressionNode(globalData, type)
|
---|
1120 | , m_expr(expr)
|
---|
1121 | {
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1125 | virtual OpcodeID opcode() const KJS_FAST_CALL = 0;
|
---|
1126 |
|
---|
1127 | protected:
|
---|
1128 | RefPtr<ExpressionNode> m_expr;
|
---|
1129 | };
|
---|
1130 |
|
---|
1131 | class UnaryPlusNode : public UnaryOpNode {
|
---|
1132 | public:
|
---|
1133 | UnaryPlusNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1134 | : UnaryOpNode(globalData, NumberType, expr)
|
---|
1135 | {
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_to_jsnumber; }
|
---|
1139 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1140 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1141 | };
|
---|
1142 |
|
---|
1143 | class NegateNode : public UnaryOpNode {
|
---|
1144 | public:
|
---|
1145 | NegateNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1146 | : UnaryOpNode(globalData, NumberType, expr)
|
---|
1147 | {
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_negate; }
|
---|
1151 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1152 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1153 | };
|
---|
1154 |
|
---|
1155 | class BitwiseNotNode : public UnaryOpNode {
|
---|
1156 | public:
|
---|
1157 | BitwiseNotNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1158 | : UnaryOpNode(globalData, NumberType, expr)
|
---|
1159 | {
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_bitnot; }
|
---|
1163 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1164 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1165 | };
|
---|
1166 |
|
---|
1167 | class LogicalNotNode : public UnaryOpNode {
|
---|
1168 | public:
|
---|
1169 | LogicalNotNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1170 | : UnaryOpNode(globalData, BooleanType, expr)
|
---|
1171 | {
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_not; }
|
---|
1175 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1176 | virtual Precedence precedence() const { return PrecUnary; }
|
---|
1177 | };
|
---|
1178 |
|
---|
1179 | class BinaryOpNode : public ExpressionNode {
|
---|
1180 | public:
|
---|
1181 | BinaryOpNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments)
|
---|
1182 | : ExpressionNode(globalData)
|
---|
1183 | , m_term1(term1)
|
---|
1184 | , m_term2(term2)
|
---|
1185 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1186 | {
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | BinaryOpNode(JSGlobalData* globalData, JSType type, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments)
|
---|
1190 | : ExpressionNode(globalData, type)
|
---|
1191 | , m_term1(term1)
|
---|
1192 | , m_term2(term2)
|
---|
1193 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1194 | {
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1198 | virtual OpcodeID opcode() const KJS_FAST_CALL = 0;
|
---|
1199 |
|
---|
1200 | protected:
|
---|
1201 | RefPtr<ExpressionNode> m_term1;
|
---|
1202 | RefPtr<ExpressionNode> m_term2;
|
---|
1203 | bool m_rightHasAssignments;
|
---|
1204 | };
|
---|
1205 |
|
---|
1206 | class ReverseBinaryOpNode : public ExpressionNode {
|
---|
1207 | public:
|
---|
1208 | ReverseBinaryOpNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments)
|
---|
1209 | : ExpressionNode(globalData)
|
---|
1210 | , m_term1(term1)
|
---|
1211 | , m_term2(term2)
|
---|
1212 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1213 | {
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | ReverseBinaryOpNode(JSGlobalData* globalData, JSType type, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments)
|
---|
1217 | : ExpressionNode(globalData, type)
|
---|
1218 | , m_term1(term1)
|
---|
1219 | , m_term2(term2)
|
---|
1220 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1221 | {
|
---|
1222 | }
|
---|
1223 |
|
---|
1224 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1225 | virtual OpcodeID opcode() const KJS_FAST_CALL = 0;
|
---|
1226 |
|
---|
1227 | protected:
|
---|
1228 | RefPtr<ExpressionNode> m_term1;
|
---|
1229 | RefPtr<ExpressionNode> m_term2;
|
---|
1230 | bool m_rightHasAssignments;
|
---|
1231 | };
|
---|
1232 |
|
---|
1233 | class MultNode : public BinaryOpNode {
|
---|
1234 | public:
|
---|
1235 | MultNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1236 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1237 | {
|
---|
1238 | }
|
---|
1239 |
|
---|
1240 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_mul; }
|
---|
1241 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1242 | virtual Precedence precedence() const { return PrecMultiplicative; }
|
---|
1243 | };
|
---|
1244 |
|
---|
1245 | class DivNode : public BinaryOpNode {
|
---|
1246 | public:
|
---|
1247 | DivNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1248 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1249 | {
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_div; }
|
---|
1253 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1254 | virtual Precedence precedence() const { return PrecMultiplicative; }
|
---|
1255 | };
|
---|
1256 |
|
---|
1257 | class ModNode : public BinaryOpNode {
|
---|
1258 | public:
|
---|
1259 | ModNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1260 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1261 | {
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_mod; }
|
---|
1265 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1266 | virtual Precedence precedence() const { return PrecMultiplicative; }
|
---|
1267 | };
|
---|
1268 |
|
---|
1269 | class AddNode : public BinaryOpNode {
|
---|
1270 | public:
|
---|
1271 | AddNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1272 | : BinaryOpNode(globalData, term1, term2, rightHasAssignments)
|
---|
1273 | {
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_add; }
|
---|
1277 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1278 | virtual Precedence precedence() const { return PrecAdditive; }
|
---|
1279 | };
|
---|
1280 |
|
---|
1281 | class SubNode : public BinaryOpNode {
|
---|
1282 | public:
|
---|
1283 | SubNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1284 | : BinaryOpNode(globalData, term1, term2, rightHasAssignments)
|
---|
1285 | {
|
---|
1286 | }
|
---|
1287 |
|
---|
1288 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_sub; }
|
---|
1289 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1290 | virtual Precedence precedence() const { return PrecAdditive; }
|
---|
1291 | };
|
---|
1292 |
|
---|
1293 | class LeftShiftNode : public BinaryOpNode {
|
---|
1294 | public:
|
---|
1295 | LeftShiftNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1296 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1297 | {
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_lshift; }
|
---|
1301 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1302 | virtual Precedence precedence() const { return PrecShift; }
|
---|
1303 | };
|
---|
1304 |
|
---|
1305 | class RightShiftNode : public BinaryOpNode {
|
---|
1306 | public:
|
---|
1307 | RightShiftNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1308 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1309 | {
|
---|
1310 | }
|
---|
1311 |
|
---|
1312 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_rshift; }
|
---|
1313 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1314 | virtual Precedence precedence() const { return PrecShift; }
|
---|
1315 | };
|
---|
1316 |
|
---|
1317 | class UnsignedRightShiftNode : public BinaryOpNode {
|
---|
1318 | public:
|
---|
1319 | UnsignedRightShiftNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1320 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1321 | {
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_urshift; }
|
---|
1325 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1326 | virtual Precedence precedence() const { return PrecShift; }
|
---|
1327 | };
|
---|
1328 |
|
---|
1329 | class LessNode : public BinaryOpNode {
|
---|
1330 | public:
|
---|
1331 | LessNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1332 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1333 | {
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_less; }
|
---|
1337 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1338 | virtual Precedence precedence() const { return PrecRelational; }
|
---|
1339 | };
|
---|
1340 |
|
---|
1341 | class GreaterNode : public ReverseBinaryOpNode {
|
---|
1342 | public:
|
---|
1343 | GreaterNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1344 | : ReverseBinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1345 | {
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_less; }
|
---|
1349 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1350 | virtual Precedence precedence() const { return PrecRelational; }
|
---|
1351 | };
|
---|
1352 |
|
---|
1353 | class LessEqNode : public BinaryOpNode {
|
---|
1354 | public:
|
---|
1355 | LessEqNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1356 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1357 | {
|
---|
1358 | }
|
---|
1359 |
|
---|
1360 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_lesseq; }
|
---|
1361 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1362 | virtual Precedence precedence() const { return PrecRelational; }
|
---|
1363 | };
|
---|
1364 |
|
---|
1365 | class GreaterEqNode : public ReverseBinaryOpNode {
|
---|
1366 | public:
|
---|
1367 | GreaterEqNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1368 | : ReverseBinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1369 | {
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_lesseq; }
|
---|
1373 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1374 | virtual Precedence precedence() const { return PrecRelational; }
|
---|
1375 | };
|
---|
1376 |
|
---|
1377 | class InstanceOfNode : public BinaryOpNode {
|
---|
1378 | public:
|
---|
1379 | InstanceOfNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1380 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1381 | {
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_instanceof; }
|
---|
1385 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1386 | virtual Precedence precedence() const { return PrecRelational; }
|
---|
1387 | };
|
---|
1388 |
|
---|
1389 | class InNode : public BinaryOpNode {
|
---|
1390 | public:
|
---|
1391 | InNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1392 | : BinaryOpNode(globalData, term1, term2, rightHasAssignments)
|
---|
1393 | {
|
---|
1394 | }
|
---|
1395 |
|
---|
1396 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_in; }
|
---|
1397 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1398 | virtual Precedence precedence() const { return PrecRelational; }
|
---|
1399 | };
|
---|
1400 |
|
---|
1401 | class EqualNode : public BinaryOpNode {
|
---|
1402 | public:
|
---|
1403 | EqualNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1404 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1405 | {
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_eq; }
|
---|
1409 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1410 | virtual Precedence precedence() const { return PrecEquality; }
|
---|
1411 | };
|
---|
1412 |
|
---|
1413 | class NotEqualNode : public BinaryOpNode {
|
---|
1414 | public:
|
---|
1415 | NotEqualNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1416 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1417 | {
|
---|
1418 | }
|
---|
1419 |
|
---|
1420 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_neq; }
|
---|
1421 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1422 | virtual Precedence precedence() const { return PrecEquality; }
|
---|
1423 | };
|
---|
1424 |
|
---|
1425 | class StrictEqualNode : public BinaryOpNode {
|
---|
1426 | public:
|
---|
1427 | StrictEqualNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1428 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1429 | {
|
---|
1430 | }
|
---|
1431 |
|
---|
1432 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_stricteq; }
|
---|
1433 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1434 | virtual Precedence precedence() const { return PrecEquality; }
|
---|
1435 | };
|
---|
1436 |
|
---|
1437 | class NotStrictEqualNode : public BinaryOpNode {
|
---|
1438 | public:
|
---|
1439 | NotStrictEqualNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1440 | : BinaryOpNode(globalData, BooleanType, term1, term2, rightHasAssignments)
|
---|
1441 | {
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_nstricteq; }
|
---|
1445 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1446 | virtual Precedence precedence() const { return PrecEquality; }
|
---|
1447 | };
|
---|
1448 |
|
---|
1449 | class BitAndNode : public BinaryOpNode {
|
---|
1450 | public:
|
---|
1451 | BitAndNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1452 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1453 | {
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_bitand; }
|
---|
1457 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1458 | virtual Precedence precedence() const { return PrecBitwiseAnd; }
|
---|
1459 | };
|
---|
1460 |
|
---|
1461 | class BitOrNode : public BinaryOpNode {
|
---|
1462 | public:
|
---|
1463 | BitOrNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1464 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1465 | {
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_bitor; }
|
---|
1469 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1470 | virtual Precedence precedence() const { return PrecBitwiseOr; }
|
---|
1471 | };
|
---|
1472 |
|
---|
1473 | class BitXOrNode : public BinaryOpNode {
|
---|
1474 | public:
|
---|
1475 | BitXOrNode(JSGlobalData* globalData, ExpressionNode* term1, ExpressionNode* term2, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1476 | : BinaryOpNode(globalData, NumberType, term1, term2, rightHasAssignments)
|
---|
1477 | {
|
---|
1478 | }
|
---|
1479 |
|
---|
1480 | virtual OpcodeID opcode() const KJS_FAST_CALL { return op_bitxor; }
|
---|
1481 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1482 | virtual Precedence precedence() const { return PrecBitwiseXor; }
|
---|
1483 | };
|
---|
1484 |
|
---|
1485 | /**
|
---|
1486 | * m_expr1 && m_expr2, m_expr1 || m_expr2
|
---|
1487 | */
|
---|
1488 | class LogicalAndNode : public ExpressionNode {
|
---|
1489 | public:
|
---|
1490 | LogicalAndNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL
|
---|
1491 | : ExpressionNode(globalData, BooleanType)
|
---|
1492 | , m_expr1(expr1)
|
---|
1493 | , m_expr2(expr2)
|
---|
1494 | {
|
---|
1495 | }
|
---|
1496 |
|
---|
1497 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1498 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1499 | virtual Precedence precedence() const { return PrecLogicalAnd; }
|
---|
1500 |
|
---|
1501 | private:
|
---|
1502 | RefPtr<ExpressionNode> m_expr1;
|
---|
1503 | RefPtr<ExpressionNode> m_expr2;
|
---|
1504 | };
|
---|
1505 |
|
---|
1506 | class LogicalOrNode : public ExpressionNode {
|
---|
1507 | public:
|
---|
1508 | LogicalOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL
|
---|
1509 | : ExpressionNode(globalData, BooleanType)
|
---|
1510 | , m_expr1(expr1)
|
---|
1511 | , m_expr2(expr2)
|
---|
1512 | {
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1516 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1517 | virtual Precedence precedence() const { return PrecLogicalOr; }
|
---|
1518 |
|
---|
1519 | private:
|
---|
1520 | RefPtr<ExpressionNode> m_expr1;
|
---|
1521 | RefPtr<ExpressionNode> m_expr2;
|
---|
1522 | };
|
---|
1523 |
|
---|
1524 | /**
|
---|
1525 | * The ternary operator, "m_logical ? m_expr1 : m_expr2"
|
---|
1526 | */
|
---|
1527 | class ConditionalNode : public ExpressionNode {
|
---|
1528 | public:
|
---|
1529 | ConditionalNode(JSGlobalData* globalData, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL
|
---|
1530 | : ExpressionNode(globalData)
|
---|
1531 | , m_logical(logical)
|
---|
1532 | , m_expr1(expr1)
|
---|
1533 | , m_expr2(expr2)
|
---|
1534 | {
|
---|
1535 | }
|
---|
1536 |
|
---|
1537 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1538 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1539 | virtual Precedence precedence() const { return PrecConditional; }
|
---|
1540 |
|
---|
1541 | private:
|
---|
1542 | RefPtr<ExpressionNode> m_logical;
|
---|
1543 | RefPtr<ExpressionNode> m_expr1;
|
---|
1544 | RefPtr<ExpressionNode> m_expr2;
|
---|
1545 | };
|
---|
1546 |
|
---|
1547 | class ReadModifyResolveNode : public ExpressionNode {
|
---|
1548 | public:
|
---|
1549 | ReadModifyResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1550 | : ExpressionNode(globalData)
|
---|
1551 | , m_ident(ident)
|
---|
1552 | , m_right(right)
|
---|
1553 | , m_operator(oper)
|
---|
1554 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1555 | {
|
---|
1556 | }
|
---|
1557 |
|
---|
1558 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1559 |
|
---|
1560 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1561 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1562 |
|
---|
1563 | protected:
|
---|
1564 | Identifier m_ident;
|
---|
1565 | RefPtr<ExpressionNode> m_right;
|
---|
1566 | size_t m_index; // Used by ReadModifyLocalVarNode.
|
---|
1567 | Operator m_operator : 31;
|
---|
1568 | bool m_rightHasAssignments : 1;
|
---|
1569 | };
|
---|
1570 |
|
---|
1571 | class AssignResolveNode : public ExpressionNode {
|
---|
1572 | public:
|
---|
1573 | AssignResolveNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1574 | : ExpressionNode(globalData)
|
---|
1575 | , m_ident(ident)
|
---|
1576 | , m_right(right)
|
---|
1577 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1578 | {
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1582 |
|
---|
1583 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1584 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1585 |
|
---|
1586 | protected:
|
---|
1587 | Identifier m_ident;
|
---|
1588 | RefPtr<ExpressionNode> m_right;
|
---|
1589 | size_t m_index; // Used by ReadModifyLocalVarNode.
|
---|
1590 | bool m_rightHasAssignments;
|
---|
1591 | };
|
---|
1592 |
|
---|
1593 | class ReadModifyBracketNode : public ExpressionNode {
|
---|
1594 | public:
|
---|
1595 | ReadModifyBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1596 | : ExpressionNode(globalData)
|
---|
1597 | , m_base(base)
|
---|
1598 | , m_subscript(subscript)
|
---|
1599 | , m_right(right)
|
---|
1600 | , m_operator(oper)
|
---|
1601 | , m_subscriptHasAssignments(subscriptHasAssignments)
|
---|
1602 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1603 | {
|
---|
1604 | }
|
---|
1605 |
|
---|
1606 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1607 |
|
---|
1608 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1609 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1610 |
|
---|
1611 | protected:
|
---|
1612 | RefPtr<ExpressionNode> m_base;
|
---|
1613 | RefPtr<ExpressionNode> m_subscript;
|
---|
1614 | RefPtr<ExpressionNode> m_right;
|
---|
1615 | Operator m_operator : 30;
|
---|
1616 | bool m_subscriptHasAssignments : 1;
|
---|
1617 | bool m_rightHasAssignments : 1;
|
---|
1618 | };
|
---|
1619 |
|
---|
1620 | class AssignBracketNode : public ExpressionNode {
|
---|
1621 | public:
|
---|
1622 | AssignBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1623 | : ExpressionNode(globalData)
|
---|
1624 | , m_base(base)
|
---|
1625 | , m_subscript(subscript)
|
---|
1626 | , m_right(right)
|
---|
1627 | , m_subscriptHasAssignments(subscriptHasAssignments)
|
---|
1628 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1629 | {
|
---|
1630 | }
|
---|
1631 |
|
---|
1632 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1633 |
|
---|
1634 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1635 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1636 |
|
---|
1637 | protected:
|
---|
1638 | RefPtr<ExpressionNode> m_base;
|
---|
1639 | RefPtr<ExpressionNode> m_subscript;
|
---|
1640 | RefPtr<ExpressionNode> m_right;
|
---|
1641 | bool m_subscriptHasAssignments : 1;
|
---|
1642 | bool m_rightHasAssignments : 1;
|
---|
1643 | };
|
---|
1644 |
|
---|
1645 | class AssignDotNode : public ExpressionNode {
|
---|
1646 | public:
|
---|
1647 | AssignDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1648 | : ExpressionNode(globalData)
|
---|
1649 | , m_base(base)
|
---|
1650 | , m_ident(ident)
|
---|
1651 | , m_right(right)
|
---|
1652 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1653 | {
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1657 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1658 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1659 |
|
---|
1660 | protected:
|
---|
1661 | RefPtr<ExpressionNode> m_base;
|
---|
1662 | Identifier m_ident;
|
---|
1663 | RefPtr<ExpressionNode> m_right;
|
---|
1664 | bool m_rightHasAssignments;
|
---|
1665 | };
|
---|
1666 |
|
---|
1667 | class ReadModifyDotNode : public ExpressionNode {
|
---|
1668 | public:
|
---|
1669 | ReadModifyDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments) KJS_FAST_CALL
|
---|
1670 | : ExpressionNode(globalData)
|
---|
1671 | , m_base(base)
|
---|
1672 | , m_ident(ident)
|
---|
1673 | , m_right(right)
|
---|
1674 | , m_operator(oper)
|
---|
1675 | , m_rightHasAssignments(rightHasAssignments)
|
---|
1676 | {
|
---|
1677 | }
|
---|
1678 |
|
---|
1679 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1680 |
|
---|
1681 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1682 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1683 |
|
---|
1684 | protected:
|
---|
1685 | RefPtr<ExpressionNode> m_base;
|
---|
1686 | Identifier m_ident;
|
---|
1687 | RefPtr<ExpressionNode> m_right;
|
---|
1688 | Operator m_operator : 31;
|
---|
1689 | bool m_rightHasAssignments : 1;
|
---|
1690 | };
|
---|
1691 |
|
---|
1692 | class AssignErrorNode : public ExpressionNode {
|
---|
1693 | public:
|
---|
1694 | AssignErrorNode(JSGlobalData* globalData, ExpressionNode* left, Operator oper, ExpressionNode* right) KJS_FAST_CALL
|
---|
1695 | : ExpressionNode(globalData)
|
---|
1696 | , m_left(left)
|
---|
1697 | , m_operator(oper)
|
---|
1698 | , m_right(right)
|
---|
1699 | {
|
---|
1700 | }
|
---|
1701 |
|
---|
1702 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1703 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1704 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1705 |
|
---|
1706 | protected:
|
---|
1707 | RefPtr<ExpressionNode> m_left;
|
---|
1708 | Operator m_operator;
|
---|
1709 | RefPtr<ExpressionNode> m_right;
|
---|
1710 | };
|
---|
1711 |
|
---|
1712 | class CommaNode : public ExpressionNode {
|
---|
1713 | public:
|
---|
1714 | CommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL
|
---|
1715 | : ExpressionNode(globalData)
|
---|
1716 | , m_expr1(expr1)
|
---|
1717 | , m_expr2(expr2)
|
---|
1718 | {
|
---|
1719 | }
|
---|
1720 |
|
---|
1721 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1722 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1723 | virtual Precedence precedence() const { return PrecExpression; }
|
---|
1724 |
|
---|
1725 | private:
|
---|
1726 | RefPtr<ExpressionNode> m_expr1;
|
---|
1727 | RefPtr<ExpressionNode> m_expr2;
|
---|
1728 | };
|
---|
1729 |
|
---|
1730 | class VarDeclCommaNode : public CommaNode {
|
---|
1731 | public:
|
---|
1732 | VarDeclCommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL
|
---|
1733 | : CommaNode(globalData, expr1, expr2)
|
---|
1734 | {
|
---|
1735 | }
|
---|
1736 | virtual Precedence precedence() const { return PrecAssignment; }
|
---|
1737 | };
|
---|
1738 |
|
---|
1739 | class ConstDeclNode : public ExpressionNode {
|
---|
1740 | public:
|
---|
1741 | ConstDeclNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* in) KJS_FAST_CALL;
|
---|
1742 |
|
---|
1743 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1744 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
1745 | PassRefPtr<ConstDeclNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }
|
---|
1746 |
|
---|
1747 | Identifier m_ident;
|
---|
1748 | ListRefPtr<ConstDeclNode> m_next;
|
---|
1749 | RefPtr<ExpressionNode> m_init;
|
---|
1750 |
|
---|
1751 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1752 | virtual RegisterID* emitCodeSingle(CodeGenerator&) KJS_FAST_CALL;
|
---|
1753 | };
|
---|
1754 |
|
---|
1755 | class ConstStatementNode : public StatementNode {
|
---|
1756 | public:
|
---|
1757 | ConstStatementNode(JSGlobalData* globalData, ConstDeclNode* next) KJS_FAST_CALL
|
---|
1758 | : StatementNode(globalData)
|
---|
1759 | , m_next(next)
|
---|
1760 | {
|
---|
1761 | }
|
---|
1762 |
|
---|
1763 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1764 |
|
---|
1765 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1766 |
|
---|
1767 | private:
|
---|
1768 | RefPtr<ConstDeclNode> m_next;
|
---|
1769 | };
|
---|
1770 |
|
---|
1771 | typedef Vector<RefPtr<StatementNode> > StatementVector;
|
---|
1772 |
|
---|
1773 | class SourceElements : public ParserRefCounted {
|
---|
1774 | public:
|
---|
1775 | SourceElements(JSGlobalData* globalData) : ParserRefCounted(globalData) {}
|
---|
1776 |
|
---|
1777 | void append(PassRefPtr<StatementNode>);
|
---|
1778 | void releaseContentsIntoVector(StatementVector& destination)
|
---|
1779 | {
|
---|
1780 | ASSERT(destination.isEmpty());
|
---|
1781 | m_statements.swap(destination);
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 | private:
|
---|
1785 | StatementVector m_statements;
|
---|
1786 | };
|
---|
1787 |
|
---|
1788 | class BlockNode : public StatementNode {
|
---|
1789 | public:
|
---|
1790 | BlockNode(JSGlobalData*, SourceElements* children) KJS_FAST_CALL;
|
---|
1791 |
|
---|
1792 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1793 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1794 |
|
---|
1795 | StatementVector& children() { return m_children; }
|
---|
1796 |
|
---|
1797 | protected:
|
---|
1798 | StatementVector m_children;
|
---|
1799 | };
|
---|
1800 |
|
---|
1801 | class EmptyStatementNode : public StatementNode {
|
---|
1802 | public:
|
---|
1803 | EmptyStatementNode(JSGlobalData* globalData) KJS_FAST_CALL // debug
|
---|
1804 | : StatementNode(globalData)
|
---|
1805 | {
|
---|
1806 | }
|
---|
1807 |
|
---|
1808 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1809 |
|
---|
1810 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1811 | virtual bool isEmptyStatement() const KJS_FAST_CALL { return true; }
|
---|
1812 | };
|
---|
1813 |
|
---|
1814 | class DebuggerStatementNode : public StatementNode {
|
---|
1815 | public:
|
---|
1816 | DebuggerStatementNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
1817 | : StatementNode(globalData)
|
---|
1818 | {
|
---|
1819 | }
|
---|
1820 |
|
---|
1821 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1822 |
|
---|
1823 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1824 | };
|
---|
1825 |
|
---|
1826 | class ExprStatementNode : public StatementNode {
|
---|
1827 | public:
|
---|
1828 | ExprStatementNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1829 | : StatementNode(globalData)
|
---|
1830 | , m_expr(expr)
|
---|
1831 | {
|
---|
1832 | }
|
---|
1833 |
|
---|
1834 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1835 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1836 |
|
---|
1837 | private:
|
---|
1838 | RefPtr<ExpressionNode> m_expr;
|
---|
1839 | };
|
---|
1840 |
|
---|
1841 | class VarStatementNode : public StatementNode {
|
---|
1842 | public:
|
---|
1843 | VarStatementNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1844 | : StatementNode(globalData)
|
---|
1845 | , m_expr(expr)
|
---|
1846 | {
|
---|
1847 | }
|
---|
1848 |
|
---|
1849 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1850 |
|
---|
1851 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1852 |
|
---|
1853 | private:
|
---|
1854 | RefPtr<ExpressionNode> m_expr;
|
---|
1855 | };
|
---|
1856 |
|
---|
1857 | class IfNode : public StatementNode {
|
---|
1858 | public:
|
---|
1859 | IfNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock) KJS_FAST_CALL
|
---|
1860 | : StatementNode(globalData)
|
---|
1861 | , m_condition(condition)
|
---|
1862 | , m_ifBlock(ifBlock)
|
---|
1863 | {
|
---|
1864 | }
|
---|
1865 |
|
---|
1866 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1867 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1868 |
|
---|
1869 | protected:
|
---|
1870 | RefPtr<ExpressionNode> m_condition;
|
---|
1871 | RefPtr<StatementNode> m_ifBlock;
|
---|
1872 | };
|
---|
1873 |
|
---|
1874 | class IfElseNode : public IfNode {
|
---|
1875 | public:
|
---|
1876 | IfElseNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock) KJS_FAST_CALL
|
---|
1877 | : IfNode(globalData, condition, ifBlock)
|
---|
1878 | , m_elseBlock(elseBlock)
|
---|
1879 | {
|
---|
1880 | }
|
---|
1881 |
|
---|
1882 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1883 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1884 |
|
---|
1885 | private:
|
---|
1886 | RefPtr<StatementNode> m_elseBlock;
|
---|
1887 | };
|
---|
1888 |
|
---|
1889 | class DoWhileNode : public StatementNode {
|
---|
1890 | public:
|
---|
1891 | DoWhileNode(JSGlobalData* globalData, StatementNode* statement, ExpressionNode* expr) KJS_FAST_CALL
|
---|
1892 | : StatementNode(globalData)
|
---|
1893 | , m_statement(statement)
|
---|
1894 | , m_expr(expr)
|
---|
1895 | {
|
---|
1896 | }
|
---|
1897 |
|
---|
1898 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1899 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1900 |
|
---|
1901 | private:
|
---|
1902 | RefPtr<StatementNode> m_statement;
|
---|
1903 | RefPtr<ExpressionNode> m_expr;
|
---|
1904 | };
|
---|
1905 |
|
---|
1906 | class WhileNode : public StatementNode {
|
---|
1907 | public:
|
---|
1908 | WhileNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL
|
---|
1909 | : StatementNode(globalData)
|
---|
1910 | , m_expr(expr)
|
---|
1911 | , m_statement(statement)
|
---|
1912 | {
|
---|
1913 | }
|
---|
1914 |
|
---|
1915 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1916 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1917 |
|
---|
1918 | private:
|
---|
1919 | RefPtr<ExpressionNode> m_expr;
|
---|
1920 | RefPtr<StatementNode> m_statement;
|
---|
1921 | };
|
---|
1922 |
|
---|
1923 | class ForNode : public StatementNode {
|
---|
1924 | public:
|
---|
1925 | ForNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl) KJS_FAST_CALL
|
---|
1926 | : StatementNode(globalData)
|
---|
1927 | , m_expr1(expr1)
|
---|
1928 | , m_expr2(expr2)
|
---|
1929 | , m_expr3(expr3)
|
---|
1930 | , m_statement(statement)
|
---|
1931 | , m_expr1WasVarDecl(expr1 && expr1WasVarDecl)
|
---|
1932 | {
|
---|
1933 | ASSERT(statement);
|
---|
1934 | }
|
---|
1935 |
|
---|
1936 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1937 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1938 |
|
---|
1939 | private:
|
---|
1940 | RefPtr<ExpressionNode> m_expr1;
|
---|
1941 | RefPtr<ExpressionNode> m_expr2;
|
---|
1942 | RefPtr<ExpressionNode> m_expr3;
|
---|
1943 | RefPtr<StatementNode> m_statement;
|
---|
1944 | bool m_expr1WasVarDecl;
|
---|
1945 | };
|
---|
1946 |
|
---|
1947 | class ForInNode : public StatementNode {
|
---|
1948 | public:
|
---|
1949 | ForInNode(JSGlobalData*, ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL;
|
---|
1950 | ForInNode(JSGlobalData*, const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL;
|
---|
1951 |
|
---|
1952 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1953 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1954 |
|
---|
1955 | private:
|
---|
1956 | Identifier m_ident;
|
---|
1957 | RefPtr<ExpressionNode> m_init;
|
---|
1958 | RefPtr<ExpressionNode> m_lexpr;
|
---|
1959 | RefPtr<ExpressionNode> m_expr;
|
---|
1960 | RefPtr<StatementNode> m_statement;
|
---|
1961 | bool m_identIsVarDecl;
|
---|
1962 | };
|
---|
1963 |
|
---|
1964 | class ContinueNode : public StatementNode {
|
---|
1965 | public:
|
---|
1966 | ContinueNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
1967 | : StatementNode(globalData)
|
---|
1968 | {
|
---|
1969 | }
|
---|
1970 |
|
---|
1971 | ContinueNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
1972 | : StatementNode(globalData)
|
---|
1973 | , m_ident(ident)
|
---|
1974 | {
|
---|
1975 | }
|
---|
1976 |
|
---|
1977 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1978 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1979 |
|
---|
1980 | private:
|
---|
1981 | Identifier m_ident;
|
---|
1982 | };
|
---|
1983 |
|
---|
1984 | class BreakNode : public StatementNode {
|
---|
1985 | public:
|
---|
1986 | BreakNode(JSGlobalData* globalData) KJS_FAST_CALL
|
---|
1987 | : StatementNode(globalData)
|
---|
1988 | {
|
---|
1989 | }
|
---|
1990 |
|
---|
1991 | BreakNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
1992 | : StatementNode(globalData)
|
---|
1993 | , m_ident(ident)
|
---|
1994 | {
|
---|
1995 | }
|
---|
1996 |
|
---|
1997 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
1998 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
1999 |
|
---|
2000 | private:
|
---|
2001 | Identifier m_ident;
|
---|
2002 | };
|
---|
2003 |
|
---|
2004 | class ReturnNode : public StatementNode {
|
---|
2005 | public:
|
---|
2006 | ReturnNode(JSGlobalData* globalData, ExpressionNode* value) KJS_FAST_CALL
|
---|
2007 | : StatementNode(globalData)
|
---|
2008 | , m_value(value)
|
---|
2009 | {
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2013 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2014 | virtual bool isReturnNode() const KJS_FAST_CALL { return true; }
|
---|
2015 |
|
---|
2016 | private:
|
---|
2017 | RefPtr<ExpressionNode> m_value;
|
---|
2018 | };
|
---|
2019 |
|
---|
2020 | class WithNode : public StatementNode {
|
---|
2021 | public:
|
---|
2022 | WithNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL
|
---|
2023 | : StatementNode(globalData)
|
---|
2024 | , m_expr(expr)
|
---|
2025 | , m_statement(statement)
|
---|
2026 | {
|
---|
2027 | }
|
---|
2028 |
|
---|
2029 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2030 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2031 |
|
---|
2032 | private:
|
---|
2033 | RefPtr<ExpressionNode> m_expr;
|
---|
2034 | RefPtr<StatementNode> m_statement;
|
---|
2035 | };
|
---|
2036 |
|
---|
2037 | class LabelNode : public StatementNode {
|
---|
2038 | public:
|
---|
2039 | LabelNode(JSGlobalData* globalData, const Identifier& label, StatementNode* statement) KJS_FAST_CALL
|
---|
2040 | : StatementNode(globalData)
|
---|
2041 | , m_label(label)
|
---|
2042 | , m_statement(statement)
|
---|
2043 | {
|
---|
2044 | }
|
---|
2045 |
|
---|
2046 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2047 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2048 | virtual void pushLabel(const Identifier& ident) KJS_FAST_CALL { m_statement->pushLabel(ident); }
|
---|
2049 |
|
---|
2050 | private:
|
---|
2051 | Identifier m_label;
|
---|
2052 | RefPtr<StatementNode> m_statement;
|
---|
2053 | };
|
---|
2054 |
|
---|
2055 | class ThrowNode : public StatementNode {
|
---|
2056 | public:
|
---|
2057 | ThrowNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
2058 | : StatementNode(globalData)
|
---|
2059 | , m_expr(expr)
|
---|
2060 | {
|
---|
2061 | }
|
---|
2062 |
|
---|
2063 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2064 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2065 |
|
---|
2066 | private:
|
---|
2067 | RefPtr<ExpressionNode> m_expr;
|
---|
2068 | };
|
---|
2069 |
|
---|
2070 | class TryNode : public StatementNode {
|
---|
2071 | public:
|
---|
2072 | TryNode(JSGlobalData* globalData, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) KJS_FAST_CALL
|
---|
2073 | : StatementNode(globalData)
|
---|
2074 | , m_tryBlock(tryBlock)
|
---|
2075 | , m_exceptionIdent(exceptionIdent)
|
---|
2076 | , m_catchBlock(catchBlock)
|
---|
2077 | , m_finallyBlock(finallyBlock)
|
---|
2078 | {
|
---|
2079 | }
|
---|
2080 |
|
---|
2081 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2082 |
|
---|
2083 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* dst = 0) KJS_FAST_CALL;
|
---|
2084 |
|
---|
2085 | private:
|
---|
2086 | RefPtr<StatementNode> m_tryBlock;
|
---|
2087 | Identifier m_exceptionIdent;
|
---|
2088 | RefPtr<StatementNode> m_catchBlock;
|
---|
2089 | RefPtr<StatementNode> m_finallyBlock;
|
---|
2090 | };
|
---|
2091 |
|
---|
2092 | class ParameterNode : public Node {
|
---|
2093 | public:
|
---|
2094 | ParameterNode(JSGlobalData* globalData, const Identifier& ident) KJS_FAST_CALL
|
---|
2095 | : Node(globalData)
|
---|
2096 | , m_ident(ident)
|
---|
2097 | {
|
---|
2098 | }
|
---|
2099 |
|
---|
2100 | ParameterNode(JSGlobalData* globalData, ParameterNode* l, const Identifier& ident) KJS_FAST_CALL
|
---|
2101 | : Node(globalData)
|
---|
2102 | , m_ident(ident)
|
---|
2103 | {
|
---|
2104 | l->m_next = this;
|
---|
2105 | }
|
---|
2106 |
|
---|
2107 | Identifier ident() KJS_FAST_CALL { return m_ident; }
|
---|
2108 | ParameterNode *nextParam() KJS_FAST_CALL { return m_next.get(); }
|
---|
2109 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2110 | PassRefPtr<ParameterNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }
|
---|
2111 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
2112 |
|
---|
2113 | private:
|
---|
2114 | friend class FuncDeclNode;
|
---|
2115 | friend class FuncExprNode;
|
---|
2116 | Identifier m_ident;
|
---|
2117 | ListRefPtr<ParameterNode> m_next;
|
---|
2118 | };
|
---|
2119 |
|
---|
2120 | class ScopeNode : public BlockNode {
|
---|
2121 | public:
|
---|
2122 | ScopeNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2123 |
|
---|
2124 | int sourceId() const KJS_FAST_CALL { return m_sourceId; }
|
---|
2125 | const UString& sourceURL() const KJS_FAST_CALL { return m_sourceURL; }
|
---|
2126 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2127 |
|
---|
2128 | bool usesEval() const { return m_usesEval; }
|
---|
2129 | bool needsClosure() const { return m_needsClosure; }
|
---|
2130 |
|
---|
2131 | VarStack& varStack() { return m_varStack; }
|
---|
2132 | FunctionStack& functionStack() { return m_functionStack; }
|
---|
2133 |
|
---|
2134 | protected:
|
---|
2135 | VarStack m_varStack;
|
---|
2136 | FunctionStack m_functionStack;
|
---|
2137 |
|
---|
2138 | private:
|
---|
2139 | UString m_sourceURL;
|
---|
2140 | int m_sourceId;
|
---|
2141 | bool m_usesEval;
|
---|
2142 | bool m_needsClosure;
|
---|
2143 | };
|
---|
2144 |
|
---|
2145 | class ProgramNode : public ScopeNode {
|
---|
2146 | public:
|
---|
2147 | static ProgramNode* create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2148 |
|
---|
2149 | ProgramCodeBlock& code(ScopeChainNode* scopeChain) KJS_FAST_CALL
|
---|
2150 | {
|
---|
2151 | if (!m_code)
|
---|
2152 | generateCode(scopeChain);
|
---|
2153 | return *m_code;
|
---|
2154 | }
|
---|
2155 |
|
---|
2156 | private:
|
---|
2157 | ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2158 |
|
---|
2159 | void generateCode(ScopeChainNode*) KJS_FAST_CALL;
|
---|
2160 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2161 |
|
---|
2162 | Vector<size_t> m_varIndexes; // Storage indexes belonging to the nodes in m_varStack. (Recorded to avoid double lookup.)
|
---|
2163 | Vector<size_t> m_functionIndexes; // Storage indexes belonging to the nodes in m_functionStack. (Recorded to avoid double lookup.)
|
---|
2164 |
|
---|
2165 | OwnPtr<ProgramCodeBlock> m_code;
|
---|
2166 | };
|
---|
2167 |
|
---|
2168 | class EvalNode : public ScopeNode {
|
---|
2169 | public:
|
---|
2170 | static EvalNode* create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2171 |
|
---|
2172 | EvalCodeBlock& code(ScopeChainNode* scopeChain) KJS_FAST_CALL
|
---|
2173 | {
|
---|
2174 | if (!m_code)
|
---|
2175 | generateCode(scopeChain);
|
---|
2176 | return *m_code;
|
---|
2177 | }
|
---|
2178 |
|
---|
2179 | private:
|
---|
2180 | EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2181 |
|
---|
2182 | void generateCode(ScopeChainNode*) KJS_FAST_CALL;
|
---|
2183 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2184 |
|
---|
2185 | OwnPtr<EvalCodeBlock> m_code;
|
---|
2186 | };
|
---|
2187 |
|
---|
2188 | class FunctionBodyNode : public ScopeNode {
|
---|
2189 | public:
|
---|
2190 | static FunctionBodyNode* create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2191 |
|
---|
2192 | Vector<Identifier>& parameters() KJS_FAST_CALL { return m_parameters; }
|
---|
2193 | UString paramString() const KJS_FAST_CALL;
|
---|
2194 |
|
---|
2195 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2196 |
|
---|
2197 | SymbolTable& symbolTable() { return m_symbolTable; } // FIXME: Remove this
|
---|
2198 |
|
---|
2199 | CodeBlock& code(ScopeChainNode* scopeChain) KJS_FAST_CALL
|
---|
2200 | {
|
---|
2201 | ASSERT(scopeChain);
|
---|
2202 | if (!m_code)
|
---|
2203 | generateCode(scopeChain);
|
---|
2204 | return *m_code;
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 | CodeBlock& generatedCode() KJS_FAST_CALL
|
---|
2208 | {
|
---|
2209 | ASSERT(m_code);
|
---|
2210 | return *m_code;
|
---|
2211 | }
|
---|
2212 |
|
---|
2213 | void mark();
|
---|
2214 |
|
---|
2215 | void setSource(const SourceRange& source) { m_source = source; }
|
---|
2216 | UString toSourceString() const KJS_FAST_CALL { return UString("{") + m_source.toString() + UString("}"); }
|
---|
2217 |
|
---|
2218 | protected:
|
---|
2219 | FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, bool usesEval, bool needsClosure) KJS_FAST_CALL;
|
---|
2220 |
|
---|
2221 | private:
|
---|
2222 | void generateCode(ScopeChainNode*) KJS_FAST_CALL;
|
---|
2223 |
|
---|
2224 | Vector<Identifier> m_parameters;
|
---|
2225 | SymbolTable m_symbolTable;
|
---|
2226 | OwnPtr<CodeBlock> m_code;
|
---|
2227 | SourceRange m_source;
|
---|
2228 | };
|
---|
2229 |
|
---|
2230 | class FuncExprNode : public ExpressionNode {
|
---|
2231 | public:
|
---|
2232 | FuncExprNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceRange& source, ParameterNode* parameter = 0) KJS_FAST_CALL
|
---|
2233 | : ExpressionNode(globalData)
|
---|
2234 | , m_ident(ident)
|
---|
2235 | , m_parameter(parameter)
|
---|
2236 | , m_body(body)
|
---|
2237 | {
|
---|
2238 | addParams();
|
---|
2239 | m_body->setSource(source);
|
---|
2240 | }
|
---|
2241 |
|
---|
2242 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2243 | JSFunction* makeFunction(ExecState*, ScopeChainNode*) KJS_FAST_CALL;
|
---|
2244 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2245 | virtual Precedence precedence() const { return PrecMember; }
|
---|
2246 | virtual bool needsParensIfLeftmost() const { return true; }
|
---|
2247 |
|
---|
2248 | FunctionBodyNode* body() { return m_body.get(); }
|
---|
2249 |
|
---|
2250 | private:
|
---|
2251 | void addParams() KJS_FAST_CALL;
|
---|
2252 |
|
---|
2253 | // Used for streamTo
|
---|
2254 | friend class PropertyNode;
|
---|
2255 | Identifier m_ident;
|
---|
2256 | RefPtr<ParameterNode> m_parameter;
|
---|
2257 | RefPtr<FunctionBodyNode> m_body;
|
---|
2258 | };
|
---|
2259 |
|
---|
2260 | class FuncDeclNode : public StatementNode {
|
---|
2261 | public:
|
---|
2262 | FuncDeclNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceRange& source, ParameterNode* parameter = 0) KJS_FAST_CALL
|
---|
2263 | : StatementNode(globalData)
|
---|
2264 | , m_ident(ident)
|
---|
2265 | , m_parameter(parameter)
|
---|
2266 | , m_body(body)
|
---|
2267 | {
|
---|
2268 | addParams();
|
---|
2269 | m_body->setSource(source);
|
---|
2270 | }
|
---|
2271 |
|
---|
2272 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2273 |
|
---|
2274 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2275 | JSFunction* makeFunction(ExecState*, ScopeChainNode*) KJS_FAST_CALL;
|
---|
2276 |
|
---|
2277 | Identifier m_ident;
|
---|
2278 |
|
---|
2279 | FunctionBodyNode* body() { return m_body.get(); }
|
---|
2280 |
|
---|
2281 | private:
|
---|
2282 | void addParams() KJS_FAST_CALL;
|
---|
2283 |
|
---|
2284 | RefPtr<ParameterNode> m_parameter;
|
---|
2285 | RefPtr<FunctionBodyNode> m_body;
|
---|
2286 | };
|
---|
2287 |
|
---|
2288 | class CaseClauseNode : public Node {
|
---|
2289 | public:
|
---|
2290 | CaseClauseNode(JSGlobalData* globalData, ExpressionNode* expr) KJS_FAST_CALL
|
---|
2291 | : Node(globalData)
|
---|
2292 | , m_expr(expr)
|
---|
2293 | {
|
---|
2294 | }
|
---|
2295 |
|
---|
2296 | CaseClauseNode(JSGlobalData* globalData, ExpressionNode* expr, SourceElements* children) KJS_FAST_CALL
|
---|
2297 | : Node(globalData)
|
---|
2298 | , m_expr(expr)
|
---|
2299 | {
|
---|
2300 | if (children)
|
---|
2301 | children->releaseContentsIntoVector(m_children);
|
---|
2302 | }
|
---|
2303 |
|
---|
2304 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2305 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
2306 |
|
---|
2307 | ExpressionNode* expr() const { return m_expr.get(); }
|
---|
2308 | StatementVector& children() { return m_children; }
|
---|
2309 |
|
---|
2310 | private:
|
---|
2311 | RefPtr<ExpressionNode> m_expr;
|
---|
2312 | StatementVector m_children;
|
---|
2313 | };
|
---|
2314 |
|
---|
2315 | class ClauseListNode : public Node {
|
---|
2316 | public:
|
---|
2317 | ClauseListNode(JSGlobalData* globalData, CaseClauseNode* clause) KJS_FAST_CALL
|
---|
2318 | : Node(globalData)
|
---|
2319 | , m_clause(clause)
|
---|
2320 | {
|
---|
2321 | }
|
---|
2322 |
|
---|
2323 | ClauseListNode(JSGlobalData* globalData, ClauseListNode* clauseList, CaseClauseNode* clause) KJS_FAST_CALL
|
---|
2324 | : Node(globalData)
|
---|
2325 | , m_clause(clause)
|
---|
2326 | {
|
---|
2327 | clauseList->m_next = this;
|
---|
2328 | }
|
---|
2329 |
|
---|
2330 | CaseClauseNode* getClause() const KJS_FAST_CALL { return m_clause.get(); }
|
---|
2331 | ClauseListNode* getNext() const KJS_FAST_CALL { return m_next.get(); }
|
---|
2332 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2333 | PassRefPtr<ClauseListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }
|
---|
2334 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
2335 |
|
---|
2336 | private:
|
---|
2337 | friend class CaseBlockNode;
|
---|
2338 | RefPtr<CaseClauseNode> m_clause;
|
---|
2339 | ListRefPtr<ClauseListNode> m_next;
|
---|
2340 | };
|
---|
2341 |
|
---|
2342 | class CaseBlockNode : public Node {
|
---|
2343 | public:
|
---|
2344 | CaseBlockNode(JSGlobalData* globalData, ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) KJS_FAST_CALL
|
---|
2345 | : Node(globalData)
|
---|
2346 | , m_list1(list1)
|
---|
2347 | , m_defaultClause(defaultClause)
|
---|
2348 | , m_list2(list2)
|
---|
2349 | {
|
---|
2350 | }
|
---|
2351 |
|
---|
2352 | RegisterID* emitCodeForBlock(CodeGenerator&, RegisterID* input, RegisterID* dst = 0) KJS_FAST_CALL;
|
---|
2353 |
|
---|
2354 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2355 | virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
|
---|
2356 |
|
---|
2357 | private:
|
---|
2358 | RefPtr<ClauseListNode> m_list1;
|
---|
2359 | RefPtr<CaseClauseNode> m_defaultClause;
|
---|
2360 | RefPtr<ClauseListNode> m_list2;
|
---|
2361 | };
|
---|
2362 |
|
---|
2363 | class SwitchNode : public StatementNode {
|
---|
2364 | public:
|
---|
2365 | SwitchNode(JSGlobalData* globalData, ExpressionNode* expr, CaseBlockNode* block) KJS_FAST_CALL
|
---|
2366 | : StatementNode(globalData)
|
---|
2367 | , m_expr(expr)
|
---|
2368 | , m_block(block)
|
---|
2369 | {
|
---|
2370 | }
|
---|
2371 |
|
---|
2372 | virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
|
---|
2373 |
|
---|
2374 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2375 |
|
---|
2376 | private:
|
---|
2377 | RefPtr<ExpressionNode> m_expr;
|
---|
2378 | RefPtr<CaseBlockNode> m_block;
|
---|
2379 | };
|
---|
2380 |
|
---|
2381 | class BreakpointCheckStatement : public StatementNode {
|
---|
2382 | public:
|
---|
2383 | BreakpointCheckStatement(JSGlobalData*, PassRefPtr<StatementNode>) KJS_FAST_CALL;
|
---|
2384 |
|
---|
2385 | virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
|
---|
2386 |
|
---|
2387 | private:
|
---|
2388 | RefPtr<StatementNode> m_statement;
|
---|
2389 | };
|
---|
2390 |
|
---|
2391 | struct ElementList {
|
---|
2392 | ElementNode* head;
|
---|
2393 | ElementNode* tail;
|
---|
2394 | };
|
---|
2395 |
|
---|
2396 | struct PropertyList {
|
---|
2397 | PropertyListNode* head;
|
---|
2398 | PropertyListNode* tail;
|
---|
2399 | };
|
---|
2400 |
|
---|
2401 | struct ArgumentList {
|
---|
2402 | ArgumentListNode* head;
|
---|
2403 | ArgumentListNode* tail;
|
---|
2404 | };
|
---|
2405 |
|
---|
2406 | struct ConstDeclList {
|
---|
2407 | ConstDeclNode* head;
|
---|
2408 | ConstDeclNode* tail;
|
---|
2409 | };
|
---|
2410 |
|
---|
2411 | struct ParameterList {
|
---|
2412 | ParameterNode* head;
|
---|
2413 | ParameterNode* tail;
|
---|
2414 | };
|
---|
2415 |
|
---|
2416 | struct ClauseList {
|
---|
2417 | ClauseListNode* head;
|
---|
2418 | ClauseListNode* tail;
|
---|
2419 | };
|
---|
2420 |
|
---|
2421 | } // namespace KJS
|
---|
2422 |
|
---|
2423 | #endif // NODES_H_
|
---|