]> Repositorios git - scryer-prolog.git/commitdiff
replace deprecated unify_complete_string call with allocate_cstr bakaq-exposed_provenance origin/bakaq-exposed_provenance
authorMark Thom <[email protected]>
Mon, 28 Apr 2025 05:27:12 +0000 (22:27 -0700)
committerMark Thom <[email protected]>
Mon, 28 Apr 2025 05:27:12 +0000 (22:27 -0700)
src/machine/system_calls.rs

index 27b92b720363bc218c3a5a16bbc03757c829c831..582f68dc0558d7c7c4e535f4a0f92743d0c612f2 100644 (file)
@@ -5133,9 +5133,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;
@@ -5143,7 +5144,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),
@@ -5156,8 +5161,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() {
@@ -5182,6 +5189,8 @@ impl Machine {
                 },
             },
         }
+
+        Ok(())
     }
 
     #[inline(always)]