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 "include/v8stdint.h" | 7 #include "include/v8stdint.h" |
8 | 8 |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 name, function_name_location, name_is_strict_reserved, kind, | 109 name, function_name_location, name_is_strict_reserved, kind, |
110 function_token_position, type, arity_restriction, ok); | 110 function_token_position, type, arity_restriction, ok); |
111 } | 111 } |
112 | 112 |
113 | 113 |
114 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 114 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
115 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { | 115 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
116 log_ = log; | 116 log_ = log; |
117 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 117 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
118 PreParserScope top_scope(scope_, GLOBAL_SCOPE); | 118 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
119 PreParserFactory top_factory(NULL, NULL, NULL); | 119 PreParserFactory top_factory(NULL, NULL); |
120 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); | 120 FunctionState top_state(&function_state_, &scope_, &top_scope, &top_factory); |
121 scope_->SetStrictMode(strict_mode); | 121 scope_->SetStrictMode(strict_mode); |
122 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 122 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
123 PreParserFactory function_factory(NULL, NULL, NULL); | 123 PreParserFactory function_factory(NULL, NULL); |
124 FunctionState function_state(&function_state_, &scope_, &function_scope, | 124 FunctionState function_state(&function_state_, &scope_, &function_scope, |
125 &function_factory); | 125 &function_factory); |
126 function_state.set_is_generator(is_generator); | 126 function_state.set_is_generator(is_generator); |
127 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 127 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
128 bool ok = true; | 128 bool ok = true; |
129 int start_position = peek_position(); | 129 int start_position = peek_position(); |
130 ParseLazyFunctionLiteralBody(&ok); | 130 ParseLazyFunctionLiteralBody(&ok); |
131 if (stack_overflow()) return kPreParseStackOverflow; | 131 if (stack_overflow()) return kPreParseStackOverflow; |
132 if (!ok) { | 132 if (!ok) { |
133 ReportUnexpectedToken(scanner()->current_token()); | 133 ReportUnexpectedToken(scanner()->current_token()); |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 Identifier function_name, Scanner::Location function_name_location, | 818 Identifier function_name, Scanner::Location function_name_location, |
819 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 819 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
820 FunctionLiteral::FunctionType function_type, | 820 FunctionLiteral::FunctionType function_type, |
821 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 821 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
822 // Function :: | 822 // Function :: |
823 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 823 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
824 | 824 |
825 // Parse function body. | 825 // Parse function body. |
826 ScopeType outer_scope_type = scope_->type(); | 826 ScopeType outer_scope_type = scope_->type(); |
827 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 827 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
828 PreParserFactory factory(NULL, NULL, NULL); | 828 PreParserFactory factory(NULL, NULL); |
829 FunctionState function_state(&function_state_, &scope_, &function_scope, | 829 FunctionState function_state(&function_state_, &scope_, &function_scope, |
830 &factory); | 830 &factory); |
831 function_state.set_is_generator(IsGeneratorFunction(kind)); | 831 function_state.set_is_generator(IsGeneratorFunction(kind)); |
832 // FormalParameterList :: | 832 // FormalParameterList :: |
833 // '(' (Identifier)*[','] ')' | 833 // '(' (Identifier)*[','] ')' |
834 Expect(Token::LPAREN, CHECK_OK); | 834 Expect(Token::LPAREN, CHECK_OK); |
835 int start_position = position(); | 835 int start_position = position(); |
836 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 836 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
837 // We don't yet know if the function will be strict, so we cannot yet produce | 837 // We don't yet know if the function will be strict, so we cannot yet produce |
838 // errors for parameter names or duplicates. However, we remember the | 838 // errors for parameter names or duplicates. However, we remember the |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 946 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
947 ParseArguments(ok); | 947 ParseArguments(ok); |
948 | 948 |
949 return Expression::Default(); | 949 return Expression::Default(); |
950 } | 950 } |
951 | 951 |
952 #undef CHECK_OK | 952 #undef CHECK_OK |
953 | 953 |
954 | 954 |
955 } } // v8::internal | 955 } } // v8::internal |
OLD | NEW |