aboutsummaryrefslogtreecommitdiff
path: root/internal/compile/serial.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/compile/serial.go')
-rw-r--r--internal/compile/serial.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/internal/compile/serial.go b/internal/compile/serial.go
index 0107ef9..adadabf 100644
--- a/internal/compile/serial.go
+++ b/internal/compile/serial.go
@@ -51,9 +51,10 @@ package compile
//
// Constant: # type data
// type varint # 0=string string
-// data ... # 1=int varint
-// # 2=float varint (bits as uint64)
-// # 3=bigint string (decimal ASCII text)
+// data ... # 1=bytes string
+// # 2=int varint
+// # 3=float varint (bits as uint64)
+// # 4=bigint string (decimal ASCII text)
//
// The encoding starts with a four-byte magic number.
// The next four bytes are a little-endian uint32
@@ -109,14 +110,17 @@ func (prog *Program) Encode() []byte {
case string:
e.int(0)
e.string(c)
- case int64:
+ case Bytes:
e.int(1)
+ e.string(string(c))
+ case int64:
+ e.int(2)
e.int64(c)
case float64:
- e.int(2)
+ e.int(3)
e.uint64(math.Float64bits(c))
case *big.Int:
- e.int(3)
+ e.int(4)
e.string(c.Text(10))
}
}
@@ -249,10 +253,12 @@ func DecodeProgram(data []byte) (_ *Program, err error) {
case 0:
c = d.string()
case 1:
- c = d.int64()
+ c = Bytes(d.string())
case 2:
- c = math.Float64frombits(d.uint64())
+ c = d.int64()
case 3:
+ c = math.Float64frombits(d.uint64())
+ case 4:
c, _ = new(big.Int).SetString(d.string(), 10)
}
constants[i] = c