Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/parser.cc

Issue 1399893002: [es7] implement |do| expressions proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix AST numbering issue + add simple TF impl Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/parser.h" 5 #include "src/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
11 #include "src/base/platform/platform.h" 11 #include "src/base/platform/platform.h"
12 #include "src/bootstrapper.h" 12 #include "src/bootstrapper.h"
13 #include "src/char-predicates-inl.h" 13 #include "src/char-predicates-inl.h"
14 #include "src/codegen.h" 14 #include "src/codegen.h"
15 #include "src/compiler.h" 15 #include "src/compiler.h"
16 #include "src/messages.h" 16 #include "src/messages.h"
17 #include "src/preparser.h" 17 #include "src/preparser.h"
18 #include "src/rewriter.h"
18 #include "src/runtime/runtime.h" 19 #include "src/runtime/runtime.h"
19 #include "src/scanner-character-streams.h" 20 #include "src/scanner-character-streams.h"
20 #include "src/scopeinfo.h" 21 #include "src/scopeinfo.h"
21 #include "src/string-stream.h" 22 #include "src/string-stream.h"
22 23
23 namespace v8 { 24 namespace v8 {
24 namespace internal { 25 namespace internal {
25 26
26 ScriptData::ScriptData(const byte* data, int length) 27 ScriptData::ScriptData(const byte* data, int length)
27 : owns_data_(false), rejected_(false), data_(data), length_(length) { 28 : owns_data_(false), rejected_(false), data_(data), length_(length) {
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function); 918 set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function);
918 set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let); 919 set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let);
919 set_allow_harmony_rest_parameters(FLAG_harmony_rest_parameters); 920 set_allow_harmony_rest_parameters(FLAG_harmony_rest_parameters);
920 set_allow_harmony_default_parameters(FLAG_harmony_default_parameters); 921 set_allow_harmony_default_parameters(FLAG_harmony_default_parameters);
921 set_allow_harmony_spread_calls(FLAG_harmony_spread_calls); 922 set_allow_harmony_spread_calls(FLAG_harmony_spread_calls);
922 set_allow_harmony_destructuring(FLAG_harmony_destructuring); 923 set_allow_harmony_destructuring(FLAG_harmony_destructuring);
923 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays); 924 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays);
924 set_allow_harmony_new_target(FLAG_harmony_new_target); 925 set_allow_harmony_new_target(FLAG_harmony_new_target);
925 set_allow_strong_mode(FLAG_strong_mode); 926 set_allow_strong_mode(FLAG_strong_mode);
926 set_allow_legacy_const(FLAG_legacy_const); 927 set_allow_legacy_const(FLAG_legacy_const);
928 set_allow_do_expression_parsing(FLAG_do_expression_parsing);
927 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 929 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
928 ++feature) { 930 ++feature) {
929 use_counts_[feature] = 0; 931 use_counts_[feature] = 0;
930 } 932 }
931 if (info->ast_value_factory() == NULL) { 933 if (info->ast_value_factory() == NULL) {
932 // info takes ownership of AstValueFactory. 934 // info takes ownership of AstValueFactory.
933 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed())); 935 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed()));
934 info->set_ast_value_factory_owned(); 936 info->set_ast_value_factory_owned();
935 ast_value_factory_ = info->ast_value_factory(); 937 ast_value_factory_ = info->ast_value_factory();
936 } 938 }
(...skipping 2637 matching lines...) Expand 10 before | Expand all | Expand 10 after
3574 3576
3575 inner_scope->set_end_position(scanner()->location().end_pos); 3577 inner_scope->set_end_position(scanner()->location().end_pos);
3576 inner_block->set_scope(inner_scope); 3578 inner_block->set_scope(inner_scope);
3577 scope_ = for_scope; 3579 scope_ = for_scope;
3578 3580
3579 outer_loop->Initialize(NULL, NULL, NULL, inner_block); 3581 outer_loop->Initialize(NULL, NULL, NULL, inner_block);
3580 return outer_block; 3582 return outer_block;
3581 } 3583 }
3582 3584
3583 3585
3586 void Parser::RewriteDoExpression(Expression* expr, bool* ok) {
3587 DCHECK(expr->IsDoExpression());
3588 if (!Rewriter::Rewrite(this, expr->AsDoExpression(), ast_value_factory())) {
3589 *ok = false;
3590 }
3591 }
3592
3593
3584 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, 3594 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
3585 bool* ok) { 3595 bool* ok) {
3586 // ForStatement :: 3596 // ForStatement ::
3587 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 3597 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
3588 3598
3589 int stmt_pos = peek_position(); 3599 int stmt_pos = peek_position();
3590 bool is_const = false; 3600 bool is_const = false;
3591 Statement* init = NULL; 3601 Statement* init = NULL;
3592 ZoneList<const AstRawString*> lexical_bindings(1, zone()); 3602 ZoneList<const AstRawString*> lexical_bindings(1, zone());
3593 3603
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
4761 SET_ALLOW(natives); 4771 SET_ALLOW(natives);
4762 SET_ALLOW(harmony_sloppy); 4772 SET_ALLOW(harmony_sloppy);
4763 SET_ALLOW(harmony_sloppy_let); 4773 SET_ALLOW(harmony_sloppy_let);
4764 SET_ALLOW(harmony_rest_parameters); 4774 SET_ALLOW(harmony_rest_parameters);
4765 SET_ALLOW(harmony_default_parameters); 4775 SET_ALLOW(harmony_default_parameters);
4766 SET_ALLOW(harmony_spread_calls); 4776 SET_ALLOW(harmony_spread_calls);
4767 SET_ALLOW(harmony_destructuring); 4777 SET_ALLOW(harmony_destructuring);
4768 SET_ALLOW(harmony_spread_arrays); 4778 SET_ALLOW(harmony_spread_arrays);
4769 SET_ALLOW(harmony_new_target); 4779 SET_ALLOW(harmony_new_target);
4770 SET_ALLOW(strong_mode); 4780 SET_ALLOW(strong_mode);
4781 SET_ALLOW(do_expression_parsing);
4771 #undef SET_ALLOW 4782 #undef SET_ALLOW
4772 } 4783 }
4773 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( 4784 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
4774 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), 4785 language_mode(), function_state_->kind(), scope_->has_simple_parameters(),
4775 logger, bookmark); 4786 logger, bookmark);
4776 if (pre_parse_timer_ != NULL) { 4787 if (pre_parse_timer_ != NULL) {
4777 pre_parse_timer_->Stop(); 4788 pre_parse_timer_->Stop();
4778 } 4789 }
4779 return result; 4790 return result;
4780 } 4791 }
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
6339 6350
6340 Expression* Parser::SpreadCallNew(Expression* function, 6351 Expression* Parser::SpreadCallNew(Expression* function,
6341 ZoneList<v8::internal::Expression*>* args, 6352 ZoneList<v8::internal::Expression*>* args,
6342 int pos) { 6353 int pos) {
6343 args->InsertAt(0, function, zone()); 6354 args->InsertAt(0, function, zone());
6344 6355
6345 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6356 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6346 } 6357 }
6347 } // namespace internal 6358 } // namespace internal
6348 } // namespace v8 6359 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698