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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 name, function_name_location, name_is_strict_reserved, is_generator, | 103 name, function_name_location, name_is_strict_reserved, is_generator, |
104 function_token_position, type, arity_restriction, ok); | 104 function_token_position, type, arity_restriction, ok); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 108 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
109 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { | 109 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
110 log_ = log; | 110 log_ = log; |
111 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 111 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
112 PreParserScope top_scope(scope_, GLOBAL_SCOPE); | 112 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
113 FunctionState top_state(&function_state_, &scope_, &top_scope); | 113 FunctionState top_state(&function_state_, &scope_, &top_scope, NULL, |
| 114 this->ast_value_factory()); |
114 scope_->SetStrictMode(strict_mode); | 115 scope_->SetStrictMode(strict_mode); |
115 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 116 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
116 FunctionState function_state(&function_state_, &scope_, &function_scope); | 117 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL, |
| 118 this->ast_value_factory()); |
117 function_state.set_is_generator(is_generator); | 119 function_state.set_is_generator(is_generator); |
118 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); | 120 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); |
119 bool ok = true; | 121 bool ok = true; |
120 int start_position = peek_position(); | 122 int start_position = peek_position(); |
121 ParseLazyFunctionLiteralBody(&ok); | 123 ParseLazyFunctionLiteralBody(&ok); |
122 if (stack_overflow()) return kPreParseStackOverflow; | 124 if (stack_overflow()) return kPreParseStackOverflow; |
123 if (!ok) { | 125 if (!ok) { |
124 ReportUnexpectedToken(scanner()->current_token()); | 126 ReportUnexpectedToken(scanner()->current_token()); |
125 } else { | 127 } else { |
126 ASSERT_EQ(Token::RBRACE, scanner()->peek()); | 128 ASSERT_EQ(Token::RBRACE, scanner()->peek()); |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 int function_token_pos, | 802 int function_token_pos, |
801 FunctionLiteral::FunctionType function_type, | 803 FunctionLiteral::FunctionType function_type, |
802 FunctionLiteral::ArityRestriction arity_restriction, | 804 FunctionLiteral::ArityRestriction arity_restriction, |
803 bool* ok) { | 805 bool* ok) { |
804 // Function :: | 806 // Function :: |
805 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 807 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
806 | 808 |
807 // Parse function body. | 809 // Parse function body. |
808 ScopeType outer_scope_type = scope_->type(); | 810 ScopeType outer_scope_type = scope_->type(); |
809 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 811 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
810 FunctionState function_state(&function_state_, &scope_, &function_scope); | 812 FunctionState function_state(&function_state_, &scope_, &function_scope, NULL, |
| 813 this->ast_value_factory()); |
811 function_state.set_is_generator(is_generator); | 814 function_state.set_is_generator(is_generator); |
812 // FormalParameterList :: | 815 // FormalParameterList :: |
813 // '(' (Identifier)*[','] ')' | 816 // '(' (Identifier)*[','] ')' |
814 Expect(Token::LPAREN, CHECK_OK); | 817 Expect(Token::LPAREN, CHECK_OK); |
815 int start_position = position(); | 818 int start_position = position(); |
816 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 819 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
817 // We don't yet know if the function will be strict, so we cannot yet produce | 820 // We don't yet know if the function will be strict, so we cannot yet produce |
818 // errors for parameter names or duplicates. However, we remember the | 821 // errors for parameter names or duplicates. However, we remember the |
819 // locations of these errors if they occur and produce the errors later. | 822 // locations of these errors if they occur and produce the errors later. |
820 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); | 823 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 928 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
926 ParseArguments(ok); | 929 ParseArguments(ok); |
927 | 930 |
928 return Expression::Default(); | 931 return Expression::Default(); |
929 } | 932 } |
930 | 933 |
931 #undef CHECK_OK | 934 #undef CHECK_OK |
932 | 935 |
933 | 936 |
934 } } // v8::internal | 937 } } // v8::internal |
OLD | NEW |