make the repl app mutable (for expect repl)

This commit is contained in:
Folkert 2022-07-23 13:45:17 +02:00
parent dfbad3c322
commit 6c0217c6f6
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
5 changed files with 58 additions and 49 deletions

View file

@ -108,7 +108,7 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
/// Size of the return value is statically determined from its Rust type
/// The `transform` callback takes the app's memory and the returned value
/// _main_fn_name is always the same and we don't use it here
fn call_function<Return, F>(&self, _main_fn_name: &str, transform: F) -> Expr<'a>
fn call_function<Return, F>(&mut self, _main_fn_name: &str, transform: F) -> Expr<'a>
where
F: Fn(&'a Self::Memory, Return) -> Expr<'a>,
Self::Memory: 'a,
@ -135,7 +135,7 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
/// _main_fn_name and _ret_bytes are only used for the CLI REPL. For Wasm they are compiled-in
/// to the test_wrapper function of the app itself
fn call_function_dynamic_size<T, F>(
&self,
&mut self,
_main_fn_name: &str,
_ret_bytes: usize,
transform: F,
@ -242,13 +242,13 @@ pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
.await
.map_err(|js| format!("{:?}", js))?;
let app = WasmReplApp { arena };
let mut app = WasmReplApp { arena };
// Run the app and transform the result value to an AST `Expr`
// Restore type constructor names, and other user-facing info that was erased during compilation.
let res_answer = jit_to_ast(
arena,
&app,
&mut app,
"", // main_fn_name is ignored (only passed to WasmReplApp methods)
main_fn_layout,
content,