| 1 |
/* -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 |
| 2 |
* -*- */ |
| 3 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef vm_Modules_h |
| 8 |
#define vm_Modules_h |
| 9 |
|
| 10 |
#include "NamespaceImports.h" |
| 11 |
|
| 12 |
#include "builtin/ModuleObject.h" |
| 13 |
#include "js/AllocPolicy.h" |
| 14 |
#include "js/GCVector.h" |
| 15 |
#include "js/RootingAPI.h" |
| 16 |
|
| 17 |
struct JSContext; |
| 18 |
|
| 19 |
namespace js { |
| 20 |
|
| 21 |
using ModuleVector = GCVector<ModuleObject*, 0, SystemAllocPolicy>; |
| 22 |
|
| 23 |
// A struct with detailed error information when import/export failed. |
| 24 |
struct ModuleErrorInfo { |
| 25 |
ModuleErrorInfo(uint32_t lineNumber_, JS::ColumnNumberOneOrigin columnNumber_) |
| 26 |
: lineNumber(lineNumber_), columnNumber(columnNumber_) {} |
| 27 |
|
| 28 |
void setImportedModule(JSContext* cx, ModuleObject* importedModule); |
| 29 |
void setCircularImport(JSContext* cx, ModuleObject* importedModule); |
| 30 |
void setForAmbiguousImport(JSContext* cx, ModuleObject* importedModule, |
| 31 |
ModuleObject* module1, ModuleObject* module2); |
| 32 |
|
| 33 |
uint32_t lineNumber; |
| 34 |
JS::ColumnNumberOneOrigin columnNumber; |
| 35 |
|
| 36 |
// The filename of the imported module. |
| 37 |
const char* imported; |
| 38 |
|
| 39 |
// The filenames of the ambiguous entries. |
| 40 |
const char* entry1; |
| 41 |
const char* entry2; |
| 42 |
|
| 43 |
// A bool to indicate the error is a circular import when it's true. |
| 44 |
bool isCircular = false; |
| 45 |
}; |
| 46 |
|
| 47 |
ModuleNamespaceObject* GetOrCreateModuleNamespace(JSContext* cx, |
| 48 |
Handle<ModuleObject*> module); |
| 49 |
|
| 50 |
void AsyncModuleExecutionFulfilled(JSContext* cx, Handle<ModuleObject*> module); |
| 51 |
|
| 52 |
// This function recusively calls AsyncModuleExecutionRejected on async parent |
| 53 |
// modules. It returns false if the stack recusion limit is exceeded. |
| 54 |
bool AsyncModuleExecutionRejected(JSContext* cx, Handle<ModuleObject*> module, |
| 55 |
HandleValue error); |
| 56 |
|
| 57 |
} // namespace js |
| 58 |
|
| 59 |
#endif // vm_Modules_h |