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

@ -43,7 +43,7 @@ pub enum ToAstProblem {
#[allow(clippy::too_many_arguments)]
pub fn jit_to_ast<'a, A: ReplApp<'a>>(
arena: &'a Bump,
app: &'a A,
app: &mut A,
main_fn_name: &str,
layout: ProcLayout<'a>,
content: &'a Content,
@ -94,6 +94,7 @@ enum NewtypeKind<'a> {
/// Returns (new type containers, optional alias content, real content).
fn unroll_newtypes_and_aliases<'a>(
env: &Env<'a, 'a>,
mut content: &'a Content,
) -> (Vec<'a, NewtypeKind<'a>>, Option<&'a Content>, &'a Content) {
let mut newtype_containers = Vec::with_capacity_in(1, env.arena);
@ -282,7 +283,7 @@ const OPAQUE_FUNCTION: Expr = Expr::Var {
fn jit_to_ast_help<'a, A: ReplApp<'a>>(
env: &Env<'a, 'a>,
app: &'a A,
app: &mut A,
main_fn_name: &str,
layout: &Layout<'a>,
content: &'a Content,

View file

@ -11,12 +11,12 @@ pub trait ReplApp<'a> {
/// Run user code that returns a type with a `Builtin` layout
/// Size of the return value is statically determined from its Rust type
/// The `transform` callback takes the app's memory and the returned value
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;
fn call_function_returns_roc_list<F>(&self, main_fn_name: &str, transform: F) -> Expr<'a>
fn call_function_returns_roc_list<F>(&mut self, main_fn_name: &str, transform: F) -> Expr<'a>
where
F: Fn(&'a Self::Memory, (usize, usize, usize)) -> Expr<'a>,
Self::Memory: 'a,
@ -25,7 +25,7 @@ pub trait ReplApp<'a> {
}
fn call_function_returns_roc_str<T, F>(
&self,
&mut self,
target_info: TargetInfo,
main_fn_name: &str,
transform: F,
@ -45,7 +45,7 @@ pub trait ReplApp<'a> {
/// Run user code that returns a struct or union, whose size is provided as an argument
/// The `transform` callback takes the app's memory and the address of the returned value
fn call_function_dynamic_size<T, F>(
&self,
&mut self,
main_fn_name: &str,
ret_bytes: usize,
transform: F,