Add a decoder.decode_lsd skeleton.

This commit is contained in:
Nigel Tao committed 2017-06-18 09:45:09 +10:00
1 parent 2543999c61
commit 8d1bf15d70
5 files changed
+35 -7

No files matched your search

+8 -3
View File
@@ -1020,11 +1020,16 @@ func (g *gen) writeCallSuspendibles(n *a.Expr, depth uint32) error {
}
g.writes(";\n")
} else if isThisDecodeHeader(g.tm, n) {
} else if isThisMethod(g.tm, n, "decode_header") {
g.printf("status = puffs_%s_%s_decode_header(self, %ssrc);\n",
g.pkgName, g.perFunc.funk.Receiver().String(g.tm), aPrefix)
g.writes("if (status) { goto cleanup0; }\n")
} else if isThisMethod(g.tm, n, "decode_lsd") {
g.printf("status = puffs_%s_%s_decode_lsd(self, %ssrc);\n",
g.pkgName, g.perFunc.funk.Receiver().String(g.tm), aPrefix)
g.writes("if (status) { goto cleanup0; }\n")
} else {
// TODO: fix this.
//
@@ -1190,13 +1195,13 @@ func isInDst(tm *t.Map, n *a.Expr, methodName t.Key) bool {
return n.ID0() == 0 && n.ID1().Key() == t.KeyIn
}
func isThisDecodeHeader(tm *t.Map, n *a.Expr) bool {
func isThisMethod(tm *t.Map, n *a.Expr, methodName string) bool {
// TODO: check that n.Args() is "(src:in.src)".
if n.ID0().Key() != t.KeyOpenParen || !n.CallSuspendible() || len(n.Args()) != 1 {
return false
}
n = n.LHS().Expr()
if n.ID0().Key() != t.KeyDot || n.ID1() != tm.ByName("decode_header") {
if n.ID0().Key() != t.KeyDot || n.ID1() != tm.ByName(methodName) {
return false
}
n = n.LHS().Expr()