| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Scanner::BookmarkScope* bookmark) { | 103 Scanner::BookmarkScope* bookmark) { |
| 104 log_ = log; | 104 log_ = log; |
| 105 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 105 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
| 106 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); | 106 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); |
| 107 PreParserFactory top_factory(NULL); | 107 PreParserFactory top_factory(NULL); |
| 108 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, | 108 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, |
| 109 &top_factory); | 109 &top_factory); |
| 110 scope_->SetLanguageMode(language_mode); | 110 scope_->SetLanguageMode(language_mode); |
| 111 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 111 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
| 112 PreParserFactory function_factory(NULL); | 112 PreParserFactory function_factory(NULL); |
| 113 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 113 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 114 &function_factory); | 114 &function_factory); |
| 115 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 115 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
| 116 bool ok = true; | 116 bool ok = true; |
| 117 int start_position = peek_position(); | 117 int start_position = peek_position(); |
| 118 ParseLazyFunctionLiteralBody(&ok, bookmark); | 118 ParseLazyFunctionLiteralBody(&ok, bookmark); |
| 119 if (bookmark && bookmark->HasBeenReset()) { | 119 if (bookmark && bookmark->HasBeenReset()) { |
| 120 ; // Do nothing, as we've just aborted scanning this function. | 120 ; // Do nothing, as we've just aborted scanning this function. |
| 121 } else if (stack_overflow()) { | 121 } else if (stack_overflow()) { |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 PreParser::Expression PreParser::ParseFunctionLiteral( | 1013 PreParser::Expression PreParser::ParseFunctionLiteral( |
| 1014 Identifier function_name, Scanner::Location function_name_location, | 1014 Identifier function_name, Scanner::Location function_name_location, |
| 1015 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1015 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 1016 FunctionLiteral::FunctionType function_type, | 1016 FunctionLiteral::FunctionType function_type, |
| 1017 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 1017 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
| 1018 // Function :: | 1018 // Function :: |
| 1019 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 1019 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 1020 | 1020 |
| 1021 // Parse function body. | 1021 // Parse function body. |
| 1022 bool outer_is_script_scope = scope_->is_script_scope(); | 1022 bool outer_is_script_scope = scope_->is_script_scope(); |
| 1023 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 1023 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
| 1024 PreParserFactory factory(NULL); | 1024 PreParserFactory factory(NULL); |
| 1025 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 1025 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 1026 &factory); | 1026 &factory); |
| 1027 FormalParameterErrorLocations error_locs; | 1027 FormalParameterErrorLocations error_locs; |
| 1028 | 1028 |
| 1029 bool is_rest = false; | 1029 bool is_rest = false; |
| 1030 Expect(Token::LPAREN, CHECK_OK); | 1030 Expect(Token::LPAREN, CHECK_OK); |
| 1031 int start_position = scanner()->location().beg_pos; | 1031 int start_position = scanner()->location().beg_pos; |
| 1032 function_scope->set_start_position(start_position); | 1032 function_scope->set_start_position(start_position); |
| 1033 int num_parameters; | 1033 int num_parameters; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 | 1174 |
| 1175 DCHECK(!spread_pos.IsValid()); | 1175 DCHECK(!spread_pos.IsValid()); |
| 1176 | 1176 |
| 1177 return Expression::Default(); | 1177 return Expression::Default(); |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 #undef CHECK_OK | 1180 #undef CHECK_OK |
| 1181 | 1181 |
| 1182 | 1182 |
| 1183 } } // v8::internal | 1183 } } // v8::internal |
| OLD | NEW |