authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2021-01-11 07:56:48-07:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2021-02-10 20:06:11-07:00
log9c797fe3ac3a377caa01bdbd74b984d11b53398e
tree225e9341a99ff908f3fd7e2b5ffa124dbe68785a
parent61bcac108cecba0ab8e1b442bd71c51306c0e9fc
signature Commit is signed but in an unrecognized format.

std.zig: reformat inline fn to callconv(.Inline)


3 files changed, 21 insertions(+), 3 deletions(-)

lib/std/zig/ast.zig+9
......@@ -1357,6 +1357,7 @@ pub const Node = struct {
13571357 extern_export_inline_token: TokenIndex,
13581358 is_extern_prototype: void, // TODO: Remove once extern fn rewriting is
13591359 is_async: void, // TODO: remove once async fn rewriting is
1360 is_inline: void, // TODO: remove once inline fn rewriting is
13601361 });
13611362
13621363 pub const RequiredFields = struct {
......@@ -1523,6 +1524,14 @@ pub const Node = struct {
15231524 self.setTrailer(.is_async, value);
15241525 }
15251526
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
15261535 fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) {
15271536 const trailers_start = @alignCast(
15281537 @alignOf(ParamDecl),
lib/std/zig/parse.zig+9-2
......@@ -493,9 +493,15 @@ const Parser = struct {
493493 extern_export_inline_token: ?TokenIndex = null,
494494 lib_name: ?*Node = null,
495495 }) !?*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
498497 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 }
499505 const cc_token: ?TokenIndex = blk: {
500506 if (p.eatToken(.Keyword_extern)) |token| {
501507 is_extern_prototype = {};
......@@ -573,6 +579,7 @@ const Parser = struct {
573579 .callconv_expr = callconv_expr,
574580 .is_extern_prototype = is_extern_prototype,
575581 .is_async = is_async,
582 .is_inline = is_inline,
576583 });
577584 std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params);
578585
lib/std/zig/render.zig+3-1
......@@ -1558,7 +1558,7 @@ fn renderExpression(
15581558 }
15591559
15601560 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)
15621562 try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline
15631563 }
15641564
......@@ -1664,6 +1664,8 @@ fn renderExpression(
16641664 try ais.writer().writeAll("callconv(.C) ");
16651665 } else if (fn_proto.getIsAsync() != null) {
16661666 try ais.writer().writeAll("callconv(.Async) ");
1667 } else if (fn_proto.getIsInline() != null) {
1668 try ais.writer().writeAll("callconv(.Inline) ");
16671669 }
16681670
16691671 switch (fn_proto.return_type) {