In this case, you need to use ‘topize’ to turn a function into a pointer:
val _ =
if b
then let
prval () = opt_unsome (f)
val res = f (get_dentry_p ())
prval () = topize(f)
in
res
end // then
else let
prval () = opt_unnone (f)
in 0 end // elseOn Thu, Jun 25, 2015 at 11:12 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:
Hi all,
Now I’m trying to trace chain of pointers with checking NULL.
/home/kiwamu/src/practice-ats/pointer_chain/main.dats: 980(line=42,
offs=21) – 1056(line=43, offs=47): error(3): mismatch of static terms
(tyleq):
The actual term is: S2Efun(FUN; lin=0; eff=S2EFFset(1); npf=-1;
S2Ecst(dentry_t_p); S2Ecst(int))
The needed term is: S2Ecst(ptr_type)
I think it’s caused by cast envless function.
I would like to check if the envless function is NULL.
How to trace chain of pointers with checking NULL?
extern fun get_dentry_p (): [l:addr] (dentry_t@l | ptr(l)) = “mac#”
I assume that ‘get_dentry_p’ is implemented in dentry.c. You need to
make its C-interface available in ATS in order to call it in ATS.On Monday, June 29, 2015 at 5:54:03 AM UTC-4, Kiwamu Okabe wrote:
Hi Hongwei,
On Sat, Jun 27, 2015 at 2:55 AM, Hongwei Xi <gmh...@gmail.com <javascript:>> wrote:
$ patscc main.dats dentry.c
main_dats.c: In function ‘mainats_void_0’:
main_dats.c:304:1: warning: implicit declaration of function
‘get_dentry_p’ [-Wimplicit-function-declaration]
ATSINSmove(tmp1, get_dentry_p()) ;
^
In file included from main_dats.c:15:0:
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:260:35:
warning: assignment makes pointer from integer without a cast #define ATSINSmove(tmp, val) (tmp = val)
^
main_dats.c:304:1: note: in expansion of macro ‘ATSINSmove’
ATSINSmove(tmp1, get_dentry_p()) ;
^
/home/kiwamu/src/ATS-Postiats/ccomp/runtime/pats_ccomp_instrset.h:203:29:
error: dereferencing pointer to incomplete type #define ATSderef(pmv, hit) ((hit)pmv)
^
–snip–
fun{s,f:type}
tracestruct (from: s, trace: (s → f), function: &f? >> opt (f, b)):
#[b:bool] bool(b) = let
val f = trace from
in
if $UN.cast{ptr}(f) = the_null_ptr then let
prval () = opt_none{f}(function)
in
false
end
else let
val () = function := f
prval () = opt_some{f}(function)
in
true
end
end
If ‘s’ and ‘f’ are supposed to be function types, then you should
use ‘s,f:type’. In any case, ‘type’ is treated as a subsort of ‘t@ype’.On Monday, June 29, 2015 at 5:48:32 AM UTC-4, Kiwamu Okabe wrote:
On Sat, Jun 27, 2015 at 12:26 AM, Hongwei Xi <gmh...@gmail.com <javascript:>> wrote:
Why not the following interface:
fun{s.f:t0ype}
tracestruct(…)
Thank’s, I didn’t know that envless function is “t@ype”.
How to find out that? $showtype say the envless function is…
Which string say that envless function is “t@ype”?
Also, why doesn’t occur error on type checking while envless function is
used as “type”? My code with envless function as “type” has no error on
both compile time and run tine.