| ... | ... | @@ -84,16 +84,17 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 84 | 84 | .block => |v| { |
| 85 | 85 | const body = astgen.Value{ .body = v.body }; |
| 86 | 86 | const bottom = astgen.Value{ .body = v.bttm }; |
| 87 | const x = if (comptime std.mem.eql(u8, v.args[0][0], "this")) search(v.args[0][1..], data) else search(v.args[0], ctx); |
| 88 | const T = @TypeOf(x); |
| 89 | const TI = @typeInfo(T); |
| 87 | 90 | switch (v.name) { |
| 88 | 91 | .each => { |
| 89 | 92 | comptime assertEqual(v.args.len, 1); |
| 90 | | const x = if (comptime std.mem.eql(u8, v.args[0][0], "this")) search(v.args[0][1..], data) else search(v.args[0], ctx); |
| 91 | 93 | for (x) |item| try do(writer, body, item, ctx, indent, flag1); |
| 92 | 94 | }, |
| 93 | 95 | .@"if" => { |
| 94 | 96 | comptime assertEqual(v.args.len, 1); |
| 95 | | const x = if (comptime std.mem.eql(u8, v.args[0][0], "this")) search(v.args[0][1..], data) else search(v.args[0], ctx); |
| 96 | | switch (@typeInfo(@TypeOf(x))) { |
| 97 | switch (TI) { |
| 97 | 98 | .Bool => try doif(writer, body, bottom, data, ctx, indent, flag1, x, true), |
| 98 | 99 | .Optional => try docap(writer, body, bottom, data, ctx, indent, flag1, x, true), |
| 99 | 100 | else => unreachable, |
| ... | ... | @@ -101,8 +102,7 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 101 | 102 | }, |
| 102 | 103 | .ifnot => { |
| 103 | 104 | comptime assertEqual(v.args.len, 1); |
| 104 | | const x = if (comptime std.mem.eql(u8, v.args[0][0], "this")) search(v.args[0][1..], data) else search(v.args[0], ctx); |
| 105 | | switch (@typeInfo(@TypeOf(x))) { |
| 105 | switch (TI) { |
| 106 | 106 | .Bool => try doif(writer, body, bottom, data, ctx, indent, flag1, x, false), |
| 107 | 107 | .Optional => try docap(writer, body, bottom, data, ctx, indent, flag1, x, false), |
| 108 | 108 | else => unreachable, |
| ... | ... | @@ -110,13 +110,11 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 110 | 110 | }, |
| 111 | 111 | .ifequal => { |
| 112 | 112 | comptime assertEqual(v.args.len, 2); |
| 113 | | const x = if (comptime std.mem.eql(u8, v.args[0][0], "this")) search(v.args[0][1..], data) else search(v.args[0], ctx); |
| 114 | 113 | const y = search(v.args[1], data); |
| 115 | 114 | if (x == y) try do(writer, body, data, ctx, indent, flag1); |
| 116 | 115 | }, |
| 117 | 116 | .ifnotequal => { |
| 118 | 117 | comptime assertEqual(v.args.len, 2); |
| 119 | | const x = if (comptime std.mem.eql(u8, v.args[0][0], "this")) search(v.args[0][1..], data) else search(v.args[0], ctx); |
| 120 | 118 | const y = if (comptime std.mem.eql(u8, v.args[1][0], "this")) search(v.args[1][1..], data) else search(v.args[1], ctx); |
| 121 | 119 | if (x != y) try do(writer, body, data, ctx, indent, flag1); |
| 122 | 120 | }, |