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/v8.h" | 5 #include "src/v8.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/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 void ParserTraits::CheckPossibleEvalCall(Expression* expression, | 516 void ParserTraits::CheckPossibleEvalCall(Expression* expression, |
517 Scope* scope) { | 517 Scope* scope) { |
518 VariableProxy* callee = expression->AsVariableProxy(); | 518 VariableProxy* callee = expression->AsVariableProxy(); |
519 if (callee != NULL && | 519 if (callee != NULL && |
520 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { | 520 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { |
521 scope->DeclarationScope()->RecordEvalCall(); | 521 scope->DeclarationScope()->RecordEvalCall(); |
522 scope->RecordEvalCall(); | |
522 } | 523 } |
523 } | 524 } |
524 | 525 |
525 | 526 |
526 Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) { | 527 Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) { |
527 VariableProxy* proxy = | 528 VariableProxy* proxy = |
528 expression != NULL ? expression->AsVariableProxy() : NULL; | 529 expression != NULL ? expression->AsVariableProxy() : NULL; |
529 if (proxy != NULL) proxy->set_is_assigned(); | 530 if (proxy != NULL) proxy->set_is_assigned(); |
530 return expression; | 531 return expression; |
531 } | 532 } |
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3287 Statement* clear_first = NULL; | 3288 Statement* clear_first = NULL; |
3288 // Make statement: first = 0. | 3289 // Make statement: first = 0. |
3289 { | 3290 { |
3290 VariableProxy* first_proxy = factory()->NewVariableProxy(first); | 3291 VariableProxy* first_proxy = factory()->NewVariableProxy(first); |
3291 Expression* const0 = factory()->NewSmiLiteral(0, RelocInfo::kNoPosition); | 3292 Expression* const0 = factory()->NewSmiLiteral(0, RelocInfo::kNoPosition); |
3292 Assignment* assignment = factory()->NewAssignment( | 3293 Assignment* assignment = factory()->NewAssignment( |
3293 Token::ASSIGN, first_proxy, const0, RelocInfo::kNoPosition); | 3294 Token::ASSIGN, first_proxy, const0, RelocInfo::kNoPosition); |
3294 clear_first = | 3295 clear_first = |
3295 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 3296 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
3296 } | 3297 } |
3297 Statement* clear_first_or_next = | 3298 Statement* clear_first_or_next = factory()->NewIfStatement( |
3298 factory()->NewIfStatement(compare, clear_first, next, next->position()); | 3299 compare, clear_first, next, RelocInfo::kNoPosition); |
3299 inner_block->AddStatement(clear_first_or_next, zone()); | 3300 inner_block->AddStatement(clear_first_or_next, zone()); |
3300 } | 3301 } |
3301 | 3302 |
3302 Variable* flag = scope_->DeclarationScope()->NewTemporary(temp_name); | 3303 Variable* flag = scope_->DeclarationScope()->NewTemporary(temp_name); |
3303 // Make statement: flag = 1. | 3304 // Make statement: flag = 1. |
3304 { | 3305 { |
3305 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); | 3306 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); |
3306 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); | 3307 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); |
3307 Assignment* assignment = factory()->NewAssignment( | 3308 Assignment* assignment = factory()->NewAssignment( |
3308 Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); | 3309 Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4031 // that it will be compiled lazily. | 4032 // that it will be compiled lazily. |
4032 | 4033 |
4033 // To make this additional case work, both Parser and PreParser implement a | 4034 // To make this additional case work, both Parser and PreParser implement a |
4034 // logic where only top-level functions will be parsed lazily. | 4035 // logic where only top-level functions will be parsed lazily. |
4035 bool is_lazily_parsed = (mode() == PARSE_LAZILY && | 4036 bool is_lazily_parsed = (mode() == PARSE_LAZILY && |
4036 scope_->AllowsLazyCompilation() && | 4037 scope_->AllowsLazyCompilation() && |
4037 !parenthesized_function_); | 4038 !parenthesized_function_); |
4038 parenthesized_function_ = false; // The bit was set for this function only. | 4039 parenthesized_function_ = false; // The bit was set for this function only. |
4039 | 4040 |
4040 if (is_lazily_parsed) { | 4041 if (is_lazily_parsed) { |
4042 for (Scope* s = scope_->outer_scope(); | |
4043 s != nullptr && (s->is_block_scope() || s->is_catch_scope() || | |
rossberg
2015/04/21 14:41:02
Would it work to make the condition
s && s != s
Dmitry Lomov (no reviews)
2015/04/21 16:59:24
Great suggestion, done.
| |
4044 s->is_with_scope()); | |
4045 s = s->outer_scope()) { | |
4046 s->ForceContextAllocation(); | |
4047 } | |
4041 SkipLazyFunctionBody(function_name, &materialized_literal_count, | 4048 SkipLazyFunctionBody(function_name, &materialized_literal_count, |
4042 &expected_property_count, CHECK_OK); | 4049 &expected_property_count, CHECK_OK); |
4043 } else { | 4050 } else { |
4044 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op, | 4051 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op, |
4045 kind, CHECK_OK); | 4052 kind, CHECK_OK); |
4046 materialized_literal_count = function_state.materialized_literal_count(); | 4053 materialized_literal_count = function_state.materialized_literal_count(); |
4047 expected_property_count = function_state.expected_property_count(); | 4054 expected_property_count = function_state.expected_property_count(); |
4048 handler_count = function_state.handler_count(); | 4055 handler_count = function_state.handler_count(); |
4049 } | 4056 } |
4050 | 4057 |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5779 | 5786 |
5780 Expression* Parser::SpreadCallNew(Expression* function, | 5787 Expression* Parser::SpreadCallNew(Expression* function, |
5781 ZoneList<v8::internal::Expression*>* args, | 5788 ZoneList<v8::internal::Expression*>* args, |
5782 int pos) { | 5789 int pos) { |
5783 args->InsertAt(0, function, zone()); | 5790 args->InsertAt(0, function, zone()); |
5784 | 5791 |
5785 return factory()->NewCallRuntime( | 5792 return factory()->NewCallRuntime( |
5786 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5793 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5787 } | 5794 } |
5788 } } // namespace v8::internal | 5795 } } // namespace v8::internal |
OLD | NEW |