feat: function (WIP)

This commit is contained in:
2025-05-03 21:35:36 +08:00
parent cc88e7c65f
commit 63fd380514
4 changed files with 45 additions and 6 deletions

View File

@@ -81,6 +81,12 @@ impl VM {
let func = stack.pop()?;
stack.push(func.call(args))?;
}
OpCode::Func { param, length } => {
todo!()
}
OpCode::Ret => {
todo!()
}
OpCode::UnOp { op } => {
use UnOp::*;
let value = stack.pop()?;
@@ -105,6 +111,9 @@ impl VM {
let rhs = stack.pop()?;
stack.tos_mut()?.concat_string(rhs);
}
OpCode::Path => {
todo!()
}
OpCode::List => {
stack.push(Value::List(List::empty()))?;
}
@@ -166,7 +175,11 @@ impl VM {
OpCode::LeaveEnv => {
env.leave();
}
_ => todo!(),
OpCode::Assert => {
if !stack.pop()?.unwrap_const().unwrap_bool() {
todo!()
}
}
}
Ok(0)
}