Add syntax support for implementing interfaces

This commit is contained in:
Nigel Tao committed 2020-01-09 15:45:29 +11:00
1 parent 8f5983f151
commit ea54c2ea11
10 files changed
+249 -97

No files matched your search

+12 -3
View File
@@ -314,11 +314,20 @@ func (h *genHelper) genWuffs(dirname string, qualifiedFilenames []string) error
if !n.Public() {
continue
}
classy := ""
fmt.Fprintf(out, "pub struct %s", n.QID().Str(&h.tm))
if n.Classy() {
classy = "?"
fmt.Fprintf(out, "?")
}
fmt.Fprintf(out, "pub struct %s%s()\n", n.QID().Str(&h.tm), classy)
if imps := n.Implements(); len(imps) > 0 {
fmt.Fprintf(out, " implements ")
for i, imp := range imps {
if i > 0 {
fmt.Fprintf(out, ", ")
}
fmt.Fprintf(out, "%s", imp.AsTypeExpr().Str(&h.tm))
}
}
fmt.Fprintf(out, "()\n")
}
}
}