Files
not-python/src/vm/frame.rs
Alek Ratzloff 582b3a4b73 Add basic blocks and implementation of flattening thunks -> basic blocks
* Basic are a more linear way of representing code. Thunks beget basic
  blocks, which beget vectors of instructions.
* Basic blocks are also being flattened into a vector of instructions
  (hopefully, no tests done yet)
* OH yeah locals can be collected too (but currently are not being
  collected in the compiler, that should come soon)

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-09-16 17:18:31 -07:00

50 lines
929 B
Rust

use crate::obj::prelude::*;
use shredder::{GcSafe, Scan, Scanner};
/// A stack call frame.
#[derive(Debug, Clone)]
pub enum FrameKind {
Root,
Native,
User {
last_pc: usize,
stack_base: usize,
fun: UserFunRef,
},
}
unsafe impl Scan for FrameKind {
fn scan(&self, scanner: &mut Scanner<'_>) {
match self {
FrameKind::User { fun, .. } => scanner.scan(fun),
_ => { /* no-op */ }
}
}
}
unsafe impl GcSafe for FrameKind {}
#[derive(Scan, Debug, Clone)]
pub struct Frame {
locals: Locals,
kind: FrameKind,
}
impl Frame {
pub fn new(locals: Locals, kind: FrameKind) -> Self {
Self { locals, kind, }
}
pub fn locals(&self) -> &Locals {
&self.locals
}
pub fn locals_mut(&mut self) -> &mut Locals {
&mut self.locals
}
pub fn kind(&self) -> &FrameKind {
&self.kind
}
}