Ignore:
Timestamp:
Apr 10, 2017, 3:17:29 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
b715c9a
Parents:
b0fedd4 (diff), b276be5 (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

    rb0fedd4 r7a054e82  
     1#include <assert>
    12#include <stdlib>
    23#include "cfa-stack.h"
     
    89
    910forall(otype T) void ?{}(stack(T)* s) {
    10         ?{}( &s->head, 0 );
     11        (&s->head){ 0 };
     12}
     13
     14forall(otype T) void copy(stack(T)* s, stack(T)* t) {
     15        stack_node(T)** crnt = &s->head;
     16        stack_node(T)* next = t->head;
     17        while ( next ) {
     18                *crnt = ((stack_node(T)*)malloc()){ next->value };
     19                stack_node(T)* acrnt = *crnt;
     20                crnt = &acrnt->next;
     21                next = next->next;
     22        }
     23        *crnt = 0;
     24}
     25
     26forall(otype T) void ?{}(stack(T)* s, stack(T) t) {
     27        stack_node(T)** crnt = &s->head;
     28        stack_node(T)* next = t.head;
     29        while ( next ) {
     30                *crnt = ((stack_node(T)*)malloc()){ next->value };
     31                stack_node(T)* acrnt = *crnt;
     32                crnt = &acrnt->next;
     33                next = next->next;
     34        }
     35        *crnt = 0;
     36}
     37
     38forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t) {
     39        if ( s->head == t.head ) return *s;
     40        clear(s);
     41        s{ t };
     42        return *s;
    1143}
    1244
    1345forall(otype T) void ^?{}(stack(T)* s) {
    14         stack_node(T)* next = s->head;
    15         while ( next ) {
    16                 stack_node(T)* crnt = next;
    17                 next = crnt->next;
    18                 delete(crnt);
    19         }
     46        clear(s);
    2047}
    2148
     
    3562        return x;
    3663}
     64
     65forall(otype T) void clear(stack(T)* s) {
     66        stack_node(T)* next = s->head;
     67        while ( next ) {
     68                stack_node(T)* crnt = next;
     69                next = crnt->next;
     70                delete(crnt);
     71        }
     72        s->head = 0;
     73}
Note: See TracChangeset for help on using the changeset viewer.