Hi all,
Can't chain "opt" between functions?
I have tried to write body of vfs_ustat function.
https://github.com/metasepi/linux-bohai-s2/blob/3299f651b9a61d60e36bef4b41216e02658c2784/metasepi/fs/DATS/statfs.dats#L30
fun user_get_super (dev: dev_t): [l:addr] (option_v(super_block_t@l, l
> null) | ptr(l)) = "mac#"
extern fun statfs_by_dentry
(dentry: dentry_t_p, sbuf: &kstatfs_t? >> opt (kstatfs_t, i==0)):
#[i:int | i != 0] int(i) = "mac#"
fun vfs_ustat_ats
(dev: dev_t, sbuf: &kstatfs_t? >> opt (kstatfs_t, i==0)): #[i:int | i
!= 0] int(i) = r where {
val (pfopt | p) = user_get_super(dev)
val r = if (p > the_null_ptr) then let
prval Some_v (pf) = pfopt
val e = statfs_by_dentry(p->s_root, sbuf);
val () = drop_super(pf | p)
in
e
end else let
prval None_v () = pfopt
in
(~ EINVAL)
end
}
However, it causes compile error.
https://travis-ci.org/metasepi/linux-bohai-s2/builds/52408252
/home/kiwamu/src/ATS-Postiats/bin/patsopt -o fs/statfs_dats.c -d
metasepi/fs/DATS/statfs.dats
/home/kiwamu/src/linux-bohai-s2/metasepi/fs/DATS/statfs.dats:
1319(line=33, offs=38) -- 1460(line=39, offs=8): error(3): mismatch of
static terms (tyleq):
The actual term is: S2Eapp(S2Ecst(opt_vt0ype_bool_vt0ype);
S2Ecst(kstatfs_t), S2Eapp(S2Ecst(==); S2Evar(i$3302$3304(7381)),
S2Eintinf(0)))
The needed term is: S2Etyrec(fltext(struct kstatfs); npf=-1;
f_type=S2Etop(knd=0; S2Ecst(lint)), f_bsize=S2Etop(knd=0;
S2Ecst(lint)), f_blocks=S2Etop(knd=0; S2Ecst(uint64_t)),
f_bfree=S2Etop(knd=0; S2Ecst(uint64_t)), f_bavail=S2Etop(knd=0;
S2Ecst(uint64_t)), f_files=S2Etop(knd=0; S2Ecst(uint64_t)),
f_ffree=S2Etop(knd=0; S2Ecst(uint64_t)), f_fsid=S2Etop(knd=0;
S2Ecst(kernel_fsid_t)), f_namelen=S2Etop(knd=0; S2Ecst(lint)),
f_frsize=S2Etop(knd=0; S2Ecst(lint)), f_flags=S2Etop(knd=0;
S2Ecst(lint)), f_spare=S2Etop(knd=0; S2Etyarr(S2Ecst(lint);
S2Eintinf(4))))
/home/kiwamu/src/linux-bohai-s2/metasepi/fs/DATS/statfs.dats:
1319(line=33, offs=38) -- 1460(line=39, offs=8): error(3): mismatch of
static terms (tyleq):
The actual term is: S2Eat(S2Eapp(S2Ecst(opt_vt0ype_bool_vt0ype);
S2Ecst(kstatfs_t), S2Eapp(S2Ecst(==); S2Evar(i$3302$3304(7381)),
S2Eintinf(0))); S2Evar(sbuf(7372)))
The needed term is: S2Eat(S2Etyrec(fltext(struct kstatfs); npf=-1;
f_type=S2Etop(knd=0; S2Ecst(lint)), f_bsize=S2Etop(knd=0;
S2Ecst(lint)), f_blocks=S2Etop(knd=0; S2Ecst(uint64_t)),
f_bfree=S2Etop(knd=0; S2Ecst(uint64_t)), f_bavail=S2Etop(knd=0;
S2Ecst(uint64_t)), f_files=S2Etop(knd=0; S2Ecst(uint64_t)),
f_ffree=S2Etop(knd=0; S2Ecst(uint64_t)), f_fsid=S2Etop(knd=0;
S2Ecst(kernel_fsid_t)), f_namelen=S2Etop(knd=0; S2Ecst(lint)),
f_frsize=S2Etop(knd=0; S2Ecst(lint)), f_flags=S2Etop(knd=0;
S2Ecst(lint)), f_spare=S2Etop(knd=0; S2Etyarr(S2Ecst(lint);
S2Eintinf(4)))); S2Evar(sbuf(7372)))
Dependent and linear types are hard work for me, even now.
Best regards,
--
Kiwamu Okabe at METASEPI DESIGN