| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 name, function_name_location, name_is_strict_reserved, kind, | 97 name, function_name_location, name_is_strict_reserved, kind, |
| 98 function_token_position, type, arity_restriction, ok); | 98 function_token_position, type, arity_restriction, ok); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 102 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 103 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { | 103 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
| 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 PreParserScope top_scope(scope_, GLOBAL_SCOPE); | 106 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
| 107 PreParserFactory top_factory(NULL, NULL, NULL); | 107 PreParserFactory top_factory(NULL); |
| 108 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); | 108 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); |
| 109 scope_->SetStrictMode(strict_mode); | 109 scope_->SetStrictMode(strict_mode); |
| 110 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 110 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
| 111 PreParserFactory function_factory(NULL, NULL, NULL); | 111 PreParserFactory function_factory(NULL); |
| 112 FunctionState function_state(&function_state_, &scope_, &function_scope, | 112 FunctionState function_state(&function_state_, &scope_, &function_scope, |
| 113 &function_factory); | 113 &function_factory); |
| 114 function_state.set_is_generator(is_generator); | 114 function_state.set_is_generator(is_generator); |
| 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); | 118 ParseLazyFunctionLiteralBody(&ok); |
| 119 if (stack_overflow()) return kPreParseStackOverflow; | 119 if (stack_overflow()) return kPreParseStackOverflow; |
| 120 if (!ok) { | 120 if (!ok) { |
| 121 ReportUnexpectedToken(scanner()->current_token()); | 121 ReportUnexpectedToken(scanner()->current_token()); |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 Identifier function_name, Scanner::Location function_name_location, | 806 Identifier function_name, Scanner::Location function_name_location, |
| 807 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 807 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 808 FunctionLiteral::FunctionType function_type, | 808 FunctionLiteral::FunctionType function_type, |
| 809 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 809 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
| 810 // Function :: | 810 // Function :: |
| 811 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 811 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 812 | 812 |
| 813 // Parse function body. | 813 // Parse function body. |
| 814 ScopeType outer_scope_type = scope_->type(); | 814 ScopeType outer_scope_type = scope_->type(); |
| 815 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 815 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
| 816 PreParserFactory factory(NULL, NULL, NULL); | 816 PreParserFactory factory(NULL); |
| 817 FunctionState function_state(&function_state_, &scope_, &function_scope, | 817 FunctionState function_state(&function_state_, &scope_, &function_scope, |
| 818 &factory); | 818 &factory); |
| 819 function_state.set_is_generator(IsGeneratorFunction(kind)); | 819 function_state.set_is_generator(IsGeneratorFunction(kind)); |
| 820 // FormalParameterList :: | 820 // FormalParameterList :: |
| 821 // '(' (Identifier)*[','] ')' | 821 // '(' (Identifier)*[','] ')' |
| 822 Expect(Token::LPAREN, CHECK_OK); | 822 Expect(Token::LPAREN, CHECK_OK); |
| 823 int start_position = position(); | 823 int start_position = position(); |
| 824 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 824 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
| 825 // We don't yet know if the function will be strict, so we cannot yet produce | 825 // We don't yet know if the function will be strict, so we cannot yet produce |
| 826 // errors for parameter names or duplicates. However, we remember the | 826 // errors for parameter names or duplicates. However, we remember the |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 934 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
| 935 ParseArguments(ok); | 935 ParseArguments(ok); |
| 936 | 936 |
| 937 return Expression::Default(); | 937 return Expression::Default(); |
| 938 } | 938 } |
| 939 | 939 |
| 940 #undef CHECK_OK | 940 #undef CHECK_OK |
| 941 | 941 |
| 942 | 942 |
| 943 } } // v8::internal | 943 } } // v8::internal |
| OLD | NEW |