Changeset e59f0bf for doc/papers/general
- Timestamp:
- Mar 9, 2018, 10:44:51 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, resolv-new, with_gc
- Children:
- 12bbb367, 8b001bd
- Parents:
- 29db723
- Location:
- doc/papers/general
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r29db723 re59f0bf 2627 2627 & \CT{C} & \CT{\CFA} & \CT{\CC} & \CT{\CCV} \\ \hline 2628 2628 maximum memory usage (MB) & 10,001 & 2,502 & 2,503 & 11,253 \\ 2629 source code size (lines) & 1 87 & 186 & 133 & 303 \\2630 redundant type annotations (lines) & 2 5& 0 & 2 & 16 \\2629 source code size (lines) & 197 & 186 & 133 & 303 \\ 2630 redundant type annotations (lines) & 27 & 0 & 2 & 16 \\ 2631 2631 binary size (KB) & 14 & 257 & 14 & 37 \\ 2632 2632 \end{tabular} … … 2796 2796 \lstset{basicstyle=\linespread{0.9}\sf\small} 2797 2797 2798 Throughout, @/***/@ designates a counted redundant type annotation .2798 Throughout, @/***/@ designates a counted redundant type annotation; code reformatted for brevity. 2799 2799 2800 2800 \smallskip\noindent … … 2806 2806 }; 2807 2807 struct stack { struct stack_node* head; }; 2808 void clear_stack( struct stack * s, void (*free_el)( void * ) ) { 2809 for ( struct stack_node * next = s->head; next; ) { 2810 struct stack_node * crnt = next; 2811 next = crnt->next; 2812 free_el( crnt->value ); 2813 free( crnt ); 2814 } 2815 s->head = NULL; 2816 } 2808 2817 struct stack new_stack() { return (struct stack){ NULL }; /***/ } 2809 2818 void copy_stack( struct stack * s, const struct stack * t, void * (*copy)( const void * ) ) { … … 2816 2825 *crnt = NULL; 2817 2826 } 2827 struct stack * assign_stack( struct stack * s, const struct stack * t, 2828 void * (*copy_el)( const void * ), void (*free_el)( void * ) ) { 2829 if ( s->head == t->head ) return s; 2830 clear_stack( s, free_el ); /***/ 2831 copy_stack( s, t, copy_el ); /***/ 2832 return s; 2833 } 2818 2834 _Bool stack_empty( const struct stack * s ) { return s->head == NULL; } 2819 2835 void push_stack( struct stack * s, void * value ) { … … 2828 2844 free( n ); 2829 2845 return x; 2830 }2831 void clear_stack( struct stack * s, void (*free_el)( void * ) ) {2832 for ( struct stack_node * next = s->head; next; ) {2833 struct stack_node * crnt = next;2834 next = crnt->next;2835 free_el( crnt->value );2836 free( crnt );2837 }2838 s->head = NULL;2839 2846 } 2840 2847 \end{cfa} … … 2848 2855 }; 2849 2856 forall( otype T ) struct stack { stack_node(T) * head; }; 2857 forall( otype T ) void clear( stack(T) & s ) with( s ) { 2858 for ( stack_node(T) * next = head; next; ) { 2859 stack_node(T) * crnt = next; 2860 next = crnt->next; 2861 ^(*crnt){}; 2862 free(crnt); 2863 } 2864 head = 0; 2865 } 2850 2866 forall( otype T ) void ?{}( stack(T) & s ) { (s.head){ 0 }; } 2851 2867 forall( otype T ) void ?{}( stack(T) & s, stack(T) t ) { … … 2878 2894 free( n ); 2879 2895 return v; 2880 }2881 forall( otype T ) void clear( stack(T) & s ) with( s ) {2882 for ( stack_node(T) * next = head; next; ) {2883 stack_node(T) * crnt = next;2884 next = crnt->next;2885 ^(*crnt){};2886 free(crnt);2887 }2888 head = 0;2889 2896 } 2890 2897 \end{cfa} … … 2900 2907 }; 2901 2908 node * head; 2909 void clear() { 2910 for ( node * next = head; next; ) { 2911 node * crnt = next; 2912 next = crnt->next; 2913 delete crnt; 2914 } 2915 head = nullptr; 2916 } 2902 2917 void copy( const stack<T> & o) { 2903 2918 node ** crnt = &head; … … 2933 2948 return x; 2934 2949 } 2935 void clear() {2936 for ( node * next = head; next; ) {2937 node * crnt = next;2938 next = crnt->next;2939 delete crnt;2940 }2941 head = nullptr;2942 }2943 2950 }; 2944 2951 \end{cfa} … … 2954 2961 }; 2955 2962 node* head; 2963 void clear() { 2964 for ( node * next = head; next; ) { 2965 node * crnt = next; 2966 next = crnt->next; 2967 delete crnt; 2968 } 2969 head = nullptr; 2970 } 2956 2971 void copy( const stack & o ) { 2957 2972 node ** crnt = &head; … … 2987 3002 return x; 2988 3003 } 2989 void clear() {2990 for ( node * next = head; next; ) {2991 node * crnt = next;2992 next = crnt->next;2993 delete crnt;2994 }2995 head = nullptr;2996 }2997 3004 }; 2998 3005 \end{cfa} -
doc/papers/general/evaluation/c-stack.c
r29db723 re59f0bf 17 17 } 18 18 *crnt = NULL; 19 } 20 21 struct stack* assign_stack(struct stack* s, const struct stack* t, 22 void* (*copy_el)(const void*), void (*free_el)(void*)) { 23 if ( s->head == t->head ) return s; 24 clear_stack( s, free_el ); /***/ 25 copy_stack( s, t, copy_el ); /***/ 26 return s; 19 27 } 20 28 -
doc/papers/general/evaluation/c-stack.h
r29db723 re59f0bf 8 8 struct stack new_stack(); 9 9 void copy_stack(struct stack* dst, const struct stack* src, void* (*copy)(const void*)); 10 struct stack* assign_stack(struct stack* dst, const struct stack* src, 11 void* (*copy_el)(const void*), void (*free_el)(void*)); 10 12 void clear_stack(struct stack* s, void (*free_el)(void*)); 11 13
Note: See TracChangeset
for help on using the changeset viewer.