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