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