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

Side by Side Diff: src/ast/modules.cc

Issue 2328283002: Revert of [modules] Basic support of exports (Closed)
Patch Set: Created 4 years, 3 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/ast/modules.h ('k') | src/ast/scopeinfo.cc » ('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/ast/modules.h" 5 #include "src/ast/modules.h"
6 #include "src/ast/ast-value-factory.h" 6 #include "src/ast/ast-value-factory.h"
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 const AstRawString* FromStringOrUndefined(Isolate* isolate, 81 const AstRawString* FromStringOrUndefined(Isolate* isolate,
82 AstValueFactory* avfactory, 82 AstValueFactory* avfactory,
83 Handle<Object> object) { 83 Handle<Object> object) {
84 if (object->IsUndefined(isolate)) return nullptr; 84 if (object->IsUndefined(isolate)) return nullptr;
85 return avfactory->GetString(Handle<String>::cast(object)); 85 return avfactory->GetString(Handle<String>::cast(object));
86 } 86 }
87 87
88 } // namespace 88 } // namespace
89 89
90 Handle<ModuleInfoEntry> ModuleDescriptor::Entry::Serialize( 90 Handle<FixedArray> ModuleDescriptor::Entry::Serialize(Isolate* isolate) const {
91 Isolate* isolate) const { 91 Handle<FixedArray> result = isolate->factory()->NewFixedArray(4);
92 return ModuleInfoEntry::New(isolate, 92 result->set(0, *ToStringOrUndefined(isolate, export_name));
93 ToStringOrUndefined(isolate, export_name), 93 result->set(1, *ToStringOrUndefined(isolate, local_name));
94 ToStringOrUndefined(isolate, local_name), 94 result->set(2, *ToStringOrUndefined(isolate, import_name));
95 ToStringOrUndefined(isolate, import_name), 95 result->set(3, *ToStringOrUndefined(isolate, module_request));
96 ToStringOrUndefined(isolate, module_request)); 96 return result;
97 } 97 }
98 98
99 ModuleDescriptor::Entry* ModuleDescriptor::Entry::Deserialize( 99 ModuleDescriptor::Entry* ModuleDescriptor::Entry::Deserialize(
100 Isolate* isolate, AstValueFactory* avfactory, 100 Isolate* isolate, AstValueFactory* avfactory, Handle<FixedArray> data) {
101 Handle<ModuleInfoEntry> entry) { 101 Entry* entry = new (avfactory->zone()) Entry(Scanner::Location::invalid());
102 Entry* result = new (avfactory->zone()) Entry(Scanner::Location::invalid()); 102 entry->export_name =
103 result->export_name = FromStringOrUndefined( 103 FromStringOrUndefined(isolate, avfactory, handle(data->get(0), isolate));
104 isolate, avfactory, handle(entry->export_name(), isolate)); 104 entry->local_name =
105 result->local_name = FromStringOrUndefined( 105 FromStringOrUndefined(isolate, avfactory, handle(data->get(1), isolate));
106 isolate, avfactory, handle(entry->local_name(), isolate)); 106 entry->import_name =
107 result->import_name = FromStringOrUndefined( 107 FromStringOrUndefined(isolate, avfactory, handle(data->get(2), isolate));
108 isolate, avfactory, handle(entry->import_name(), isolate)); 108 entry->module_request =
109 result->module_request = FromStringOrUndefined( 109 FromStringOrUndefined(isolate, avfactory, handle(data->get(3), isolate));
110 isolate, avfactory, handle(entry->module_request(), isolate)); 110 return entry;
111 return result;
112 } 111 }
113 112
114 void ModuleDescriptor::MakeIndirectExportsExplicit(Zone* zone) { 113 void ModuleDescriptor::MakeIndirectExportsExplicit(Zone* zone) {
115 for (auto it = regular_exports_.begin(); it != regular_exports_.end();) { 114 for (auto it = regular_exports_.begin(); it != regular_exports_.end();) {
116 Entry* entry = it->second; 115 Entry* entry = it->second;
117 DCHECK_NOT_NULL(entry->local_name); 116 DCHECK_NOT_NULL(entry->local_name);
118 auto import = regular_imports_.find(entry->local_name); 117 auto import = regular_imports_.find(entry->local_name);
119 if (import != regular_imports_.end()) { 118 if (import != regular_imports_.end()) {
120 // Found an indirect export. Patch export entry and move it from regular 119 // Found an indirect export. Patch export entry and move it from regular
121 // to special. 120 // to special.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return false; 176 return false;
178 } 177 }
179 } 178 }
180 179
181 MakeIndirectExportsExplicit(zone); 180 MakeIndirectExportsExplicit(zone);
182 return true; 181 return true;
183 } 182 }
184 183
185 } // namespace internal 184 } // namespace internal
186 } // namespace v8 185 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.h ('k') | src/ast/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698