Changeset 7a054e82 for doc/generic_types/evaluation/cfa-stack.c
- Timestamp:
- Apr 10, 2017, 3:17:29 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- b715c9a
- Parents:
- b0fedd4 (diff), b276be5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/evaluation/cfa-stack.c
rb0fedd4 r7a054e82 1 #include <assert> 1 2 #include <stdlib> 2 3 #include "cfa-stack.h" … … 8 9 9 10 forall(otype T) void ?{}(stack(T)* s) { 10 ?{}( &s->head, 0 ); 11 (&s->head){ 0 }; 12 } 13 14 forall(otype T) void copy(stack(T)* s, stack(T)* t) { 15 stack_node(T)** crnt = &s->head; 16 stack_node(T)* next = t->head; 17 while ( next ) { 18 *crnt = ((stack_node(T)*)malloc()){ next->value }; 19 stack_node(T)* acrnt = *crnt; 20 crnt = &acrnt->next; 21 next = next->next; 22 } 23 *crnt = 0; 24 } 25 26 forall(otype T) void ?{}(stack(T)* s, stack(T) t) { 27 stack_node(T)** crnt = &s->head; 28 stack_node(T)* next = t.head; 29 while ( next ) { 30 *crnt = ((stack_node(T)*)malloc()){ next->value }; 31 stack_node(T)* acrnt = *crnt; 32 crnt = &acrnt->next; 33 next = next->next; 34 } 35 *crnt = 0; 36 } 37 38 forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t) { 39 if ( s->head == t.head ) return *s; 40 clear(s); 41 s{ t }; 42 return *s; 11 43 } 12 44 13 45 forall(otype T) void ^?{}(stack(T)* s) { 14 stack_node(T)* next = s->head; 15 while ( next ) { 16 stack_node(T)* crnt = next; 17 next = crnt->next; 18 delete(crnt); 19 } 46 clear(s); 20 47 } 21 48 … … 35 62 return x; 36 63 } 64 65 forall(otype T) void clear(stack(T)* s) { 66 stack_node(T)* next = s->head; 67 while ( next ) { 68 stack_node(T)* crnt = next; 69 next = crnt->next; 70 delete(crnt); 71 } 72 s->head = 0; 73 }
Note: See TracChangeset
for help on using the changeset viewer.