Skip to content

WebAssembly does not support multi-file programs #2456

Open
@ianyong

Description

@ianyong

Because Sourceror is not part of js-slang, the pre-processing step which handles imports & exports does not work with Sourceror. This means that the WebAssembly variants of Source do not support multi-file programs currently. Instead, only the entrypoint file is passed to Sourceror currently:

const entrypointCode = files[entrypointFilePath];
function call_variant(variant: Variant) {
if (variant === Variant.NON_DET) {
return entrypointCode.trim() === TRY_AGAIN
? call(resume, lastNonDetResult)
: call(runFilesInContext, files, entrypointFilePath, context, {
executionMethod: 'interpreter',
originalMaxExecTime: execTime,
stepLimit: stepLimit,
useSubst: substActiveAndCorrectChapter
});
} else if (variant === Variant.LAZY) {
return call(runFilesInContext, files, entrypointFilePath, context, {
scheduler: 'preemptive',
originalMaxExecTime: execTime,
stepLimit: stepLimit,
useSubst: substActiveAndCorrectChapter
});
} else if (variant === Variant.WASM) {
// Note: WASM does not support multiple file programs.
return call(wasm_compile_and_run, entrypointCode, context, actionType === EVAL_REPL);
} else {
throw new Error('Unknown variant: ' + variant);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions