Skip to content

Commit b6a3235

Browse files
Repl module "default_js_slang" function support (#1363)
* Repl module "default_js_slang" function support My module "repl" have a function called "default_js_slang" that allows students to run code in js-slang side through my module. This function need support from js-slang side to get the evaluation function and context in "sourceRunner.ts". * Fix lint errors --------- Co-authored-by: Martin Henz <henz@comp.nus.edu.sg>
1 parent 001dd04 commit b6a3235

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/runner/sourceRunner.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ async function runNative(
138138
let sourceMapJson: RawSourceMap | undefined
139139
try {
140140
appendModulesToContext(transpiledProgram, context)
141+
142+
// Repl module "default_js_slang" function support (Wang Zihan)
143+
if (context.moduleContexts['repl'] !== undefined) {
144+
;(context.moduleContexts['repl'] as any).js_slang = {}
145+
;(context.moduleContexts['repl'] as any).js_slang.sourceFilesRunner = sourceFilesRunner
146+
if ((context.moduleContexts['repl'] as any).js_slang.context === undefined)
147+
(context.moduleContexts['repl'] as any).js_slang.context = context
148+
}
149+
141150
switch (context.variant) {
142151
case Variant.GPU:
143152
transpileToGPU(transpiledProgram)

0 commit comments

Comments
 (0)