| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 name, function_name_location, name_is_strict_reserved, kind, | 99 name, function_name_location, name_is_strict_reserved, kind, |
| 100 function_token_position, type, arity_restriction, ok); | 100 function_token_position, type, arity_restriction, ok); |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 104 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 105 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { | 105 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
| 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 PreParserScope top_scope(scope_, SCRIPT_SCOPE); | 108 PreParserScope top_scope(scope_, SCRIPT_SCOPE); |
| 109 PreParserFactory top_factory(NULL); | 109 PreParserFactory top_factory(NULL, NULL); |
| 110 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); | 110 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); |
| 111 scope_->SetStrictMode(strict_mode); | 111 scope_->SetStrictMode(strict_mode); |
| 112 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 112 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
| 113 PreParserFactory function_factory(NULL); | 113 PreParserFactory function_factory(NULL, NULL); |
| 114 FunctionState function_state(&function_state_, &scope_, &function_scope, | 114 FunctionState function_state(&function_state_, &scope_, &function_scope, |
| 115 &function_factory); | 115 &function_factory); |
| 116 function_state.set_is_generator(is_generator); | 116 function_state.set_is_generator(is_generator); |
| 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); | 120 ParseLazyFunctionLiteralBody(&ok); |
| 121 if (stack_overflow()) return kPreParseStackOverflow; | 121 if (stack_overflow()) return kPreParseStackOverflow; |
| 122 if (!ok) { | 122 if (!ok) { |
| 123 ReportUnexpectedToken(scanner()->current_token()); | 123 ReportUnexpectedToken(scanner()->current_token()); |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 Identifier function_name, Scanner::Location function_name_location, | 843 Identifier function_name, Scanner::Location function_name_location, |
| 844 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 844 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 845 FunctionLiteral::FunctionType function_type, | 845 FunctionLiteral::FunctionType function_type, |
| 846 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 846 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
| 847 // Function :: | 847 // Function :: |
| 848 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 848 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 849 | 849 |
| 850 // Parse function body. | 850 // Parse function body. |
| 851 ScopeType outer_scope_type = scope_->type(); | 851 ScopeType outer_scope_type = scope_->type(); |
| 852 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 852 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
| 853 PreParserFactory factory(NULL); | 853 PreParserFactory factory(NULL, NULL); |
| 854 FunctionState function_state(&function_state_, &scope_, &function_scope, | 854 FunctionState function_state(&function_state_, &scope_, &function_scope, |
| 855 &factory); | 855 &factory); |
| 856 function_state.set_is_generator(IsGeneratorFunction(kind)); | 856 function_state.set_is_generator(IsGeneratorFunction(kind)); |
| 857 // FormalParameterList :: | 857 // FormalParameterList :: |
| 858 // '(' (Identifier)*[','] ')' | 858 // '(' (Identifier)*[','] ')' |
| 859 Expect(Token::LPAREN, CHECK_OK); | 859 Expect(Token::LPAREN, CHECK_OK); |
| 860 int start_position = position(); | 860 int start_position = position(); |
| 861 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 861 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
| 862 // We don't yet know if the function will be strict, so we cannot yet produce | 862 // We don't yet know if the function will be strict, so we cannot yet produce |
| 863 // errors for parameter names or duplicates. However, we remember the | 863 // errors for parameter names or duplicates. However, we remember the |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 1014 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
| 1015 ParseArguments(ok); | 1015 ParseArguments(ok); |
| 1016 | 1016 |
| 1017 return Expression::Default(); | 1017 return Expression::Default(); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 #undef CHECK_OK | 1020 #undef CHECK_OK |
| 1021 | 1021 |
| 1022 | 1022 |
| 1023 } } // v8::internal | 1023 } } // v8::internal |
| OLD | NEW |