ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 3365b37 was
385c130,
checked in by Thierry Delisle <tdelisle@…>, 9 years ago
|
pre merge
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | #include <stddef.h> |
---|
2 | #include <stdint.h> |
---|
3 | |
---|
4 | //------------------------------------------------------------------------------ |
---|
5 | //Declaration |
---|
6 | trait allocator_c(otype T, otype allocator_t) { |
---|
7 | void realloc(allocator_t*, size_t); |
---|
8 | T* data(allocator_t*); |
---|
9 | }; |
---|
10 | |
---|
11 | forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) |
---|
12 | struct vector |
---|
13 | { |
---|
14 | allocator_t storage; |
---|
15 | size_t size; |
---|
16 | }; |
---|
17 | |
---|
18 | //------------------------------------------------------------------------------ |
---|
19 | //Allocator |
---|
20 | forall(otype T) |
---|
21 | struct heap_allocator |
---|
22 | { |
---|
23 | T* storage; |
---|
24 | size_t capacity; |
---|
25 | }; |
---|
26 | |
---|
27 | forall(otype T) |
---|
28 | void realloc(heap_allocator(T)* this, size_t size); |
---|
29 | |
---|
30 | forall(otype T) |
---|
31 | inline T* data(heap_allocator(T)* this) |
---|
32 | { |
---|
33 | return this->storage; |
---|
34 | } |
---|
35 | |
---|
36 | //------------------------------------------------------------------------------ |
---|
37 | //Modifiers |
---|
38 | forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) |
---|
39 | void push_back(vector(T, allocator_t)* this, T value); |
---|
40 | |
---|
41 | typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t; |
---|
42 | |
---|
43 | inline void test() |
---|
44 | { |
---|
45 | worklist_t w; |
---|
46 | intptr_t zero = 0; |
---|
47 | push_back(&w, &zero); |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.