- Timestamp:
- May 1, 2018, 9:17:06 AM (7 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, with_gc
- Children:
- 1518b39, 7f0001c, 94dea96
- Parents:
- 8a5bdf0
- Location:
- doc/papers/general
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r8a5bdf0 r4c80a75 2875 2875 } 2876 2876 _Bool stack_empty( const stack * s ) { 2877 2877 return s->head == NULL; 2878 2878 } 2879 2879 void push_stack( stack * s, void * v ) { 2880 node * n = malloc( sizeof(node)); /***/2880 node * n = malloc( sizeof(node) ); /***/ 2881 2881 *n = (node){ v, s->head }; /***/ 2882 2882 s->head = n; … … 2908 2908 }; 2909 2909 struct stack { node(T) * head; }; 2910 void ?{}( stack(T) & s ) { (s.head){ 0 }; } 2911 void ?{}( stack(T) & s, stack(T) t ) { 2910 void ?{}( stack(T) & s, stack(T) t ) { // copy 2912 2911 node(T) ** cr = &s.head; 2913 2912 for ( node(T) * nx = t.head; nx; nx = nx->next ) { … … 2923 2922 nx = cr->next; 2924 2923 ^(*cr){}; 2925 free( cr);2924 free( cr ); 2926 2925 } 2927 2926 head = 0; 2928 2927 } 2928 2929 2929 \end{cfa} 2930 2930 & 2931 2931 \begin{cfa}[xleftmargin=0pt,aboveskip=0pt,belowskip=0pt] 2932 void ?{}( stack(T) & s ) { (s.head){ 0 }; } 2932 2933 void ^?{}( stack(T) & s) { clear( s ); } 2933 2934 stack(T) ?=?( stack(T) & s, stack(T) t ) { … … 2954 2955 } 2955 2956 } 2956 2957 2957 \end{cfa} 2958 2958 \end{tabular} … … 3003 3003 return *this; 3004 3004 } 3005 bool empty() const { return head == nullptr; } 3005 bool empty() const { 3006 return head == nullptr; 3007 } 3006 3008 void push( const T & value ) { 3007 3009 head = new node{ value, head }; /***/ … … 3015 3017 } 3016 3018 }; 3017 3018 3019 3019 3020 3020 \end{cfa} … … 3066 3066 return *this; 3067 3067 } 3068 bool empty() const { return head == nullptr; } 3068 bool empty() const { 3069 return head == nullptr; 3070 } 3069 3071 void push( const object & value ) { 3070 3072 head = new node{ value, head }; /***/ … … 3079 3081 }; 3080 3082 3081 3082 3083 3083 \end{cfa} 3084 3084 \end{tabular} -
doc/papers/general/evaluation/c-stack.c
r8a5bdf0 r4c80a75 27 27 } 28 28 29 stack new_stack() { return (stack){ NULL }; /***/ } 29 stack new_stack() { 30 return (stack){ NULL }; /***/ 31 } 30 32 31 33 stack * assign_stack( stack * s, const stack * t, … … 37 39 } 38 40 39 _Bool stack_empty( const stack * s ) { return s->head == NULL; } 41 _Bool stack_empty( const stack * s ) { 42 return s->head == NULL; 43 } 40 44 41 45 void push_stack( stack * s, void * v ) { -
doc/papers/general/evaluation/c-stack.h
r8a5bdf0 r4c80a75 6 6 } stack; 7 7 8 void copy_stack(stack * dst, const stack * src, void * (* copy)(const void *)); 9 void clear_stack(stack * s, void (*free_el)(void *)); 8 10 stack new_stack(); 9 void copy_stack(stack * dst, const stack * src, void * (* copy)(const void *));10 11 stack * assign_stack( stack * dst, const stack * src, 11 12 void * (* copy_el)(const void *), void (* free_el)(void *)); 12 void clear_stack(stack * s, void (*free_el)(void *));13 13 14 14 _Bool stack_empty( const stack * s ); -
doc/papers/general/evaluation/cfa-stack.c
r8a5bdf0 r4c80a75 8 8 }; 9 9 10 void ?{}( stack(T) & s ) { (s.head){ 0 }; } 11 12 void ?{}( stack(T) & s, stack(T) t ) { 10 void ?{}( stack(T) & s, stack(T) t ) { // copy 13 11 node(T) ** cr = &s.head; 14 12 for ( node(T) * nx = t.head; nx; nx = nx->next ) { … … 20 18 } 21 19 22 void ^?{}( stack(T) & s) { clear( s ); } 23 24 void clear( stack(T) & s ) with( s ) { 20 void clear( stack(T) & s ) with( s ) { 25 21 for ( node(T) * nx = head; nx; ) { 26 22 node(T) * cr = nx; 27 23 nx = cr->next; 28 24 ^(*cr){}; 29 free( cr);25 free( cr ); 30 26 } 31 27 head = 0; 32 28 } 29 30 void ?{}( stack(T) & s ) { (s.head){ 0 }; } 31 void ^?{}( stack(T) & s) { clear( s ); } 33 32 34 33 stack(T) ?=?( stack(T) & s, stack(T) t ) { … … 39 38 } 40 39 41 _Bool empty( const stack(T) & s ) { return s.head == 0; } 40 _Bool empty( const stack(T) & s ) { 41 return s.head == 0; 42 } 42 43 43 44 void push( stack(T) & s, T value ) with( s ) { -
doc/papers/general/evaluation/cfa-stack.h
r8a5bdf0 r4c80a75 7 7 }; 8 8 9 void ?{}( stack(T) & s, stack(T) t ); 10 void clear( stack(T) & s ); 9 11 void ?{}( stack(T) & s ); 10 void ?{}( stack(T) & s, stack(T) t );11 12 void ^?{}( stack(T) & s); 12 void clear( stack(T) & s );13 13 14 14 stack(T) ?=?( stack(T) & s, stack(T) t ); -
doc/papers/general/evaluation/cpp-stack.hpp
r8a5bdf0 r4c80a75 10 10 node * head; 11 11 12 stack() : head( nullptr ) {} 13 stack( const stack<T> & o ) { copy( o ); } 12 void copy( const stack<T> & o ) { 13 node ** cr = &head; 14 for ( node * nx = o.head; nx; nx = nx->next ) { 15 *cr = new node{ nx->value }; /***/ 16 cr = &(*cr)->next; 17 } 18 *cr = nullptr; 19 } 14 20 15 21 void clear() { … … 22 28 } 23 29 24 void copy( const stack<T> & o ) { 25 node ** cr = &head; 26 for ( node * nx = o.head; nx; nx = nx->next ) { 27 *cr = new node{ nx->value }; /***/ 28 cr = &(*cr)->next; 29 } 30 *cr = nullptr; 31 } 32 30 stack() : head( nullptr ) {} 31 stack( const stack<T> & o ) { copy( o ); } 33 32 ~stack() { clear(); } 34 33 35 stack & operator= 34 stack & operator=( const stack<T> & o ) { 36 35 if ( this == &o ) return *this; 37 36 clear(); … … 40 39 } 41 40 42 bool empty() const { return head == nullptr; } 41 bool empty() const { 42 return head == nullptr; 43 } 43 44 44 void push( const T & value ) { head = new node{ value, head }; /***/ } 45 void push( const T & value ) { 46 head = new node{ value, head }; /***/ 47 } 45 48 46 49 T pop() { -
doc/papers/general/evaluation/cpp-vstack.cpp
r8a5bdf0 r4c80a75 3 3 4 4 stack::node::node( const object & v, node * n ) : value( v.new_copy() ), next( n ) {} 5 6 void stack::copy( const stack & o ) { 7 node ** cr = &head; 8 for ( node * nx = o.head; nx; nx = nx->next ) { 9 *cr = new node{ *nx->value }; /***/ 10 cr = &(*cr)->next; 11 } 12 *cr = nullptr; 13 } 5 14 6 15 void stack::clear() { … … 11 20 } 12 21 head = nullptr; 13 }14 15 void stack::copy( const stack & o ) {16 node ** cr = &head;17 for ( node * nx = o.head; nx; nx = nx->next ) {18 *cr = new node{ *nx->value }; /***/19 cr = &(*cr)->next;20 }21 *cr = nullptr;22 22 } 23 23 … … 33 33 } 34 34 35 bool stack::empty() const { return head == nullptr; } 35 bool stack::empty() const { 36 return head == nullptr; 37 } 36 38 37 void stack::push( const object & value ) { head = new node{ value, head }; /***/ } 39 void stack::push( const object & value ) { 40 head = new node{ value, head }; /***/ 41 } 38 42 39 43 ptr<object> stack::pop() { -
doc/papers/general/evaluation/cpp-vstack.hpp
r8a5bdf0 r4c80a75 10 10 node * head; 11 11 12 void copy( const stack & o ); 12 13 void clear(); 13 void copy( const stack & o );14 14 15 15 stack();
Note: See TracChangeset
for help on using the changeset viewer.