Ignore:
Timestamp:
Apr 19, 2017, 10:15:45 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
cd348e7
Parents:
221c2de (diff), de4ce0e (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/evaluation/cfa-stack.c

    r221c2de r154fdc8  
    77};
    88
    9 forall(otype T) void ?{}(stack(T)* s) {
    10         ?{}( &s->head, 0 );
     9forall(otype T) void ?{}(stack(T)* s) { (&s->head){ 0 }; }
     10
     11forall(otype T) void ?{}(stack(T)* s, stack(T) t) {
     12        stack_node(T)** crnt = &s->head;
     13        stack_node(T)* next = t.head;
     14        while ( next ) {
     15                *crnt = ((stack_node(T)*)malloc()){ next->value }; /***/
     16                stack_node(T)* acrnt = *crnt;
     17                crnt = &acrnt->next;
     18                next = next->next;
     19        }
     20        *crnt = 0;
    1121}
    1222
    13 forall(otype T) void ^?{}(stack(T)* s) {
     23forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t) {
     24        if ( s->head == t.head ) return *s;
     25        clear(s);
     26        s{ t };
     27        return *s;
     28}
     29
     30forall(otype T) void ^?{}(stack(T)* s) { clear(s); }
     31
     32forall(otype T) _Bool empty(const stack(T)* s) { return s->head == 0; }
     33
     34forall(otype T) void push(stack(T)* s, T value) {
     35        s->head = ((stack_node(T)*)malloc()){ value, s->head }; /***/
     36}
     37
     38forall(otype T) T pop(stack(T)* s) {
     39        stack_node(T)* n = s->head;
     40        s->head = n->next;
     41        T x = n->value;
     42        ^n{};
     43        free(n);
     44        return x;
     45}
     46
     47forall(otype T) void clear(stack(T)* s) {
    1448        stack_node(T)* next = s->head;
    1549        while ( next ) {
     
    1852                delete(crnt);
    1953        }
     54        s->head = 0;
    2055}
    21 
    22 forall(otype T) _Bool empty(const stack(T)* s) {
    23         return s->head == 0;
    24 }
    25 
    26 forall(otype T) void push(stack(T)* s, T value) {
    27         s->head = ((stack_node(T)*)malloc()){ value, s->head };
    28 }
    29 
    30 forall(otype T) T pop(stack(T)* s) {
    31         stack_node(T)* n = s->head;
    32         s->head = n->next;
    33         T x = n->value;
    34         delete(n);
    35         return x;
    36 }
Note: See TracChangeset for help on using the changeset viewer.