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/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 Loading... |
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_harmony_do_expressions(FLAG_harmony_do_expressions); |
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 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4046 DCHECK(parser_->allow_harmony_default_parameters()); | 4048 DCHECK(parser_->allow_harmony_default_parameters()); |
4047 DCHECK(!assignment->is_compound()); | 4049 DCHECK(!assignment->is_compound()); |
4048 initializer = assignment->value(); | 4050 initializer = assignment->value(); |
4049 expr = assignment->target(); | 4051 expr = assignment->target(); |
4050 } | 4052 } |
4051 | 4053 |
4052 AddFormalParameter(parameters, expr, initializer, is_rest); | 4054 AddFormalParameter(parameters, expr, initializer, is_rest); |
4053 } | 4055 } |
4054 | 4056 |
4055 | 4057 |
| 4058 DoExpression* Parser::ParseDoExpression(bool* ok) { |
| 4059 // AssignmentExpression :: |
| 4060 // do '{' StatementList '}' |
| 4061 int pos = peek_position(); |
| 4062 |
| 4063 Expect(Token::DO, CHECK_OK); |
| 4064 Variable* result = |
| 4065 scope_->NewTemporary(ast_value_factory()->dot_result_string()); |
| 4066 Block* block = ParseScopedBlock(nullptr, CHECK_OK); |
| 4067 DoExpression* expr = factory()->NewDoExpression(block, result, pos); |
| 4068 if (!Rewriter::Rewrite(this, expr, ast_value_factory())) { |
| 4069 *ok = false; |
| 4070 return nullptr; |
| 4071 } |
| 4072 return expr; |
| 4073 } |
| 4074 |
| 4075 |
4056 void ParserTraits::ParseArrowFunctionFormalParameterList( | 4076 void ParserTraits::ParseArrowFunctionFormalParameterList( |
4057 ParserFormalParameters* parameters, Expression* expr, | 4077 ParserFormalParameters* parameters, Expression* expr, |
4058 const Scanner::Location& params_loc, | 4078 const Scanner::Location& params_loc, |
4059 Scanner::Location* duplicate_loc, bool* ok) { | 4079 Scanner::Location* duplicate_loc, bool* ok) { |
4060 if (expr->IsEmptyParentheses()) return; | 4080 if (expr->IsEmptyParentheses()) return; |
4061 | 4081 |
4062 ParseArrowFunctionFormalParameters(parameters, expr, params_loc, ok); | 4082 ParseArrowFunctionFormalParameters(parameters, expr, params_loc, ok); |
4063 if (!*ok) return; | 4083 if (!*ok) return; |
4064 | 4084 |
4065 ExpressionClassifier classifier; | 4085 ExpressionClassifier classifier; |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4785 SET_ALLOW(natives); | 4805 SET_ALLOW(natives); |
4786 SET_ALLOW(harmony_sloppy); | 4806 SET_ALLOW(harmony_sloppy); |
4787 SET_ALLOW(harmony_sloppy_let); | 4807 SET_ALLOW(harmony_sloppy_let); |
4788 SET_ALLOW(harmony_rest_parameters); | 4808 SET_ALLOW(harmony_rest_parameters); |
4789 SET_ALLOW(harmony_default_parameters); | 4809 SET_ALLOW(harmony_default_parameters); |
4790 SET_ALLOW(harmony_spread_calls); | 4810 SET_ALLOW(harmony_spread_calls); |
4791 SET_ALLOW(harmony_destructuring); | 4811 SET_ALLOW(harmony_destructuring); |
4792 SET_ALLOW(harmony_spread_arrays); | 4812 SET_ALLOW(harmony_spread_arrays); |
4793 SET_ALLOW(harmony_new_target); | 4813 SET_ALLOW(harmony_new_target); |
4794 SET_ALLOW(strong_mode); | 4814 SET_ALLOW(strong_mode); |
| 4815 SET_ALLOW(harmony_do_expressions); |
4795 #undef SET_ALLOW | 4816 #undef SET_ALLOW |
4796 } | 4817 } |
4797 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( | 4818 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( |
4798 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), | 4819 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), |
4799 logger, bookmark); | 4820 logger, bookmark); |
4800 if (pre_parse_timer_ != NULL) { | 4821 if (pre_parse_timer_ != NULL) { |
4801 pre_parse_timer_->Stop(); | 4822 pre_parse_timer_->Stop(); |
4802 } | 4823 } |
4803 return result; | 4824 return result; |
4804 } | 4825 } |
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6361 | 6382 |
6362 Expression* Parser::SpreadCallNew(Expression* function, | 6383 Expression* Parser::SpreadCallNew(Expression* function, |
6363 ZoneList<v8::internal::Expression*>* args, | 6384 ZoneList<v8::internal::Expression*>* args, |
6364 int pos) { | 6385 int pos) { |
6365 args->InsertAt(0, function, zone()); | 6386 args->InsertAt(0, function, zone()); |
6366 | 6387 |
6367 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); | 6388 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); |
6368 } | 6389 } |
6369 } // namespace internal | 6390 } // namespace internal |
6370 } // namespace v8 | 6391 } // namespace v8 |
OLD | NEW |