generate: Add Generator.generateDecodeBranch stub
This commit is contained in:
parent
fae702edfd
commit
41b3376fa3
@ -485,7 +485,8 @@ func (this *Generator) generateDecodeValue(typ Type, valueSource, tagSource, abo
|
|||||||
}
|
}
|
||||||
case TypeArray:
|
case TypeArray:
|
||||||
// OTA: <length: UN> <elementTag: tape.Tag> <values>*
|
// OTA: <length: UN> <elementTag: tape.Tag> <values>*
|
||||||
// TODO: branch
|
nn, err := this.generateDecodeBranch(typ, valueSource, tagSource)
|
||||||
|
n += nn; if err != nil { return n, err }
|
||||||
case TypeTable:
|
case TypeTable:
|
||||||
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
||||||
nn, err := this.iprintf(
|
nn, err := this.iprintf(
|
||||||
@ -496,7 +497,8 @@ func (this *Generator) generateDecodeValue(typ Type, valueSource, tagSource, abo
|
|||||||
n += nn; if err != nil { return n, err }
|
n += nn; if err != nil { return n, err }
|
||||||
case TypeTableDefined:
|
case TypeTableDefined:
|
||||||
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
||||||
// TODO: branch
|
nn, err := this.generateDecodeBranch(typ, valueSource, tagSource)
|
||||||
|
n += nn; if err != nil { return n, err }
|
||||||
case TypeNamed:
|
case TypeNamed:
|
||||||
// WHATEVER: [WHATEVER]
|
// WHATEVER: [WHATEVER]
|
||||||
nn, err := this.iprintf("nn, err = %s.DecodeValue(decoder, %s)\n", valueSource, tagSource)
|
nn, err := this.iprintf("nn, err = %s.DecodeValue(decoder, %s)\n", valueSource, tagSource)
|
||||||
@ -510,6 +512,23 @@ func (this *Generator) generateDecodeValue(typ Type, valueSource, tagSource, abo
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// generateDencodeValue generates code to call an aggregate decoder function,
|
||||||
|
// for a specified type. The definition of the function is deferred so no
|
||||||
|
// duplicates are created. The function overwrites memory pointed to by the
|
||||||
|
// variable (or parenthetical statement) specified by valueSource, and the value
|
||||||
|
// will be encoded according to the tag stored in the variable (or parenthetical
|
||||||
|
// statement) specified by tagSource. the code generated is a BLOCK and expects
|
||||||
|
// these variables to be defined:
|
||||||
|
//
|
||||||
|
// - decoder *tape.Decoder
|
||||||
|
// - n int
|
||||||
|
// - err error
|
||||||
|
// - nn int
|
||||||
|
func (this *Generator) generateDecodeBranch(typ Type, valueSource, tagSource string) (n int, err error) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Generator) generateErrorCheck() (n int, err error) {
|
func (this *Generator) generateErrorCheck() (n int, err error) {
|
||||||
return this.iprintf("n += nn; if err != nil { return n, err }\n")
|
return this.iprintf("n += nn; if err != nil { return n, err }\n")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user