enable command debug printing

This commit is contained in:
Luna 2020-05-30 22:39:45 -03:00
parent c3b83c3e4b
commit 47a97636cd
2 changed files with 18 additions and 1 deletions

View file

@ -103,6 +103,19 @@ pub const NewCommand = struct {
rotate,
};
pub fn tagToType(tag: Tag) type {
return switch (tag) {
.noop => Noop,
.load => Load,
.quicksave => Quicksave,
.runqs => RunQS,
.amp => Amp,
.rflanger => RFlanger,
else => @panic("TODO"),
};
}
pub fn cast(base: *@This(), comptime T: type) ?*T {
if (base.tag != T.base_tag)
return null;
@ -110,6 +123,10 @@ pub const NewCommand = struct {
return @fieldParentPtr(T, "base", base);
}
pub fn print(base: *const @This()) void {
std.debug.warn("{}\n", .{base.tag});
}
pub const Noop = struct {
pub const base_tag = Tag.noop;
base: NewCommand,

View file

@ -778,7 +778,7 @@ pub const Runner = struct {
debug_flag: bool,
) !void {
for (cmds.items) |cmd| {
// if (debug_flag) const_cmd.print();
cmd.print();
try self.newRunCommand(cmd);
}
}