assert: pretty print function calls too

pull/4313/head
Delyan Angelov 2020-04-09 13:24:13 +03:00
parent 56c3a8b9a2
commit 806f86e4e2
1 changed files with 22 additions and 0 deletions

View File

@ -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 {