OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 name, function_scope, body, materialized_literal_count, | 285 name, function_scope, body, materialized_literal_count, |
286 expected_property_count, parameter_count, parameter_count, | 286 expected_property_count, parameter_count, parameter_count, |
287 FunctionLiteral::kNoDuplicateParameters, | 287 FunctionLiteral::kNoDuplicateParameters, |
288 FunctionLiteral::kAnonymousExpression, default_eager_compile_hint(), pos); | 288 FunctionLiteral::kAnonymousExpression, default_eager_compile_hint(), pos); |
289 | 289 |
290 function_literal->set_requires_class_field_init(requires_class_field_init); | 290 function_literal->set_requires_class_field_init(requires_class_field_init); |
291 | 291 |
292 return function_literal; | 292 return function_literal; |
293 } | 293 } |
294 | 294 |
295 | |
296 // ---------------------------------------------------------------------------- | |
297 // Target is a support class to facilitate manipulation of the | |
298 // Parser's target_stack_ (the stack of potential 'break' and | |
299 // 'continue' statement targets). Upon construction, a new target is | |
300 // added; it is removed upon destruction. | |
301 | |
302 class ParserTarget BASE_EMBEDDED { | |
303 public: | |
304 ParserTarget(ParserBase<Parser>* parser, BreakableStatement* statement) | |
305 : variable_(&parser->impl()->target_stack_), | |
306 statement_(statement), | |
307 previous_(parser->impl()->target_stack_) { | |
308 parser->impl()->target_stack_ = this; | |
309 } | |
310 | |
311 ~ParserTarget() { *variable_ = previous_; } | |
312 | |
313 ParserTarget* previous() { return previous_; } | |
314 BreakableStatement* statement() { return statement_; } | |
315 | |
316 private: | |
317 ParserTarget** variable_; | |
318 BreakableStatement* statement_; | |
319 ParserTarget* previous_; | |
320 }; | |
321 | |
322 class ParserTargetScope BASE_EMBEDDED { | |
323 public: | |
324 explicit ParserTargetScope(ParserBase<Parser>* parser) | |
325 : variable_(&parser->impl()->target_stack_), | |
326 previous_(parser->impl()->target_stack_) { | |
327 parser->impl()->target_stack_ = nullptr; | |
328 } | |
329 | |
330 ~ParserTargetScope() { *variable_ = previous_; } | |
331 | |
332 private: | |
333 ParserTarget** variable_; | |
334 ParserTarget* previous_; | |
335 }; | |
336 | |
337 | |
338 // ---------------------------------------------------------------------------- | 295 // ---------------------------------------------------------------------------- |
339 // The CHECK_OK macro is a convenient macro to enforce error | 296 // The CHECK_OK macro is a convenient macro to enforce error |
340 // handling for functions that may fail (by returning !*ok). | 297 // handling for functions that may fail (by returning !*ok). |
341 // | 298 // |
342 // CAUTION: This macro appends extra statements after a call, | 299 // CAUTION: This macro appends extra statements after a call, |
343 // thus it must never be used where only a single statement | 300 // thus it must never be used where only a single statement |
344 // is correct (e.g. an if statement branch w/o braces)! | 301 // is correct (e.g. an if statement branch w/o braces)! |
345 | 302 |
346 #define CHECK_OK_VALUE(x) ok); \ | 303 #define CHECK_OK_VALUE(x) ok); \ |
347 if (!*ok) return x; \ | 304 if (!*ok) return x; \ |
(...skipping 5092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5440 | 5397 |
5441 return final_loop; | 5398 return final_loop; |
5442 } | 5399 } |
5443 | 5400 |
5444 #undef CHECK_OK | 5401 #undef CHECK_OK |
5445 #undef CHECK_OK_VOID | 5402 #undef CHECK_OK_VOID |
5446 #undef CHECK_FAILED | 5403 #undef CHECK_FAILED |
5447 | 5404 |
5448 } // namespace internal | 5405 } // namespace internal |
5449 } // namespace v8 | 5406 } // namespace v8 |
OLD | NEW |