| ... | ... | @@ -74,6 +74,7 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 74 | 74 | }, |
| 75 | 75 | .block => |v| { |
| 76 | 76 | const body = astgen.Value{ .body = v.body }; |
| 77 | const bottom = astgen.Value{ .body = v.bttm }; |
| 77 | 78 | switch (v.name) { |
| 78 | 79 | .each => { |
| 79 | 80 | comptime assertEqual(v.args.len, 1); |
| ... | ... | @@ -83,22 +84,36 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 83 | 84 | .@"if" => { |
| 84 | 85 | comptime assertEqual(v.args.len, 1); |
| 85 | 86 | const x = search(v.args[0], data); |
| 86 | | const content = switch (@typeInfo(@TypeOf(x))) { |
| 87 | | .Bool => if (x) v.body else v.bttm, |
| 88 | | .Optional => if (x) |_| v.body else v.bttm, |
| 87 | switch (@typeInfo(@TypeOf(x))) { |
| 88 | .Bool => if (x) { |
| 89 | try do(writer, body, data, ctx, indent, flag1); |
| 90 | } else { |
| 91 | try do(writer, bottom, data, ctx, indent, flag1); |
| 92 | }, |
| 93 | .Optional => if (x) |_| { |
| 94 | try do(writer, body, data, ctx, indent, flag1); |
| 95 | } else { |
| 96 | try do(writer, bottom, data, ctx, indent, flag1); |
| 97 | }, |
| 89 | 98 | else => unreachable, |
| 90 | | }; |
| 91 | | try do(writer, body, content, ctx, indent, flag1); |
| 99 | } |
| 92 | 100 | }, |
| 93 | 101 | .ifnot => { |
| 94 | 102 | comptime assertEqual(v.args.len, 1); |
| 95 | 103 | const x = search(v.args[0], data); |
| 96 | | const content = switch (@typeInfo(@TypeOf(x))) { |
| 97 | | .Bool => if (x) v.bttm else v.body, |
| 98 | | .Optional => if (x) |_| v.bttm else v.body, |
| 104 | switch (@typeInfo(@TypeOf(x))) { |
| 105 | .Bool => if (x) { |
| 106 | try do(writer, bottom, data, ctx, indent, flag1); |
| 107 | } else { |
| 108 | try do(writer, body, data, ctx, indent, flag1); |
| 109 | }, |
| 110 | .Optional => if (x) |_| { |
| 111 | try do(writer, bottom, data, ctx, indent, flag1); |
| 112 | } else { |
| 113 | try do(writer, body, data, ctx, indent, flag1); |
| 114 | }, |
| 99 | 115 | else => unreachable, |
| 100 | | }; |
| 101 | | try do(writer, body, content, ctx, indent, flag1); |
| 116 | } |
| 102 | 117 | }, |
| 103 | 118 | .ifequal => { |
| 104 | 119 | comptime assertEqual(v.args.len, 2); |