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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // The same idea for '-foo' => 'foo*(-1)'. | 417 // The same idea for '-foo' => 'foo*(-1)'. |
418 if (op == Token::SUB) { | 418 if (op == Token::SUB) { |
419 return factory()->NewBinaryOperation( | 419 return factory()->NewBinaryOperation( |
420 Token::MUL, expression, factory()->NewNumberLiteral(-1, pos), pos); | 420 Token::MUL, expression, factory()->NewNumberLiteral(-1, pos), pos); |
421 } | 421 } |
422 // ...and one more time for '~foo' => 'foo^(~0)'. | 422 // ...and one more time for '~foo' => 'foo^(~0)'. |
423 if (op == Token::BIT_NOT) { | 423 if (op == Token::BIT_NOT) { |
424 return factory()->NewBinaryOperation( | 424 return factory()->NewBinaryOperation( |
425 Token::BIT_XOR, expression, factory()->NewNumberLiteral(~0, pos), pos); | 425 Token::BIT_XOR, expression, factory()->NewNumberLiteral(~0, pos), pos); |
426 } | 426 } |
| 427 |
427 return factory()->NewUnaryOperation(op, expression, pos); | 428 return factory()->NewUnaryOperation(op, expression, pos); |
428 } | 429 } |
429 | 430 |
430 Expression* Parser::BuildIteratorResult(Expression* value, bool done) { | 431 Expression* Parser::BuildIteratorResult(Expression* value, bool done) { |
431 int pos = kNoSourcePosition; | 432 int pos = kNoSourcePosition; |
432 | 433 |
433 if (value == nullptr) value = factory()->NewUndefinedLiteral(pos); | 434 if (value == nullptr) value = factory()->NewUndefinedLiteral(pos); |
434 | 435 |
435 auto args = new (zone()) ZoneList<Expression*>(2, zone()); | 436 auto args = new (zone()) ZoneList<Expression*>(2, zone()); |
436 args->Add(value, zone()); | 437 args->Add(value, zone()); |
(...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 // handle as the function name. Remember if we were passed a non-empty | 2525 // handle as the function name. Remember if we were passed a non-empty |
2525 // handle to decide whether to invoke function name inference. | 2526 // handle to decide whether to invoke function name inference. |
2526 bool should_infer_name = function_name == NULL; | 2527 bool should_infer_name = function_name == NULL; |
2527 | 2528 |
2528 // We want a non-null handle as the function name. | 2529 // We want a non-null handle as the function name. |
2529 if (should_infer_name) { | 2530 if (should_infer_name) { |
2530 function_name = ast_value_factory()->empty_string(); | 2531 function_name = ast_value_factory()->empty_string(); |
2531 } | 2532 } |
2532 | 2533 |
2533 FunctionLiteral::EagerCompileHint eager_compile_hint = | 2534 FunctionLiteral::EagerCompileHint eager_compile_hint = |
2534 function_state_->next_function_is_parenthesized() | 2535 (function_state_->next_function_is_parenthesized() || |
| 2536 function_state_->next_function_is_exclaimed()) |
2535 ? FunctionLiteral::kShouldEagerCompile | 2537 ? FunctionLiteral::kShouldEagerCompile |
2536 : default_eager_compile_hint(); | 2538 : default_eager_compile_hint(); |
2537 | 2539 |
2538 // Determine if the function can be parsed lazily. Lazy parsing is | 2540 // Determine if the function can be parsed lazily. Lazy parsing is |
2539 // different from lazy compilation; we need to parse more eagerly than we | 2541 // different from lazy compilation; we need to parse more eagerly than we |
2540 // compile. | 2542 // compile. |
2541 | 2543 |
2542 // We can only parse lazily if we also compile lazily. The heuristics for lazy | 2544 // We can only parse lazily if we also compile lazily. The heuristics for lazy |
2543 // compilation are: | 2545 // compilation are: |
2544 // - It must not have been prohibited by the caller to Parse (some callers | 2546 // - It must not have been prohibited by the caller to Parse (some callers |
(...skipping 2890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5435 | 5437 |
5436 return final_loop; | 5438 return final_loop; |
5437 } | 5439 } |
5438 | 5440 |
5439 #undef CHECK_OK | 5441 #undef CHECK_OK |
5440 #undef CHECK_OK_VOID | 5442 #undef CHECK_OK_VOID |
5441 #undef CHECK_FAILED | 5443 #undef CHECK_FAILED |
5442 | 5444 |
5443 } // namespace internal | 5445 } // namespace internal |
5444 } // namespace v8 | 5446 } // namespace v8 |
OLD | NEW |