A function like struct_foo_get_b can be defined (automatically) as a macro
in C:
fun{}
struct_foo_get_b{l:agz}(x: !struct_foo_ptr(l)): int = ret where {
val (pf | p) = takeout_struct_foo (x)
val ret = p->b
val () = addback_struct_foo (pf | p)
}
In this way, you do not need to implement struct_foo in ATS. That is, the
following line is not needed:
assume struct_foo = struct_foo_impl
On Monday, August 22, 2016 at 6:00:55 AM UTC-4, Kiwamu Okabe wrote:
>
> Hi Hongwei,
>
> On Mon, Aug 22, 2016 at 2:28 PM, Hongwei Xi <...> wrote:
> > Basically, I think that every struct in C should be first mapped to an
> > abstract type.
>
> I used mutual struct in your style:
>
>
> https://github.com/jats-ug/practice-ats/blob/4af1b892edc700d33312b9289ff7a72861b9a4a1/template_struct/main.dats#L134
>
>
> However, following code at line 134 causes error...
>
> ```
> val foo_ptr = takeout_struct_foo_ptr (addr@foo)
> val () = foo_ptr.b := 9 // error(3): the type
> [S2Eapp(S2Ecst(struct_foo_ptr); S2Evar(foo(8452)))] is expected to be
> a tyrec(record).
> ```
>
> > Also, there is no need to start with C syntax. You can (and probably
> should)
> > start
> > with some syntax of your design and then later find a way to translate C
> > syntax into
> > your designed syntax. I call this doing-things-in-stages. Trying to do a
> > complex thing
> > in one step usually ends up with a failure and some frustration.
>
> Yes. You know that I already made some code for kernel.
>
>
> https://github.com/metasepi/linux-bohai-s2/blob/bohai-s2/metasepi/include/linux/SATS/statfs.sats#L10
>
>
> Now, I need some semi-automatically-generate tool to try rewriting
> such kernel widely.
> Such kernel has many many interfaces written by C language!!!
>
> Best regards,
> --
> Kiwamu Okabe at METASEPI DESIGN
>
--
You received this message because you are subscribed to the Google Groups
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/f99d10fd-435a-4201-9a0c-5bbd3643eb30%40googlegroups.com.