feat: gc (does compile, but WIP)

This commit is contained in:
2025-05-27 21:08:59 +08:00
parent 319c12c1f4
commit c3ace28af1
20 changed files with 696 additions and 575 deletions

View File

@@ -1,6 +1,6 @@
use hashbrown::HashMap;
use ecow::EcoString;
use gc_arena::Collect;
use hashbrown::HashMap;
use crate::ty::common::Const;
use crate::ty::internal::Param;
@@ -18,10 +18,14 @@ pub enum OpCode {
LookUp { sym: usize },
/// load a thunk lazily onto stack
LoadThunk { idx: usize },
/// load a thunk value onto stack
LoadValue { idx: usize },
/// let TOS capture current environment
CaptureEnv,
/// force TOS to value
ForceValue,
/// TODO:
InsertValue,
/// [ .. func arg ] consume 2 elements, call `func` with arg
Call,
@@ -73,18 +77,19 @@ pub enum OpCode {
SelectDynamicOrDefault,
/// enter the let environment of the attribute set at TOS
EnterLetEnv,
/// exit current let envrironment
LeaveLetEnv,
/// enter the with environment of the attribute set at TOS
EnterWithEnv,
/// exit current with envrironment
LeaveWithEnv,
/// exit current envrironment
LeaveEnv,
/// TODO:
PopEnv,
/// illegal operation, used as termporary placeholder
Illegal,
}
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Collect)]
#[collect(no_drop)]
pub enum BinOp {
Add,
Sub,
@@ -98,7 +103,8 @@ pub enum BinOp {
Upd,
}
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Collect)]
#[collect(no_drop)]
pub enum UnOp {
Neg,
Not,