Skip to content
Snippets Groups Projects
Commit 109d2f73 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'fix_parse' into 'main'

Fix RefCell borrows in parse

See merge request !88
parents 70bb396d 01b9cbd4
No related branches found
No related tags found
1 merge request!88Fix RefCell borrows in parse
Pipeline #200776 passed
......@@ -978,20 +978,17 @@ fn parse_constant<'a>(
Type::UnsignedInteger64 => parse_unsigned_integer64(ir_text)?,
Type::Float32 => parse_float32(ir_text)?,
Type::Float64 => parse_float64(ir_text)?,
Type::Product(ref tys) => parse_product_constant(
ir_text,
context.borrow_mut().get_type_id(ty.clone()),
tys,
context,
)?,
Type::Summation(ref tys) => parse_summation_constant(
ir_text,
context.borrow_mut().get_type_id(ty.clone()),
tys,
context,
)?,
Type::Product(ref tys) => {
let prod_ty = context.borrow_mut().get_type_id(ty.clone());
parse_product_constant(ir_text, prod_ty, tys, context)?
}
Type::Summation(ref tys) => {
let sum_ty = context.borrow_mut().get_type_id(ty.clone());
parse_summation_constant(ir_text, sum_ty, tys, context)?
}
Type::Array(_, _) => {
parse_array_constant(ir_text, context.borrow_mut().get_type_id(ty.clone()))?
let array_ty = context.borrow_mut().get_type_id(ty.clone());
parse_array_constant(ir_text, array_ty)?
}
};
Ok((ir_text, constant))
......@@ -1094,11 +1091,8 @@ fn parse_product_constant<'a>(
ir_text = nom::character::complete::char(',')(ir_text)?.0;
}
ir_text = nom::character::complete::multispace0(ir_text)?.0;
let (ir_text_tmp, id) = parse_constant_id(
ir_text,
context.borrow().reverse_type_map.get(ty).unwrap().clone(),
context,
)?;
let ty = context.borrow().reverse_type_map.get(ty).unwrap().clone();
let (ir_text_tmp, id) = parse_constant_id(ir_text, ty, context)?;
subconstants.push(id);
ir_text = ir_text_tmp;
}
......@@ -1127,16 +1121,13 @@ fn parse_summation_constant<'a>(
let ir_text = nom::character::complete::multispace0(ir_text)?.0;
let ir_text = nom::character::complete::char(',')(ir_text)?.0;
let ir_text = nom::character::complete::multispace0(ir_text)?.0;
let (ir_text, id) = parse_constant_id(
ir_text,
context
.borrow()
.reverse_type_map
.get(&tys[variant as usize])
.unwrap()
.clone(),
context,
)?;
let ty = context
.borrow()
.reverse_type_map
.get(&tys[variant as usize])
.unwrap()
.clone();
let (ir_text, id) = parse_constant_id(ir_text, ty, context)?;
let ir_text = nom::character::complete::multispace0(ir_text)?.0;
let ir_text = nom::character::complete::char(')')(ir_text)?.0;
Ok((ir_text, Constant::Summation(sum_ty, variant, id)))
......
fn tricky(x: i32) -> i32
not_used = constant(prod(u64, u64), prod(0, 0))
one = constant(i32, 1)
two = constant(i32, 2)
loop = region(start, if2_true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment