You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
1017 B

#include"a.h" // ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - https://codeberg.org/ngn/k/raw/branch/master/LICENSE
//serialize
S A f8(Lv,Ay)_(cts(y,(V*)&v,8))
S A2(f,y=Nx(apc(y,xt));
P(xtA||xtS,y=Nx(f8(xn,y));i(xn,y=Nx(f(ii(x,i),y)))x(y))
XmMA(f(AT(tA,mut(x)),y))
Xs(Lv=xv;Qs=qs(&v);In=Sn(s)+1;y=Nx(apc(y,n));cts(y,s,n))
XP(f8(x,y))
Xr(f(AT(tA,mut(x)),Nx(apc(y,xw<<3|xk))))
XF(f(AT(tA,mut(x)),Nx(apc(y,xv<<3|xk))))
In=8*xtT;x(cts(y,xV-n,n+xn*xW)))
A1(ser,f(x,oC))
//deserialize
S C*s,*p;
#define h(n) ({P(p-s<n,ed0());C*r=s;s+=n;r;})
#define h1 (*(C*)h(1))
#define h8 (*(L*)h(8))
S A0(g,Ct=h1;P(!in(t,tn),ed0())
P(t==tA||t==tS,Ln=h8;P(!in(n,1ll<<45),ed0())Ax=AN(0,an(t,n));i(n,xq(Nx(g())))x)
P(t==tm||t==tM,Ax=N(g());P(!xtA||xn-2||_t(xx)>tM||_t(xy)>tM||_N(xx)-_N(xy),ed0())AT(t,mut(x)))
P(t==ts,Nn=h1;sym(h(n)))
P(TP(t),h8)
P(t==tr,Cc=h1;AT(t,AK(c&7,AW(c>>3,N(g())))))
P(TF(t),Cc=h1;AT(t,AK(c&7,AV(c>>3,N(g())))))
Ln=t<tm?h8:1;P(!in(n,1ll<<45),ed0())aV(t,n,h(n*TZ[t])))
A1(des,XC(s=xV;p=s+xn;x(g()))ed1(x))