| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 101 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 102 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) { | 102 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) { |
| 103 log_ = log; | 103 log_ = log; |
| 104 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 104 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
| 105 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); | 105 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); |
| 106 PreParserFactory top_factory(NULL); | 106 PreParserFactory top_factory(NULL); |
| 107 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, | 107 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, |
| 108 &top_factory); | 108 &top_factory); |
| 109 scope_->SetLanguageMode(language_mode); | 109 scope_->SetLanguageMode(language_mode); |
| 110 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 110 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
| 111 PreParserFactory function_factory(NULL); | 111 PreParserFactory function_factory(NULL); |
| 112 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 112 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 113 &function_factory); | 113 &function_factory); |
| 114 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 114 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
| 115 bool ok = true; | 115 bool ok = true; |
| 116 int start_position = peek_position(); | 116 int start_position = peek_position(); |
| 117 ParseLazyFunctionLiteralBody(&ok); | 117 ParseLazyFunctionLiteralBody(&ok); |
| 118 if (stack_overflow()) return kPreParseStackOverflow; | 118 if (stack_overflow()) return kPreParseStackOverflow; |
| 119 if (!ok) { | 119 if (!ok) { |
| 120 ReportUnexpectedToken(scanner()->current_token()); | 120 ReportUnexpectedToken(scanner()->current_token()); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 PreParser::Expression PreParser::ParseFunctionLiteral( | 975 PreParser::Expression PreParser::ParseFunctionLiteral( |
| 976 Identifier function_name, Scanner::Location function_name_location, | 976 Identifier function_name, Scanner::Location function_name_location, |
| 977 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 977 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 978 FunctionLiteral::FunctionType function_type, | 978 FunctionLiteral::FunctionType function_type, |
| 979 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 979 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
| 980 // Function :: | 980 // Function :: |
| 981 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 981 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 982 | 982 |
| 983 // Parse function body. | 983 // Parse function body. |
| 984 bool outer_is_script_scope = scope_->is_script_scope(); | 984 bool outer_is_script_scope = scope_->is_script_scope(); |
| 985 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 985 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
| 986 PreParserFactory factory(NULL); | 986 PreParserFactory factory(NULL); |
| 987 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 987 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 988 &factory); | 988 &factory); |
| 989 FormalParameterErrorLocations error_locs; | 989 FormalParameterErrorLocations error_locs; |
| 990 | 990 |
| 991 bool is_rest = false; | 991 bool is_rest = false; |
| 992 Expect(Token::LPAREN, CHECK_OK); | 992 Expect(Token::LPAREN, CHECK_OK); |
| 993 int start_position = scanner()->location().beg_pos; | 993 int start_position = scanner()->location().beg_pos; |
| 994 function_scope->set_start_position(start_position); | 994 function_scope->set_start_position(start_position); |
| 995 int num_parameters; | 995 int num_parameters; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 | 1134 |
| 1135 DCHECK(!spread_pos.IsValid()); | 1135 DCHECK(!spread_pos.IsValid()); |
| 1136 | 1136 |
| 1137 return Expression::Default(); | 1137 return Expression::Default(); |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 #undef CHECK_OK | 1140 #undef CHECK_OK |
| 1141 | 1141 |
| 1142 | 1142 |
| 1143 } } // v8::internal | 1143 } } // v8::internal |
| OLD | NEW |