Search in sources :

Example 1 with HostResolveImportedModule

use of com.github.anba.es6draft.runtime.modules.ModuleSemantics.HostResolveImportedModule 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;
}
Also used : ExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext) ExecutionContext.newModuleDeclarationExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext.newModuleDeclarationExecutionContext) ExecutionContext.newModuleExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext.newModuleExecutionContext) HostResolveImportedModule(com.github.anba.es6draft.runtime.modules.ModuleSemantics.HostResolveImportedModule) Module(com.github.anba.es6draft.Module) Realm(com.github.anba.es6draft.runtime.Realm) ModuleEnvironmentRecord(com.github.anba.es6draft.runtime.ModuleEnvironmentRecord)

Aggregations

Module (com.github.anba.es6draft.Module)1 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)1 ExecutionContext.newModuleDeclarationExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext.newModuleDeclarationExecutionContext)1 ExecutionContext.newModuleExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext.newModuleExecutionContext)1 ModuleEnvironmentRecord (com.github.anba.es6draft.runtime.ModuleEnvironmentRecord)1 Realm (com.github.anba.es6draft.runtime.Realm)1 HostResolveImportedModule (com.github.anba.es6draft.runtime.modules.ModuleSemantics.HostResolveImportedModule)1