use of com.github.anba.es6draft.Module in project es6draft by anba.
the class SourceTextModuleRecord method instantiate.
/**
* 15.2.1.16.4 ModuleDeclarationInstantiation( ) Concrete Method
*/
@Override
public void instantiate() throws IOException, MalformedNameException, ResolutionException {
/* step 1 */
SourceTextModuleRecord module = this;
/* step 2 */
Realm realm = module.realm;
/* step 3 */
assert realm != null : "module is not linked";
/* step 4 */
Module code = module.scriptCode;
/* step 5 */
if (module.environment != null) {
return;
}
/* step 6 */
LexicalEnvironment<ModuleEnvironmentRecord> env = newModuleEnvironment(realm.getGlobalEnv());
/* step 7 */
module.environment = env;
/* step 8 */
for (String required : module.requestedModules) {
/* step 8.a (note) */
/* steps 8.b-c */
ModuleRecord requiredModule = HostResolveImportedModule(module, required);
/* steps 8.d-e */
requiredModule.instantiate();
}
/* steps 9-17 */
ExecutionContext context = newModuleDeclarationExecutionContext(realm, code);
code.getModuleBody().moduleDeclarationInstantiation(context, this, env);
module.instantiated = true;
}
use of com.github.anba.es6draft.Module in project es6draft by anba.
the class SourceTextModuleRecord method ModuleDeclarationEnvironmentSetup.
/**
* 15.2.1.16.4.2 ModuleDeclarationEnvironmentSetup( module )
*/
private static void ModuleDeclarationEnvironmentSetup(SourceTextModuleRecord module) throws IOException, ResolutionException, MalformedNameException {
/* step 3 */
Realm realm = module.realm;
/* step 4 */
assert realm != null : "module is not linked";
/* step 5 */
LexicalEnvironment<ModuleEnvironmentRecord> env = newModuleEnvironment(realm.getGlobalEnv());
/* step 6 */
module.environment = env;
/* steps 1-2, 7-14 (generated code) */
Module code = module.scriptCode;
ExecutionContext context = newModuleDeclarationExecutionContext(realm, code);
code.getModuleBody().moduleDeclarationInstantiation(context, module, env);
}
use of com.github.anba.es6draft.Module in project es6draft by anba.
the class ModuleOperations method importMeta.
public static ScriptObject importMeta(ExecutionContext cx) {
/* steps 1-2 */
Executable executable = cx.getActiveScriptOrModule();
assert executable instanceof Module;
SourceIdentifier moduleId = executable.getSource().getSourceId();
Realm realm = cx.getRealm();
ModuleRecord moduleRecord = realm.getModuleLoader().get(moduleId, realm);
/* step 3 */
ScriptObject importMeta = moduleRecord.getMeta();
/* step 4 */
if (importMeta == null) {
/* step 4.a */
importMeta = ObjectCreate(cx, (ScriptObject) null);
/* steps 4.b-e */
cx.getRuntimeContext().getImportMeta().accept(importMeta, moduleRecord);
/* step 4.f */
moduleRecord.setMeta(importMeta);
/* step 4.g */
return importMeta;
}
/* step 5 */
return importMeta;
}
Aggregations