Skip to content

Commit

Permalink
Handle recursive structs.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Apr 1, 2020
1 parent 455ce13 commit 9b7b78e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions compiler/ast/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,16 @@ func flattenStruct(t types.Info) circuit.IO {
}

for _, f := range t.Struct {
// XXX recursive structs.
result = append(result, circuit.IOArg{
Name: f.Name,
Type: f.Type.String(),
Size: f.Type.Bits,
})
if f.Type.Type == types.Struct {
ios := flattenStruct(f.Type)
result = append(result, ios...)
} else {
result = append(result, circuit.IOArg{
Name: f.Name,
Type: f.Type.String(),
Size: f.Type.Bits,
})
}
}

return result
Expand Down

0 comments on commit 9b7b78e

Please sign in to comment.