HLVM Type System

This is an attempt to formalize the type system of HLVM.

Basic Types

The following unboxed basic types are supported :

  • i8 and ui8, size : 1 byte
  • i16 and ui16, size : 2 bytes
  • i32 and ui32, size : 4 bytes
  • i64 and ui64, size : 8 bytes
  • float, size : 4 bytes
  • double, size : 8 bytes
  • inat and uinat, 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 content
  • ui32 : the length of the array
  • void*: 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