From: Mark Thom Date: Mon, 28 Apr 2025 05:27:12 +0000 (-0700) Subject: replace deprecated unify_complete_string call with allocate_cstr X-Git-Tag: v0.10.0~35^2~19 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=4e0493474e911e0a7039f461842c30bb0a77a8da;p=scryer-prolog.git replace deprecated unify_complete_string call with allocate_cstr --- diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 0570e1e3..d47b36e9 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -5115,9 +5115,10 @@ impl Machine { let result_reg = self.deref_register(2); if let Some(code) = self.machine_st.value_to_str_like(code) { match js_sys::eval(&code.as_str()) { - Ok(result) => self.unify_js_value(result, result_reg), - Err(result) => self.unify_js_value(result, result_reg), + Ok(result) => self.unify_js_value(result, result_reg)?, + Err(result) => self.unify_js_value(result, result_reg)?, }; + return Ok(()); } self.machine_st.fail = true; @@ -5125,7 +5126,11 @@ impl Machine { } #[cfg(target_arch = "wasm32")] - fn unify_js_value(&mut self, result: wasm_bindgen::JsValue, result_reg: HeapCellValue) { + fn unify_js_value( + &mut self, + result: wasm_bindgen::JsValue, + result_reg: HeapCellValue, + ) -> CallResult { match result.as_bool() { Some(result) => match result { true => self.machine_st.unify_atom(atom!("true"), result_reg), @@ -5138,8 +5143,10 @@ impl Machine { } None => match result.as_string() { Some(result) => { - let result = AtomTable::build_with(&self.machine_st.atom_tbl, &result); - self.machine_st.unify_complete_string(result, result_reg); + resource_error_call_result!( + self.machine_st, + self.machine_st.heap.allocate_cstr(result.as_str()) + ); } None => { if result.is_null() { @@ -5164,6 +5171,8 @@ impl Machine { }, }, } + + Ok(()) } #[inline(always)]