fix compile issues

This commit is contained in:
Sébastien Besnier 2020-12-28 21:17:27 +01:00
parent 07d4f8dc15
commit 4e9387cbda
4 changed files with 35 additions and 14 deletions

View File

@ -93,7 +93,10 @@ fn jit_to_ast_help<'a>(
),
Layout::Builtin(Builtin::EmptyList) => {
Ok(run_jit_function!(lib, main_fn_name, &'static str, |_| {
Expr::List(&[])
Expr::List {
items: &[],
final_comments: &[],
}
}))
}
Layout::Builtin(Builtin::List(_, elem_layout)) => Ok(run_jit_function!(
@ -251,7 +254,10 @@ fn ptr_to_ast<'a>(
num_to_ast(env, f64_to_ast(env.arena, num), content)
}
Layout::Builtin(Builtin::EmptyList) => Expr::List(&[]),
Layout::Builtin(Builtin::EmptyList) => Expr::List {
items: &[],
final_comments: &[],
},
Layout::Builtin(Builtin::List(_, elem_layout)) => {
// Turn the (ptr, len) wrapper struct into actual ptr and len values.
let len = unsafe { *(ptr.offset(env.ptr_bytes as isize) as *const usize) };
@ -331,7 +337,10 @@ fn list_to_ast<'a>(
let output = output.into_bump_slice();
Expr::List(output)
Expr::List {
items: output,
final_comments: &[],
}
}
fn single_tag_union_to_ast<'a>(

View File

@ -285,7 +285,9 @@ pub fn canonicalize_expr<'a>(
}
}
ast::Expr::Str(literal) => flatten_str_literal(env, var_store, scope, literal),
ast::Expr::List(loc_elems) => {
ast::Expr::List {
items: loc_elems, ..
} => {
if loc_elems.is_empty() {
(
List {

View File

@ -109,14 +109,24 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
arena.alloc(Located { region, value })
}
List(elems) | Nested(List(elems)) => {
let mut new_elems = Vec::with_capacity_in(elems.len(), arena);
List {
items,
final_comments,
}
| Nested(List {
items,
final_comments,
}) => {
let mut new_items = Vec::with_capacity_in(items.len(), arena);
for elem in elems.iter() {
new_elems.push(desugar_expr(arena, elem));
for item in items.iter() {
new_items.push(desugar_expr(arena, item));
}
let new_elems = new_elems.into_bump_slice();
let value: Expr<'a> = List(new_elems);
let new_items = new_items.into_bump_slice();
let value: Expr<'a> = List {
items: new_items,
final_comments,
};
arena.alloc(Located {
region: loc_expr.region,

View File

@ -285,14 +285,14 @@ pub fn to_expr2<'a>(
Str(literal) => flatten_str_literal(env, scope, &literal),
List(elements) => {
List { items, .. } => {
let mut output = Output::default();
let output_ref = &mut output;
let elems = PoolVec::with_capacity(elements.len() as u32, env.pool);
let elems = PoolVec::with_capacity(items.len() as u32, env.pool);
for (node_id, element) in elems.iter_node_ids().zip(elements.iter()) {
let (expr, sub_output) = to_expr2(env, scope, &element.value, element.region);
for (node_id, item) in elems.iter_node_ids().zip(items.iter()) {
let (expr, sub_output) = to_expr2(env, scope, &item.value, item.region);
output_ref.union(sub_output);