authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-12-07 19:34:00+01:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-12-10 23:09:01+01:00
log47c309c34a23bcec9b3d72dade688965893614a4
treed641501e0fcdf6c83d557aeb6bbd4721b1a06d37
parent75f3e7a4a05db7ea805e581f78117a41768945ae
signaturelock-open Commit is signed but in an unrecognized format.

AstGen: increase zig fmt off/on granularity

This enables automatic formatting for a significant amount of code that currently doesn't deviate from the standard zig fmt enforced style.

1 files changed, 10 insertions(+), 6 deletions(-)

src/AstGen.zig+10-6
...@@ -6739,7 +6739,6 @@ fn builtinCall(...@@ -6739,7 +6739,6 @@ fn builtinCall(
6739 }6739 }
6740 }6740 }
67416741
6742 // zig fmt: off
6743 switch (info.tag) {6742 switch (info.tag) {
6744 .import => {6743 .import => {
6745 const node_tags = tree.nodes.items(.tag);6744 const node_tags = tree.nodes.items(.tag);
...@@ -6768,7 +6767,7 @@ fn builtinCall(...@@ -6768,7 +6767,7 @@ fn builtinCall(
6768 astgen.extra.items[extra_index] = @enumToInt(param_ref);6767 astgen.extra.items[extra_index] = @enumToInt(param_ref);
6769 extra_index += 1;6768 extra_index += 1;
6770 }6769 }
6771 const result = try gz.addExtendedMultiOpPayloadIndex(.compile_log,payload_index, params.len);6770 const result = try gz.addExtendedMultiOpPayloadIndex(.compile_log, payload_index, params.len);
6772 return rvalue(gz, rl, result, node);6771 return rvalue(gz, rl, result, node);
6773 },6772 },
6774 .field => {6773 .field => {
...@@ -6784,11 +6783,14 @@ fn builtinCall(...@@ -6784,11 +6783,14 @@ fn builtinCall(
6784 });6783 });
6785 return rvalue(gz, rl, result, node);6784 return rvalue(gz, rl, result, node);
6786 },6785 },
6786
6787 // zig fmt: off
6787 .as => return as( gz, scope, rl, node, params[0], params[1]),6788 .as => return as( gz, scope, rl, node, params[0], params[1]),
6788 .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]),6789 .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]),
6789 .TypeOf => return typeOf( gz, scope, rl, node, params),6790 .TypeOf => return typeOf( gz, scope, rl, node, params),
6790 .union_init => return unionInit(gz, scope, rl, node, params),6791 .union_init => return unionInit(gz, scope, rl, node, params),
6791 .c_import => return cImport( gz, scope, node, params[0]),6792 .c_import => return cImport( gz, scope, node, params[0]),
6793 // zig fmt: on
67926794
6793 .@"export" => {6795 .@"export" => {
6794 const node_tags = tree.nodes.items(.tag);6796 const node_tags = tree.nodes.items(.tag);
...@@ -6858,9 +6860,7 @@ fn builtinCall(...@@ -6858,9 +6860,7 @@ fn builtinCall(
6858 const field_ident = dot_token + 1;6860 const field_ident = dot_token + 1;
6859 decl_name = try astgen.identAsString(field_ident);6861 decl_name = try astgen.identAsString(field_ident);
6860 },6862 },
6861 else => return astgen.failNode(6863 else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}),
6862 params[0], "symbol to export must identify a declaration", .{},
6863 ),
6864 }6864 }
6865 const options = try comptimeExpr(gz, scope, .{ .ty = .export_options_type }, params[1]);6865 const options = try comptimeExpr(gz, scope, .{ .ty = .export_options_type }, params[1]);
6866 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{6866 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
...@@ -6888,6 +6888,7 @@ fn builtinCall(...@@ -6888,6 +6888,7 @@ fn builtinCall(
68886888
6889 .breakpoint => return simpleNoOpVoid(gz, rl, node, .breakpoint),6889 .breakpoint => return simpleNoOpVoid(gz, rl, node, .breakpoint),
68906890
6891 // zig fmt: off
6891 .This => return rvalue(gz, rl, try gz.addNodeExtended(.this, node), node),6892 .This => return rvalue(gz, rl, try gz.addNodeExtended(.this, node), node),
6892 .return_address => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr, node), node),6893 .return_address => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr, node), node),
6893 .src => return rvalue(gz, rl, try gz.addNodeExtended(.builtin_src, node), node),6894 .src => return rvalue(gz, rl, try gz.addNodeExtended(.builtin_src, node), node),
...@@ -6942,6 +6943,8 @@ fn builtinCall(...@@ -6942,6 +6943,8 @@ fn builtinCall(
6942 .err_set_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .err_set_cast),6943 .err_set_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .err_set_cast),
6943 .ptr_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .ptr_cast),6944 .ptr_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .ptr_cast),
6944 .truncate => return typeCast(gz, scope, rl, node, params[0], params[1], .truncate),6945 .truncate => return typeCast(gz, scope, rl, node, params[0], params[1], .truncate),
6946 // zig fmt: on
6947
6945 .align_cast => {6948 .align_cast => {
6946 const dest_align = try comptimeExpr(gz, scope, align_rl, params[0]);6949 const dest_align = try comptimeExpr(gz, scope, align_rl, params[0]);
6947 const rhs = try expr(gz, scope, .none, params[1]);6950 const rhs = try expr(gz, scope, .none, params[1]);
...@@ -6952,6 +6955,7 @@ fn builtinCall(...@@ -6952,6 +6955,7 @@ fn builtinCall(
6952 return rvalue(gz, rl, result, node);6955 return rvalue(gz, rl, result, node);
6953 },6956 },
69546957
6958 // zig fmt: off
6955 .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl),6959 .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl),
6956 .has_field => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_field),6960 .has_field => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_field),
69576961
...@@ -6978,6 +6982,7 @@ fn builtinCall(...@@ -6978,6 +6982,7 @@ fn builtinCall(
69786982
6979 .cmpxchg_strong => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_strong),6983 .cmpxchg_strong => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_strong),
6980 .cmpxchg_weak => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_weak),6984 .cmpxchg_weak => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_weak),
6985 // zig fmt: on
69816986
6982 .wasm_memory_size => {6987 .wasm_memory_size => {
6983 const operand = try expr(gz, scope, .{ .ty = .u32_type }, params[0]);6988 const operand = try expr(gz, scope, .{ .ty = .u32_type }, params[0]);
...@@ -7222,7 +7227,6 @@ fn builtinCall(...@@ -7222,7 +7227,6 @@ fn builtinCall(
7222 return rvalue(gz, rl, result, node);7227 return rvalue(gz, rl, result, node);
7223 },7228 },
7224 }7229 }
7225 // zig fmt: on
7226}7230}
72277231
7228fn simpleNoOpVoid(7232fn simpleNoOpVoid(