From 5a2043ded5e0bef984a70e8db6b86f72624e51fb Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Sat, 16 May 2020 17:21:42 +0300 Subject: [PATCH] Fixed the build for the latest std.zig parser fixes --- src/analysis.zig | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/analysis.zig b/src/analysis.zig index a02af92..0a1797a 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -120,21 +120,22 @@ pub fn getFunctionSnippet(allocator: *std.mem.Allocator, tree: *ast.Tree, func: try buffer.appendSlice(": "); } - if (param_decl.var_args_token) |_| { - try buffer.appendSlice("..."); - continue; - } + switch (param_decl.param_type) { + .var_args => try buffer.appendSlice("..."), + .var_type => try buffer.appendSlice("var"), + .type_expr => |type_expr| { + var curr_tok = type_expr.firstToken(); + var end_tok =type_expr.lastToken(); + while (curr_tok <= end_tok) : (curr_tok += 1) { + const id = tree.tokens.at(curr_tok).id; + const is_comma = tree.tokens.at(curr_tok).id == .Comma; - var curr_tok = param_decl.type_node.firstToken(); - var end_tok = param_decl.type_node.lastToken(); - while (curr_tok <= end_tok) : (curr_tok += 1) { - const id = tree.tokens.at(curr_tok).id; - const is_comma = tree.tokens.at(curr_tok).id == .Comma; + if (curr_tok == end_tok and is_comma) continue; - if (curr_tok == end_tok and is_comma) continue; - - try buffer.appendSlice(tree.tokenSlice(curr_tok)); - if (is_comma or id == .Keyword_const) try buffer.append(' '); + try buffer.appendSlice(tree.tokenSlice(curr_tok)); + if (is_comma or id == .Keyword_const) try buffer.append(' '); + } + } } try buffer.append('}');