> Hm, how do I spell the operations? I've got something like this to
> represent the arguments to the 'socket' function, which on Linux allows
> the 'type' argument to be bitwise-ored with certain modifiers (the ATS_
> prefix indicates a macro taken from a C include):
Right now using bitwise operators in the statics is a bit experimental with an
external constraint solver. I'm working on getting the solver into the main
ATS contrib repo so others may use it as well.
As far as syntax goes, you probably won't want to use the "int" sort
since any static int
term is considered a natural number without bound. Instead, we can use
a new sort
called a bit vector that models machine integers. This sort is
provided by most SMT
solvers so we can use it in the ATS statics.
If I understand your requirement correctly, suppose we have the
following type at our
disposal. This is hardly official, but it illustrates how I think you
could implement the example
you provided. This currently won't work in ATS right now.
abst@ype int (bv:bv16) = int
This associates a static signed 16 bit vector with the normal integer
type. Of course, the choice of
what size bit vector to use is machine dependent, but that's a
separate issue. We can rewrite your
example using the new bv16 sort in the statics using the lor operator
described by Hongwei.
dataprop domain(bv16) = AF_UNIX (ATS_AF_UNIX) (* TODO include other
address families *)
dataprop type_base(bv16) = SOCK_STREAM (ATS_SOCK_STREAM) (* TODO
include other socket types *)
dataprop type_modifier(bv16) = SOCK_NONBLOCK (ATS_SOCK_NONBLOCK) |
SOCK_CLOEXEC (ATS_SOCK_CLOEXEC)
dataprop type(bv16) =
| {t: bv16} base (t) of (type_base(bv16))
| {t, m: bv16} or ((t lor m)) of (type(t), type_modifier(m))
fn socket {d, t: bv16} (domain d, type t | int d, int t): [fd: int]
(filedes fd | int fd)
I need to finish adding more support for bit vectors in the external
constraint solver, but I'll post an announcement when
it's ready to use.
Thanks,
Will