Variables (#8)

This commit was merged in pull request #8.
This commit is contained in:
2026-05-02 20:12:15 -05:00
parent f9733f3b20
commit 9bc6ad1c92
10 changed files with 100 additions and 27 deletions

View File

@@ -131,6 +131,33 @@ void VM::step()
stack_.push(stack_.peek());
break;
//
// variables
//
case Instruction::PushValues8:
case Instruction::PushValues16:
case Instruction::PushValues32:
for (int i = 0; i < op.operator_; ++i)
push_nil();
break;
case Instruction::SetValue8:
case Instruction::SetValue16:
case Instruction::SetValue32: {
Value a = stack_.pop();
stack_.set(op.operator_, a);
break;
}
case Instruction::DuplicateValue8:
case Instruction::DuplicateValue16:
case Instruction::DuplicateValue32: {
Value a = stack_.at(op.operator_);
stack_.push(a);
break;
}
//
// logical/arithmetic
//