Changeset 29db723 for doc/papers/general/evaluation/cfastack.c
 Timestamp:
 Mar 8, 2018, 11:04:14 PM (5 years ago)
 Branches:
 aaronthesis, armeh, cleanupdtors, deferred_resn, demangler, enum, forallpointerdecay, jacob/cs343translation, jenkinssandbox, master, newast, newastuniqueexpr, newenv, no_list, persistentindexer, pthreademulation, qualifiedEnum, resolvnew, with_gc
 Children:
 81e8ab0, e59f0bf
 Parents:
 deb52a0
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

doc/papers/general/evaluation/cfastack.c
rdeb52a0 r29db723 2 2 #include "cfastack.h" 3 3 4 forall( otype T) struct stack_node {4 forall( otype T ) struct stack_node { 5 5 T value; 6 6 stack_node(T) * next; 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 ) {11 forall( otype T ) void ?{}( stack(T) & s, stack(T) t ) { 12 12 stack_node(T) ** crnt = &s.head; 13 13 for ( stack_node(T) * next = t.head; next; next = next>next ) { … … 19 19 } 20 20 21 forall( otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) {21 forall( otype T ) stack(T) ?=?( stack(T) & s, stack(T) t ) { 22 22 if ( s.head == t.head ) return s; 23 23 clear( s ); … … 26 26 } 27 27 28 forall( otype T) void ^?{}( stack(T) & s) { clear( s ); }28 forall( otype T ) void ^?{}( stack(T) & s) { clear( s ); } 29 29 30 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; } 31 31 32 forall( otype T) void push( stack(T) & s, T value ) with( s ) {33 stack_node(T) * n = alloc();32 forall( otype T ) void push( stack(T) & s, T value ) with( s ) { 33 stack_node(T) * n = alloc(); 34 34 (*n){ value, head }; 35 35 head = n; 36 36 } 37 37 38 forall( otype T) T pop( stack(T) & s ) with( s ) {38 forall( otype T ) T pop( stack(T) & s ) with( s ) { 39 39 stack_node(T) * n = head; 40 40 head = n>next; 41 T x= n>value;41 T v = n>value; 42 42 ^(*n){}; 43 43 free( n ); 44 return x;44 return v; 45 45 } 46 46 47 forall( otype T) void clear( stack(T) & s ) with( s ) {47 forall( otype T ) void clear( stack(T) & s ) with( s ) { 48 48 for ( stack_node(T) * next = head; next; ) { 49 49 stack_node(T) * crnt = next;
Note: See TracChangeset
for help on using the changeset viewer.