diff --git a/internal/engine.cm b/internal/engine.cm index 97e3995d..ff384479 100644 --- a/internal/engine.cm +++ b/internal/engine.cm @@ -187,7 +187,7 @@ var _verify_ir_mod = null // _summary_resolver is set after shop loads (null during bootstrap). var _summary_resolver = null -function extract_module_summaries(compiled) { +function extract_module_summaries(compiled, ctx) { if (_summary_resolver == null) return null var instrs = null var summaries = [] @@ -253,7 +253,7 @@ function extract_module_summaries(compiled) { path = arg_map[text(f_slot)] if (path != null) { result_slot = instr[2] - summary = _summary_resolver(path) + summary = _summary_resolver(path, ctx) if (summary != null) { if (summary._native != true) { summaries[] = {slot: result_slot, summary: summary} @@ -275,7 +275,7 @@ function extract_module_summaries(compiled) { } // Run AST through mcode pipeline -> register VM -function run_ast_fn(name, ast, env) { +function run_ast_fn(name, ast, env, pkg) { var compiled = mcode_mod(ast) var ms = null var _ui = 0 @@ -295,7 +295,7 @@ function run_ast_fn(name, ast, env) { } if (!_no_warn) { compiled._warn = true - ms = extract_module_summaries(compiled) + ms = extract_module_summaries(compiled, pkg) if (ms != null) { if (length(ms.summaries) > 0) { compiled._module_summaries = ms.summaries @@ -351,7 +351,7 @@ function compile_to_blob(name, ast) { } // Compile user program AST to blob with diagnostics -function compile_user_blob(name, ast) { +function compile_user_blob(name, ast, pkg) { var compiled = mcode_mod(ast) var ms = null var _ui = 0 @@ -362,7 +362,7 @@ function compile_user_blob(name, ast) { var _has_errors = false if (!_no_warn) { compiled._warn = true - ms = extract_module_summaries(compiled) + ms = extract_module_summaries(compiled, pkg) if (ms != null) { if (length(ms.summaries) > 0) { compiled._module_summaries = ms.summaries @@ -625,8 +625,8 @@ var shop = use_core('internal/shop') use_core('build') // Wire up module summary resolver now that shop is available -_summary_resolver = function(path) { - var info = shop.resolve_import_info(path, null) +_summary_resolver = function(path, ctx) { + var info = shop.resolve_import_info(path, ctx) if (info == null) return null if (info.type == 'native') return {_native: true} var resolved = info.resolved_path @@ -1556,7 +1556,7 @@ $_.clock(_ => { } else { script = text(source_blob) ast = analyze(script, prog_path) - mach_blob = compile_user_blob(prog, ast) + mach_blob = compile_user_blob(prog, ast, pkg) if (cached_path) { ensure_build_dir() fd.slurpwrite(cached_path, mach_blob) diff --git a/json.c b/json.c index c479d941..3fe92bdb 100644 --- a/json.c +++ b/json.c @@ -52,8 +52,8 @@ static JSValue js_cell_json_decode (JSContext *ctx, JSValue this_val, int argc, } static const JSCFunctionListEntry js_cell_json_funcs[] = { - JS_CFUNC_DEF ("encode", 1, js_cell_json_encode), - JS_CFUNC_DEF ("decode", 1, js_cell_json_decode), + JS_CFUNC_DEF ("encode", 4, js_cell_json_encode), + JS_CFUNC_DEF ("decode", 2, js_cell_json_decode), }; JSValue js_core_json_use (JSContext *ctx) {