]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. | |
3 | * | |
4 | * This library is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU Library General Public | |
6 | * License as published by the Free Software Foundation; either | |
7 | * version 2 of the License, or (at your option) any later version. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | * Library General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Library General Public License | |
15 | * along with this library; see the file COPYING.LIB. If not, write to | |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
17 | * Boston, MA 02110-1301, USA. | |
18 | * | |
19 | */ | |
20 | ||
21 | #ifndef NodeConstructors_h | |
22 | #define NodeConstructors_h | |
23 | ||
24 | #include "Nodes.h" | |
25 | #include "Lexer.h" | |
26 | #include "Parser.h" | |
27 | ||
28 | namespace JSC { | |
29 | ||
30 | inline void* ParserArenaFreeable::operator new(size_t size, VM* vm) | |
31 | { | |
32 | return vm->parserArena->allocateFreeable(size); | |
33 | } | |
34 | ||
35 | inline void* ParserArenaDeletable::operator new(size_t size, VM* vm) | |
36 | { | |
37 | return vm->parserArena->allocateDeletable(size); | |
38 | } | |
39 | ||
40 | inline ParserArenaRefCounted::ParserArenaRefCounted(VM* vm) | |
41 | { | |
42 | vm->parserArena->derefWithArena(adoptRef(this)); | |
43 | } | |
44 | ||
45 | inline Node::Node(const JSTokenLocation& location) | |
46 | : m_lineNumber(location.line) | |
47 | , m_startOffset(location.startOffset) | |
48 | , m_lineStartOffset(location.lineStartOffset) | |
49 | { | |
50 | ASSERT(location.startOffset >= location.lineStartOffset); | |
51 | } | |
52 | ||
53 | inline ExpressionNode::ExpressionNode(const JSTokenLocation& location, ResultType resultType) | |
54 | : Node(location) | |
55 | , m_resultType(resultType) | |
56 | { | |
57 | } | |
58 | ||
59 | inline StatementNode::StatementNode(const JSTokenLocation& location) | |
60 | : Node(location) | |
61 | , m_lastLine(-1) | |
62 | { | |
63 | } | |
64 | ||
65 | inline ConstantNode::ConstantNode(const JSTokenLocation& location, ResultType resultType) | |
66 | : ExpressionNode(location, resultType) | |
67 | { | |
68 | } | |
69 | ||
70 | inline NullNode::NullNode(const JSTokenLocation& location) | |
71 | : ConstantNode(location, ResultType::nullType()) | |
72 | { | |
73 | } | |
74 | ||
75 | inline BooleanNode::BooleanNode(const JSTokenLocation& location, bool value) | |
76 | : ConstantNode(location, ResultType::booleanType()) | |
77 | , m_value(value) | |
78 | { | |
79 | } | |
80 | ||
81 | inline NumberNode::NumberNode(const JSTokenLocation& location, double value) | |
82 | : ConstantNode(location, JSValue(value).isInt32() ? ResultType::numberTypeIsInt32() : ResultType::numberType()) | |
83 | , m_value(value) | |
84 | { | |
85 | } | |
86 | ||
87 | inline StringNode::StringNode(const JSTokenLocation& location, const Identifier& value) | |
88 | : ConstantNode(location, ResultType::stringType()) | |
89 | , m_value(value) | |
90 | { | |
91 | } | |
92 | ||
93 | inline RegExpNode::RegExpNode(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags) | |
94 | : ExpressionNode(location) | |
95 | , m_pattern(pattern) | |
96 | , m_flags(flags) | |
97 | { | |
98 | } | |
99 | ||
100 | inline ThisNode::ThisNode(const JSTokenLocation& location) | |
101 | : ExpressionNode(location) | |
102 | { | |
103 | } | |
104 | ||
105 | inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, unsigned startOffset, unsigned divotLine, unsigned divotLineStart) | |
106 | : ExpressionNode(location) | |
107 | , m_ident(ident) | |
108 | , m_startOffset(startOffset) | |
109 | , m_divotLine(divotLine) | |
110 | , m_divotLineStart(divotLineStart) | |
111 | { | |
112 | ASSERT(m_startOffset >= m_divotLineStart); | |
113 | } | |
114 | ||
115 | inline ElementNode::ElementNode(int elision, ExpressionNode* node) | |
116 | : m_next(0) | |
117 | , m_elision(elision) | |
118 | , m_node(node) | |
119 | { | |
120 | } | |
121 | ||
122 | inline ElementNode::ElementNode(ElementNode* l, int elision, ExpressionNode* node) | |
123 | : m_next(0) | |
124 | , m_elision(elision) | |
125 | , m_node(node) | |
126 | { | |
127 | l->m_next = this; | |
128 | } | |
129 | ||
130 | inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision) | |
131 | : ExpressionNode(location) | |
132 | , m_element(0) | |
133 | , m_elision(elision) | |
134 | , m_optional(true) | |
135 | { | |
136 | } | |
137 | ||
138 | inline ArrayNode::ArrayNode(const JSTokenLocation& location, ElementNode* element) | |
139 | : ExpressionNode(location) | |
140 | , m_element(element) | |
141 | , m_elision(0) | |
142 | , m_optional(false) | |
143 | { | |
144 | } | |
145 | ||
146 | inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision, ElementNode* element) | |
147 | : ExpressionNode(location) | |
148 | , m_element(element) | |
149 | , m_elision(elision) | |
150 | , m_optional(true) | |
151 | { | |
152 | } | |
153 | ||
154 | inline PropertyNode::PropertyNode(VM*, const Identifier& name, ExpressionNode* assign, Type type) | |
155 | : m_name(name) | |
156 | , m_assign(assign) | |
157 | , m_type(type) | |
158 | { | |
159 | } | |
160 | ||
161 | inline PropertyNode::PropertyNode(VM* vm, double name, ExpressionNode* assign, Type type) | |
162 | : m_name(vm->parserArena->identifierArena().makeNumericIdentifier(vm, name)) | |
163 | , m_assign(assign) | |
164 | , m_type(type) | |
165 | { | |
166 | } | |
167 | ||
168 | inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node) | |
169 | : ExpressionNode(location) | |
170 | , m_node(node) | |
171 | , m_next(0) | |
172 | { | |
173 | } | |
174 | ||
175 | inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node, PropertyListNode* list) | |
176 | : ExpressionNode(location) | |
177 | , m_node(node) | |
178 | , m_next(0) | |
179 | { | |
180 | list->m_next = this; | |
181 | } | |
182 | ||
183 | inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location) | |
184 | : ExpressionNode(location) | |
185 | , m_list(0) | |
186 | { | |
187 | } | |
188 | ||
189 | inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location, PropertyListNode* list) | |
190 | : ExpressionNode(location) | |
191 | , m_list(list) | |
192 | { | |
193 | } | |
194 | ||
195 | inline BracketAccessorNode::BracketAccessorNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments) | |
196 | : ExpressionNode(location) | |
197 | , m_base(base) | |
198 | , m_subscript(subscript) | |
199 | , m_subscriptHasAssignments(subscriptHasAssignments) | |
200 | { | |
201 | } | |
202 | ||
203 | inline DotAccessorNode::DotAccessorNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident) | |
204 | : ExpressionNode(location) | |
205 | , m_base(base) | |
206 | , m_ident(ident) | |
207 | { | |
208 | } | |
209 | ||
210 | inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ExpressionNode* expr) | |
211 | : ExpressionNode(location) | |
212 | , m_next(0) | |
213 | , m_expr(expr) | |
214 | { | |
215 | } | |
216 | ||
217 | inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ArgumentListNode* listNode, ExpressionNode* expr) | |
218 | : ExpressionNode(location) | |
219 | , m_next(0) | |
220 | , m_expr(expr) | |
221 | { | |
222 | listNode->m_next = this; | |
223 | } | |
224 | ||
225 | inline ArgumentsNode::ArgumentsNode() | |
226 | : m_listNode(0) | |
227 | { | |
228 | } | |
229 | ||
230 | inline ArgumentsNode::ArgumentsNode(ArgumentListNode* listNode) | |
231 | : m_listNode(listNode) | |
232 | { | |
233 | } | |
234 | ||
235 | inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr) | |
236 | : ExpressionNode(location) | |
237 | , m_expr(expr) | |
238 | , m_args(0) | |
239 | { | |
240 | } | |
241 | ||
242 | inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args) | |
243 | : ExpressionNode(location) | |
244 | , m_expr(expr) | |
245 | , m_args(args) | |
246 | { | |
247 | } | |
248 | ||
249 | inline EvalFunctionCallNode::EvalFunctionCallNode(const JSTokenLocation& location, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
250 | : ExpressionNode(location) | |
251 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
252 | , m_args(args) | |
253 | { | |
254 | ASSERT(divot >= divotLineStart); | |
255 | } | |
256 | ||
257 | inline FunctionCallValueNode::FunctionCallValueNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
258 | : ExpressionNode(location) | |
259 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
260 | , m_expr(expr) | |
261 | , m_args(args) | |
262 | { | |
263 | } | |
264 | ||
265 | inline FunctionCallResolveNode::FunctionCallResolveNode(const JSTokenLocation& location, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
266 | : ExpressionNode(location) | |
267 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
268 | , m_ident(ident) | |
269 | , m_args(args) | |
270 | { | |
271 | } | |
272 | ||
273 | inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
274 | : ExpressionNode(location) | |
275 | , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
276 | , m_base(base) | |
277 | , m_subscript(subscript) | |
278 | , m_args(args) | |
279 | { | |
280 | } | |
281 | ||
282 | inline FunctionCallDotNode::FunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
283 | : ExpressionNode(location) | |
284 | , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
285 | , m_base(base) | |
286 | , m_ident(ident) | |
287 | , m_args(args) | |
288 | { | |
289 | } | |
290 | ||
291 | inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
292 | : FunctionCallDotNode(location, base, ident, args, divot, startOffset, endOffset, divotLine, divotLineStart) | |
293 | { | |
294 | } | |
295 | ||
296 | inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
297 | : FunctionCallDotNode(location, base, ident, args, divot, startOffset, endOffset, divotLine, divotLineStart) | |
298 | { | |
299 | } | |
300 | ||
301 | inline PostfixNode::PostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
302 | : PrefixNode(location, expr, oper, divot, startOffset, endOffset, divotLine, divotLineStart) | |
303 | { | |
304 | } | |
305 | ||
306 | inline DeleteResolveNode::DeleteResolveNode(const JSTokenLocation& location, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
307 | : ExpressionNode(location) | |
308 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
309 | , m_ident(ident) | |
310 | { | |
311 | } | |
312 | ||
313 | inline DeleteBracketNode::DeleteBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
314 | : ExpressionNode(location) | |
315 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
316 | , m_base(base) | |
317 | , m_subscript(subscript) | |
318 | { | |
319 | } | |
320 | ||
321 | inline DeleteDotNode::DeleteDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
322 | : ExpressionNode(location) | |
323 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
324 | , m_base(base) | |
325 | , m_ident(ident) | |
326 | { | |
327 | } | |
328 | ||
329 | inline DeleteValueNode::DeleteValueNode(const JSTokenLocation& location, ExpressionNode* expr) | |
330 | : ExpressionNode(location) | |
331 | , m_expr(expr) | |
332 | { | |
333 | } | |
334 | ||
335 | inline VoidNode::VoidNode(const JSTokenLocation& location, ExpressionNode* expr) | |
336 | : ExpressionNode(location) | |
337 | , m_expr(expr) | |
338 | { | |
339 | } | |
340 | ||
341 | inline TypeOfResolveNode::TypeOfResolveNode(const JSTokenLocation& location, const Identifier& ident) | |
342 | : ExpressionNode(location, ResultType::stringType()) | |
343 | , m_ident(ident) | |
344 | { | |
345 | } | |
346 | ||
347 | inline TypeOfValueNode::TypeOfValueNode(const JSTokenLocation& location, ExpressionNode* expr) | |
348 | : ExpressionNode(location, ResultType::stringType()) | |
349 | , m_expr(expr) | |
350 | { | |
351 | } | |
352 | ||
353 | inline PrefixNode::PrefixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
354 | : ExpressionNode(location) | |
355 | , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
356 | , m_expr(expr) | |
357 | , m_operator(oper) | |
358 | { | |
359 | } | |
360 | ||
361 | inline UnaryOpNode::UnaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr, OpcodeID opcodeID) | |
362 | : ExpressionNode(location, type) | |
363 | , m_expr(expr) | |
364 | , m_opcodeID(opcodeID) | |
365 | { | |
366 | } | |
367 | ||
368 | inline UnaryPlusNode::UnaryPlusNode(const JSTokenLocation& location, ExpressionNode* expr) | |
369 | : UnaryOpNode(location, ResultType::numberType(), expr, op_to_number) | |
370 | { | |
371 | } | |
372 | ||
373 | inline NegateNode::NegateNode(const JSTokenLocation& location, ExpressionNode* expr) | |
374 | : UnaryOpNode(location, ResultType::numberType(), expr, op_negate) | |
375 | { | |
376 | } | |
377 | ||
378 | inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr) | |
379 | : ExpressionNode(location, ResultType::forBitOp()) | |
380 | , m_expr(expr) | |
381 | { | |
382 | } | |
383 | ||
384 | inline LogicalNotNode::LogicalNotNode(const JSTokenLocation& location, ExpressionNode* expr) | |
385 | : UnaryOpNode(location, ResultType::booleanType(), expr, op_not) | |
386 | { | |
387 | } | |
388 | ||
389 | inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments) | |
390 | : ExpressionNode(location) | |
391 | , m_expr1(expr1) | |
392 | , m_expr2(expr2) | |
393 | , m_opcodeID(opcodeID) | |
394 | , m_rightHasAssignments(rightHasAssignments) | |
395 | { | |
396 | } | |
397 | ||
398 | inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments) | |
399 | : ExpressionNode(location, type) | |
400 | , m_expr1(expr1) | |
401 | , m_expr2(expr2) | |
402 | , m_opcodeID(opcodeID) | |
403 | , m_rightHasAssignments(rightHasAssignments) | |
404 | { | |
405 | } | |
406 | ||
407 | inline MultNode::MultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
408 | : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mul, rightHasAssignments) | |
409 | { | |
410 | } | |
411 | ||
412 | inline DivNode::DivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
413 | : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_div, rightHasAssignments) | |
414 | { | |
415 | } | |
416 | ||
417 | ||
418 | inline ModNode::ModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
419 | : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mod, rightHasAssignments) | |
420 | { | |
421 | } | |
422 | ||
423 | inline AddNode::AddNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
424 | : BinaryOpNode(location, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments) | |
425 | { | |
426 | } | |
427 | ||
428 | inline SubNode::SubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
429 | : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_sub, rightHasAssignments) | |
430 | { | |
431 | } | |
432 | ||
433 | inline LeftShiftNode::LeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
434 | : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments) | |
435 | { | |
436 | } | |
437 | ||
438 | inline RightShiftNode::RightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
439 | : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments) | |
440 | { | |
441 | } | |
442 | ||
443 | inline UnsignedRightShiftNode::UnsignedRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
444 | : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_urshift, rightHasAssignments) | |
445 | { | |
446 | } | |
447 | ||
448 | inline LessNode::LessNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
449 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments) | |
450 | { | |
451 | } | |
452 | ||
453 | inline GreaterNode::GreaterNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
454 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greater, rightHasAssignments) | |
455 | { | |
456 | } | |
457 | ||
458 | inline LessEqNode::LessEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
459 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments) | |
460 | { | |
461 | } | |
462 | ||
463 | inline GreaterEqNode::GreaterEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
464 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greatereq, rightHasAssignments) | |
465 | { | |
466 | } | |
467 | ||
468 | inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments) | |
469 | : BinaryOpNode(location, type, expr1, expr2, opcodeID, rightHasAssignments) | |
470 | { | |
471 | } | |
472 | ||
473 | inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments) | |
474 | : BinaryOpNode(location, expr1, expr2, opcodeID, rightHasAssignments) | |
475 | { | |
476 | } | |
477 | ||
478 | inline InstanceOfNode::InstanceOfNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
479 | : ThrowableBinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments) | |
480 | { | |
481 | } | |
482 | ||
483 | inline InNode::InNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
484 | : ThrowableBinaryOpNode(location, expr1, expr2, op_in, rightHasAssignments) | |
485 | { | |
486 | } | |
487 | ||
488 | inline EqualNode::EqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
489 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments) | |
490 | { | |
491 | } | |
492 | ||
493 | inline NotEqualNode::NotEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
494 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments) | |
495 | { | |
496 | } | |
497 | ||
498 | inline StrictEqualNode::StrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
499 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments) | |
500 | { | |
501 | } | |
502 | ||
503 | inline NotStrictEqualNode::NotStrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
504 | : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments) | |
505 | { | |
506 | } | |
507 | ||
508 | inline BitAndNode::BitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
509 | : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments) | |
510 | { | |
511 | } | |
512 | ||
513 | inline BitOrNode::BitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
514 | : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments) | |
515 | { | |
516 | } | |
517 | ||
518 | inline BitXOrNode::BitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments) | |
519 | : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments) | |
520 | { | |
521 | } | |
522 | ||
523 | inline LogicalOpNode::LogicalOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper) | |
524 | : ExpressionNode(location, ResultType::forLogicalOp(expr1->resultDescriptor(), expr2->resultDescriptor())) | |
525 | , m_expr1(expr1) | |
526 | , m_expr2(expr2) | |
527 | , m_operator(oper) | |
528 | { | |
529 | } | |
530 | ||
531 | inline ConditionalNode::ConditionalNode(const JSTokenLocation& location, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) | |
532 | : ExpressionNode(location) | |
533 | , m_logical(logical) | |
534 | , m_expr1(expr1) | |
535 | , m_expr2(expr2) | |
536 | { | |
537 | } | |
538 | ||
539 | inline ReadModifyResolveNode::ReadModifyResolveNode(const JSTokenLocation& location, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
540 | : ExpressionNode(location) | |
541 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
542 | , m_ident(ident) | |
543 | , m_right(right) | |
544 | , m_operator(oper) | |
545 | , m_rightHasAssignments(rightHasAssignments) | |
546 | { | |
547 | ASSERT(divot >= divotLineStart); | |
548 | ASSERT(divot - startOffset >= divotLineStart); | |
549 | } | |
550 | ||
551 | inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right) | |
552 | : ExpressionNode(location) | |
553 | , m_ident(ident) | |
554 | , m_right(right) | |
555 | { | |
556 | } | |
557 | ||
558 | inline ReadModifyBracketNode::ReadModifyBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
559 | : ExpressionNode(location) | |
560 | , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
561 | , m_base(base) | |
562 | , m_subscript(subscript) | |
563 | , m_right(right) | |
564 | , m_operator(oper) | |
565 | , m_subscriptHasAssignments(subscriptHasAssignments) | |
566 | , m_rightHasAssignments(rightHasAssignments) | |
567 | { | |
568 | } | |
569 | ||
570 | inline AssignBracketNode::AssignBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
571 | : ExpressionNode(location) | |
572 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
573 | , m_base(base) | |
574 | , m_subscript(subscript) | |
575 | , m_right(right) | |
576 | , m_subscriptHasAssignments(subscriptHasAssignments) | |
577 | , m_rightHasAssignments(rightHasAssignments) | |
578 | { | |
579 | } | |
580 | ||
581 | inline AssignDotNode::AssignDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
582 | : ExpressionNode(location) | |
583 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
584 | , m_base(base) | |
585 | , m_ident(ident) | |
586 | , m_right(right) | |
587 | , m_rightHasAssignments(rightHasAssignments) | |
588 | { | |
589 | } | |
590 | ||
591 | inline ReadModifyDotNode::ReadModifyDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
592 | : ExpressionNode(location) | |
593 | , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
594 | , m_base(base) | |
595 | , m_ident(ident) | |
596 | , m_right(right) | |
597 | , m_operator(oper) | |
598 | , m_rightHasAssignments(rightHasAssignments) | |
599 | { | |
600 | } | |
601 | ||
602 | inline AssignErrorNode::AssignErrorNode(const JSTokenLocation& location, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart) | |
603 | : ExpressionNode(location) | |
604 | , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart) | |
605 | { | |
606 | } | |
607 | ||
608 | inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2) | |
609 | : ExpressionNode(location) | |
610 | { | |
611 | m_expressions.append(expr1); | |
612 | m_expressions.append(expr2); | |
613 | } | |
614 | ||
615 | inline ConstStatementNode::ConstStatementNode(const JSTokenLocation& location, ConstDeclNode* next) | |
616 | : StatementNode(location) | |
617 | , m_next(next) | |
618 | { | |
619 | } | |
620 | ||
621 | inline SourceElements::SourceElements() | |
622 | { | |
623 | } | |
624 | ||
625 | inline EmptyStatementNode::EmptyStatementNode(const JSTokenLocation& location) | |
626 | : StatementNode(location) | |
627 | { | |
628 | } | |
629 | ||
630 | inline DebuggerStatementNode::DebuggerStatementNode(const JSTokenLocation& location) | |
631 | : StatementNode(location) | |
632 | { | |
633 | } | |
634 | ||
635 | inline ExprStatementNode::ExprStatementNode(const JSTokenLocation& location, ExpressionNode* expr) | |
636 | : StatementNode(location) | |
637 | , m_expr(expr) | |
638 | { | |
639 | } | |
640 | ||
641 | inline VarStatementNode::VarStatementNode(const JSTokenLocation& location, ExpressionNode* expr) | |
642 | : StatementNode(location) | |
643 | , m_expr(expr) | |
644 | { | |
645 | } | |
646 | ||
647 | inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock) | |
648 | : StatementNode(location) | |
649 | , m_condition(condition) | |
650 | , m_ifBlock(ifBlock) | |
651 | , m_elseBlock(elseBlock) | |
652 | { | |
653 | } | |
654 | ||
655 | inline DoWhileNode::DoWhileNode(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr) | |
656 | : StatementNode(location) | |
657 | , m_statement(statement) | |
658 | , m_expr(expr) | |
659 | { | |
660 | } | |
661 | ||
662 | inline WhileNode::WhileNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement) | |
663 | : StatementNode(location) | |
664 | , m_expr(expr) | |
665 | , m_statement(statement) | |
666 | { | |
667 | } | |
668 | ||
669 | inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement) | |
670 | : StatementNode(location) | |
671 | , m_expr1(expr1) | |
672 | , m_expr2(expr2) | |
673 | , m_expr3(expr3) | |
674 | , m_statement(statement) | |
675 | { | |
676 | ASSERT(statement); | |
677 | } | |
678 | ||
679 | inline ContinueNode::ContinueNode(VM* vm, const JSTokenLocation& location) | |
680 | : StatementNode(location) | |
681 | , m_ident(vm->propertyNames->nullIdentifier) | |
682 | { | |
683 | } | |
684 | ||
685 | inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident) | |
686 | : StatementNode(location) | |
687 | , m_ident(ident) | |
688 | { | |
689 | } | |
690 | ||
691 | inline BreakNode::BreakNode(VM* vm, const JSTokenLocation& location) | |
692 | : StatementNode(location) | |
693 | , m_ident(vm->propertyNames->nullIdentifier) | |
694 | { | |
695 | } | |
696 | ||
697 | inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident) | |
698 | : StatementNode(location) | |
699 | , m_ident(ident) | |
700 | { | |
701 | } | |
702 | ||
703 | inline ReturnNode::ReturnNode(const JSTokenLocation& location, ExpressionNode* value) | |
704 | : StatementNode(location) | |
705 | , m_value(value) | |
706 | { | |
707 | } | |
708 | ||
709 | inline WithNode::WithNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, uint32_t divot, unsigned divotLine, unsigned divotLineStart, uint32_t expressionLength) | |
710 | : StatementNode(location) | |
711 | , m_expr(expr) | |
712 | , m_statement(statement) | |
713 | , m_divot(divot) | |
714 | , m_divotLine(divotLine) | |
715 | , m_divotLineStart(divotLineStart) | |
716 | , m_expressionLength(expressionLength) | |
717 | { | |
718 | } | |
719 | ||
720 | inline LabelNode::LabelNode(const JSTokenLocation& location, const Identifier& name, StatementNode* statement) | |
721 | : StatementNode(location) | |
722 | , m_name(name) | |
723 | , m_statement(statement) | |
724 | { | |
725 | } | |
726 | ||
727 | inline ThrowNode::ThrowNode(const JSTokenLocation& location, ExpressionNode* expr) | |
728 | : StatementNode(location) | |
729 | , m_expr(expr) | |
730 | { | |
731 | } | |
732 | ||
733 | inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) | |
734 | : StatementNode(location) | |
735 | , m_tryBlock(tryBlock) | |
736 | , m_exceptionIdent(exceptionIdent) | |
737 | , m_catchBlock(catchBlock) | |
738 | , m_finallyBlock(finallyBlock) | |
739 | { | |
740 | } | |
741 | ||
742 | inline ParameterNode::ParameterNode(const Identifier& ident) | |
743 | : m_ident(ident) | |
744 | , m_next(0) | |
745 | { | |
746 | } | |
747 | ||
748 | inline ParameterNode::ParameterNode(ParameterNode* l, const Identifier& ident) | |
749 | : m_ident(ident) | |
750 | , m_next(0) | |
751 | { | |
752 | l->m_next = this; | |
753 | } | |
754 | ||
755 | inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter) | |
756 | : ExpressionNode(location) | |
757 | , m_body(body) | |
758 | { | |
759 | m_body->finishParsing(source, parameter, ident, FunctionNameIsInScope); | |
760 | } | |
761 | ||
762 | inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter) | |
763 | : StatementNode(location) | |
764 | , m_body(body) | |
765 | { | |
766 | m_body->finishParsing(source, parameter, ident, FunctionNameIsNotInScope); | |
767 | } | |
768 | ||
769 | inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements) | |
770 | : m_expr(expr) | |
771 | , m_statements(statements) | |
772 | { | |
773 | } | |
774 | ||
775 | inline ClauseListNode::ClauseListNode(CaseClauseNode* clause) | |
776 | : m_clause(clause) | |
777 | , m_next(0) | |
778 | { | |
779 | } | |
780 | ||
781 | inline ClauseListNode::ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause) | |
782 | : m_clause(clause) | |
783 | , m_next(0) | |
784 | { | |
785 | clauseList->m_next = this; | |
786 | } | |
787 | ||
788 | inline CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) | |
789 | : m_list1(list1) | |
790 | , m_defaultClause(defaultClause) | |
791 | , m_list2(list2) | |
792 | { | |
793 | } | |
794 | ||
795 | inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block) | |
796 | : StatementNode(location) | |
797 | , m_expr(expr) | |
798 | , m_block(block) | |
799 | { | |
800 | } | |
801 | ||
802 | inline ConstDeclNode::ConstDeclNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* init) | |
803 | : ExpressionNode(location) | |
804 | , m_ident(ident) | |
805 | , m_next(0) | |
806 | , m_init(init) | |
807 | { | |
808 | } | |
809 | ||
810 | inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements) | |
811 | : StatementNode(location) | |
812 | , m_statements(statements) | |
813 | { | |
814 | } | |
815 | ||
816 | inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) | |
817 | : StatementNode(location) | |
818 | , m_init(0) | |
819 | , m_lexpr(l) | |
820 | , m_expr(expr) | |
821 | , m_statement(statement) | |
822 | { | |
823 | } | |
824 | ||
825 | inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement, unsigned divot, int startOffset, int endOffset, unsigned divotLine, unsigned divotLineStart) | |
826 | : StatementNode(location) | |
827 | , m_init(0) | |
828 | , m_lexpr(new (vm) ResolveNode(location, ident, divot - startOffset, divotLine, divotLineStart)) | |
829 | , m_expr(expr) | |
830 | , m_statement(statement) | |
831 | { | |
832 | if (in) { | |
833 | AssignResolveNode* node = new (vm) AssignResolveNode(location, ident, in); | |
834 | ASSERT(divot >= divotLineStart); | |
835 | node->setExceptionSourceCode(divot, divot - startOffset, endOffset - divot, divotLine, divotLineStart); | |
836 | m_init = node; | |
837 | } | |
838 | // for( var foo = bar in baz ) | |
839 | } | |
840 | ||
841 | } // namespace JSC | |
842 | ||
843 | #endif // NodeConstructors_h |