ast: add str for ArrayInit (#8022)
parent
0f2a770b9c
commit
fdf5f5003b
|
@ -183,6 +183,23 @@ pub fn (lit &StringInterLiteral) get_fspec_braces(i int) (string, bool) {
|
|||
// string representation of expr
|
||||
pub fn (x Expr) str() string {
|
||||
match x {
|
||||
ArrayInit {
|
||||
mut fields := []string{}
|
||||
if x.has_len {
|
||||
fields << 'len: $x.len_expr.str()'
|
||||
}
|
||||
if x.has_cap {
|
||||
fields << 'cap: $x.cap_expr.str()'
|
||||
}
|
||||
if x.has_default {
|
||||
fields << 'init: $x.default_expr.str()'
|
||||
}
|
||||
if fields.len > 0 {
|
||||
return '[]T{${fields.join(', ')}}'
|
||||
} else {
|
||||
return x.exprs.str()
|
||||
}
|
||||
}
|
||||
CTempVar {
|
||||
return x.orig.str()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue