| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 103 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 104 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, | 104 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, |
| 105 Scanner::BookmarkScope* bookmark) { | 105 Scanner::BookmarkScope* bookmark) { |
| 106 log_ = log; | 106 log_ = log; |
| 107 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 107 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
| 108 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); | 108 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); |
| 109 PreParserFactory top_factory(NULL); | 109 PreParserFactory top_factory(NULL); |
| 110 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, | 110 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, |
| 111 &top_factory); | 111 &top_factory); |
| 112 scope_->SetLanguageMode(language_mode); | 112 scope_->SetLanguageMode(language_mode); |
| 113 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 113 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
| 114 PreParserFactory function_factory(NULL); | 114 PreParserFactory function_factory(NULL); |
| 115 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 115 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 116 &function_factory); | 116 &function_factory); |
| 117 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 117 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
| 118 bool ok = true; | 118 bool ok = true; |
| 119 int start_position = peek_position(); | 119 int start_position = peek_position(); |
| 120 ParseLazyFunctionLiteralBody(&ok, bookmark); | 120 ParseLazyFunctionLiteralBody(&ok, bookmark); |
| 121 if (bookmark && bookmark->HasBeenReset()) { | 121 if (bookmark && bookmark->HasBeenReset()) { |
| 122 ; // Do nothing, as we've just aborted scanning this function. | 122 ; // Do nothing, as we've just aborted scanning this function. |
| 123 } else if (stack_overflow()) { | 123 } else if (stack_overflow()) { |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 PreParser::Expression PreParser::ParseFunctionLiteral( | 1021 PreParser::Expression PreParser::ParseFunctionLiteral( |
| 1022 Identifier function_name, Scanner::Location function_name_location, | 1022 Identifier function_name, Scanner::Location function_name_location, |
| 1023 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1023 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 1024 FunctionLiteral::FunctionType function_type, | 1024 FunctionLiteral::FunctionType function_type, |
| 1025 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 1025 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
| 1026 // Function :: | 1026 // Function :: |
| 1027 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 1027 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 1028 | 1028 |
| 1029 // Parse function body. | 1029 // Parse function body. |
| 1030 bool outer_is_script_scope = scope_->is_script_scope(); | 1030 bool outer_is_script_scope = scope_->is_script_scope(); |
| 1031 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 1031 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); |
| 1032 PreParserFactory factory(NULL); | 1032 PreParserFactory factory(NULL); |
| 1033 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 1033 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 1034 &factory); | 1034 &factory); |
| 1035 ExpressionClassifier formals_classifier; | 1035 ExpressionClassifier formals_classifier; |
| 1036 | 1036 |
| 1037 bool has_rest = false; | 1037 bool has_rest = false; |
| 1038 Expect(Token::LPAREN, CHECK_OK); | 1038 Expect(Token::LPAREN, CHECK_OK); |
| 1039 int start_position = scanner()->location().beg_pos; | 1039 int start_position = scanner()->location().beg_pos; |
| 1040 function_scope->set_start_position(start_position); | 1040 function_scope->set_start_position(start_position); |
| 1041 int num_parameters; | 1041 int num_parameters; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 | 1186 |
| 1187 DCHECK(!spread_pos.IsValid()); | 1187 DCHECK(!spread_pos.IsValid()); |
| 1188 | 1188 |
| 1189 return Expression::Default(); | 1189 return Expression::Default(); |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 #undef CHECK_OK | 1192 #undef CHECK_OK |
| 1193 | 1193 |
| 1194 | 1194 |
| 1195 } } // v8::internal | 1195 } } // v8::internal |
| OLD | NEW |