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

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

Issue 2278973002: [modules] Rename ModuleDescriptor::ModuleEntry to ModuleDescriptor::Entry. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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 | « no previous file | src/ast/modules.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 #ifndef V8_AST_MODULES_H_ 5 #ifndef V8_AST_MODULES_H_
6 #define V8_AST_MODULES_H_ 6 #define V8_AST_MODULES_H_
7 7
8 #include "src/parsing/scanner.h" // Only for Scanner::Location. 8 #include "src/parsing/scanner.h" // Only for Scanner::Location.
9 #include "src/pending-compilation-error-handler.h" 9 #include "src/pending-compilation-error-handler.h"
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // export * from "foo.js"; 63 // export * from "foo.js";
64 void AddStarExport( 64 void AddStarExport(
65 const AstRawString* module_request, const Scanner::Location loc, 65 const AstRawString* module_request, const Scanner::Location loc,
66 Zone* zone); 66 Zone* zone);
67 67
68 // Check if module is well-formed and report error if not. 68 // Check if module is well-formed and report error if not.
69 // Also canonicalize indirect exports. 69 // Also canonicalize indirect exports.
70 bool Validate(ModuleScope* module_scope, 70 bool Validate(ModuleScope* module_scope,
71 PendingCompilationErrorHandler* error_handler, Zone* zone); 71 PendingCompilationErrorHandler* error_handler, Zone* zone);
72 72
73 struct ModuleEntry : public ZoneObject { 73 struct Entry : public ZoneObject {
74 const Scanner::Location location; 74 const Scanner::Location location;
75 const AstRawString* export_name; 75 const AstRawString* export_name;
76 const AstRawString* local_name; 76 const AstRawString* local_name;
77 const AstRawString* import_name; 77 const AstRawString* import_name;
78 const AstRawString* module_request; 78 const AstRawString* module_request;
79 79
80 explicit ModuleEntry(Scanner::Location loc) 80 explicit Entry(Scanner::Location loc)
81 : location(loc), 81 : location(loc),
82 export_name(nullptr), 82 export_name(nullptr),
83 local_name(nullptr), 83 local_name(nullptr),
84 import_name(nullptr), 84 import_name(nullptr),
85 module_request(nullptr) {} 85 module_request(nullptr) {}
86 }; 86 };
87 87
88 // Empty imports and namespace imports. 88 // Empty imports and namespace imports.
89 const ZoneList<const ModuleEntry*>& special_imports() const { 89 const ZoneList<const Entry*>& special_imports() const {
90 return special_imports_; 90 return special_imports_;
91 } 91 }
92 92
93 // All the remaining imports, indexed by local name. 93 // All the remaining imports, indexed by local name.
94 const ZoneMap<const AstRawString*, const ModuleEntry*>& regular_imports() 94 const ZoneMap<const AstRawString*, const Entry*>& regular_imports() const {
95 const {
96 return regular_imports_; 95 return regular_imports_;
97 } 96 }
98 97
99 // Star exports and explicitly indirect exports. 98 // Star exports and explicitly indirect exports.
100 const ZoneList<const ModuleEntry*>& special_exports() const { 99 const ZoneList<const Entry*>& special_exports() const {
101 return special_exports_; 100 return special_exports_;
102 } 101 }
103 102
104 // All the remaining exports, indexed by local name. 103 // All the remaining exports, indexed by local name.
105 const ZoneMultimap<const AstRawString*, ModuleEntry*>& regular_exports() 104 const ZoneMultimap<const AstRawString*, Entry*>& regular_exports() const {
106 const {
107 return regular_exports_; 105 return regular_exports_;
108 } 106 }
109 107
110 private: 108 private:
111 // TODO(neis): Use STL datastructure instead of ZoneList? 109 // TODO(neis): Use STL datastructure instead of ZoneList?
112 ZoneList<const ModuleEntry*> special_exports_; 110 ZoneList<const Entry*> special_exports_;
113 ZoneList<const ModuleEntry*> special_imports_; 111 ZoneList<const Entry*> special_imports_;
114 ZoneMultimap<const AstRawString*, ModuleEntry*> regular_exports_; 112 ZoneMultimap<const AstRawString*, Entry*> regular_exports_;
115 ZoneMap<const AstRawString*, const ModuleEntry*> regular_imports_; 113 ZoneMap<const AstRawString*, const Entry*> regular_imports_;
116 114
117 // If there are multiple export entries with the same export name, return one 115 // If there are multiple export entries with the same export name, return one
118 // of them. Otherwise return nullptr. 116 // of them. Otherwise return nullptr.
119 const ModuleEntry* FindDuplicateExport(Zone* zone) const; 117 const Entry* FindDuplicateExport(Zone* zone) const;
120 118
121 // Find any implicitly indirect exports and make them explicit. 119 // Find any implicitly indirect exports and make them explicit.
122 // 120 //
123 // An explicitly indirect export is an export entry arising from an export 121 // An explicitly indirect export is an export entry arising from an export
124 // statement of the following form: 122 // statement of the following form:
125 // export {a as c} from "X"; 123 // export {a as c} from "X";
126 // An implicitly indirect export corresponds to 124 // An implicitly indirect export corresponds to
127 // export {b as c}; 125 // export {b as c};
128 // in the presence of an import statement of the form 126 // in the presence of an import statement of the form
129 // import {a as b} from "X"; 127 // import {a as b} from "X";
130 // This function finds such implicitly indirect export entries and rewrites 128 // This function finds such implicitly indirect export entries and rewrites
131 // them by filling in the import name and module request, as well as nulling 129 // them by filling in the import name and module request, as well as nulling
132 // out the local name. Effectively, it turns 130 // out the local name. Effectively, it turns
133 // import {a as b} from "X"; export {b as c}; 131 // import {a as b} from "X"; export {b as c};
134 // into: 132 // into:
135 // import {a as b} from "X"; export {a as c} from "X"; 133 // import {a as b} from "X"; export {a as c} from "X";
136 // (The import entry is never deleted.) 134 // (The import entry is never deleted.)
137 void MakeIndirectExportsExplicit(Zone* zone); 135 void MakeIndirectExportsExplicit(Zone* zone);
138 }; 136 };
139 137
140 } // namespace internal 138 } // namespace internal
141 } // namespace v8 139 } // namespace v8
142 140
143 #endif // V8_AST_MODULES_H_ 141 #endif // V8_AST_MODULES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/modules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698