Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: src/parsing/parser.cc

Issue 2372373002: Remove getters that duplicate FunctionKind in SharedFunctionInfo and ParseInfo (Closed)
Patch Set: Remove SharedFunctionInfo::is_resumable and FunctionState stuff Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parse-info.cc ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 // Parse the function literal. 933 // Parse the function literal.
934 Scope* outer = original_scope_; 934 Scope* outer = original_scope_;
935 DeclarationScope* outer_function = outer->GetClosureScope(); 935 DeclarationScope* outer_function = outer->GetClosureScope();
936 DCHECK(outer); 936 DCHECK(outer);
937 FunctionState function_state(&function_state_, &scope_state_, 937 FunctionState function_state(&function_state_, &scope_state_,
938 outer_function); 938 outer_function);
939 BlockState block_state(&scope_state_, outer); 939 BlockState block_state(&scope_state_, outer);
940 DCHECK(is_sloppy(outer->language_mode()) || 940 DCHECK(is_sloppy(outer->language_mode()) ||
941 is_strict(info->language_mode())); 941 is_strict(info->language_mode()));
942 FunctionLiteral::FunctionType function_type = ComputeFunctionType(info); 942 FunctionLiteral::FunctionType function_type = ComputeFunctionType(info);
943 FunctionKind kind = info->function_kind();
943 bool ok = true; 944 bool ok = true;
944 945
945 if (info->is_arrow()) { 946 if (IsArrowFunction(kind)) {
946 bool is_async = allow_harmony_async_await() && info->is_async(); 947 if (allow_harmony_async_await() && IsAsyncFunction(kind)) {
947 if (is_async) {
948 DCHECK(!scanner()->HasAnyLineTerminatorAfterNext()); 948 DCHECK(!scanner()->HasAnyLineTerminatorAfterNext());
949 if (!Check(Token::ASYNC)) { 949 if (!Check(Token::ASYNC)) {
950 CHECK(stack_overflow()); 950 CHECK(stack_overflow());
951 return nullptr; 951 return nullptr;
952 } 952 }
953 if (!(peek_any_identifier() || peek() == Token::LPAREN)) { 953 if (!(peek_any_identifier() || peek() == Token::LPAREN)) {
954 CHECK(stack_overflow()); 954 CHECK(stack_overflow());
955 return nullptr; 955 return nullptr;
956 } 956 }
957 } 957 }
958 958
959 // TODO(adamk): We should construct this scope from the ScopeInfo. 959 // TODO(adamk): We should construct this scope from the ScopeInfo.
960 FunctionKind arrow_kind = is_async ? kAsyncArrowFunction : kArrowFunction; 960 DeclarationScope* scope = NewFunctionScope(kind);
961 DeclarationScope* scope = NewFunctionScope(arrow_kind);
962 961
963 // These two bits only need to be explicitly set because we're 962 // These two bits only need to be explicitly set because we're
964 // not passing the ScopeInfo to the Scope constructor. 963 // not passing the ScopeInfo to the Scope constructor.
965 // TODO(adamk): Remove these calls once the above NewScope call 964 // TODO(adamk): Remove these calls once the above NewScope call
966 // passes the ScopeInfo. 965 // passes the ScopeInfo.
967 if (info->calls_eval()) { 966 if (info->calls_eval()) {
968 scope->RecordEvalCall(); 967 scope->RecordEvalCall();
969 } 968 }
970 SetLanguageMode(scope, info->language_mode()); 969 SetLanguageMode(scope, info->language_mode());
971 970
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 if (scanner()->location().end_pos == info->end_position()) { 1003 if (scanner()->location().end_pos == info->end_position()) {
1005 // The pre-parser saw an arrow function here, so the full parser 1004 // The pre-parser saw an arrow function here, so the full parser
1006 // must produce a FunctionLiteral. 1005 // must produce a FunctionLiteral.
1007 DCHECK(expression->IsFunctionLiteral()); 1006 DCHECK(expression->IsFunctionLiteral());
1008 result = expression->AsFunctionLiteral(); 1007 result = expression->AsFunctionLiteral();
1009 } else { 1008 } else {
1010 ok = false; 1009 ok = false;
1011 } 1010 }
1012 } 1011 }
1013 } 1012 }
1014 } else if (info->is_default_constructor()) { 1013 } else if (IsDefaultConstructor(kind)) {
1015 DCHECK_EQ(scope(), outer); 1014 DCHECK_EQ(scope(), outer);
1016 bool is_subclass_constructor = 1015 bool is_subclass_constructor = IsSubclassConstructor(kind);
1017 IsSubclassConstructor(info->function_kind());
1018 result = DefaultConstructor( 1016 result = DefaultConstructor(
1019 raw_name, is_subclass_constructor, info->requires_class_field_init(), 1017 raw_name, is_subclass_constructor, info->requires_class_field_init(),
1020 info->start_position(), info->end_position(), info->language_mode()); 1018 info->start_position(), info->end_position(), info->language_mode());
1021 if (!is_subclass_constructor && info->requires_class_field_init()) { 1019 if (!is_subclass_constructor && info->requires_class_field_init()) {
1022 result = InsertClassFieldInitializer(result); 1020 result = InsertClassFieldInitializer(result);
1023 } 1021 }
1024 } else if (info->is_class_field_initializer()) { 1022 } else if (info->is_class_field_initializer()) {
1025 Handle<SharedFunctionInfo> shared_info = info->shared_info(); 1023 Handle<SharedFunctionInfo> shared_info = info->shared_info();
1026 DCHECK(!shared_info.is_null()); 1024 DCHECK(!shared_info.is_null());
1027 if (shared_info->length() == 0) { 1025 if (shared_info->length() == 0) {
1028 result = ParseClassFieldForInitializer( 1026 result = ParseClassFieldForInitializer(
1029 info->start_position() != info->end_position(), &ok); 1027 info->start_position() != info->end_position(), &ok);
1030 } else { 1028 } else {
1031 result = SynthesizeClassFieldInitializer(shared_info->length()); 1029 result = SynthesizeClassFieldInitializer(shared_info->length());
1032 } 1030 }
1033 } else { 1031 } else {
1034 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(), 1032 result = ParseFunctionLiteral(
1035 kSkipFunctionNameCheck, 1033 raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind,
1036 info->function_kind(), kNoSourcePosition, 1034 kNoSourcePosition, function_type, info->language_mode(), &ok);
1037 function_type, info->language_mode(), &ok);
1038 if (info->requires_class_field_init()) { 1035 if (info->requires_class_field_init()) {
1039 result = InsertClassFieldInitializer(result); 1036 result = InsertClassFieldInitializer(result);
1040 } 1037 }
1041 } 1038 }
1042 // Make sure the results agree. 1039 // Make sure the results agree.
1043 DCHECK(ok == (result != nullptr)); 1040 DCHECK(ok == (result != nullptr));
1044 } 1041 }
1045 1042
1046 // Make sure the target stack is empty. 1043 // Make sure the target stack is empty.
1047 DCHECK_NULL(target_stack_); 1044 DCHECK_NULL(target_stack_);
(...skipping 4514 matching lines...) Expand 10 before | Expand all | Expand 10 after
5562 5559
5563 return final_loop; 5560 return final_loop;
5564 } 5561 }
5565 5562
5566 #undef CHECK_OK 5563 #undef CHECK_OK
5567 #undef CHECK_OK_VOID 5564 #undef CHECK_OK_VOID
5568 #undef CHECK_FAILED 5565 #undef CHECK_FAILED
5569 5566
5570 } // namespace internal 5567 } // namespace internal
5571 } // namespace v8 5568 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parse-info.cc ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698