Compare commits
No commits in common. "9c6387973fc5f2d70762905abd45ce38aaef5b9d" and "6497fc1dd8d7a600c00c38bfbe5e9df8775a96ed" have entirely different histories.
9c6387973f
...
6497fc1dd8
2 changed files with 8 additions and 36 deletions
15
src/lang.zig
15
src/lang.zig
|
@ -116,7 +116,7 @@ pub const NewCommand = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cast(base: *const @This(), comptime T: type) ?*const T {
|
pub fn cast(base: *@This(), comptime T: type) ?*T {
|
||||||
if (base.tag != T.base_tag)
|
if (base.tag != T.base_tag)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ pub const NewCommand = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print(base: *const @This()) void {
|
pub fn print(base: *const @This()) void {
|
||||||
std.debug.warn("tag: {}\n", .{base.tag});
|
std.debug.warn("{}\n", .{base.tag});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const Noop = struct {
|
pub const Noop = struct {
|
||||||
|
@ -268,7 +268,7 @@ pub const Command = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CommandList = std.ArrayList(*NewCommand);
|
pub const CommandList = std.ArrayList(NewCommand);
|
||||||
pub const ArgList = std.ArrayList([]const u8);
|
pub const ArgList = std.ArrayList([]const u8);
|
||||||
|
|
||||||
pub const KeywordMap = std.StringHashMap(CommandType);
|
pub const KeywordMap = std.StringHashMap(CommandType);
|
||||||
|
@ -413,24 +413,21 @@ pub const Lang = struct {
|
||||||
usize => try std.fmt.parseInt(usize, arg, 10),
|
usize => try std.fmt.parseInt(usize, arg, 10),
|
||||||
i32 => try std.fmt.parseInt(i32, arg, 10),
|
i32 => try std.fmt.parseInt(i32, arg, 10),
|
||||||
f32 => try std.fmt.parseFloat(f32, arg),
|
f32 => try std.fmt.parseFloat(f32, arg),
|
||||||
[]const u8 => try self.allocator.dupe(u8, arg),
|
[]const u8 => arg,
|
||||||
else => @panic("Invalid parameter type (" ++ @typeName(cmd_field.field_type) ++ ") left on command struct " ++ @typeName(command_struct) ++ "."),
|
else => @panic("Invalid parameter type (" ++ @typeName(cmd_field.field_type) ++ ") left on command struct " ++ @typeName(command_struct) ++ "."),
|
||||||
};
|
};
|
||||||
|
|
||||||
std.debug.warn("parsing {}, arg of type {} => {}\n", .{ @typeName(command_struct), @typeName(@TypeOf(argument_value)), argument_value });
|
|
||||||
|
|
||||||
@field(cmd, cmd_field.name) = argument_value;
|
@field(cmd, cmd_field.name) = argument_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.base.tag = command_struct.base_tag;
|
cmd.base.tag = command_struct.base_tag;
|
||||||
const command = cmd.base.cast(command_struct).?;
|
|
||||||
std.debug.warn("cmd: {}\n", .{command});
|
|
||||||
|
|
||||||
try commands.append(&cmd.base);
|
try commands.append(cmd.base);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(self: *Lang, data: []const u8) !CommandList {
|
pub fn parse(self: *Lang, data: []const u8) !CommandList {
|
||||||
var splitted_it = std.mem.split(data, ";");
|
var splitted_it = std.mem.split(data, ";");
|
||||||
|
// try self.fillKeywords();
|
||||||
var cmds = CommandList.init(self.allocator);
|
var cmds = CommandList.init(self.allocator);
|
||||||
|
|
||||||
while (splitted_it.next()) |stmt_orig| {
|
while (splitted_it.next()) |stmt_orig| {
|
||||||
|
|
|
@ -374,24 +374,7 @@ pub const Runner = struct {
|
||||||
try image.runPlugin("http://calf.sourceforge.net/plugins/VintageDelay", pos, params);
|
try image.runPlugin("http://calf.sourceforge.net/plugins/VintageDelay", pos, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn newRunCommandSingle(
|
fn newRunCommand(self: *@This(), cmd: lang.NewCommand) !void {}
|
||||||
self: *@This(),
|
|
||||||
cmd: lang.NewCommand,
|
|
||||||
comptime tag: lang.NewCommand.Tag,
|
|
||||||
) !void {
|
|
||||||
comptime const typ = lang.NewCommand.tagToType(tag);
|
|
||||||
const command = cmd.cast(typ).?;
|
|
||||||
std.debug.warn("{} {}\n", .{ command.path.ptr, command.path.len });
|
|
||||||
|
|
||||||
std.debug.warn("{}\n", .{command});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn newRunCommand(self: *@This(), cmd: lang.NewCommand) !void {
|
|
||||||
switch (cmd.tag) {
|
|
||||||
.load => try self.newRunCommandSingle(cmd, .load),
|
|
||||||
else => @panic("TODO"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
|
fn runCommand(self: *Runner, cmd: *lang.Command) !void {
|
||||||
var params = ParamList.init(self.allocator);
|
var params = ParamList.init(self.allocator);
|
||||||
|
@ -796,15 +779,7 @@ pub const Runner = struct {
|
||||||
) !void {
|
) !void {
|
||||||
for (cmds.items) |cmd| {
|
for (cmds.items) |cmd| {
|
||||||
cmd.print();
|
cmd.print();
|
||||||
|
try self.newRunCommand(cmd);
|
||||||
switch (cmd.tag) {
|
|
||||||
.load => {
|
|
||||||
const proper_cmd = cmd.cast(lang.NewCommand.Load).?;
|
|
||||||
std.debug.warn("got load! {}\n", .{proper_cmd});
|
|
||||||
},
|
|
||||||
else => @panic("TODO"),
|
|
||||||
}
|
|
||||||
try self.newRunCommand(cmd.*);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue