mirror of
https://github.com/Kindelia/Kind2.git
synced 2024-09-11 07:15:45 +03:00
Lit: resolve 0 problem with varlen serialization
This commit is contained in:
parent
ec49dafd9d
commit
1826f4bea1
@ -417,11 +417,15 @@ Litereum.deserialize.varlen(bits: Bits): Pair<Bits,Nat>
|
||||
{bits, Nat.sub(value,1)}
|
||||
|
||||
Litereum.serialize.varlen.go(value: Nat): Bits
|
||||
if Nat.eql(value,1) then
|
||||
Bits.o(Bits.e)
|
||||
else if Nat.eql(Nat.mod(value,2),0)
|
||||
then Bits.i(Bits.o(Litereum.serialize.varlen.go(Nat.div(value,2))))
|
||||
else Bits.i(Bits.i(Litereum.serialize.varlen.go(Nat.div(value,2))))
|
||||
case value {
|
||||
zero: Bits.e
|
||||
succ:
|
||||
if Nat.eql(value,1) then
|
||||
Bits.o(Bits.e)
|
||||
else if Nat.eql(Nat.mod(value,2),0)
|
||||
then Bits.i(Bits.o(Litereum.serialize.varlen.go(Nat.div(value,2))))
|
||||
else Bits.i(Bits.i(Litereum.serialize.varlen.go(Nat.div(value,2))))
|
||||
}
|
||||
|
||||
Litereum.deserialize.varlen.go(bits: Bits): Pair<Bits,Nat>
|
||||
case bits {
|
||||
|
@ -1,16 +1,3 @@
|
||||
Test: _
|
||||
let world = Litereum.genesis
|
||||
let code = `
|
||||
eval #50
|
||||
type Bool { true{} false{} }
|
||||
eval +(#10, #20)
|
||||
`
|
||||
let block = Parser.run!(Litereum.parse.block(world), code) abort IO.print("deu ruim")
|
||||
IO {
|
||||
log("Block: ")
|
||||
for tx in block:
|
||||
IO.print("- " | Litereum.show.transaction(world, tx))
|
||||
log("Evaluation: ")
|
||||
let tmp = Litereum.run.block(world, block)
|
||||
IO.print("Done!")
|
||||
}
|
||||
let b = Litereum.serialize.varlen.go(12)
|
||||
Litereum.deserialize.varlen.go(b)
|
Loading…
Reference in New Issue
Block a user