feat: function (WIP)

This commit is contained in:
2025-05-04 13:58:34 +08:00
parent 63fd380514
commit 6ecd20854a
12 changed files with 228 additions and 79 deletions

View File

@@ -1,6 +1,6 @@
use ecow::EcoString;
use crate::ty::internal::{Const, Param};
use crate::ty::internal::Const;
type Slice<T> = Box<[T]>;
@@ -35,7 +35,17 @@ pub enum OpCode {
/// return a value
Ret,
/// make a function
Func { param: Param, length: usize },
Func { idx: ThunkIdx },
/// push param `sym` into TOS
PushIdentParam { sym: EcoString },
/// push formal param `sym` into TOS
PushFormalParam { sym: EcoString },
/// push default formal param with thunkidx `idx` into TOS
PushDefaultParam { idx: ThunkIdx },
/// TODO:
SetEllipsis,
/// TODO:
SetAlias { sym: EcoString },
/// consume 1 element, assert TOS is true
Assert,