| author | |
| committer | |
| log | 8545836a4d8ab0ae1411b827c0fe1bcdcb268b72 |
| tree | ad686de7feaab9423194268ec77775adbe087f25 |
| parent | fbafbd426268e0bbd3c938936459d680dc4eaaa6 |
9 files changed, 11 insertions(+), 431 deletions(-)
lib/compiler/reduce/Walk.zig-9| ... | @@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void { | ... | @@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void { |
| 501 | .@"asm", | 501 | .@"asm", |
| 502 | => return walkAsm(w, ast.fullAsm(node).?), | 502 | => return walkAsm(w, ast.fullAsm(node).?), |
| 503 | 503 | ||
| 504 | .asm_legacy => { | ||
| 505 | return walkAsmLegacy(w, ast.legacyAsm(node).?); | ||
| 506 | }, | ||
| 507 | |||
| 508 | .enum_literal => { | 504 | .enum_literal => { |
| 509 | return walkIdentifier(w, ast.nodeMainToken(node)); // name | 505 | return walkIdentifier(w, ast.nodeMainToken(node)); // name |
| 510 | }, | 506 | }, |
| ... | @@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void { | ... | @@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void { |
| 881 | try walkExpressions(w, asm_node.ast.items); | 877 | try walkExpressions(w, asm_node.ast.items); |
| 882 | } | 878 | } |
| 883 | 879 | ||
| 884 | fn walkAsmLegacy(w: *Walk, asm_node: Ast.full.AsmLegacy) Error!void { | ||
| 885 | try walkExpression(w, asm_node.ast.template); | ||
| 886 | try walkExpressions(w, asm_node.ast.items); | ||
| 887 | } | ||
| 888 | |||
| 889 | /// Check if it is already gutted (i.e. its body replaced with `@trap()`). | 880 | /// Check if it is already gutted (i.e. its body replaced with `@trap()`). |
| 890 | fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool { | 881 | fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool { |
| 891 | // skip over discards | 882 | // skip over discards |
lib/docs/wasm/Walk.zig-2| ... | @@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index) | ... | @@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index) |
| 791 | try expr(w, scope, parent_decl, full.ast.template); | 791 | try expr(w, scope, parent_decl, full.ast.template); |
| 792 | }, | 792 | }, |
| 793 | 793 | ||
| 794 | .asm_legacy => {}, | ||
| 795 | |||
| 796 | .builtin_call_two, | 794 | .builtin_call_two, |
| 797 | .builtin_call_two_comma, | 795 | .builtin_call_two_comma, |
| 798 | .builtin_call, | 796 | .builtin_call, |
lib/std/zig/Ast.zig-118| ... | @@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { | ... | @@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { |
| 636 | .@"nosuspend", | 636 | .@"nosuspend", |
| 637 | .asm_simple, | 637 | .asm_simple, |
| 638 | .@"asm", | 638 | .@"asm", |
| 639 | .asm_legacy, | ||
| 640 | .array_type, | 639 | .array_type, |
| 641 | .array_type_sentinel, | 640 | .array_type_sentinel, |
| 642 | .error_value, | 641 | .error_value, |
| ... | @@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { | ... | @@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { |
| 1050 | n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter | 1049 | n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter |
| 1051 | } | 1050 | } |
| 1052 | }, | 1051 | }, |
| 1053 | .asm_legacy => { | ||
| 1054 | _, const extra_index = tree.nodeData(n).node_and_extra; | ||
| 1055 | const extra = tree.extraData(extra_index, Node.AsmLegacy); | ||
| 1056 | return extra.rparen + end_offset; | ||
| 1057 | }, | ||
| 1058 | .@"asm" => { | 1052 | .@"asm" => { |
| 1059 | _, const extra_index = tree.nodeData(n).node_and_extra; | 1053 | _, const extra_index = tree.nodeData(n).node_and_extra; |
| 1060 | const extra = tree.extraData(extra_index, Node.Asm); | 1054 | const extra = tree.extraData(extra_index, Node.Asm); |
| ... | @@ -1897,18 +1891,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { | ... | @@ -1897,18 +1891,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { |
| 1897 | }); | 1891 | }); |
| 1898 | } | 1892 | } |
| 1899 | 1893 | ||
| 1900 | pub fn asmLegacy(tree: Ast, node: Node.Index) full.AsmLegacy { | ||
| 1901 | const template, const extra_index = tree.nodeData(node).node_and_extra; | ||
| 1902 | const extra = tree.extraData(extra_index, Node.AsmLegacy); | ||
| 1903 | const items = tree.extraDataSlice(.{ .start = extra.items_start, .end = extra.items_end }, Node.Index); | ||
| 1904 | return tree.legacyAsmComponents(.{ | ||
| 1905 | .asm_token = tree.nodeMainToken(node), | ||
| 1906 | .template = template, | ||
| 1907 | .items = items, | ||
| 1908 | .rparen = extra.rparen, | ||
| 1909 | }); | ||
| 1910 | } | ||
| 1911 | |||
| 1912 | pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { | 1894 | pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { |
| 1913 | const template, const extra_index = tree.nodeData(node).node_and_extra; | 1895 | const template, const extra_index = tree.nodeData(node).node_and_extra; |
| 1914 | const extra = tree.extraData(extra_index, Node.Asm); | 1896 | const extra = tree.extraData(extra_index, Node.Asm); |
| ... | @@ -2214,67 +2196,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N | ... | @@ -2214,67 +2196,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N |
| 2214 | return result; | 2196 | return result; |
| 2215 | } | 2197 | } |
| 2216 | 2198 | ||
| 2217 | fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy { | ||
| 2218 | var result: full.AsmLegacy = .{ | ||
| 2219 | .ast = info, | ||
| 2220 | .volatile_token = null, | ||
| 2221 | .inputs = &.{}, | ||
| 2222 | .outputs = &.{}, | ||
| 2223 | .first_clobber = null, | ||
| 2224 | }; | ||
| 2225 | if (tree.tokenTag(info.asm_token + 1) == .keyword_volatile) { | ||
| 2226 | result.volatile_token = info.asm_token + 1; | ||
| 2227 | } | ||
| 2228 | const outputs_end: usize = for (info.items, 0..) |item, i| { | ||
| 2229 | switch (tree.nodeTag(item)) { | ||
| 2230 | .asm_output => continue, | ||
| 2231 | else => break i, | ||
| 2232 | } | ||
| 2233 | } else info.items.len; | ||
| 2234 | |||
| 2235 | result.outputs = info.items[0..outputs_end]; | ||
| 2236 | result.inputs = info.items[outputs_end..]; | ||
| 2237 | |||
| 2238 | if (info.items.len == 0) { | ||
| 2239 | // asm ("foo" ::: "a", "b"); | ||
| 2240 | const template_token = tree.lastToken(info.template); | ||
| 2241 | if (tree.tokenTag(template_token + 1) == .colon and | ||
| 2242 | tree.tokenTag(template_token + 2) == .colon and | ||
| 2243 | tree.tokenTag(template_token + 3) == .colon and | ||
| 2244 | tree.tokenTag(template_token + 4) == .string_literal) | ||
| 2245 | { | ||
| 2246 | result.first_clobber = template_token + 4; | ||
| 2247 | } | ||
| 2248 | } else if (result.inputs.len != 0) { | ||
| 2249 | // asm ("foo" :: [_] "" (y) : "a", "b"); | ||
| 2250 | const last_input = result.inputs[result.inputs.len - 1]; | ||
| 2251 | const rparen = tree.lastToken(last_input); | ||
| 2252 | var i = rparen + 1; | ||
| 2253 | // Allow a (useless) comma right after the closing parenthesis. | ||
| 2254 | if (tree.tokenTag(i) == .comma) i = i + 1; | ||
| 2255 | if (tree.tokenTag(i) == .colon and | ||
| 2256 | tree.tokenTag(i + 1) == .string_literal) | ||
| 2257 | { | ||
| 2258 | result.first_clobber = i + 1; | ||
| 2259 | } | ||
| 2260 | } else { | ||
| 2261 | // asm ("foo" : [_] "" (x) :: "a", "b"); | ||
| 2262 | const last_output = result.outputs[result.outputs.len - 1]; | ||
| 2263 | const rparen = tree.lastToken(last_output); | ||
| 2264 | var i = rparen + 1; | ||
| 2265 | // Allow a (useless) comma right after the closing parenthesis. | ||
| 2266 | if (tree.tokenTag(i) == .comma) i = i + 1; | ||
| 2267 | if (tree.tokenTag(i) == .colon and | ||
| 2268 | tree.tokenTag(i + 1) == .colon and | ||
| 2269 | tree.tokenTag(i + 2) == .string_literal) | ||
| 2270 | { | ||
| 2271 | result.first_clobber = i + 2; | ||
| 2272 | } | ||
| 2273 | } | ||
| 2274 | |||
| 2275 | return result; | ||
| 2276 | } | ||
| 2277 | |||
| 2278 | fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { | 2199 | fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm { |
| 2279 | var result: full.Asm = .{ | 2200 | var result: full.Asm = .{ |
| 2280 | .ast = info, | 2201 | .ast = info, |
| ... | @@ -2492,14 +2413,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm { | ... | @@ -2492,14 +2413,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm { |
| 2492 | }; | 2413 | }; |
| 2493 | } | 2414 | } |
| 2494 | 2415 | ||
| 2495 | /// To be deleted after 0.15.0 is tagged | ||
| 2496 | pub fn legacyAsm(tree: Ast, node: Node.Index) ?full.AsmLegacy { | ||
| 2497 | return switch (tree.nodeTag(node)) { | ||
| 2498 | .asm_legacy => tree.asmLegacy(node), | ||
| 2499 | else => null, | ||
| 2500 | }; | ||
| 2501 | } | ||
| 2502 | |||
| 2503 | pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { | 2416 | pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call { |
| 2504 | return switch (tree.nodeTag(node)) { | 2417 | return switch (tree.nodeTag(node)) { |
| 2505 | .call, .call_comma => tree.callFull(node), | 2418 | .call, .call_comma => tree.callFull(node), |
| ... | @@ -2894,21 +2807,6 @@ pub const full = struct { | ... | @@ -2894,21 +2807,6 @@ pub const full = struct { |
| 2894 | }; | 2807 | }; |
| 2895 | }; | 2808 | }; |
| 2896 | 2809 | ||
| 2897 | pub const AsmLegacy = struct { | ||
| 2898 | ast: Components, | ||
| 2899 | volatile_token: ?TokenIndex, | ||
| 2900 | first_clobber: ?TokenIndex, | ||
| 2901 | outputs: []const Node.Index, | ||
| 2902 | inputs: []const Node.Index, | ||
| 2903 | |||
| 2904 | pub const Components = struct { | ||
| 2905 | asm_token: TokenIndex, | ||
| 2906 | template: Node.Index, | ||
| 2907 | items: []const Node.Index, | ||
| 2908 | rparen: TokenIndex, | ||
| 2909 | }; | ||
| 2910 | }; | ||
| 2911 | |||
| 2912 | pub const Call = struct { | 2810 | pub const Call = struct { |
| 2913 | ast: Components, | 2811 | ast: Components, |
| 2914 | 2812 | ||
| ... | @@ -3905,14 +3803,6 @@ pub const Node = struct { | ... | @@ -3905,14 +3803,6 @@ pub const Node = struct { |
| 3905 | /// | 3803 | /// |
| 3906 | /// The `main_token` field is the `asm` token. | 3804 | /// The `main_token` field is the `asm` token. |
| 3907 | asm_simple, | 3805 | asm_simple, |
| 3908 | /// `asm(lhs, a)`. | ||
| 3909 | /// | ||
| 3910 | /// The `data` field is a `.node_and_extra`: | ||
| 3911 | /// 1. a `Node.Index` to lhs. | ||
| 3912 | /// 2. a `ExtraIndex` to `AsmLegacy`. | ||
| 3913 | /// | ||
| 3914 | /// The `main_token` field is the `asm` token. | ||
| 3915 | asm_legacy, | ||
| 3916 | /// `asm(a, b)`. | 3806 | /// `asm(a, b)`. |
| 3917 | /// | 3807 | /// |
| 3918 | /// The `data` field is a `.node_and_extra`: | 3808 | /// The `data` field is a `.node_and_extra`: |
| ... | @@ -4089,14 +3979,6 @@ pub const Node = struct { | ... | @@ -4089,14 +3979,6 @@ pub const Node = struct { |
| 4089 | callconv_expr: OptionalIndex, | 3979 | callconv_expr: OptionalIndex, |
| 4090 | }; | 3980 | }; |
| 4091 | 3981 | ||
| 4092 | /// To be removed after 0.15.0 is tagged | ||
| 4093 | pub const AsmLegacy = struct { | ||
| 4094 | items_start: ExtraIndex, | ||
| 4095 | items_end: ExtraIndex, | ||
| 4096 | /// Needed to make lastToken() work. | ||
| 4097 | rparen: TokenIndex, | ||
| 4098 | }; | ||
| 4099 | |||
| 4100 | pub const Asm = struct { | 3982 | pub const Asm = struct { |
| 4101 | items_start: ExtraIndex, | 3983 | items_start: ExtraIndex, |
| 4102 | items_end: ExtraIndex, | 3984 | items_end: ExtraIndex, |
lib/std/zig/Ast/Render.zig-182| ... | @@ -896,9 +896,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void { | ... | @@ -896,9 +896,6 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void { |
| 896 | .@"asm", | 896 | .@"asm", |
| 897 | => return renderAsm(r, tree.fullAsm(node).?, space), | 897 | => return renderAsm(r, tree.fullAsm(node).?, space), |
| 898 | 898 | ||
| 899 | // To be removed after 0.15.0 is tagged | ||
| 900 | .asm_legacy => return renderAsmLegacy(r, tree.legacyAsm(node).?, space), | ||
| 901 | |||
| 902 | .enum_literal => { | 899 | .enum_literal => { |
| 903 | try renderToken(r, tree.nodeMainToken(node) - 1, .none); // . | 900 | try renderToken(r, tree.nodeMainToken(node) - 1, .none); // . |
| 904 | return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name | 901 | return renderIdentifier(r, tree.nodeMainToken(node), space, .eagerly_unquote); // name |
| ... | @@ -2413,185 +2410,6 @@ fn renderContainerDecl( | ... | @@ -2413,185 +2410,6 @@ fn renderContainerDecl( |
| 2413 | return renderToken(r, rbrace, space); // rbrace | 2410 | return renderToken(r, rbrace, space); // rbrace |
| 2414 | } | 2411 | } |
| 2415 | 2412 | ||
| 2416 | fn renderAsmLegacy( | ||
| 2417 | r: *Render, | ||
| 2418 | asm_node: Ast.full.AsmLegacy, | ||
| 2419 | space: Space, | ||
| 2420 | ) Error!void { | ||
| 2421 | const tree = r.tree; | ||
| 2422 | const ais = r.ais; | ||
| 2423 | |||
| 2424 | try renderToken(r, asm_node.ast.asm_token, .space); // asm | ||
| 2425 | |||
| 2426 | if (asm_node.volatile_token) |volatile_token| { | ||
| 2427 | try renderToken(r, volatile_token, .space); // volatile | ||
| 2428 | try renderToken(r, volatile_token + 1, .none); // lparen | ||
| 2429 | } else { | ||
| 2430 | try renderToken(r, asm_node.ast.asm_token + 1, .none); // lparen | ||
| 2431 | } | ||
| 2432 | |||
| 2433 | if (asm_node.ast.items.len == 0) { | ||
| 2434 | try ais.forcePushIndent(.normal); | ||
| 2435 | if (asm_node.first_clobber) |first_clobber| { | ||
| 2436 | // asm ("foo" ::: "a", "b") | ||
| 2437 | // asm ("foo" ::: "a", "b",) | ||
| 2438 | try renderExpression(r, asm_node.ast.template, .space); | ||
| 2439 | // Render the three colons. | ||
| 2440 | try renderToken(r, first_clobber - 3, .none); | ||
| 2441 | try renderToken(r, first_clobber - 2, .none); | ||
| 2442 | try renderToken(r, first_clobber - 1, .space); | ||
| 2443 | |||
| 2444 | try ais.writeAll(".{ "); | ||
| 2445 | |||
| 2446 | var tok_i = first_clobber; | ||
| 2447 | while (true) : (tok_i += 1) { | ||
| 2448 | try ais.writeByte('.'); | ||
| 2449 | _ = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2450 | try ais.writeAll(" = true"); | ||
| 2451 | |||
| 2452 | tok_i += 1; | ||
| 2453 | switch (tree.tokenTag(tok_i)) { | ||
| 2454 | .r_paren => { | ||
| 2455 | try ais.writeAll(" }"); | ||
| 2456 | ais.popIndent(); | ||
| 2457 | return renderToken(r, tok_i, space); | ||
| 2458 | }, | ||
| 2459 | .comma => { | ||
| 2460 | if (tree.tokenTag(tok_i + 1) == .r_paren) { | ||
| 2461 | try ais.writeAll(" }"); | ||
| 2462 | ais.popIndent(); | ||
| 2463 | return renderToken(r, tok_i + 1, space); | ||
| 2464 | } else { | ||
| 2465 | try renderToken(r, tok_i, .space); | ||
| 2466 | } | ||
| 2467 | }, | ||
| 2468 | else => unreachable, | ||
| 2469 | } | ||
| 2470 | } | ||
| 2471 | } else { | ||
| 2472 | unreachable; | ||
| 2473 | } | ||
| 2474 | } | ||
| 2475 | |||
| 2476 | try ais.forcePushIndent(.normal); | ||
| 2477 | try renderExpression(r, asm_node.ast.template, .newline); | ||
| 2478 | ais.setIndentDelta(asm_indent_delta); | ||
| 2479 | const colon1 = tree.lastToken(asm_node.ast.template) + 1; | ||
| 2480 | |||
| 2481 | const colon2 = if (asm_node.outputs.len == 0) colon2: { | ||
| 2482 | try renderToken(r, colon1, .newline); // : | ||
| 2483 | break :colon2 colon1 + 1; | ||
| 2484 | } else colon2: { | ||
| 2485 | try renderToken(r, colon1, .space); // : | ||
| 2486 | |||
| 2487 | try ais.forcePushIndent(.normal); | ||
| 2488 | for (asm_node.outputs, 0..) |asm_output, i| { | ||
| 2489 | if (i + 1 < asm_node.outputs.len) { | ||
| 2490 | const next_asm_output = asm_node.outputs[i + 1]; | ||
| 2491 | try renderAsmOutput(r, asm_output, .none); | ||
| 2492 | |||
| 2493 | const comma = tree.firstToken(next_asm_output) - 1; | ||
| 2494 | try renderToken(r, comma, .newline); // , | ||
| 2495 | try renderExtraNewlineToken(r, tree.firstToken(next_asm_output)); | ||
| 2496 | } else if (asm_node.inputs.len == 0 and asm_node.first_clobber == null) { | ||
| 2497 | try ais.pushSpace(.comma); | ||
| 2498 | try renderAsmOutput(r, asm_output, .comma); | ||
| 2499 | ais.popSpace(); | ||
| 2500 | ais.popIndent(); | ||
| 2501 | ais.setIndentDelta(indent_delta); | ||
| 2502 | ais.popIndent(); | ||
| 2503 | return renderToken(r, asm_node.ast.rparen, space); // rparen | ||
| 2504 | } else { | ||
| 2505 | try ais.pushSpace(.comma); | ||
| 2506 | try renderAsmOutput(r, asm_output, .comma); | ||
| 2507 | ais.popSpace(); | ||
| 2508 | const comma_or_colon = tree.lastToken(asm_output) + 1; | ||
| 2509 | ais.popIndent(); | ||
| 2510 | break :colon2 switch (tree.tokenTag(comma_or_colon)) { | ||
| 2511 | .comma => comma_or_colon + 1, | ||
| 2512 | else => comma_or_colon, | ||
| 2513 | }; | ||
| 2514 | } | ||
| 2515 | } else unreachable; | ||
| 2516 | }; | ||
| 2517 | |||
| 2518 | const colon3 = if (asm_node.inputs.len == 0) colon3: { | ||
| 2519 | try renderToken(r, colon2, .newline); // : | ||
| 2520 | break :colon3 colon2 + 1; | ||
| 2521 | } else colon3: { | ||
| 2522 | try renderToken(r, colon2, .space); // : | ||
| 2523 | try ais.forcePushIndent(.normal); | ||
| 2524 | for (asm_node.inputs, 0..) |asm_input, i| { | ||
| 2525 | if (i + 1 < asm_node.inputs.len) { | ||
| 2526 | const next_asm_input = asm_node.inputs[i + 1]; | ||
| 2527 | try renderAsmInput(r, asm_input, .none); | ||
| 2528 | |||
| 2529 | const first_token = tree.firstToken(next_asm_input); | ||
| 2530 | try renderToken(r, first_token - 1, .newline); // , | ||
| 2531 | try renderExtraNewlineToken(r, first_token); | ||
| 2532 | } else if (asm_node.first_clobber == null) { | ||
| 2533 | try ais.pushSpace(.comma); | ||
| 2534 | try renderAsmInput(r, asm_input, .comma); | ||
| 2535 | ais.popSpace(); | ||
| 2536 | ais.popIndent(); | ||
| 2537 | ais.setIndentDelta(indent_delta); | ||
| 2538 | ais.popIndent(); | ||
| 2539 | return renderToken(r, asm_node.ast.rparen, space); // rparen | ||
| 2540 | } else { | ||
| 2541 | try ais.pushSpace(.comma); | ||
| 2542 | try renderAsmInput(r, asm_input, .comma); | ||
| 2543 | ais.popSpace(); | ||
| 2544 | const comma_or_colon = tree.lastToken(asm_input) + 1; | ||
| 2545 | ais.popIndent(); | ||
| 2546 | break :colon3 switch (tree.tokenTag(comma_or_colon)) { | ||
| 2547 | .comma => comma_or_colon + 1, | ||
| 2548 | else => comma_or_colon, | ||
| 2549 | }; | ||
| 2550 | } | ||
| 2551 | } | ||
| 2552 | unreachable; | ||
| 2553 | }; | ||
| 2554 | |||
| 2555 | try renderToken(r, colon3, .space); // : | ||
| 2556 | try ais.writeAll(".{ "); | ||
| 2557 | const first_clobber = asm_node.first_clobber.?; | ||
| 2558 | var tok_i = first_clobber; | ||
| 2559 | while (true) { | ||
| 2560 | switch (tree.tokenTag(tok_i + 1)) { | ||
| 2561 | .r_paren => { | ||
| 2562 | ais.setIndentDelta(indent_delta); | ||
| 2563 | try ais.writeByte('.'); | ||
| 2564 | const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2565 | try ais.writeAll(" = true }"); | ||
| 2566 | try renderSpace(r, tok_i, lexeme_len, .newline); | ||
| 2567 | ais.popIndent(); | ||
| 2568 | return renderToken(r, tok_i + 1, space); | ||
| 2569 | }, | ||
| 2570 | .comma => { | ||
| 2571 | switch (tree.tokenTag(tok_i + 2)) { | ||
| 2572 | .r_paren => { | ||
| 2573 | ais.setIndentDelta(indent_delta); | ||
| 2574 | try ais.writeByte('.'); | ||
| 2575 | const lexeme_len = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2576 | try ais.writeAll(" = true }"); | ||
| 2577 | try renderSpace(r, tok_i, lexeme_len, .newline); | ||
| 2578 | ais.popIndent(); | ||
| 2579 | return renderToken(r, tok_i + 2, space); | ||
| 2580 | }, | ||
| 2581 | else => { | ||
| 2582 | try ais.writeByte('.'); | ||
| 2583 | _ = try writeStringLiteralAsIdentifier(r, tok_i); | ||
| 2584 | try ais.writeAll(" = true"); | ||
| 2585 | try renderToken(r, tok_i + 1, .space); | ||
| 2586 | tok_i += 2; | ||
| 2587 | }, | ||
| 2588 | } | ||
| 2589 | }, | ||
| 2590 | else => unreachable, | ||
| 2591 | } | ||
| 2592 | } | ||
| 2593 | } | ||
| 2594 | |||
| 2595 | fn renderAsm( | 2413 | fn renderAsm( |
| 2596 | r: *Render, | 2414 | r: *Render, |
| 2597 | asm_node: Ast.full.Asm, | 2415 | asm_node: Ast.full.Asm, |
lib/std/zig/AstGen.zig-10| ... | @@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins | ... | @@ -507,7 +507,6 @@ fn lvalExpr(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Ins |
| 507 | .bool_or, | 507 | .bool_or, |
| 508 | .@"asm", | 508 | .@"asm", |
| 509 | .asm_simple, | 509 | .asm_simple, |
| 510 | .asm_legacy, | ||
| 511 | .string_literal, | 510 | .string_literal, |
| 512 | .number_literal, | 511 | .number_literal, |
| 513 | .call, | 512 | .call, |
| ... | @@ -814,12 +813,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE | ... | @@ -814,12 +813,6 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 814 | .@"asm", | 813 | .@"asm", |
| 815 | => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), | 814 | => return asmExpr(gz, scope, ri, node, tree.fullAsm(node).?), |
| 816 | 815 | ||
| 817 | .asm_legacy => { | ||
| 818 | return astgen.failNodeNotes(node, "legacy asm clobbers syntax", .{}, &[_]u32{ | ||
| 819 | try astgen.errNoteNode(node, "use 'zig fmt' to auto-upgrade", .{}), | ||
| 820 | }); | ||
| 821 | }, | ||
| 822 | |||
| 823 | .string_literal => return stringLiteral(gz, ri, node), | 816 | .string_literal => return stringLiteral(gz, ri, node), |
| 824 | .multiline_string_literal => return multilineStringLiteral(gz, ri, node), | 817 | .multiline_string_literal => return multilineStringLiteral(gz, ri, node), |
| 825 | 818 | ||
| ... | @@ -10502,7 +10495,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev | ... | @@ -10502,7 +10495,6 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) BuiltinFn.Ev |
| 10502 | 10495 | ||
| 10503 | .@"asm", | 10496 | .@"asm", |
| 10504 | .asm_simple, | 10497 | .asm_simple, |
| 10505 | .asm_legacy, | ||
| 10506 | .identifier, | 10498 | .identifier, |
| 10507 | .field_access, | 10499 | .field_access, |
| 10508 | .deref, | 10500 | .deref, |
| ... | @@ -10746,7 +10738,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In | ... | @@ -10746,7 +10738,6 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In |
| 10746 | .tagged_union_enum_tag_trailing, | 10738 | .tagged_union_enum_tag_trailing, |
| 10747 | .@"asm", | 10739 | .@"asm", |
| 10748 | .asm_simple, | 10740 | .asm_simple, |
| 10749 | .asm_legacy, | ||
| 10750 | .add, | 10741 | .add, |
| 10751 | .add_wrap, | 10742 | .add_wrap, |
| 10752 | .add_sat, | 10743 | .add_sat, |
| ... | @@ -10985,7 +10976,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { | ... | @@ -10985,7 +10976,6 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool { |
| 10985 | .tagged_union_enum_tag_trailing, | 10976 | .tagged_union_enum_tag_trailing, |
| 10986 | .@"asm", | 10977 | .@"asm", |
| 10987 | .asm_simple, | 10978 | .asm_simple, |
| 10988 | .asm_legacy, | ||
| 10989 | .add, | 10979 | .add, |
| 10990 | .add_wrap, | 10980 | .add_wrap, |
| 10991 | .add_sat, | 10981 | .add_sat, |
lib/std/zig/AstRlAnnotate.zig-1| ... | @@ -310,7 +310,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI | ... | @@ -310,7 +310,6 @@ fn expr(astrl: *AstRlAnnotate, node: Ast.Node.Index, block: ?*Block, ri: ResultI |
| 310 | .unreachable_literal, | 310 | .unreachable_literal, |
| 311 | .asm_simple, | 311 | .asm_simple, |
| 312 | .@"asm", | 312 | .@"asm", |
| 313 | .asm_legacy, | ||
| 314 | .enum_literal, | 313 | .enum_literal, |
| 315 | .error_value, | 314 | .error_value, |
| 316 | .anyframe_literal, | 315 | .anyframe_literal, |
lib/std/zig/Parse.zig-26| ... | @@ -2857,32 +2857,6 @@ fn expectAsmExpr(p: *Parse) !Node.Index { | ... | @@ -2857,32 +2857,6 @@ fn expectAsmExpr(p: *Parse) !Node.Index { |
| 2857 | 2857 | ||
| 2858 | _ = p.eatToken(.colon) orelse break :clobbers .none; | 2858 | _ = p.eatToken(.colon) orelse break :clobbers .none; |
| 2859 | 2859 | ||
| 2860 | // For automatic upgrades; delete after 0.15.0 released. | ||
| 2861 | if (p.tokenTag(p.tok_i) == .string_literal) { | ||
| 2862 | while (p.eatToken(.string_literal)) |_| { | ||
| 2863 | switch (p.tokenTag(p.tok_i)) { | ||
| 2864 | .comma => p.tok_i += 1, | ||
| 2865 | .colon, .r_paren, .r_brace, .r_bracket => break, | ||
| 2866 | // Likely just a missing comma; give error but continue parsing. | ||
| 2867 | else => try p.warnExpected(.comma), | ||
| 2868 | } | ||
| 2869 | } | ||
| 2870 | const rparen = try p.expectToken(.r_paren); | ||
| 2871 | const span = try p.listToSpan(p.scratch.items[scratch_top..]); | ||
| 2872 | return p.addNode(.{ | ||
| 2873 | .tag = .asm_legacy, | ||
| 2874 | .main_token = asm_token, | ||
| 2875 | .data = .{ .node_and_extra = .{ | ||
| 2876 | template, | ||
| 2877 | try p.addExtra(Node.AsmLegacy{ | ||
| 2878 | .items_start = span.start, | ||
| 2879 | .items_end = span.end, | ||
| 2880 | .rparen = rparen, | ||
| 2881 | }), | ||
| 2882 | } }, | ||
| 2883 | }); | ||
| 2884 | } | ||
| 2885 | |||
| 2886 | break :clobbers (try p.expectExpr()).toOptional(); | 2860 | break :clobbers (try p.expectExpr()).toOptional(); |
| 2887 | } else .none; | 2861 | } else .none; |
| 2888 | 2862 |
lib/std/zig/ZonGen.zig+1-1| ... | @@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator | ... | @@ -238,7 +238,7 @@ fn expr(zg: *ZonGen, node: Ast.Node.Index, dest_node: Zoir.Node.Index) Allocator |
| 238 | => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}), | 238 | => try zg.addErrorNode(node, "control flow is not allowed in ZON", .{}), |
| 239 | 239 | ||
| 240 | .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}), | 240 | .@"comptime" => try zg.addErrorNode(node, "keyword 'comptime' is not allowed in ZON", .{}), |
| 241 | .asm_simple, .@"asm", .asm_legacy => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), | 241 | .asm_simple, .@"asm" => try zg.addErrorNode(node, "inline asm is not allowed in ZON", .{}), |
| 242 | 242 | ||
| 243 | .builtin_call_two, | 243 | .builtin_call_two, |
| 244 | .builtin_call_two_comma, | 244 | .builtin_call_two_comma, |
lib/std/zig/parser_test.zig+10-82| ... | @@ -31,54 +31,16 @@ test "zig fmt: tuple struct" { | ... | @@ -31,54 +31,16 @@ test "zig fmt: tuple struct" { |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | test "zig fmt: preserves clobbers in inline asm with stray comma" { | 33 | test "zig fmt: preserves clobbers in inline asm with stray comma" { |
| 34 | try testTransform( | 34 | try testCanonical( |
| 35 | \\fn foo() void { | ||
| 36 | \\ asm volatile ("" | ||
| 37 | \\ : [_] "" (-> type), | ||
| 38 | \\ : | ||
| 39 | \\ : "clobber" | ||
| 40 | \\ ); | ||
| 41 | \\ asm volatile ("" | ||
| 42 | \\ : | ||
| 43 | \\ : [_] "" (type), | ||
| 44 | \\ : "clobber" | ||
| 45 | \\ ); | ||
| 46 | \\} | ||
| 47 | \\ | ||
| 48 | , | ||
| 49 | \\fn foo() void { | 35 | \\fn foo() void { |
| 50 | \\ asm volatile ("" | 36 | \\ asm volatile ("" |
| 51 | \\ : [_] "" (-> type), | 37 | \\ : [_] "" (-> type), |
| 52 | \\ : | 38 | \\ : |
| 53 | \\ : .{ .clobber = true } | 39 | \\ : .{ .clobber = true }); |
| 54 | \\ ); | ||
| 55 | \\ asm volatile ("" | 40 | \\ asm volatile ("" |
| 56 | \\ : | 41 | \\ : |
| 57 | \\ : [_] "" (type), | 42 | \\ : [_] "" (type), |
| 58 | \\ : .{ .clobber = true } | 43 | \\ : .{ .clobber = true }); |
| 59 | \\ ); | ||
| 60 | \\} | ||
| 61 | \\ | ||
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | test "zig fmt: remove trailing comma at the end of assembly clobber" { | ||
| 66 | try testTransform( | ||
| 67 | \\fn foo() void { | ||
| 68 | \\ asm volatile ("" | ||
| 69 | \\ : [_] "" (-> type), | ||
| 70 | \\ : | ||
| 71 | \\ : "clobber1", "clobber2", | ||
| 72 | \\ ); | ||
| 73 | \\} | ||
| 74 | \\ | ||
| 75 | , | ||
| 76 | \\fn foo() void { | ||
| 77 | \\ asm volatile ("" | ||
| 78 | \\ : [_] "" (-> type), | ||
| 79 | \\ : | ||
| 80 | \\ : .{ .clobber1 = true, .clobber2 = true } | ||
| 81 | \\ ); | ||
| 82 | \\} | 44 | \\} |
| 83 | \\ | 45 | \\ |
| 84 | ); | 46 | ); |
| ... | @@ -641,27 +603,7 @@ test "zig fmt: builtin call with trailing comma" { | ... | @@ -641,27 +603,7 @@ test "zig fmt: builtin call with trailing comma" { |
| 641 | } | 603 | } |
| 642 | 604 | ||
| 643 | test "zig fmt: asm expression with comptime content" { | 605 | test "zig fmt: asm expression with comptime content" { |
| 644 | try testTransform( | 606 | try testCanonical( |
| 645 | \\comptime { | ||
| 646 | \\ asm ("foo" ++ "bar"); | ||
| 647 | \\} | ||
| 648 | \\pub fn main() void { | ||
| 649 | \\ asm volatile ("foo" ++ "bar"); | ||
| 650 | \\ asm volatile ("foo" ++ "bar" | ||
| 651 | \\ : [_] "" (x), | ||
| 652 | \\ ); | ||
| 653 | \\ asm volatile ("foo" ++ "bar" | ||
| 654 | \\ : [_] "" (x), | ||
| 655 | \\ : [_] "" (y), | ||
| 656 | \\ ); | ||
| 657 | \\ asm volatile ("foo" ++ "bar" | ||
| 658 | \\ : [_] "" (x), | ||
| 659 | \\ : [_] "" (y), | ||
| 660 | \\ : "h", "e", "l", "l", "o" | ||
| 661 | \\ ); | ||
| 662 | \\} | ||
| 663 | \\ | ||
| 664 | , | ||
| 665 | \\comptime { | 607 | \\comptime { |
| 666 | \\ asm ("foo" ++ "bar"); | 608 | \\ asm ("foo" ++ "bar"); |
| 667 | \\} | 609 | \\} |
| ... | @@ -677,8 +619,7 @@ test "zig fmt: asm expression with comptime content" { | ... | @@ -677,8 +619,7 @@ test "zig fmt: asm expression with comptime content" { |
| 677 | \\ asm volatile ("foo" ++ "bar" | 619 | \\ asm volatile ("foo" ++ "bar" |
| 678 | \\ : [_] "" (x), | 620 | \\ : [_] "" (x), |
| 679 | \\ : [_] "" (y), | 621 | \\ : [_] "" (y), |
| 680 | \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true } | 622 | \\ : .{ .h = true, .e = true, .l = true, .l = true, .o = true }); |
| 681 | \\ ); | ||
| 682 | \\} | 623 | \\} |
| 683 | \\ | 624 | \\ |
| 684 | ); | 625 | ); |
| ... | @@ -2198,7 +2139,7 @@ test "zig fmt: simple asm" { | ... | @@ -2198,7 +2139,7 @@ test "zig fmt: simple asm" { |
| 2198 | \\ asm ("not real assembly" | 2139 | \\ asm ("not real assembly" |
| 2199 | \\ :[a] "x" (->i32),:[a] "x" (1),); | 2140 | \\ :[a] "x" (->i32),:[a] "x" (1),); |
| 2200 | \\ asm ("still not real assembly" | 2141 | \\ asm ("still not real assembly" |
| 2201 | \\ :::"a","b",); | 2142 | \\ :::.{.a=true,.b=true}); |
| 2202 | \\} | 2143 | \\} |
| 2203 | , | 2144 | , |
| 2204 | \\comptime { | 2145 | \\comptime { |
| ... | @@ -3940,24 +3881,13 @@ test "zig fmt: fn type" { | ... | @@ -3940,24 +3881,13 @@ test "zig fmt: fn type" { |
| 3940 | } | 3881 | } |
| 3941 | 3882 | ||
| 3942 | test "zig fmt: inline asm" { | 3883 | test "zig fmt: inline asm" { |
| 3943 | try testTransform( | 3884 | try testCanonical( |
| 3944 | \\pub fn syscall1(number: usize, arg1: usize) usize { | ||
| 3945 | \\ return asm volatile ("syscall" | ||
| 3946 | \\ : [ret] "={rax}" (-> usize), | ||
| 3947 | \\ : [number] "{rax}" (number), | ||
| 3948 | \\ [arg1] "{rdi}" (arg1), | ||
| 3949 | \\ : "rcx", "r11" | ||
| 3950 | \\ ); | ||
| 3951 | \\} | ||
| 3952 | \\ | ||
| 3953 | , | ||
| 3954 | \\pub fn syscall1(number: usize, arg1: usize) usize { | 3885 | \\pub fn syscall1(number: usize, arg1: usize) usize { |
| 3955 | \\ return asm volatile ("syscall" | 3886 | \\ return asm volatile ("syscall" |
| 3956 | \\ : [ret] "={rax}" (-> usize), | 3887 | \\ : [ret] "={rax}" (-> usize), |
| 3957 | \\ : [number] "{rax}" (number), | 3888 | \\ : [number] "{rax}" (number), |
| 3958 | \\ [arg1] "{rdi}" (arg1), | 3889 | \\ [arg1] "{rdi}" (arg1), |
| 3959 | \\ : .{ .rcx = true, .r11 = true } | 3890 | \\ : .{ .rcx = true, .r11 = true }); |
| 3960 | \\ ); | ||
| 3961 | \\} | 3891 | \\} |
| 3962 | \\ | 3892 | \\ |
| 3963 | ); | 3893 | ); |
| ... | @@ -5789,8 +5719,7 @@ test "zig fmt: canonicalize symbols (asm)" { | ... | @@ -5789,8 +5719,7 @@ test "zig fmt: canonicalize symbols (asm)" { |
| 5789 | \\ [@"arg1"] "{rdi}" (arg), | 5719 | \\ [@"arg1"] "{rdi}" (arg), |
| 5790 | \\ [arg2] "{rsi}" (arg), | 5720 | \\ [arg2] "{rsi}" (arg), |
| 5791 | \\ [arg3] "{rdx}" (arg), | 5721 | \\ [arg3] "{rdx}" (arg), |
| 5792 | \\ : "rcx", "fn" | 5722 | \\ : .{ .rcx = true, .@"fn" = true }); |
| 5793 | \\ ); | ||
| 5794 | \\ | 5723 | \\ |
| 5795 | \\ const @"false": usize = 10; | 5724 | \\ const @"false": usize = 10; |
| 5796 | \\ const @"true" = "explode"; | 5725 | \\ const @"true" = "explode"; |
| ... | @@ -5811,8 +5740,7 @@ test "zig fmt: canonicalize symbols (asm)" { | ... | @@ -5811,8 +5740,7 @@ test "zig fmt: canonicalize symbols (asm)" { |
| 5811 | \\ [arg1] "{rdi}" (arg), | 5740 | \\ [arg1] "{rdi}" (arg), |
| 5812 | \\ [arg2] "{rsi}" (arg), | 5741 | \\ [arg2] "{rsi}" (arg), |
| 5813 | \\ [arg3] "{rdx}" (arg), | 5742 | \\ [arg3] "{rdx}" (arg), |
| 5814 | \\ : .{ .rcx = true, .@"fn" = true } | 5743 | \\ : .{ .rcx = true, .@"fn" = true }); |
| 5815 | \\ ); | ||
| 5816 | \\ | 5744 | \\ |
| 5817 | \\ const @"false": usize = 10; | 5745 | \\ const @"false": usize = 10; |
| 5818 | \\ const @"true" = "explode"; | 5746 | \\ const @"true" = "explode"; |