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

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

Issue 2158913005: Introduce NewScriptScope that creates a top-level scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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 "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 DCHECK_NULL(scope_state_); 932 DCHECK_NULL(scope_state_);
933 DCHECK_NULL(target_stack_); 933 DCHECK_NULL(target_stack_);
934 934
935 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; 935 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY;
936 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; 936 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY;
937 937
938 FunctionLiteral* result = NULL; 938 FunctionLiteral* result = NULL;
939 { 939 {
940 // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native 940 // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native
941 // context, which will have the "this" binding for script scopes. 941 // context, which will have the "this" binding for script scopes.
942 Scope* scope = NewScope(nullptr, SCRIPT_SCOPE); 942 Scope* scope = NewScriptScope();
943 info->set_script_scope(scope); 943 info->set_script_scope(scope);
944 if (!info->context().is_null() && !info->context()->IsNativeContext()) { 944 if (!info->context().is_null() && !info->context()->IsNativeContext()) {
945 scope = Scope::DeserializeScopeChain(info->isolate(), zone(), 945 scope = Scope::DeserializeScopeChain(info->isolate(), zone(),
946 *info->context(), scope, 946 *info->context(), scope,
947 ast_value_factory()); 947 ast_value_factory());
948 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this 948 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this
949 // means the Parser cannot operate independent of the V8 heap. Tell the 949 // means the Parser cannot operate independent of the V8 heap. Tell the
950 // string table to internalize strings and values right after they're 950 // string table to internalize strings and values right after they're
951 // created. This kind of parsing can only be done in the main thread. 951 // created. This kind of parsing can only be done in the main thread.
952 DCHECK(parsing_on_main_thread_); 952 DCHECK(parsing_on_main_thread_);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 const AstRawString* raw_name = ast_value_factory()->GetString(name); 1096 const AstRawString* raw_name = ast_value_factory()->GetString(name);
1097 fni_->PushEnclosingName(raw_name); 1097 fni_->PushEnclosingName(raw_name);
1098 1098
1099 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 1099 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
1100 1100
1101 // Place holder for the result. 1101 // Place holder for the result.
1102 FunctionLiteral* result = nullptr; 1102 FunctionLiteral* result = nullptr;
1103 1103
1104 { 1104 {
1105 // Parse the function literal. 1105 // Parse the function literal.
1106 Scope* scope = NewScope(nullptr, SCRIPT_SCOPE); 1106 Scope* scope = NewScriptScope();
1107 info->set_script_scope(scope); 1107 info->set_script_scope(scope);
1108 if (!info->context().is_null()) { 1108 if (!info->context().is_null()) {
1109 // Ok to use Isolate here, since lazy function parsing is only done in the 1109 // Ok to use Isolate here, since lazy function parsing is only done in the
1110 // main thread. 1110 // main thread.
1111 DCHECK(parsing_on_main_thread_); 1111 DCHECK(parsing_on_main_thread_);
1112 scope = Scope::DeserializeScopeChain(isolate, zone(), *info->context(), 1112 scope = Scope::DeserializeScopeChain(isolate, zone(), *info->context(),
1113 scope, ast_value_factory()); 1113 scope, ast_value_factory());
1114 } 1114 }
1115 original_scope_ = scope; 1115 original_scope_ = scope;
1116 AstNodeFactory function_factory(ast_value_factory()); 1116 AstNodeFactory function_factory(ast_value_factory());
(...skipping 5958 matching lines...) Expand 10 before | Expand all | Expand 10 after
7075 node->Print(Isolate::Current()); 7075 node->Print(Isolate::Current());
7076 } 7076 }
7077 #endif // DEBUG 7077 #endif // DEBUG
7078 7078
7079 #undef CHECK_OK 7079 #undef CHECK_OK
7080 #undef CHECK_OK_VOID 7080 #undef CHECK_OK_VOID
7081 #undef CHECK_FAILED 7081 #undef CHECK_FAILED
7082 7082
7083 } // namespace internal 7083 } // namespace internal
7084 } // namespace v8 7084 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698