Ignore:
Timestamp:
Mar 2, 2018, 6:22:52 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
2097cd4, 82c367d
Parents:
938dd75 (diff), c9b3a41 (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:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r938dd75 r000ff2c  
    44forall(otype T) struct stack_node {
    55        T value;
    6         stack_node(T)* next;
     6        stack_node(T) * next;
    77};
     8forall(otype T) void ?{}( stack_node(T) & node, T value, stack_node(T) * next ) {
     9    node.value = value;
     10    node.next = next;
     11}
    812
    9 forall(otype T) void ?{}(stack(T)& s) { (s.head){ 0 }; }
     13forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; }
    1014
    11 forall(otype T) void ?{}(stack(T)& s, stack(T) t) {
    12         stack_node(T)** crnt = &s.head;
    13         for ( stack_node(T)* next = t.head; next; next = next->next ) {
    14                 // *crnt = &(*(stack_node(T)*)malloc()){ next->value }; /***/
     15forall(otype T) void ?{}( stack(T) & s, stack(T) t ) {
     16        stack_node(T) ** crnt = &s.head;
     17        for ( stack_node(T) * next = t.head; next; next = next->next ) {
     18                // *crnt = new( next->value, 0 );
    1519                stack_node(T)* new_node = ((stack_node(T)*)malloc());
    1620                (*new_node){ next->value }; /***/
    1721                *crnt = new_node;
    18 
    19                 stack_node(T)* acrnt = *crnt;
     22                stack_node(T) * acrnt = *crnt;
    2023                crnt = &acrnt->next;
    2124        }
     
    2326}
    2427
    25 forall(otype T) stack(T) ?=?(stack(T)& s, stack(T) t) {
     28forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) {
    2629        if ( s.head == t.head ) return s;
    27         clear(s);
     30        clear( s );
    2831        s{ t };
    2932        return s;
    3033}
    3134
    32 forall(otype T) void ^?{}(stack(T)& s) { clear(s); }
     35forall(otype T) void ^?{}( stack(T) & s) { clear( s ); }
    3336
    34 forall(otype T) _Bool empty(const stack(T)& s) { return s.head == 0; }
     37forall(otype T) _Bool empty( const stack(T) & s ) { return s.head == 0; }
    3538
    36 forall(otype T) void push(stack(T)& s, T value) {
    37         // s.head = &(*(stack_node(T)*)malloc()){ value, s.head }; /***/
     39forall(otype T) void push( stack(T) & s, T value ) {
     40        // s.head = new( value, s.head );
    3841        stack_node(T)* new_node = ((stack_node(T)*)malloc());
    3942        (*new_node){ value, s.head }; /***/
     
    4144}
    4245
    43 forall(otype T) T pop(stack(T)& s) {
    44         stack_node(T)* n = s.head;
     46forall(otype T) T pop( stack(T) & s ) {
     47        stack_node(T) * n = s.head;
    4548        s.head = n->next;
    46         T x = n->value;
    47         ^n{};
    48         free(n);
    49         return x;
     49        T v = n->value;
     50        delete( n );
     51        return v;
    5052}
    5153
    52 forall(otype T) void clear(stack(T)& s) {
    53     for ( stack_node(T)* next = s.head; next; ) {
    54                 stack_node(T)* crnt = next;
     54forall(otype T) void clear( stack(T) & s ) {
     55        for ( stack_node(T) * next = s.head; next; ) {
     56                stack_node(T) * crnt = next;
    5557                next = crnt->next;
    56                 delete(crnt);
     58                delete( crnt );
    5759        }
    5860        s.head = 0;
Note: See TracChangeset for help on using the changeset viewer.