| | 1 | == Idea == |
| | 2 | |
| | 3 | New data structures are needed in CIVL-C in order to model what happens in OpenMP and other complex APIs. Sequences, sets, and maps, specifically. |
| | 4 | The purpose of this page is to propose the new interface for these structures. |
| | 5 | |
| | 6 | == Typeof == |
| | 7 | |
| | 8 | First we need a new expression `$typeof`. This expression has the syntax `$typeof(typename)`. It is just like `sizeof` syntactically. It represents any type as a value. The type of the `$typeof` expression is the type `$type`. This is also represented in the CIVL model layer as "dynamic type". |
| | 9 | |
| | 10 | == Sequences == |
| | 11 | |
| | 12 | New type: `$seq`. Functions: |
| | 13 | |
| | 14 | {{{ |
| | 15 | /* Returns the empty seq whose elements (if it had any) |
| | 16 | * would have the given type. The type becomes associated |
| | 17 | * with the seq. */ |
| | 18 | $seq $seq_empty($type type); |
| | 19 | |
| | 20 | /* Returns the type of an element that goes in this seq */ |
| | 21 | $type $seq_element_type($seq v); |
| | 22 | |
| | 23 | /* Returns the seq that is like the given one but with one more |
| | 24 | * element added. A runtime exception is generated if the thing pointed |
| | 25 | * to by eltptr doesn't have the right type for v. */ |
| | 26 | $seq $seq_add($seq v, void * eltptr); |
| | 27 | |
| | 28 | /* Returns the seq that is like the given one but with the element |
| | 29 | * at position index removed and the subsequent elements shifted down */ |
| | 30 | $seq $seq_remove($seq v, int index); |
| | 31 | |
| | 32 | /* Returns the seq that is like the given one but with the element |
| | 33 | * at position index replaced with whatever object is pointed to by |
| | 34 | * ptr. */ |
| | 35 | $seq $seq_set($seq v, int index, void * ptr); |
| | 36 | |
| | 37 | /* Returns the length of the seq (i.e., the number of elements) */ |
| | 38 | int $seq_length($seq v); |
| | 39 | |
| | 40 | /* Returns the seq that is like the given one but with an element |
| | 41 | * inserted at position i (and the subsequent elements shifted up). |
| | 42 | * The parameter eltptr is a pointer to the element to insert. */ |
| | 43 | $seq $seq_insert($seq v, int index, void * eltptr); |
| | 44 | |
| | 45 | /* Gets the element at position index and stores it in wherever |
| | 46 | * ptr points to. */ |
| | 47 | void $seq_get($seq v, int index, void * ptr); |
| | 48 | |
| | 49 | /* Returns the subsequence */ |
| | 50 | $seq $seq_sub($seq v, int start, int stop); |
| | 51 | |
| | 52 | }}} |
| | 53 | |
| | 54 | |
| | 55 | == Sets == |
| | 56 | |
| | 57 | |
| | 58 | |
| | 59 | == Maps == |
| | 60 | |