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

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: Some cleanup 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 3082 matching lines...) Expand 10 before | Expand all | Expand 10 after
4019 DCHECK(parser_->allow_harmony_default_parameters()); 4021 DCHECK(parser_->allow_harmony_default_parameters());
4020 DCHECK(!assignment->is_compound()); 4022 DCHECK(!assignment->is_compound());
4021 initializer = assignment->value(); 4023 initializer = assignment->value();
4022 expr = assignment->target(); 4024 expr = assignment->target();
4023 } 4025 }
4024 4026
4025 AddFormalParameter(parameters, expr, initializer, is_rest); 4027 AddFormalParameter(parameters, expr, initializer, is_rest);
4026 } 4028 }
4027 4029
4028 4030
4031 DoExpression* Parser::ParseDoExpression(bool* ok) {
4032 // AssignmentExpression ::
4033 // do '{' StatementList '}'
4034 int pos = peek_position();
4035
4036 Expect(Token::DO, CHECK_OK);
4037 Variable* result =
4038 scope_->NewTemporary(ast_value_factory()->dot_result_string());
4039 Block* block = ParseScopedBlock(nullptr, CHECK_OK);
4040 DoExpression* expr = factory()->NewDoExpression(block, result, pos);
4041 if (!Rewriter::Rewrite(this, expr, ast_value_factory())) {
4042 *ok = false;
4043 return nullptr;
4044 }
4045 return expr;
4046 }
4047
4048
4029 void ParserTraits::ParseArrowFunctionFormalParameterList( 4049 void ParserTraits::ParseArrowFunctionFormalParameterList(
4030 ParserFormalParameters* parameters, Expression* expr, 4050 ParserFormalParameters* parameters, Expression* expr,
4031 const Scanner::Location& params_loc, 4051 const Scanner::Location& params_loc,
4032 Scanner::Location* duplicate_loc, bool* ok) { 4052 Scanner::Location* duplicate_loc, bool* ok) {
4033 if (expr->IsEmptyParentheses()) return; 4053 if (expr->IsEmptyParentheses()) return;
4034 4054
4035 ParseArrowFunctionFormalParameters(parameters, expr, params_loc, ok); 4055 ParseArrowFunctionFormalParameters(parameters, expr, params_loc, ok);
4036 if (!*ok) return; 4056 if (!*ok) return;
4037 4057
4038 ExpressionClassifier classifier; 4058 ExpressionClassifier classifier;
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
4761 SET_ALLOW(natives); 4781 SET_ALLOW(natives);
4762 SET_ALLOW(harmony_sloppy); 4782 SET_ALLOW(harmony_sloppy);
4763 SET_ALLOW(harmony_sloppy_let); 4783 SET_ALLOW(harmony_sloppy_let);
4764 SET_ALLOW(harmony_rest_parameters); 4784 SET_ALLOW(harmony_rest_parameters);
4765 SET_ALLOW(harmony_default_parameters); 4785 SET_ALLOW(harmony_default_parameters);
4766 SET_ALLOW(harmony_spread_calls); 4786 SET_ALLOW(harmony_spread_calls);
4767 SET_ALLOW(harmony_destructuring); 4787 SET_ALLOW(harmony_destructuring);
4768 SET_ALLOW(harmony_spread_arrays); 4788 SET_ALLOW(harmony_spread_arrays);
4769 SET_ALLOW(harmony_new_target); 4789 SET_ALLOW(harmony_new_target);
4770 SET_ALLOW(strong_mode); 4790 SET_ALLOW(strong_mode);
4791 SET_ALLOW(do_expression_parsing);
4771 #undef SET_ALLOW 4792 #undef SET_ALLOW
4772 } 4793 }
4773 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( 4794 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
4774 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), 4795 language_mode(), function_state_->kind(), scope_->has_simple_parameters(),
4775 logger, bookmark); 4796 logger, bookmark);
4776 if (pre_parse_timer_ != NULL) { 4797 if (pre_parse_timer_ != NULL) {
4777 pre_parse_timer_->Stop(); 4798 pre_parse_timer_->Stop();
4778 } 4799 }
4779 return result; 4800 return result;
4780 } 4801 }
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
6339 6360
6340 Expression* Parser::SpreadCallNew(Expression* function, 6361 Expression* Parser::SpreadCallNew(Expression* function,
6341 ZoneList<v8::internal::Expression*>* args, 6362 ZoneList<v8::internal::Expression*>* args,
6342 int pos) { 6363 int pos) {
6343 args->InsertAt(0, function, zone()); 6364 args->InsertAt(0, function, zone());
6344 6365
6345 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6366 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6346 } 6367 }
6347 } // namespace internal 6368 } // namespace internal
6348 } // namespace v8 6369 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698