Control frames, jumps & stack unwinding.

This commit is contained in:
losfair
2019-02-20 22:56:32 +08:00
parent 93d2713bde
commit 61c83507a4
2 changed files with 211 additions and 4 deletions

View File

@ -46,7 +46,7 @@ pub struct ValueInfo {
pub location: ValueLocation,
}
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ValueLocation {
Register(u8),
Stack,
@ -66,7 +66,7 @@ impl ValueLocation {
Ok(id)
} else {
Err(CodegenError {
message: "not a register location"
message: "not a register location",
})
}
}
@ -140,3 +140,16 @@ impl ValueStack {
self.values.truncate(target_depth);
}
}
impl ControlStack {
pub fn new(label: DynamicLabel, returns: Vec<WpType>) -> ControlStack {
ControlStack {
frames: vec![ControlFrame {
label: label,
loop_like: false,
returns: returns,
value_stack_depth_before: 0,
}],
}
}
}