Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | MLtonPointer |
2 | ============ | |
3 | ||
4 | [source,sml] | |
5 | ---- | |
6 | signature MLTON_POINTER = | |
7 | sig | |
8 | eqtype t | |
9 | ||
10 | val add: t * word -> t | |
11 | val compare: t * t -> order | |
12 | val diff: t * t -> word | |
13 | val getInt8: t * int -> Int8.int | |
14 | val getInt16: t * int -> Int16.int | |
15 | val getInt32: t * int -> Int32.int | |
16 | val getInt64: t * int -> Int64.int | |
17 | val getPointer: t * int -> t | |
18 | val getReal32: t * int -> Real32.real | |
19 | val getReal64: t * int -> Real64.real | |
20 | val getWord8: t * int -> Word8.word | |
21 | val getWord16: t * int -> Word16.word | |
22 | val getWord32: t * int -> Word32.word | |
23 | val getWord64: t * int -> Word64.word | |
24 | val null: t | |
25 | val setInt8: t * int * Int8.int -> unit | |
26 | val setInt16: t * int * Int16.int -> unit | |
27 | val setInt32: t * int * Int32.int -> unit | |
28 | val setInt64: t * int * Int64.int -> unit | |
29 | val setPointer: t * int * t -> unit | |
30 | val setReal32: t * int * Real32.real -> unit | |
31 | val setReal64: t * int * Real64.real -> unit | |
32 | val setWord8: t * int * Word8.word -> unit | |
33 | val setWord16: t * int * Word16.word -> unit | |
34 | val setWord32: t * int * Word32.word -> unit | |
35 | val setWord64: t * int * Word64.word -> unit | |
36 | val sizeofPointer: word | |
37 | val sub: t * word -> t | |
38 | end | |
39 | ---- | |
40 | ||
41 | * `eqtype t` | |
42 | + | |
43 | the type of pointers, i.e. machine addresses. | |
44 | ||
45 | * `add (p, w)` | |
46 | + | |
47 | returns the pointer `w` bytes after than `p`. Does not check for | |
48 | overflow. | |
49 | ||
50 | * `compare (p1, p2)` | |
51 | + | |
52 | compares the pointer `p1` to the pointer `p2` (as addresses). | |
53 | ||
54 | * `diff (p1, p2)` | |
55 | + | |
56 | returns the number of bytes `w` such that `add (p2, w) = p1`. Does | |
57 | not check for overflow. | |
58 | ||
59 | * ++get__<X>__ (p, i)++ | |
60 | + | |
61 | returns the object stored at index i of the array of _X_ objects | |
62 | pointed to by `p`. For example, `getWord32 (p, 7)` returns the 32-bit | |
63 | word stored 28 bytes beyond `p`. | |
64 | ||
65 | * `null` | |
66 | + | |
67 | the null pointer, i.e. 0. | |
68 | ||
69 | * ++set__<X>__ (p, i, v)++ | |
70 | + | |
71 | assigns `v` to the object stored at index i of the array of _X_ | |
72 | objects pointed to by `p`. For example, `setWord32 (p, 7, w)` stores | |
73 | the 32-bit word `w` at the address 28 bytes beyond `p`. | |
74 | ||
75 | * `sizeofPointer` | |
76 | + | |
77 | size, in bytes, of a pointer. | |
78 | ||
79 | * `sub (p, w)` | |
80 | + | |
81 | returns the pointer `w` bytes before `p`. Does not check for | |
82 | overflow. |