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

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

Issue 2224333002: [modules] Split imports into regular and special, store regular ones in a map. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 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.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
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 : exports_(1, zone), imports_(1, zone) {} 22 : exports_(1, zone), special_imports_(1, zone), regular_imports_(zone) {}
23 23
24 // import x from "foo.js"; 24 // import x from "foo.js";
25 // import {x} from "foo.js"; 25 // import {x} from "foo.js";
26 // import {x as y} from "foo.js"; 26 // import {x as y} from "foo.js";
27 void AddImport( 27 void AddImport(
28 const AstRawString* import_name, const AstRawString* local_name, 28 const AstRawString* import_name, const AstRawString* local_name,
29 const AstRawString* module_request, const Scanner::Location loc, 29 const AstRawString* module_request, const Scanner::Location loc,
30 Zone* zone); 30 Zone* zone);
31 31
32 // import * as x from "foo.js"; 32 // import * as x from "foo.js";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const AstRawString* module_request; 75 const AstRawString* module_request;
76 76
77 explicit ModuleEntry(Scanner::Location loc) 77 explicit ModuleEntry(Scanner::Location loc)
78 : location(loc), 78 : location(loc),
79 export_name(nullptr), 79 export_name(nullptr),
80 local_name(nullptr), 80 local_name(nullptr),
81 import_name(nullptr), 81 import_name(nullptr),
82 module_request(nullptr) {} 82 module_request(nullptr) {}
83 }; 83 };
84 84
85 const ZoneList<const ModuleEntry*>& exports() { return exports_; } 85 const ZoneList<const ModuleEntry*>& exports() const { return exports_; }
86 const ZoneList<const ModuleEntry*>& imports() { return imports_; } 86
87 // Empty imports and namespace imports.
88 const ZoneList<const ModuleEntry*>& special_imports() const {
89 return special_imports_;
90 }
91
92 // All the remaining imports, indexed by local name.
93 const ZoneMap<const AstRawString*, const ModuleEntry*>& regular_imports()
94 const {
95 return regular_imports_;
96 }
87 97
88 private: 98 private:
89 ZoneList<const ModuleEntry*> exports_; 99 ZoneList<const ModuleEntry*> exports_;
90 ZoneList<const ModuleEntry*> imports_; 100 ZoneList<const ModuleEntry*> special_imports_;
101 ZoneMap<const AstRawString*, const ModuleEntry*> regular_imports_;
91 }; 102 };
92 103
93 } // namespace internal 104 } // namespace internal
94 } // namespace v8 105 } // namespace v8
95 106
96 #endif // V8_AST_MODULES_H_ 107 #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