From 806f86e4e29578380abc02c205085cc88973b31e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 9 Apr 2020 13:24:13 +0300 Subject: [PATCH] assert: pretty print function calls too --- vlib/v/ast/str.v | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index d51a21b1d3..d7d86bb166 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -119,12 +119,34 @@ pub fn (x Expr) str() string { CastExpr { return '${it.typname}(${it.expr.str()})' } + CallExpr { + sargs := args2str(it.args) + if it.is_method { + return '${it.left.str()}.${it.name}($sargs)' + } + return '${it.mod}.${it.name}($sargs)' + } else { return '[unhandled expr type ${typeof(x)}]' } } } +pub fn (a CallArg) str() string { + if a.is_mut { + return 'mut ${a.expr.str()}' + } + return '${a.expr.str()}' +} + +pub fn args2str(args []CallArg) string { + mut res := []string + for a in args { + res << a.str() + } + return res.join(', ') +} + pub fn (node Stmt) str() string { match node { AssignStmt {