feat: execute source control flow and exact real arithmetic

This commit is contained in:
2026-11-12 10:48:27 +08:00
parent f3e1670c58
commit 5ff1c68f5f
28 changed files with 1045 additions and 117 deletions
+9 -2
View File
@@ -258,6 +258,8 @@ pub(crate) fn read_only_opcode(opcode: Opcode) -> bool {
| Opcode::PopJumpIfTrue
| Opcode::ToBool
| Opcode::UnaryNot
| Opcode::BinaryArithmetic
| Opcode::UnaryNegate
| Opcode::CompareOp
| Opcode::LoadDeref
| Opcode::LoadClosure
@@ -354,6 +356,7 @@ fn verify(
| Opcode::LoadAttr
| Opcode::StoreAttr => index < layout.names.len(),
Opcode::CompareOp => compare_operation(argument).is_some(),
Opcode::BinaryArithmetic => argument <= 3,
Opcode::Copy => argument >= 1,
Opcode::Swap => argument >= 2,
Opcode::JumpForward
@@ -394,8 +397,12 @@ fn verify(
| Opcode::StoreDeref
| Opcode::PopJumpIfFalse
| Opcode::PopJumpIfTrue => (1, 1, 0),
Opcode::ToBool | Opcode::UnaryNot | Opcode::LoadAttr | Opcode::Await => (1, 1, 1),
Opcode::CompareOp => (2, 2, 1),
Opcode::ToBool
| Opcode::UnaryNot
| Opcode::LoadAttr
| Opcode::Await
| Opcode::UnaryNegate => (1, 1, 1),
Opcode::CompareOp | Opcode::BinaryArithmetic => (2, 2, 1),
Opcode::StoreAttr => (2, 2, 0),
Opcode::Copy => (argument, 0, 1),
Opcode::Swap => (argument, 0, 0),