generate: Fix more semantic errors in the generated code
This commit is contained in:
parent
e48be0bc15
commit
3bf365a7a9
@ -217,13 +217,17 @@ func (this *Generator) generateEncodeValue(typ Type, valueSource, tagSource stri
|
||||
// SI stores the value in the tag, so we write nothing here
|
||||
break
|
||||
}
|
||||
nn, err := this.iprintf("nn, err = encoder.WriteInt%d(%s)\n", bitsToBytes(typ.Bits), valueSource)
|
||||
prefix := "WriteUint"
|
||||
if typ.Signed {
|
||||
prefix = "WriteInt"
|
||||
}
|
||||
nn, err := this.iprintf("nn, err = encoder.%s%d(%s)\n", prefix, typ.Bits, valueSource)
|
||||
n += nn; if err != nil { return n, err }
|
||||
nn, err = this.generateErrorCheck()
|
||||
n += nn; if err != nil { return n, err }
|
||||
case TypeFloat:
|
||||
// FP: <value: FloatN>
|
||||
nn, err := this.iprintf("nn, err = encoder.WriteFloat%d(%s)\n", bitsToBytes(typ.Bits), valueSource)
|
||||
nn, err := this.iprintf("nn, err = encoder.WriteFloat%d(%s)\n", typ.Bits, valueSource)
|
||||
n += nn; if err != nil { return n, err }
|
||||
nn, err = this.generateErrorCheck()
|
||||
n += nn; if err != nil { return n, err }
|
||||
@ -504,9 +508,12 @@ func (this *Generator) generateType(typ Type) (n int, err error) {
|
||||
nn, err := this.generateTypeTableDefined(typ)
|
||||
n += nn; if err != nil { return n, err }
|
||||
case TypeNamed:
|
||||
actual, err := this.resolveTypeName(typ.Name)
|
||||
if err != nil { return n, err }
|
||||
nn, err := this.generateType(actual)
|
||||
if builtin := this.resolveBuiltinType(typ.Name); builtin != nil {
|
||||
nn, err := this.generateType(builtin)
|
||||
n += nn; if err != nil { return n, err }
|
||||
return n, nil
|
||||
}
|
||||
nn, err := this.print(typ.Name)
|
||||
n += nn; if err != nil { return n, err }
|
||||
}
|
||||
return n, nil
|
||||
|
Loading…
Reference in New Issue
Block a user