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 FunctionState top_state(&function_state_, &scope_, &top_scope, NULL, | 119 PreParserFactory top_factory(NULL, NULL, NULL); |
120 this->ast_value_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 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL, | 123 PreParserFactory function_factory(NULL, NULL, NULL); |
124 this->ast_value_factory()); | 124 FunctionState function_state(&function_state_, &scope_, &function_scope, |
| 125 &function_factory); |
125 function_state.set_is_generator(is_generator); | 126 function_state.set_is_generator(is_generator); |
126 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 127 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
127 bool ok = true; | 128 bool ok = true; |
128 int start_position = peek_position(); | 129 int start_position = peek_position(); |
129 ParseLazyFunctionLiteralBody(&ok); | 130 ParseLazyFunctionLiteralBody(&ok); |
130 if (stack_overflow()) return kPreParseStackOverflow; | 131 if (stack_overflow()) return kPreParseStackOverflow; |
131 if (!ok) { | 132 if (!ok) { |
132 ReportUnexpectedToken(scanner()->current_token()); | 133 ReportUnexpectedToken(scanner()->current_token()); |
133 } else { | 134 } else { |
134 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 135 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 Identifier function_name, Scanner::Location function_name_location, | 818 Identifier function_name, Scanner::Location function_name_location, |
818 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 819 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
819 FunctionLiteral::FunctionType function_type, | 820 FunctionLiteral::FunctionType function_type, |
820 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 821 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
821 // Function :: | 822 // Function :: |
822 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 823 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
823 | 824 |
824 // Parse function body. | 825 // Parse function body. |
825 ScopeType outer_scope_type = scope_->type(); | 826 ScopeType outer_scope_type = scope_->type(); |
826 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 827 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
827 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL, | 828 PreParserFactory factory(NULL, NULL, NULL); |
828 this->ast_value_factory()); | 829 FunctionState function_state(&function_state_, &scope_, &function_scope, |
| 830 &factory); |
829 function_state.set_is_generator(IsGeneratorFunction(kind)); | 831 function_state.set_is_generator(IsGeneratorFunction(kind)); |
830 // FormalParameterList :: | 832 // FormalParameterList :: |
831 // '(' (Identifier)*[','] ')' | 833 // '(' (Identifier)*[','] ')' |
832 Expect(Token::LPAREN, CHECK_OK); | 834 Expect(Token::LPAREN, CHECK_OK); |
833 int start_position = position(); | 835 int start_position = position(); |
834 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 836 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
835 // 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 |
836 // errors for parameter names or duplicates. However, we remember the | 838 // errors for parameter names or duplicates. However, we remember the |
837 // locations of these errors if they occur and produce the errors later. | 839 // locations of these errors if they occur and produce the errors later. |
838 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); | 840 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 946 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
945 ParseArguments(ok); | 947 ParseArguments(ok); |
946 | 948 |
947 return Expression::Default(); | 949 return Expression::Default(); |
948 } | 950 } |
949 | 951 |
950 #undef CHECK_OK | 952 #undef CHECK_OK |
951 | 953 |
952 | 954 |
953 } } // v8::internal | 955 } } // v8::internal |
OLD | NEW |