| 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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 | 870 |
| 871 // Compute the parsing mode. | 871 // Compute the parsing mode. |
| 872 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; | 872 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; |
| 873 if (allow_natives_syntax() || extension_ != NULL || | 873 if (allow_natives_syntax() || extension_ != NULL || |
| 874 (*scope)->is_eval_scope()) { | 874 (*scope)->is_eval_scope()) { |
| 875 mode = PARSE_EAGERLY; | 875 mode = PARSE_EAGERLY; |
| 876 } | 876 } |
| 877 ParsingModeScope parsing_mode(this, mode); | 877 ParsingModeScope parsing_mode(this, mode); |
| 878 | 878 |
| 879 // Enters 'scope'. | 879 // Enters 'scope'. |
| 880 FunctionState function_state(&function_state_, &scope_, *scope, zone(), | 880 AstNodeFactory<AstConstructionVisitor> function_factory( |
| 881 ast_value_factory(), info->ast_node_id_gen()); | 881 zone(), ast_value_factory(), info->ast_node_id_gen()); |
| 882 FunctionState function_state(&function_state_, &scope_, *scope, |
| 883 &function_factory); |
| 882 | 884 |
| 883 scope_->SetStrictMode(info->strict_mode()); | 885 scope_->SetStrictMode(info->strict_mode()); |
| 884 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 886 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| 885 bool ok = true; | 887 bool ok = true; |
| 886 int beg_pos = scanner()->location().beg_pos; | 888 int beg_pos = scanner()->location().beg_pos; |
| 887 ParseSourceElements(body, Token::EOS, info->is_eval(), true, eval_scope, | 889 ParseSourceElements(body, Token::EOS, info->is_eval(), true, eval_scope, |
| 888 &ok); | 890 &ok); |
| 889 | 891 |
| 890 if (ok && strict_mode() == STRICT) { | 892 if (ok && strict_mode() == STRICT) { |
| 891 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); | 893 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 | 985 |
| 984 { | 986 { |
| 985 // Parse the function literal. | 987 // Parse the function literal. |
| 986 Scope* scope = NewScope(scope_, GLOBAL_SCOPE); | 988 Scope* scope = NewScope(scope_, GLOBAL_SCOPE); |
| 987 info()->SetGlobalScope(scope); | 989 info()->SetGlobalScope(scope); |
| 988 if (!info()->closure().is_null()) { | 990 if (!info()->closure().is_null()) { |
| 989 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, | 991 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, |
| 990 zone()); | 992 zone()); |
| 991 } | 993 } |
| 992 original_scope_ = scope; | 994 original_scope_ = scope; |
| 993 FunctionState function_state(&function_state_, &scope_, scope, zone(), | 995 AstNodeFactory<AstConstructionVisitor> function_factory( |
| 994 ast_value_factory(), | 996 zone(), ast_value_factory(), info()->ast_node_id_gen()); |
| 995 info()->ast_node_id_gen()); | 997 FunctionState function_state(&function_state_, &scope_, scope, |
| 998 &function_factory); |
| 996 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); | 999 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); |
| 997 DCHECK(info()->strict_mode() == shared_info->strict_mode()); | 1000 DCHECK(info()->strict_mode() == shared_info->strict_mode()); |
| 998 scope->SetStrictMode(shared_info->strict_mode()); | 1001 scope->SetStrictMode(shared_info->strict_mode()); |
| 999 FunctionLiteral::FunctionType function_type = shared_info->is_expression() | 1002 FunctionLiteral::FunctionType function_type = shared_info->is_expression() |
| 1000 ? (shared_info->is_anonymous() | 1003 ? (shared_info->is_anonymous() |
| 1001 ? FunctionLiteral::ANONYMOUS_EXPRESSION | 1004 ? FunctionLiteral::ANONYMOUS_EXPRESSION |
| 1002 : FunctionLiteral::NAMED_EXPRESSION) | 1005 : FunctionLiteral::NAMED_EXPRESSION) |
| 1003 : FunctionLiteral::DECLARATION; | 1006 : FunctionLiteral::DECLARATION; |
| 1004 bool ok = true; | 1007 bool ok = true; |
| 1005 | 1008 |
| (...skipping 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3484 int handler_count = 0; | 3487 int handler_count = 0; |
| 3485 FunctionLiteral::ParameterFlag duplicate_parameters = | 3488 FunctionLiteral::ParameterFlag duplicate_parameters = |
| 3486 FunctionLiteral::kNoDuplicateParameters; | 3489 FunctionLiteral::kNoDuplicateParameters; |
| 3487 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ | 3490 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ |
| 3488 ? FunctionLiteral::kIsParenthesized | 3491 ? FunctionLiteral::kIsParenthesized |
| 3489 : FunctionLiteral::kNotParenthesized; | 3492 : FunctionLiteral::kNotParenthesized; |
| 3490 AstProperties ast_properties; | 3493 AstProperties ast_properties; |
| 3491 BailoutReason dont_optimize_reason = kNoReason; | 3494 BailoutReason dont_optimize_reason = kNoReason; |
| 3492 // Parse function body. | 3495 // Parse function body. |
| 3493 { | 3496 { |
| 3494 FunctionState function_state(&function_state_, &scope_, scope, zone(), | 3497 AstNodeFactory<AstConstructionVisitor> function_factory( |
| 3495 ast_value_factory(), | 3498 zone(), ast_value_factory(), info()->ast_node_id_gen()); |
| 3496 info()->ast_node_id_gen()); | 3499 FunctionState function_state(&function_state_, &scope_, scope, |
| 3500 &function_factory); |
| 3497 scope_->SetScopeName(function_name); | 3501 scope_->SetScopeName(function_name); |
| 3498 | 3502 |
| 3499 if (is_generator) { | 3503 if (is_generator) { |
| 3500 // For generators, allocating variables in contexts is currently a win | 3504 // For generators, allocating variables in contexts is currently a win |
| 3501 // because it minimizes the work needed to suspend and resume an | 3505 // because it minimizes the work needed to suspend and resume an |
| 3502 // activation. | 3506 // activation. |
| 3503 scope_->ForceContextAllocation(); | 3507 scope_->ForceContextAllocation(); |
| 3504 | 3508 |
| 3505 // Calling a generator returns a generator object. That object is stored | 3509 // Calling a generator returns a generator object. That object is stored |
| 3506 // in a temporary variable, a definition that is used by "yield" | 3510 // in a temporary variable, a definition that is used by "yield" |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4946 | 4950 |
| 4947 // We cannot internalize on a background thread; a foreground task will take | 4951 // We cannot internalize on a background thread; a foreground task will take |
| 4948 // care of calling Parser::Internalize just before compilation. | 4952 // care of calling Parser::Internalize just before compilation. |
| 4949 | 4953 |
| 4950 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 4954 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
| 4951 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 4955 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
| 4952 log_ = NULL; | 4956 log_ = NULL; |
| 4953 } | 4957 } |
| 4954 } | 4958 } |
| 4955 } } // namespace v8::internal | 4959 } } // namespace v8::internal |
| OLD | NEW |