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