replace deprecated unify_complete_string call with allocate_cstr

This commit is contained in:
Mark Thom
2025-04-27 22:27:12 -07:00
committed by Mark Thom
parent a9847eef65
commit 4e0493474e

View File

@@ -5115,9 +5115,10 @@ impl Machine {
let result_reg = self.deref_register(2); let result_reg = self.deref_register(2);
if let Some(code) = self.machine_st.value_to_str_like(code) { if let Some(code) = self.machine_st.value_to_str_like(code) {
match js_sys::eval(&code.as_str()) { match js_sys::eval(&code.as_str()) {
Ok(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), Err(result) => self.unify_js_value(result, result_reg)?,
}; };
return Ok(()); return Ok(());
} }
self.machine_st.fail = true; self.machine_st.fail = true;
@@ -5125,7 +5126,11 @@ impl Machine {
} }
#[cfg(target_arch = "wasm32")] #[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() { match result.as_bool() {
Some(result) => match result { Some(result) => match result {
true => self.machine_st.unify_atom(atom!("true"), result_reg), true => self.machine_st.unify_atom(atom!("true"), result_reg),
@@ -5138,8 +5143,10 @@ impl Machine {
} }
None => match result.as_string() { None => match result.as_string() {
Some(result) => { Some(result) => {
let result = AtomTable::build_with(&self.machine_st.atom_tbl, &result); resource_error_call_result!(
self.machine_st.unify_complete_string(result, result_reg); self.machine_st,
self.machine_st.heap.allocate_cstr(result.as_str())
);
} }
None => { None => {
if result.is_null() { if result.is_null() {
@@ -5164,6 +5171,8 @@ impl Machine {
}, },
}, },
} }
Ok(())
} }
#[inline(always)] #[inline(always)]