| author | |
| committer | |
| log | 9c797fe3ac3a377caa01bdbd74b984d11b53398e |
| tree | 225e9341a99ff908f3fd7e2b5ffa124dbe68785a |
| parent | 61bcac108cecba0ab8e1b442bd71c51306c0e9fc |
| signature | Commit is signed but in an unrecognized format. |
3 files changed, 21 insertions(+), 3 deletions(-)
lib/std/zig/ast.zig+9| ... | ... | @@ -1357,6 +1357,7 @@ pub const Node = struct { |
| 1357 | 1357 | extern_export_inline_token: TokenIndex, |
| 1358 | 1358 | is_extern_prototype: void, // TODO: Remove once extern fn rewriting is |
| 1359 | 1359 | is_async: void, // TODO: remove once async fn rewriting is |
| 1360 | is_inline: void, // TODO: remove once inline fn rewriting is | |
| 1360 | 1361 | }); |
| 1361 | 1362 | |
| 1362 | 1363 | pub const RequiredFields = struct { |
| ... | ... | @@ -1523,6 +1524,14 @@ pub const Node = struct { |
| 1523 | 1524 | self.setTrailer(.is_async, value); |
| 1524 | 1525 | } |
| 1525 | 1526 | |
| 1527 | pub fn getIsInline(self: *const FnProto) ?void { | |
| 1528 | return self.getTrailer(.is_inline); | |
| 1529 | } | |
| 1530 | ||
| 1531 | pub fn setIsInline(self: *FnProto, value: void) void { | |
| 1532 | self.setTrailer(.is_inline, value); | |
| 1533 | } | |
| 1534 | ||
| 1526 | 1535 | fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) { |
| 1527 | 1536 | const trailers_start = @alignCast( |
| 1528 | 1537 | @alignOf(ParamDecl), |
lib/std/zig/parse.zig+9-2| ... | ... | @@ -493,9 +493,15 @@ const Parser = struct { |
| 493 | 493 | extern_export_inline_token: ?TokenIndex = null, |
| 494 | 494 | lib_name: ?*Node = null, |
| 495 | 495 | }) !?*Node { |
| 496 | // TODO: Remove once extern/async fn rewriting is | |
| 497 | var is_async: ?void = null; | |
| 496 | // TODO: Remove once extern/async/inline fn rewriting is | |
| 498 | 497 | var is_extern_prototype: ?void = null; |
| 498 | var is_async: ?void = null; | |
| 499 | var is_inline: ?void = null; | |
| 500 | if (fields.extern_export_inline_token != null and | |
| 501 | p.token_ids[fields.extern_export_inline_token.?] == .Keyword_inline) | |
| 502 | { | |
| 503 | is_inline = {}; | |
| 504 | } | |
| 499 | 505 | const cc_token: ?TokenIndex = blk: { |
| 500 | 506 | if (p.eatToken(.Keyword_extern)) |token| { |
| 501 | 507 | is_extern_prototype = {}; |
| ... | ... | @@ -573,6 +579,7 @@ const Parser = struct { |
| 573 | 579 | .callconv_expr = callconv_expr, |
| 574 | 580 | .is_extern_prototype = is_extern_prototype, |
| 575 | 581 | .is_async = is_async, |
| 582 | .is_inline = is_inline, | |
| 576 | 583 | }); |
| 577 | 584 | std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params); |
| 578 | 585 |
lib/std/zig/render.zig+3-1| ... | ... | @@ -1558,7 +1558,7 @@ fn renderExpression( |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | if (fn_proto.getExternExportInlineToken()) |extern_export_inline_token| { |
| 1561 | if (fn_proto.getIsExternPrototype() == null) | |
| 1561 | if (fn_proto.getIsExternPrototype() == null and fn_proto.getIsInline() == null) | |
| 1562 | 1562 | try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline |
| 1563 | 1563 | } |
| 1564 | 1564 | |
| ... | ... | @@ -1664,6 +1664,8 @@ fn renderExpression( |
| 1664 | 1664 | try ais.writer().writeAll("callconv(.C) "); |
| 1665 | 1665 | } else if (fn_proto.getIsAsync() != null) { |
| 1666 | 1666 | try ais.writer().writeAll("callconv(.Async) "); |
| 1667 | } else if (fn_proto.getIsInline() != null) { | |
| 1668 | try ais.writer().writeAll("callconv(.Inline) "); | |
| 1667 | 1669 | } |
| 1668 | 1670 | |
| 1669 | 1671 | switch (fn_proto.return_type) { |