uCBQN/build/src/serialize.bqn
2022-12-23 23:09:55 +02:00

54 lines
1.5 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

eltype2bit 1,8,16,32,64,8'c',16'c',32'c'
eltypeWidth 1,1,2,4,8,1,2,4
SStep •Type
{
𝕩 •internal.Squeeze
eltype •internal.ElType𝕩
ר/
0, eltype
328•bit._cast =𝕩
648•bit._cast 𝕩
{
eltype=8? SStep¨ 𝕩;
eltypeeltype2bit, 8•bit._cast (8×·÷8˙)(0=eltype) 𝕩
}𝕩
}
{ 1, 648•bit._cast𝕩 }
{ 2, 328•bit._cast𝕩 }
{𝕊:!"Cannot serialize functions"}
{𝕊:!"Cannot serialize 1-modifiers"}
{𝕊:!"Cannot serialize 2-modifiers"}
{𝕊:!"Cannot serialize namespaces"}
Serialize {
lists
{0=•Type𝕩? 𝕊¨𝕩; lists<𝕩 1} SStep 𝕩
lists
}
Deserialize {
s𝕩
off0
Next {r𝕩offs off+𝕩 r}
Read { 𝕊:
type Next 1
type
{𝕊:
et Next 1
rank 832•bit._cast Next 4
shape 864•bit._cast Next rank×8
shape{
et=8? Read¨ ×´shape;
8, eteltype2bit•bit._cast Next (÷8)(0=et) (eteltypeWidth)×´shape
}
}
{𝕊: 8, 64 •bit._cast Next 8}
{𝕊: 8, 32'c'•bit._cast Next 4}
@
}
r Read@
off=s? r;
! "invalid input: data after end"
}