- File:
-
- 1 edited
-
doc/papers/general/evaluation/cfa-stack.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/evaluation/cfa-stack.c
r986dd36 r604e76d 7 7 }; 8 8 9 forall(otype T) void ?{}(stack(T) & s) { (s.head){ 0 }; }9 forall(otype T) void ?{}(stack(T)* s) { (&s->head){ 0 }; } 10 10 11 forall(otype T) void ?{}(stack(T) &s, stack(T) t) {12 stack_node(T)** crnt = &s .head;11 forall(otype T) void ?{}(stack(T)* s, stack(T) t) { 12 stack_node(T)** crnt = &s->head; 13 13 for ( stack_node(T)* next = t.head; next; next = next->next ) { 14 // *crnt = &(*(stack_node(T)*)malloc()){ next->value }; /***/ 15 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 16 (*new_node){ next->value }; /***/ 17 *crnt = new_node; 18 14 *crnt = ((stack_node(T)*)malloc()){ next->value }; /***/ 19 15 stack_node(T)* acrnt = *crnt; 20 16 crnt = &acrnt->next; … … 23 19 } 24 20 25 forall(otype T) stack(T) ?=?(stack(T) &s, stack(T) t) {26 if ( s .head == t.head ) returns;21 forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t) { 22 if ( s->head == t.head ) return *s; 27 23 clear(s); 28 24 s{ t }; 29 return s;25 return *s; 30 26 } 31 27 32 forall(otype T) void ^?{}(stack(T) &s) { clear(s); }28 forall(otype T) void ^?{}(stack(T)* s) { clear(s); } 33 29 34 forall(otype T) _Bool empty(const stack(T) & s) { return s.head == 0; }30 forall(otype T) _Bool empty(const stack(T)* s) { return s->head == 0; } 35 31 36 forall(otype T) void push(stack(T)& s, T value) { 37 // s.head = &(*(stack_node(T)*)malloc()){ value, s.head }; /***/ 38 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 39 (*new_node){ value, s.head }; /***/ 40 s.head = new_node; 32 forall(otype T) void push(stack(T)* s, T value) { 33 s->head = ((stack_node(T)*)malloc()){ value, s->head }; /***/ 41 34 } 42 35 43 forall(otype T) T pop(stack(T) &s) {44 stack_node(T)* n = s .head;45 s .head = n->next;36 forall(otype T) T pop(stack(T)* s) { 37 stack_node(T)* n = s->head; 38 s->head = n->next; 46 39 T x = n->value; 47 40 ^n{}; … … 50 43 } 51 44 52 forall(otype T) void clear(stack(T) &s) {53 for ( stack_node(T)* next = s .head; next; ) {45 forall(otype T) void clear(stack(T)* s) { 46 for ( stack_node(T)* next = s->head; next; ) { 54 47 stack_node(T)* crnt = next; 55 48 next = crnt->next; 56 49 delete(crnt); 57 50 } 58 s .head = 0;51 s->head = 0; 59 52 }
Note:
See TracChangeset
for help on using the changeset viewer.