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

Unified Diff: src/ast/modules.h

Issue 2277273002: [modules] Partial support for (de-)serializing module descriptor entries. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Depend on my other CL. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast/modules.cc » ('j') | src/ast/modules.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/modules.h
diff --git a/src/ast/modules.h b/src/ast/modules.h
index 5b6a86cc2de613db45073d74440ab580c038ad91..7e78ac2bad9927332d1ee64a5cc5dfa252d16c0d 100644
--- a/src/ast/modules.h
+++ b/src/ast/modules.h
@@ -24,6 +24,9 @@ class ModuleDescriptor : public ZoneObject {
regular_exports_(zone),
regular_imports_(zone) {}
+ // The following Add* methods are high-level convenience functions for use by
+ // the parser.
+
// import x from "foo.js";
// import {x} from "foo.js";
// import {x as y} from "foo.js";
@@ -83,6 +86,10 @@ class ModuleDescriptor : public ZoneObject {
local_name(nullptr),
import_name(nullptr),
module_request(nullptr) {}
+
+ Handle<FixedArray> Serialize(Isolate* isolate) const;
+ static Entry* Deserialize(Isolate* isolate, AstValueFactory* avfactory,
+ Handle<FixedArray> data);
};
// Empty imports and namespace imports.
@@ -105,6 +112,34 @@ class ModuleDescriptor : public ZoneObject {
return regular_exports_;
}
+ void AddRegularExport(Entry* entry) {
adamk 2016/08/25 15:56:20 Can these methods be private?
neis 2016/08/26 07:28:03 No, they are used by the ModuleScope constructor w
+ DCHECK_NOT_NULL(entry->export_name);
+ DCHECK_NOT_NULL(entry->local_name);
+ DCHECK_NULL(entry->import_name);
+ regular_exports_.insert(std::make_pair(entry->local_name, entry));
+ }
+
+ void AddSpecialExport(const Entry* entry, Zone* zone) {
+ DCHECK_NOT_NULL(entry->module_request);
+ special_exports_.Add(entry, zone);
+ }
+
+ void AddRegularImport(const Entry* entry) {
+ DCHECK_NOT_NULL(entry->import_name);
+ DCHECK_NOT_NULL(entry->local_name);
+ DCHECK_NOT_NULL(entry->module_request);
+ DCHECK_NULL(entry->export_name);
+ regular_imports_.insert(std::make_pair(entry->local_name, entry));
+ // We don't care if there's already an entry for this local name, as in that
+ // case we will report an error when declaring the variable.
+ }
+
+ void AddSpecialImport(const Entry* entry, Zone* zone) {
+ DCHECK_NOT_NULL(entry->module_request);
+ DCHECK_NULL(entry->export_name);
+ special_imports_.Add(entry, zone);
+ }
+
private:
// TODO(neis): Use STL datastructure instead of ZoneList?
ZoneList<const Entry*> special_exports_;
« no previous file with comments | « no previous file | src/ast/modules.cc » ('j') | src/ast/modules.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698