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

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

Issue 2302783002: [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
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"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 15
16 class AstRawString; 16 class AstRawString;
17 17 class ModuleInfoEntry;
18 18
19 class ModuleDescriptor : public ZoneObject { 19 class ModuleDescriptor : public ZoneObject {
20 public: 20 public:
21 explicit ModuleDescriptor(Zone* zone) 21 explicit ModuleDescriptor(Zone* zone)
22 : special_exports_(1, zone), 22 : special_exports_(1, zone),
23 special_imports_(1, zone), 23 special_imports_(1, zone),
24 regular_exports_(zone), 24 regular_exports_(zone),
25 regular_imports_(zone) {} 25 regular_imports_(zone) {}
26 26
27 // The following Add* methods are high-level convenience functions for use by 27 // The following Add* methods are high-level convenience functions for use by
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool Validate(ModuleScope* module_scope, 73 bool Validate(ModuleScope* module_scope,
74 PendingCompilationErrorHandler* error_handler, Zone* zone); 74 PendingCompilationErrorHandler* error_handler, Zone* zone);
75 75
76 struct Entry : public ZoneObject { 76 struct Entry : public ZoneObject {
77 const Scanner::Location location; 77 const Scanner::Location location;
78 const AstRawString* export_name; 78 const AstRawString* export_name;
79 const AstRawString* local_name; 79 const AstRawString* local_name;
80 const AstRawString* import_name; 80 const AstRawString* import_name;
81 const AstRawString* module_request; 81 const AstRawString* module_request;
82 82
83 // TODO(neis): Remove local_name component?
83 explicit Entry(Scanner::Location loc) 84 explicit Entry(Scanner::Location loc)
84 : location(loc), 85 : location(loc),
85 export_name(nullptr), 86 export_name(nullptr),
86 local_name(nullptr), 87 local_name(nullptr),
87 import_name(nullptr), 88 import_name(nullptr),
88 module_request(nullptr) {} 89 module_request(nullptr) {}
89 90
90 Handle<FixedArray> Serialize(Isolate* isolate) const; 91 // (De-)serialization support.
92 // Note that the location value is not preserved as it's only needed by the
93 // parser. (A Deserialize'd entry has an invalid location.)
94 Handle<ModuleInfoEntry> Serialize(Isolate* isolate) const;
91 static Entry* Deserialize(Isolate* isolate, AstValueFactory* avfactory, 95 static Entry* Deserialize(Isolate* isolate, AstValueFactory* avfactory,
92 Handle<FixedArray> data); 96 Handle<ModuleInfoEntry> entry);
93 }; 97 };
94 98
neis 2016/09/02 12:06:07 If we have Serialize and Deserialize here for entr
95 // Empty imports and namespace imports. 99 // Empty imports and namespace imports.
96 const ZoneList<const Entry*>& special_imports() const { 100 const ZoneList<const Entry*>& special_imports() const {
97 return special_imports_; 101 return special_imports_;
98 } 102 }
99 103
100 // All the remaining imports, indexed by local name. 104 // All the remaining imports, indexed by local name.
101 const ZoneMap<const AstRawString*, const Entry*>& regular_imports() const { 105 const ZoneMap<const AstRawString*, const Entry*>& regular_imports() const {
102 return regular_imports_; 106 return regular_imports_;
103 } 107 }
104 108
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // into: 171 // into:
168 // import {a as b} from "X"; export {a as c} from "X"; 172 // import {a as b} from "X"; export {a as c} from "X";
169 // (The import entry is never deleted.) 173 // (The import entry is never deleted.)
170 void MakeIndirectExportsExplicit(Zone* zone); 174 void MakeIndirectExportsExplicit(Zone* zone);
171 }; 175 };
172 176
173 } // namespace internal 177 } // namespace internal
174 } // namespace v8 178 } // namespace v8
175 179
176 #endif // V8_AST_MODULES_H_ 180 #endif // V8_AST_MODULES_H_
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/modules.cc » ('j') | src/interpreter/bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698