|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
use std::collections::HashMap; |
|
|
|
|
use std::sync::atomic::AtomicU32; |
|
|
|
|
use std::sync::atomic::{AtomicU32, Ordering}; |
|
|
|
|
|
|
|
|
|
use crate::asm::data::{Rd, RdData}; |
|
|
|
|
use crate::asm::data::literal::{Label, Value}; |
|
|
|
@ -63,7 +63,10 @@ impl Flatten for Vec<Box<dyn Flatten>> { |
|
|
|
|
|
|
|
|
|
impl Flatten for Routine { |
|
|
|
|
fn flatten(self: Box<Self>, label_num: &AtomicU32) -> Result<Vec<Op>, CrsnError> { |
|
|
|
|
let mut ops = vec![ |
|
|
|
|
let skip_label = Label::Numbered(label_num.fetch_add(1, Ordering::Relaxed)); |
|
|
|
|
|
|
|
|
|
let mut ops : Vec<Op> = vec![ |
|
|
|
|
BuiltinOp::FarJump(skip_label.clone()).into(), |
|
|
|
|
BuiltinOp::Barrier(Some(format!("Routine \"{}\" start", self.name).into())).into(), |
|
|
|
|
BuiltinOp::Routine(self.name.clone()).into(), |
|
|
|
|
]; |
|
|
|
@ -71,6 +74,7 @@ impl Flatten for Routine { |
|
|
|
|
ops.extend(self.body.flatten(label_num)?); |
|
|
|
|
|
|
|
|
|
ops.push(BuiltinOp::Barrier(Some(format!("Routine \"{}\" end", self.name).into())).into()); |
|
|
|
|
ops.push(BuiltinOp::FarLabel(skip_label).into()); |
|
|
|
|
|
|
|
|
|
numbered_labels_to_skips(ops) |
|
|
|
|
} |
|
|
|
|