Ignore:
Timestamp:
May 1, 2018, 9:17:06 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

update evaluation programs

Location:
doc/papers/general/evaluation
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/general/evaluation/c-stack.c

    r8a5bdf0 r4c80a75  
    2727}
    2828
    29 stack new_stack() { return (stack){ NULL }; /***/ }
     29stack new_stack() {
     30        return (stack){ NULL }; /***/
     31}
    3032
    3133stack * assign_stack( stack * s, const stack * t,
     
    3739}
    3840
    39 _Bool stack_empty( const stack * s ) { return s->head == NULL; }
     41_Bool stack_empty( const stack * s ) {
     42        return s->head == NULL;
     43}
    4044
    4145void push_stack( stack * s, void * v ) {
  • doc/papers/general/evaluation/c-stack.h

    r8a5bdf0 r4c80a75  
    66} stack;
    77
     8void copy_stack(stack * dst, const stack * src, void * (* copy)(const void *));
     9void clear_stack(stack * s, void (*free_el)(void *));
    810stack new_stack();
    9 void copy_stack(stack * dst, const stack * src, void * (* copy)(const void *));
    1011stack * assign_stack( stack * dst, const stack * src,
    1112        void * (* copy_el)(const void *), void (* free_el)(void *));
    12 void clear_stack(stack * s, void (*free_el)(void *));
    1313
    1414_Bool stack_empty( const stack * s );
  • doc/papers/general/evaluation/cfa-stack.c

    r8a5bdf0 r4c80a75  
    88        };
    99
    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
    1311                node(T) ** cr = &s.head;
    1412                for ( node(T) * nx = t.head; nx; nx = nx->next ) {
     
    2018        }
    2119
    22         void ^?{}( stack(T) & s) { clear( s ); }
    23 
    24     void clear( stack(T) & s ) with( s ) {
     20        void clear( stack(T) & s ) with( s ) {
    2521                for ( node(T) * nx = head; nx; ) {
    2622                        node(T) * cr = nx;
    2723                        nx = cr->next;
    2824                        ^(*cr){};
    29                         free(cr);
     25                        free( cr );
    3026                }
    3127                head = 0;
    3228        }
     29
     30        void ?{}( stack(T) & s ) { (s.head){ 0 }; }
     31        void ^?{}( stack(T) & s) { clear( s ); }
    3332
    3433        stack(T) ?=?( stack(T) & s, stack(T) t ) {
     
    3938        }
    4039
    41         _Bool empty( const stack(T) & s ) { return s.head == 0; }
     40        _Bool empty( const stack(T) & s ) {
     41                return s.head == 0;
     42        }
    4243
    4344        void push( stack(T) & s, T value ) with( s ) {
  • doc/papers/general/evaluation/cfa-stack.h

    r8a5bdf0 r4c80a75  
    77        };
    88
     9        void ?{}( stack(T) & s, stack(T) t );
     10        void clear( stack(T) & s );
    911        void ?{}( stack(T) & s );
    10         void ?{}( stack(T) & s, stack(T) t );
    1112        void ^?{}( stack(T) & s);
    12         void clear( stack(T) & s );
    1313
    1414        stack(T) ?=?( stack(T) & s, stack(T) t );
  • doc/papers/general/evaluation/cpp-stack.hpp

    r8a5bdf0 r4c80a75  
    1010        node * head;
    1111
    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        }
    1420
    1521        void clear() {
     
    2228        }
    2329
    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 ); }
    3332        ~stack() { clear(); }
    3433
    35         stack & operator= ( const stack<T> & o ) {
     34        stack & operator=( const stack<T> & o ) {
    3635                if ( this == &o ) return *this;
    3736                clear();
     
    4039        }
    4140
    42         bool empty() const { return head == nullptr; }
     41        bool empty() const {
     42                return head == nullptr;
     43        }
    4344
    44         void push( const T & value ) { head = new node{ value, head };  /***/ }
     45        void push( const T & value ) {
     46                head = new node{ value, head };  /***/
     47        }
    4548
    4649        T pop() {
  • doc/papers/general/evaluation/cpp-vstack.cpp

    r8a5bdf0 r4c80a75  
    33
    44stack::node::node( const object & v, node * n ) : value( v.new_copy() ), next( n ) {}
     5
     6void 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}
    514
    615void stack::clear() {
     
    1120        }
    1221        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;
    2222}
    2323
     
    3333}
    3434
    35 bool stack::empty() const { return head == nullptr; }
     35bool stack::empty() const {
     36        return head == nullptr;
     37}
    3638
    37 void stack::push( const object & value ) { head = new node{ value, head }; /***/ }
     39void stack::push( const object & value ) {
     40        head = new node{ value, head }; /***/
     41}
    3842
    3943ptr<object> stack::pop() {
  • doc/papers/general/evaluation/cpp-vstack.hpp

    r8a5bdf0 r4c80a75  
    1010        node * head;
    1111
     12        void copy( const stack & o );
    1213        void clear();
    13         void copy( const stack & o );
    1414
    1515        stack();
Note: See TracChangeset for help on using the changeset viewer.