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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && | 545 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && |
546 info->isolate()->is_tail_call_elimination_enabled()); | 546 info->isolate()->is_tail_call_elimination_enabled()); |
547 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); | 547 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); |
548 set_allow_harmony_function_sent(FLAG_harmony_function_sent); | 548 set_allow_harmony_function_sent(FLAG_harmony_function_sent); |
549 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); | 549 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); |
550 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); | 550 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); |
551 set_allow_harmony_class_fields(FLAG_harmony_class_fields); | 551 set_allow_harmony_class_fields(FLAG_harmony_class_fields); |
552 set_allow_harmony_object_rest_spread(FLAG_harmony_object_rest_spread); | 552 set_allow_harmony_object_rest_spread(FLAG_harmony_object_rest_spread); |
553 set_allow_harmony_dynamic_import(FLAG_harmony_dynamic_import); | 553 set_allow_harmony_dynamic_import(FLAG_harmony_dynamic_import); |
554 set_allow_harmony_async_iteration(FLAG_harmony_async_iteration); | 554 set_allow_harmony_async_iteration(FLAG_harmony_async_iteration); |
| 555 set_allow_harmony_template_escapes(FLAG_harmony_template_escapes); |
555 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 556 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
556 ++feature) { | 557 ++feature) { |
557 use_counts_[feature] = 0; | 558 use_counts_[feature] = 0; |
558 } | 559 } |
559 if (info->ast_value_factory() == NULL) { | 560 if (info->ast_value_factory() == NULL) { |
560 // info takes ownership of AstValueFactory. | 561 // info takes ownership of AstValueFactory. |
561 info->set_ast_value_factory(new AstValueFactory( | 562 info->set_ast_value_factory(new AstValueFactory( |
562 zone(), info->isolate()->ast_string_constants(), info->hash_seed())); | 563 zone(), info->isolate()->ast_string_constants(), info->hash_seed())); |
563 info->set_ast_value_factory_owned(); | 564 info->set_ast_value_factory_owned(); |
564 ast_value_factory_ = info->ast_value_factory(); | 565 ast_value_factory_ = info->ast_value_factory(); |
(...skipping 2924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3489 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), | 3490 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), |
3490 "V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD, | 3491 "V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD, |
3491 "runtime-call-stats", std::move(value)); | 3492 "runtime-call-stats", std::move(value)); |
3492 } | 3493 } |
3493 } | 3494 } |
3494 | 3495 |
3495 Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) { | 3496 Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) { |
3496 return new (zone()) TemplateLiteral(zone(), pos); | 3497 return new (zone()) TemplateLiteral(zone(), pos); |
3497 } | 3498 } |
3498 | 3499 |
3499 | 3500 void Parser::AddTemplateSpan(TemplateLiteralState* state, bool should_cook, |
3500 void Parser::AddTemplateSpan(TemplateLiteralState* state, bool tail) { | 3501 bool tail) { |
| 3502 DCHECK(should_cook || allow_harmony_template_escapes()); |
3501 int pos = scanner()->location().beg_pos; | 3503 int pos = scanner()->location().beg_pos; |
3502 int end = scanner()->location().end_pos - (tail ? 1 : 2); | 3504 int end = scanner()->location().end_pos - (tail ? 1 : 2); |
3503 const AstRawString* tv = scanner()->CurrentSymbol(ast_value_factory()); | |
3504 const AstRawString* trv = scanner()->CurrentRawSymbol(ast_value_factory()); | 3505 const AstRawString* trv = scanner()->CurrentRawSymbol(ast_value_factory()); |
3505 Literal* cooked = factory()->NewStringLiteral(tv, pos); | |
3506 Literal* raw = factory()->NewStringLiteral(trv, pos); | 3506 Literal* raw = factory()->NewStringLiteral(trv, pos); |
3507 (*state)->AddTemplateSpan(cooked, raw, end, zone()); | 3507 if (should_cook) { |
| 3508 const AstRawString* tv = scanner()->CurrentSymbol(ast_value_factory()); |
| 3509 Literal* cooked = factory()->NewStringLiteral(tv, pos); |
| 3510 (*state)->AddTemplateSpan(cooked, raw, end, zone()); |
| 3511 } else { |
| 3512 (*state)->AddTemplateSpan(GetLiteralUndefined(pos), raw, end, zone()); |
| 3513 } |
3508 } | 3514 } |
3509 | 3515 |
3510 | 3516 |
3511 void Parser::AddTemplateExpression(TemplateLiteralState* state, | 3517 void Parser::AddTemplateExpression(TemplateLiteralState* state, |
3512 Expression* expression) { | 3518 Expression* expression) { |
3513 (*state)->AddExpression(expression, zone()); | 3519 (*state)->AddExpression(expression, zone()); |
3514 } | 3520 } |
3515 | 3521 |
3516 | 3522 |
3517 Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start, | 3523 Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start, |
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5064 | 5070 |
5065 return final_loop; | 5071 return final_loop; |
5066 } | 5072 } |
5067 | 5073 |
5068 #undef CHECK_OK | 5074 #undef CHECK_OK |
5069 #undef CHECK_OK_VOID | 5075 #undef CHECK_OK_VOID |
5070 #undef CHECK_FAILED | 5076 #undef CHECK_FAILED |
5071 | 5077 |
5072 } // namespace internal | 5078 } // namespace internal |
5073 } // namespace v8 | 5079 } // namespace v8 |
OLD | NEW |