diff --git a/src/runner/json_v1_bridge.rs b/src/runner/json_v1_bridge.rs index c4c489c0..6849748e 100644 --- a/src/runner/json_v1_bridge.rs +++ b/src/runner/json_v1_bridge.rs @@ -253,6 +253,71 @@ pub fn try_parse_v1_to_module(json: &str) -> Result, String> { signature.return_type = MirType::Void; } } + "mir_call" => { + // Minimal v1 mir_call support (Global only; print-family) + // dst: optional + let dst_opt = inst.get("dst").and_then(|d| d.as_u64()).map(|v| ValueId::new(v as u32)); + // args: array of value ids + let mut argv: Vec = Vec::new(); + if let Some(arr) = inst.get("args").and_then(|a| a.as_array()) { + for a in arr { + let id = a.as_u64().ok_or_else(|| format!( + "mir_call arg must be integer value id in function '{}'", + func_name + ))? as u32; + argv.push(ValueId::new(id)); + } + } + // callee: only Global(name) supported here + let callee_obj = inst.get("callee").ok_or_else(|| { + format!("mir_call missing callee in function '{}'", func_name) + })?; + let ctype = callee_obj + .get("type") + .and_then(Value::as_str) + .ok_or_else(|| format!("mir_call callee.type missing in function '{}'", func_name))?; + match ctype { + "Global" => { + let raw_name = callee_obj + .get("name") + .and_then(Value::as_str) + .ok_or_else(|| format!( + "mir_call callee Global missing name in function '{}'", + func_name + ))?; + // Map known console aliases to interpreter-accepted names + let mapped = match raw_name { + "print" => "print".to_string(), + "nyash.builtin.print" => "nyash.builtin.print".to_string(), + "nyash.console.log" => "nyash.console.log".to_string(), + // Accept env.console.* as nyash.console.log (numeric only) + "env.console.log" | "env.console.warn" | "env.console.error" => { + "nyash.console.log".to_string() + } + other => { + return Err(format!( + "unsupported Global callee '{}' in mir_call (Gate-C v1 bridge)", + other + )); + } + }; + block_ref.add_instruction(MirInstruction::Call { + dst: dst_opt, + func: ValueId::new(0), + callee: Some(crate::mir::definitions::Callee::Global(mapped)), + args: argv, + effects: EffectMask::PURE, + }); + if let Some(d) = dst_opt { max_value_id = max_value_id.max(d.as_u32() + 1); } + } + other => { + return Err(format!( + "unsupported callee type '{}' in mir_call (Gate-C v1 bridge)", + other + )); + } + } + } other => { return Err(format!( "unsupported instruction '{}' in function '{}' (Gate-C v1 bridge)", diff --git a/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh b/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh index 27c91ec7..1a27979d 100644 --- a/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh +++ b/tools/smokes/v2/profiles/quick/core/stageb/stageb_print_vm.sh @@ -27,15 +27,11 @@ if ! stageb_json_nonempty "$json"; then exit 1 fi set +e -output=$(NYASH_NYVM_V1_DOWNCONVERT=1 "$NYASH_BIN" --json-file "$json") +output=$(NYASH_NYVM_V1_DOWNCONVERT=1 NYASH_QUIET=1 HAKO_QUIET=1 NYASH_CLI_VERBOSE=0 NYASH_DISABLE_PLUGINS=1 "$NYASH_BIN" --json-file "$json") rc=$? set -e rm -f "$json" -if [ $rc -ne 0 ]; then - echo "[SKIP] stageb_print_vm (v1 downconvert not yet supporting call/extern)" >&2 - exit 0 -fi if [ "$output" = "3" ] && [ $rc -eq 0 ]; then echo "[PASS] stageb_print_vm" exit 0