| ... | @@ -73,56 +73,42 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype | ... | @@ -73,56 +73,42 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 73 | @compileError("pek: compile: unsupported type: " ++ @typeName(TO)); | 73 | @compileError("pek: compile: unsupported type: " ++ @typeName(TO)); |
| 74 | }, | 74 | }, |
| 75 | .block => |v| { | 75 | .block => |v| { |
| | 76 | const body = astgen.Value{ .body = v.body }; |
| 76 | switch (v.name) { | 77 | switch (v.name) { |
| 77 | .each => { | 78 | .each => { |
| 78 | comptime assertEqual(v.args.len, 1); | 79 | comptime assertEqual(v.args.len, 1); |
| 79 | const x = search(v.args[0], data); | 80 | const x = search(v.args[0], data); |
| 80 | inline for (x) |item| { | 81 | inline for (x) |item| try do(writer, body, item, ctx, indent, flag1); |
| 81 | inline for (v.body) |val| { | | |
| 82 | try do(writer, val, item, ctx, indent, flag1); | | |
| 83 | } | | |
| 84 | } | | |
| 85 | }, | 82 | }, |
| 86 | .@"if" => { | 83 | .@"if" => { |
| 87 | comptime assertEqual(v.args.len, 1); | 84 | comptime assertEqual(v.args.len, 1); |
| 88 | const x = search(v.args[0], data); | 85 | const x = search(v.args[0], data); |
| 89 | if (x) { | 86 | if (x) try do(writer, body, data, ctx, indent, flag1); |
| 90 | inline for (v.body) |val| { | | |
| 91 | try do(writer, val, data, ctx, indent, flag1); | | |
| 92 | } | | |
| 93 | } | | |
| 94 | }, | 87 | }, |
| 95 | .ifnot => { | 88 | .ifnot => { |
| 96 | comptime assertEqual(v.args.len, 1); | 89 | comptime assertEqual(v.args.len, 1); |
| 97 | const x = search(v.args[0], data); | 90 | const x = search(v.args[0], data); |
| 98 | if (!x) { | 91 | if (!x) try do(writer, body, data, ctx, indent, flag1); |
| 99 | inline for (v.body) |val| { | | |
| 100 | try do(writer, val, data, ctx, indent, flag1); | | |
| 101 | } | | |
| 102 | } | | |
| 103 | }, | 92 | }, |
| 104 | .ifequal => { | 93 | .ifequal => { |
| 105 | comptime assertEqual(v.args.len, 2); | 94 | comptime assertEqual(v.args.len, 2); |
| 106 | const x = search(v.args[0], data); | 95 | const x = search(v.args[0], data); |
| 107 | const y = search(v.args[1], data); | 96 | const y = search(v.args[1], data); |
| 108 | if (x == y) { | 97 | if (x == y) try do(writer, body, data, ctx, indent, flag1); |
| 109 | inline for (v.body) |val| { | | |
| 110 | try do(writer, val, data, ctx, indent, flag1); | | |
| 111 | } | | |
| 112 | } | | |
| 113 | }, | 98 | }, |
| 114 | .ifnotequal => { | 99 | .ifnotequal => { |
| 115 | comptime assertEqual(v.args.len, 2); | 100 | comptime assertEqual(v.args.len, 2); |
| 116 | const x = search(v.args[0], data); | 101 | const x = search(v.args[0], data); |
| 117 | const y = search(v.args[1], data); | 102 | const y = search(v.args[1], data); |
| 118 | if (x != y) { | 103 | if (x != y) try do(writer, body, data, ctx, indent, flag1); |
| 119 | inline for (v.body) |val| { | | |
| 120 | try do(writer, val, data, ctx, indent, flag1); | | |
| 121 | } | | |
| 122 | } | | |
| 123 | }, | 104 | }, |
| 124 | } | 105 | } |
| 125 | }, | 106 | }, |
| | 107 | .body => |v| { |
| | 108 | inline for (v) |val| { |
| | 109 | try do(writer, val, data, ctx, indent, flag1); |
| | 110 | } |
| | 111 | }, |
| 126 | else => unreachable, | 112 | else => unreachable, |
| 127 | } | 113 | } |
| 128 | } | 114 | } |