[MLton-devel] types for RSSA
Stephen Weeks
MLton@mlton.org
Mon, 18 Nov 2002 11:02:50 -0800
> I'm a little confused on how datatypes with both value carrying and
> non-value carrying variants are represented.
The enumSize was meant to specify the number of non-value-carrying
variants. The integer values of the tags was implicit. Actually, to
make stuff completely explicity, maybe I should go for the following
structure Mtype:
sig
datatype t =
Char
| Int
| IntOrPointer of {enum: int vector,
objects: {index: int} vector}
| Real
| Word
end
So now, nonCarrying specifies the values of all the tags.
> I.e., is there a case when enumSize < Vector.length objects?
Yes, for example in the case of a single tuple, 0 = enumSize
(enum is the empty vector) and 1 = Vector.length objects.
> So, SSA datatypes like
>
> list_4 = nil_3 | ::_4 of (list_4, char)
> list_3 = nil_4 | ::_3 of (list_3, char vector)
> list_2 = nil_2 | ::_0 of (list_2, (int * int))
> bufStyle_0 = Line_0 of (word8 array) | Buffered_0 of (word8 array)
> bool = false | true
>
> would be represented as:
...
Right, except for my intent was that the enumSize was just the non
value carrying, and so would be 1, not 2, for list_{4,3,2}
> How about these:
> list_1 = nil_1 | ::_2 of (list_1, (bufStyle_0 * bool ref) ref)
> list_0 = nil_0 | ::_1 of (list_0, list_1 ref)
> exn = ex_undefined_0
> | ClosedStream_0
> | Subscript_0
> | Size_0
> | Overflow
> | Io_0 of (char vector, exn)
> | SysErr_0 of (char vector)
> | Fail_0 of (char vector)
signature RSSA =
sig
structure Mtype:
sig
datatype t =
Char
| Int
| IntOrPointer of {enum: int vector,
objects: {index: int} vector}
| Real
| Word
end
structure MemChunk:
sig
datatype t =
T of {components: {mutable: bool,
offset: int,
ty: Mtype.t} vector,
width: int}
end
structure ObjectType:
sig
datatype t =
Array of MemChunk.t
| Stack
| Tuple of MemChunk.t
| Vector of MemChunk.t
end
structure Function:
sig
type t
end
structure Program:
sig
datatype t = T of {functions: Function.t list,
main: Function.t,
objectTypes: ObjectType.t vector}
end
end
functor F (S: sig
include RSSA
val bool: Mtype.t
val bufStyle_0: Mtype.t
end) =
struct
open S
datatype z = datatype Mtype.t
val list_1: Mtype.t =
IntOrPointer {enum = #[1],
objects = #[{index = 0}]}
val list_0: Mtype.t =
IntOrPointer {enum = #[1],
objects = #[{index = 4}]}
val exn: Mtype.t =
IntOrPointer {enum = #[1,3,5,7,9],
objects = #[{index = 6}, {index = 8}, {index = 9}]}
val pointer: int -> Mtype.t =
fn index => IntOrPointer {enum = #[],
objects = #[{index = index}]}
val charVector: Mtype.t = pointer 7
datatype z = datatype ObjectType.t
val objectTypes: ObjectType.t vector =
#[
(* 0 ::_2 of (list_1, (bufStyle_0 * bool ref) ref) *)
Tuple (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = list_1},
{mutable = false,
offset = 4,
ty = pointer 1}],
width = 8}),
(* 1 (bufStyle_0 * bool ref) ref *)
Tuple (MemChunk.T {components = #[{mutable = true,
offset = 0,
ty = pointer 2}],
width = 4}),
(* 2 bufStyle_0 * bool ref *)
Tuple (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = bufStyle_0},
{mutable = false,
offset = 4,
ty = pointer 3}],
width = 8}),
(* 3 bool ref *)
Tuple (MemChunk.T {components = #[{mutable = true,
offset = 0,
ty = bool}],
width = 4}),
(* 4 ::_1 of (list_0, list_1 ref) *)
Tuple (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = list_0},
{mutable = false,
offset = 4,
ty = pointer 5}],
width = 8}),
(* 5 list_1 ref *)
Tuple (MemChunk.T {components = #[{mutable = true,
offset = 0,
ty = list_1}],
width = 4}),
(* 6 Io_0 of (char vector, exn) *)
Tuple (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = charVector},
{mutable = false,
offset = 4,
ty = exn}],
width = 8}),
(* 7 char vector *)
Vector (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = Char}],
width = 1}),
(* 8 SysErr_0 of (char vector) *)
Tuple (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = charVector}],
width = 4}),
(* 9 Fail_0 of (char vector) *)
Tuple (MemChunk.T {components = #[{mutable = false,
offset = 0,
ty = charVector}],
width = 4})
]
end
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel