mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Revert unneeded changes
This commit is contained in:
parent
cb2f85ed95
commit
a3ffc12569
6 changed files with 36 additions and 38 deletions
|
@ -19,9 +19,9 @@ use roc_types::subs::{Content, FlatType, GetSubsSlice, RecordFields, Subs, Union
|
|||
|
||||
use crate::{ReplApp, ReplAppMemory};
|
||||
|
||||
struct Env<'a> {
|
||||
struct Env<'a, 'env> {
|
||||
arena: &'a Bump,
|
||||
subs: &'a Subs,
|
||||
subs: &'env Subs,
|
||||
target_info: TargetInfo,
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ pub fn jit_to_ast<'a, A: ReplApp<'a>>(
|
|||
subs: &'a Subs,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<Expr<'a>, ToAstProblem> {
|
||||
let mut env = Env {
|
||||
let env = Env {
|
||||
arena,
|
||||
subs,
|
||||
target_info,
|
||||
|
@ -57,10 +57,10 @@ pub fn jit_to_ast<'a, A: ReplApp<'a>>(
|
|||
ProcLayout {
|
||||
arguments: [],
|
||||
result,
|
||||
..
|
||||
captures_niche: _,
|
||||
} => {
|
||||
// this is a thunk
|
||||
jit_to_ast_help(&mut env, app, main_fn_name, &result, content)
|
||||
jit_to_ast_help(&env, app, main_fn_name, &result, content)
|
||||
}
|
||||
_ => Err(ToAstProblem::FunctionLayout),
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ enum NewtypeKind<'a> {
|
|||
///
|
||||
/// Returns (new type containers, optional alias content, real content).
|
||||
fn unroll_newtypes_and_aliases<'a>(
|
||||
env: &Env<'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);
|
||||
|
@ -135,7 +135,7 @@ fn unroll_newtypes_and_aliases<'a>(
|
|||
}
|
||||
|
||||
fn apply_newtypes<'a>(
|
||||
env: &Env<'a>,
|
||||
env: &Env<'a, '_>,
|
||||
newtype_containers: Vec<'a, NewtypeKind<'a>>,
|
||||
mut expr: Expr<'a>,
|
||||
) -> Expr<'a> {
|
||||
|
@ -162,7 +162,7 @@ fn apply_newtypes<'a>(
|
|||
expr
|
||||
}
|
||||
|
||||
fn unroll_recursion_var<'a>(env: &Env<'a>, mut content: &'a Content) -> &'a Content {
|
||||
fn unroll_recursion_var<'a>(env: &Env<'a, 'a>, mut content: &'a Content) -> &'a Content {
|
||||
while let Content::RecursionVar { structure, .. } = content {
|
||||
content = env.subs.get_content_without_compacting(*structure);
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ fn unroll_recursion_var<'a>(env: &Env<'a>, mut content: &'a Content) -> &'a Cont
|
|||
}
|
||||
|
||||
fn get_tags_vars_and_variant<'a>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, '_>,
|
||||
tags: &UnionTags,
|
||||
opt_rec_var: Option<Variable>,
|
||||
) -> (MutMap<TagName, std::vec::Vec<Variable>>, UnionVariant<'a>) {
|
||||
|
@ -188,7 +188,7 @@ fn get_tags_vars_and_variant<'a>(
|
|||
}
|
||||
|
||||
fn expr_of_tag<'a, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &'a M,
|
||||
data_addr: usize,
|
||||
tag_name: &TagName,
|
||||
|
@ -212,7 +212,7 @@ fn expr_of_tag<'a, M: ReplAppMemory>(
|
|||
/// Gets the tag ID of a union variant, assuming that the tag ID is stored alongside (after) the
|
||||
/// tag data. The caller is expected to check that the tag ID is indeed stored this way.
|
||||
fn tag_id_from_data<'a, M: ReplAppMemory>(
|
||||
env: &Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &M,
|
||||
union_layout: UnionLayout,
|
||||
data_addr: usize,
|
||||
|
@ -240,7 +240,7 @@ fn tag_id_from_data<'a, M: ReplAppMemory>(
|
|||
/// - the tag ID
|
||||
/// - the address of the data of the union variant, unmasked if the pointer held the tag ID
|
||||
fn tag_id_from_recursive_ptr<'a, M: ReplAppMemory>(
|
||||
env: &Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &M,
|
||||
union_layout: UnionLayout,
|
||||
rec_addr: usize,
|
||||
|
@ -265,7 +265,7 @@ const OPAQUE_FUNCTION: Expr = Expr::Var {
|
|||
};
|
||||
|
||||
fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
app: &'a A,
|
||||
main_fn_name: &str,
|
||||
layout: &Layout<'a>,
|
||||
|
@ -345,11 +345,6 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
|||
todo!("add support for rendering builtin {:?} to the REPL", other)
|
||||
}
|
||||
Layout::Struct { field_layouts, .. } => {
|
||||
let fields = [Layout::u64(), *layout];
|
||||
let layout = Layout::struct_no_name_order(&fields);
|
||||
|
||||
let result_stack_size = layout.stack_size(env.target_info);
|
||||
|
||||
let struct_addr_to_ast = |mem: &'a A::Memory, addr: usize| match raw_content {
|
||||
Content::Structure(FlatType::Record(fields, _)) => {
|
||||
Ok(struct_to_ast(env, mem, addr, *fields))
|
||||
|
@ -395,6 +390,11 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
|||
}
|
||||
};
|
||||
|
||||
let fields = [Layout::u64(), *layout];
|
||||
let layout = Layout::struct_no_name_order(&fields);
|
||||
|
||||
let result_stack_size = layout.stack_size(env.target_info);
|
||||
|
||||
app.call_function_dynamic_size(
|
||||
main_fn_name,
|
||||
result_stack_size as usize,
|
||||
|
@ -463,7 +463,7 @@ fn jit_to_ast_help<'a, A: ReplApp<'a>>(
|
|||
result.map(|e| apply_newtypes(env, newtype_containers, e))
|
||||
}
|
||||
|
||||
fn tag_name_to_expr<'a>(env: &Env<'a>, tag_name: &TagName) -> Expr<'a> {
|
||||
fn tag_name_to_expr<'a>(env: &Env<'a, '_>, tag_name: &TagName) -> Expr<'a> {
|
||||
Expr::Tag(env.arena.alloc_str(&tag_name.as_ident_str()))
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ enum WhenRecursive<'a> {
|
|||
}
|
||||
|
||||
fn addr_to_ast<'a, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &'a M,
|
||||
addr: usize,
|
||||
layout: &Layout<'a>,
|
||||
|
@ -771,7 +771,7 @@ fn addr_to_ast<'a, M: ReplAppMemory>(
|
|||
}
|
||||
|
||||
fn list_to_ast<'a, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &'a M,
|
||||
addr: usize,
|
||||
len: usize,
|
||||
|
@ -823,7 +823,7 @@ fn list_to_ast<'a, M: ReplAppMemory>(
|
|||
}
|
||||
|
||||
fn single_tag_union_to_ast<'a, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &'a M,
|
||||
addr: usize,
|
||||
field_layouts: &'a [Layout<'a>],
|
||||
|
@ -850,7 +850,7 @@ fn single_tag_union_to_ast<'a, M: ReplAppMemory>(
|
|||
}
|
||||
|
||||
fn sequence_of_expr<'a, I, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &'a M,
|
||||
addr: usize,
|
||||
sequence: I,
|
||||
|
@ -882,7 +882,7 @@ where
|
|||
}
|
||||
|
||||
fn struct_to_ast<'a, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, 'a>,
|
||||
mem: &'a M,
|
||||
addr: usize,
|
||||
record_fields: RecordFields,
|
||||
|
@ -1007,7 +1007,7 @@ fn unpack_two_element_tag_union(
|
|||
}
|
||||
|
||||
fn bool_to_ast<'a, M: ReplAppMemory>(
|
||||
env: &Env<'a>,
|
||||
env: &Env<'a, '_>,
|
||||
mem: &M,
|
||||
value: bool,
|
||||
content: &Content,
|
||||
|
@ -1082,7 +1082,7 @@ fn bool_to_ast<'a, M: ReplAppMemory>(
|
|||
}
|
||||
|
||||
fn byte_to_ast<'a, M: ReplAppMemory>(
|
||||
env: &mut Env<'a>,
|
||||
env: &Env<'a, '_>,
|
||||
mem: &M,
|
||||
value: u8,
|
||||
content: &Content,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue