fix command ptr alignment
This commit is contained in:
parent
c0da5e68b7
commit
3af4dc575a
2 changed files with 17 additions and 6 deletions
13
src/lang.zig
13
src/lang.zig
|
@ -143,7 +143,18 @@ pub const Command = struct {
|
||||||
if (base.tag != T.base_tag)
|
if (base.tag != T.base_tag)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
const ptr: *const T = @alignCast(@fieldParentPtr("base", base));
|
//const baseInt = @intFromPtr(base);
|
||||||
|
|
||||||
|
//log.debug("casting from {d}", .{baseInt});
|
||||||
|
//log.debug("aligns from 8? {d}", .{baseInt % 8});
|
||||||
|
//log.debug("align T: {d} {s}", .{ @alignOf(*T), @typeName(T) });
|
||||||
|
//log.debug("align base: {d} {s}", .{ @alignOf(*const @This()), @typeName(@This()) });
|
||||||
|
const base_aligned: *const @This() = @alignCast(base);
|
||||||
|
|
||||||
|
const parented = @as(*const T, @alignCast(@fieldParentPtr("base", base_aligned)));
|
||||||
|
|
||||||
|
const ptr: *const T = @alignCast(parented);
|
||||||
|
//log.debug("align: {d}\n", .{@alignOf(@TypeOf(ptr))});
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ pub const Runner = struct {
|
||||||
try image.saveTo(out_path);
|
try image.saveTo(out_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn runQSCmd(self: *Runner, cmd: lang.Command) !void {
|
fn runQSCmd(self: *Runner, cmd: *lang.Command) !void {
|
||||||
const runqs = cmd.cast(lang.Command.RunQS).?;
|
const runqs = cmd.cast(lang.Command.RunQS).?;
|
||||||
var image = try self.getImage();
|
var image = try self.getImage();
|
||||||
const out_path = try self.makeGlitchedPath();
|
const out_path = try self.makeGlitchedPath();
|
||||||
|
@ -211,7 +211,7 @@ pub const Runner = struct {
|
||||||
_ = try proc.spawnAndWait();
|
_ = try proc.spawnAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rotateCmd(self: *Runner, cmd: lang.Command) !void {
|
fn rotateCmd(self: *Runner, cmd: *lang.Command) !void {
|
||||||
const rotate_cmd = cmd.cast(lang.Command.Rotate).?;
|
const rotate_cmd = cmd.cast(lang.Command.Rotate).?;
|
||||||
|
|
||||||
const image = try self.getImage();
|
const image = try self.getImage();
|
||||||
|
@ -255,7 +255,7 @@ pub const Runner = struct {
|
||||||
|
|
||||||
fn runSingleCommand(
|
fn runSingleCommand(
|
||||||
self: *@This(),
|
self: *@This(),
|
||||||
cmd: lang.Command,
|
cmd: *lang.Command,
|
||||||
comptime tag: lang.Command.Tag,
|
comptime tag: lang.Command.Tag,
|
||||||
) !void {
|
) !void {
|
||||||
const typ = lang.Command.tagToType(tag);
|
const typ = lang.Command.tagToType(tag);
|
||||||
|
@ -267,7 +267,7 @@ pub const Runner = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn runCommand(self: *@This(), cmd: lang.Command) !void {
|
fn runCommand(self: *@This(), cmd: *lang.Command) !void {
|
||||||
switch (cmd.tag) {
|
switch (cmd.tag) {
|
||||||
.noop => {},
|
.noop => {},
|
||||||
.load => {
|
.load => {
|
||||||
|
@ -322,7 +322,7 @@ pub const Runner = struct {
|
||||||
_ = debug_flag;
|
_ = debug_flag;
|
||||||
for (cmds.list.items) |cmd| {
|
for (cmds.list.items) |cmd| {
|
||||||
cmd.print();
|
cmd.print();
|
||||||
try self.runCommand(cmd.*);
|
try self.runCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue