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 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_, GLOBAL_SCOPE); | 108 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
109 PreParserFactory top_factory(NULL, NULL, NULL); | 109 PreParserFactory top_factory(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, NULL, NULL); | 113 PreParserFactory function_factory(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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 Identifier function_name, Scanner::Location function_name_location, | 808 Identifier function_name, Scanner::Location function_name_location, |
809 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 809 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
810 FunctionLiteral::FunctionType function_type, | 810 FunctionLiteral::FunctionType function_type, |
811 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 811 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
812 // Function :: | 812 // Function :: |
813 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 813 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
814 | 814 |
815 // Parse function body. | 815 // Parse function body. |
816 ScopeType outer_scope_type = scope_->type(); | 816 ScopeType outer_scope_type = scope_->type(); |
817 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 817 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
818 PreParserFactory factory(NULL, NULL, NULL); | 818 PreParserFactory factory(NULL); |
819 FunctionState function_state(&function_state_, &scope_, &function_scope, | 819 FunctionState function_state(&function_state_, &scope_, &function_scope, |
820 &factory); | 820 &factory); |
821 function_state.set_is_generator(IsGeneratorFunction(kind)); | 821 function_state.set_is_generator(IsGeneratorFunction(kind)); |
822 // FormalParameterList :: | 822 // FormalParameterList :: |
823 // '(' (Identifier)*[','] ')' | 823 // '(' (Identifier)*[','] ')' |
824 Expect(Token::LPAREN, CHECK_OK); | 824 Expect(Token::LPAREN, CHECK_OK); |
825 int start_position = position(); | 825 int start_position = position(); |
826 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 826 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
827 // We don't yet know if the function will be strict, so we cannot yet produce | 827 // We don't yet know if the function will be strict, so we cannot yet produce |
828 // errors for parameter names or duplicates. However, we remember the | 828 // errors for parameter names or duplicates. However, we remember the |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 936 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
937 ParseArguments(ok); | 937 ParseArguments(ok); |
938 | 938 |
939 return Expression::Default(); | 939 return Expression::Default(); |
940 } | 940 } |
941 | 941 |
942 #undef CHECK_OK | 942 #undef CHECK_OK |
943 | 943 |
944 | 944 |
945 } } // v8::internal | 945 } } // v8::internal |
OLD | NEW |