V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
module-inl.h
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_OBJECTS_MODULE_INL_H_
6 #define V8_OBJECTS_MODULE_INL_H_
7 
8 #include "src/objects/module.h"
9 
10 #include "src/objects-inl.h" // Needed for write barriers
11 #include "src/objects/scope-info.h"
12 
13 // Has to be the last include (doesn't have include guards):
14 #include "src/objects/object-macros.h"
15 
16 namespace v8 {
17 namespace internal {
18 
19 CAST_ACCESSOR(Module)
20 ACCESSORS(Module, code, Object, kCodeOffset)
21 ACCESSORS2(Module, exports, ObjectHashTable, kExportsOffset)
22 ACCESSORS2(Module, regular_exports, FixedArray, kRegularExportsOffset)
23 ACCESSORS2(Module, regular_imports, FixedArray, kRegularImportsOffset)
24 ACCESSORS(Module, module_namespace, HeapObject, kModuleNamespaceOffset)
25 ACCESSORS2(Module, requested_modules, FixedArray, kRequestedModulesOffset)
26 ACCESSORS(Module, script, Script, kScriptOffset)
27 ACCESSORS(Module, exception, Object, kExceptionOffset)
28 ACCESSORS(Module, import_meta, Object, kImportMetaOffset)
29 SMI_ACCESSORS(Module, status, kStatusOffset)
30 SMI_ACCESSORS(Module, dfs_index, kDfsIndexOffset)
31 SMI_ACCESSORS(Module, dfs_ancestor_index, kDfsAncestorIndexOffset)
32 SMI_ACCESSORS(Module, hash, kHashOffset)
33 
34 ModuleInfo Module::info() const {
35  return (status() >= kEvaluating)
36  ? ModuleInfo::cast(code())
37  : GetSharedFunctionInfo()->scope_info()->ModuleDescriptorInfo();
38 }
39 
40 CAST_ACCESSOR(JSModuleNamespace)
41 ACCESSORS(JSModuleNamespace, module, Module, kModuleOffset)
42 
43 CAST_ACCESSOR(ModuleInfoEntry)
44 ACCESSORS(ModuleInfoEntry, export_name, Object, kExportNameOffset)
45 ACCESSORS(ModuleInfoEntry, local_name, Object, kLocalNameOffset)
46 ACCESSORS(ModuleInfoEntry, import_name, Object, kImportNameOffset)
47 SMI_ACCESSORS(ModuleInfoEntry, module_request, kModuleRequestOffset)
48 SMI_ACCESSORS(ModuleInfoEntry, cell_index, kCellIndexOffset)
49 SMI_ACCESSORS(ModuleInfoEntry, beg_pos, kBegPosOffset)
50 SMI_ACCESSORS(ModuleInfoEntry, end_pos, kEndPosOffset)
51 
52 OBJECT_CONSTRUCTORS_IMPL(ModuleInfo, FixedArray)
53 CAST_ACCESSOR2(ModuleInfo)
54 
55 FixedArray ModuleInfo::module_requests() const {
56  return FixedArray::cast(get(kModuleRequestsIndex));
57 }
58 
59 FixedArray ModuleInfo::special_exports() const {
60  return FixedArray::cast(get(kSpecialExportsIndex));
61 }
62 
63 FixedArray ModuleInfo::regular_exports() const {
64  return FixedArray::cast(get(kRegularExportsIndex));
65 }
66 
67 FixedArray ModuleInfo::regular_imports() const {
68  return FixedArray::cast(get(kRegularImportsIndex));
69 }
70 
71 FixedArray ModuleInfo::namespace_imports() const {
72  return FixedArray::cast(get(kNamespaceImportsIndex));
73 }
74 
75 FixedArray ModuleInfo::module_request_positions() const {
76  return FixedArray::cast(get(kModuleRequestPositionsIndex));
77 }
78 
79 #ifdef DEBUG
80 bool ModuleInfo::Equals(ModuleInfo other) const {
81  return regular_exports() == other->regular_exports() &&
82  regular_imports() == other->regular_imports() &&
83  special_exports() == other->special_exports() &&
84  namespace_imports() == other->namespace_imports() &&
85  module_requests() == other->module_requests() &&
86  module_request_positions() == other->module_request_positions();
87 }
88 #endif
89 
90 } // namespace internal
91 } // namespace v8
92 
93 #include "src/objects/object-macros-undef.h"
94 
95 #endif // V8_OBJECTS_MODULE_INL_H_
Definition: libplatform.h:13