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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); | 547 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
548 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && | 548 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && |
549 info->isolate()->is_tail_call_elimination_enabled()); | 549 info->isolate()->is_tail_call_elimination_enabled()); |
550 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); | 550 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); |
551 set_allow_harmony_function_sent(FLAG_harmony_function_sent); | 551 set_allow_harmony_function_sent(FLAG_harmony_function_sent); |
552 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); | 552 set_allow_harmony_restrictive_generators(FLAG_harmony_restrictive_generators); |
553 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); | 553 set_allow_harmony_trailing_commas(FLAG_harmony_trailing_commas); |
554 set_allow_harmony_class_fields(FLAG_harmony_class_fields); | 554 set_allow_harmony_class_fields(FLAG_harmony_class_fields); |
555 set_allow_harmony_object_rest_spread(FLAG_harmony_object_rest_spread); | 555 set_allow_harmony_object_rest_spread(FLAG_harmony_object_rest_spread); |
556 set_allow_harmony_dynamic_import(FLAG_harmony_dynamic_import); | 556 set_allow_harmony_dynamic_import(FLAG_harmony_dynamic_import); |
| 557 set_allow_harmony_template_escapes(FLAG_harmony_template_escapes); |
557 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 558 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
558 ++feature) { | 559 ++feature) { |
559 use_counts_[feature] = 0; | 560 use_counts_[feature] = 0; |
560 } | 561 } |
561 if (info->ast_value_factory() == NULL) { | 562 if (info->ast_value_factory() == NULL) { |
562 // info takes ownership of AstValueFactory. | 563 // info takes ownership of AstValueFactory. |
563 info->set_ast_value_factory(new AstValueFactory( | 564 info->set_ast_value_factory(new AstValueFactory( |
564 zone(), info->isolate()->ast_string_constants(), info->hash_seed())); | 565 zone(), info->isolate()->ast_string_constants(), info->hash_seed())); |
565 info->set_ast_value_factory_owned(); | 566 info->set_ast_value_factory_owned(); |
566 ast_value_factory_ = info->ast_value_factory(); | 567 ast_value_factory_ = info->ast_value_factory(); |
(...skipping 2890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3457 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), | 3458 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), |
3458 "V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD, | 3459 "V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD, |
3459 "runtime-call-stats", std::move(value)); | 3460 "runtime-call-stats", std::move(value)); |
3460 } | 3461 } |
3461 } | 3462 } |
3462 | 3463 |
3463 Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) { | 3464 Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) { |
3464 return new (zone()) TemplateLiteral(zone(), pos); | 3465 return new (zone()) TemplateLiteral(zone(), pos); |
3465 } | 3466 } |
3466 | 3467 |
3467 | 3468 void Parser::AddTemplateSpan(TemplateLiteralState* state, bool should_cook, |
3468 void Parser::AddTemplateSpan(TemplateLiteralState* state, bool tail) { | 3469 bool tail) { |
| 3470 DCHECK(should_cook || allow_harmony_template_escapes()); |
3469 int pos = scanner()->location().beg_pos; | 3471 int pos = scanner()->location().beg_pos; |
3470 int end = scanner()->location().end_pos - (tail ? 1 : 2); | 3472 int end = scanner()->location().end_pos - (tail ? 1 : 2); |
3471 const AstRawString* tv = scanner()->CurrentSymbol(ast_value_factory()); | |
3472 const AstRawString* trv = scanner()->CurrentRawSymbol(ast_value_factory()); | 3473 const AstRawString* trv = scanner()->CurrentRawSymbol(ast_value_factory()); |
3473 Literal* cooked = factory()->NewStringLiteral(tv, pos); | |
3474 Literal* raw = factory()->NewStringLiteral(trv, pos); | 3474 Literal* raw = factory()->NewStringLiteral(trv, pos); |
3475 (*state)->AddTemplateSpan(cooked, raw, end, zone()); | 3475 if (should_cook) { |
| 3476 const AstRawString* tv = scanner()->CurrentSymbol(ast_value_factory()); |
| 3477 Literal* cooked = factory()->NewStringLiteral(tv, pos); |
| 3478 (*state)->AddTemplateSpan(cooked, raw, end, zone()); |
| 3479 } else { |
| 3480 (*state)->AddTemplateSpan(GetLiteralUndefined(pos), raw, end, zone()); |
| 3481 } |
3476 } | 3482 } |
3477 | 3483 |
3478 | 3484 |
3479 void Parser::AddTemplateExpression(TemplateLiteralState* state, | 3485 void Parser::AddTemplateExpression(TemplateLiteralState* state, |
3480 Expression* expression) { | 3486 Expression* expression) { |
3481 (*state)->AddExpression(expression, zone()); | 3487 (*state)->AddExpression(expression, zone()); |
3482 } | 3488 } |
3483 | 3489 |
3484 | 3490 |
3485 Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start, | 3491 Expression* Parser::CloseTemplateLiteral(TemplateLiteralState* state, int start, |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5018 | 5024 |
5019 return final_loop; | 5025 return final_loop; |
5020 } | 5026 } |
5021 | 5027 |
5022 #undef CHECK_OK | 5028 #undef CHECK_OK |
5023 #undef CHECK_OK_VOID | 5029 #undef CHECK_OK_VOID |
5024 #undef CHECK_FAILED | 5030 #undef CHECK_FAILED |
5025 | 5031 |
5026 } // namespace internal | 5032 } // namespace internal |
5027 } // namespace v8 | 5033 } // namespace v8 |
OLD | NEW |