fix: content behavior bugs
This commit is contained in:
parent
2260ccda25
commit
11d99fba38
59 changed files with 243 additions and 31 deletions
|
|
@ -235,6 +235,7 @@ pub const Choice = struct {
|
|||
pub const Opcode = enum(u8) {
|
||||
/// Exit the VM normally.
|
||||
exit,
|
||||
done,
|
||||
ret,
|
||||
/// Pop a value off the stack, discarding it.
|
||||
pop,
|
||||
|
|
@ -395,9 +396,8 @@ fn setGlobal(vm: *Story, key: Value, value: Value) !void {
|
|||
|
||||
fn execute(vm: *Story) !std.ArrayListUnmanaged(u8) {
|
||||
const gpa = vm.allocator;
|
||||
errdefer {
|
||||
vm.can_advance = false;
|
||||
}
|
||||
errdefer vm.can_advance = false;
|
||||
|
||||
if (vm.isCallStackEmpty()) return .empty;
|
||||
|
||||
var stream_writer = std.Io.Writer.Allocating.init(gpa);
|
||||
|
|
@ -415,6 +415,10 @@ fn execute(vm: *Story) !std.ArrayListUnmanaged(u8) {
|
|||
vm.can_advance = false;
|
||||
return .empty;
|
||||
},
|
||||
.done => {
|
||||
vm.can_advance = false;
|
||||
return .empty;
|
||||
},
|
||||
.true => {
|
||||
const value: Value = .{ .bool = true };
|
||||
try vm.pushStack(value);
|
||||
|
|
@ -588,7 +592,6 @@ fn execute(vm: *Story) !std.ArrayListUnmanaged(u8) {
|
|||
frame.ip += 3;
|
||||
},
|
||||
.br_table => {
|
||||
// No-op currently.
|
||||
frame.ip += 1;
|
||||
},
|
||||
.br_select_index => {
|
||||
|
|
@ -599,7 +602,12 @@ fn execute(vm: *Story) !std.ArrayListUnmanaged(u8) {
|
|||
.br_dispatch => {
|
||||
const index = vm.choice_index;
|
||||
const branch_dispatch = vm.current_choices.items[index];
|
||||
defer vm.current_choices.clearRetainingCapacity();
|
||||
defer {
|
||||
for (vm.current_choices.items) |*choice| {
|
||||
choice.text.deinit(gpa);
|
||||
}
|
||||
vm.current_choices.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
frame.ip = branch_dispatch.dest_offset;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue