Skip to content

Commit

Permalink
compile conditional for control_repeat_until
Browse files Browse the repository at this point in the history
  • Loading branch information
pufferfish101007 committed Aug 23, 2023
1 parent 574781f commit b329386
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,38 @@ impl IrBlockVec for Vec<IrBlock> {
}
step_from_top_block(block_info.next.clone().unwrap(), last_nexts.clone(), blocks, Rc::clone(&context), steps);
step_from_top_block(substack_id.clone(), vec![looper_id], blocks, Rc::clone(&context), steps);
let opcodes = vec![
IrOpcode::hq_goto_if { step: Some(substack_id.clone()), does_yield: false },
IrOpcode::hq_goto { step: Some(block_info.next.clone().unwrap()), does_yield: false },
];
steps.insert(block_id.clone(), Step::new(opcodes.clone().into_iter().map(IrBlock::from).collect::<Vec<_>>(), Rc::clone(&context)));
let mut opcodes = vec![];
for (name, input) in &block_info.inputs {
if matches!(name.as_str(), "SUBSTACK" | "SUBSTACK2") {
continue;
}
match input {
Input::Shadow(_, maybe_block, _) | Input::NoShadow(_, maybe_block) => {
let Some(block) = maybe_block else { panic!("block doest exist"); };
match block {
BlockArrayOrId::Id(id) => {
opcodes.add_block(
id.clone(),
blocks,
Rc::clone(&context),
vec![],
steps,
);
}
BlockArrayOrId::Array(arr) => {
opcodes.add_block_arr(arr);
}
}
}
}
}
opcodes.append(&mut vec![
IrOpcode::hq_goto_if { step: Some(substack_id.clone()), does_yield: false }.into(),
IrOpcode::hq_goto { step: Some(block_info.next.clone().unwrap()), does_yield: false }.into(),
]);
steps.insert(block_id.clone(), Step::new(opcodes.clone(), Rc::clone(&context)));
//step_from_top_block(block_id.clone(), last_nexts.clone(), blocks, Rc::clone(&context), steps);
opcodes
opcodes.into_iter().map(|block| block.opcode().clone()).collect::<Vec<_>>()
}
_ => todo!(),
}).into_iter().map(IrBlock::from).collect());
Expand Down

0 comments on commit b329386

Please sign in to comment.