HLVM Type System
This is an attempt to formalize the type system of HLVM.
Basic Types
The following unboxed basic types are supported :
i8andui8, size : 1 bytei16andui16, size : 2 bytesi32andui32, size : 4 bytesi64andui64, size : 8 bytesfloat, size : 4 bytesdouble, size : 8 bytesinatanduinat, size : 4/8 bytes (system dependent)bool, size : 4 bytes ???void, size : 4 bytes ???
Structural Types
Array
'a array : resizable array containing uniform types. The memory structure is {type*,ui32,void*}
type*: a pointer to the type of the array contentui32: the length of the arrayvoid*: the elements of the array
The following APIs can be use on arrays :
$aalloc : ui32 -> 'a -> 'a array: allocate a new array with a default value$aget : 'a array -> ui32 -> 'a: read an element from an array, an exception occurs if bounds checking fails$aset : 'a array -> ui32 -> 'a -> void: write an element into$asize : 'a array -> ui32: returns the size of the array$resize : 'a array -> ui32 -> 'a -> unit: resize the array by filling with a default value
Ref
'a ref : a reference to a given value. Memory size is 2 words, the memory structure is {type*,'a*}.
$ralloc : 'a -> 'a ref: allocate a reference$rget : 'a ref -> 'a: get the reference value$rset : 'a ref -> 'a -> unit: set the reference value
Tuple
('a, 'b, 'c....)
Function
'a -> 'b -> 'c ....
Union
'a | 'b | 'c ...
{type*,uinat tag, ... }
version #5564, modified 2009-03-14 16:23:22 by ncannasse