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