Ignore:
Timestamp:
Mar 6, 2018, 12:11:11 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:
520145b, e5d4e5c, e6c5e79
Parents:
094476d (diff), 1feb535f (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

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

Legend:

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

    r094476d rcaa649b  
    1 #include <stdio.h>
     1#include <fstream>
     2#include <stdlib>
     3#include <stdbool.h>
    24#include "bench.h"
    35#include "cfa-stack.h"
     
    57#include "cfa-print.h"
    68
    7 int main( int argc, char *argv[] ) {
    8         FILE * out = fopen( "/dev/null", "w" );
    9         int maxi = 0, vali = 42;
    10         stack(int) si, ti;
     9int main( int argc, char * argv[] ) {
     10        ofstream out = { "/dev/null" };
     11        int max = 0, val = 42;
     12        stack( int ) s, t;
    1113
    12         REPEAT_TIMED( "push_int", N, push( &si, vali ); )
    13         TIMED( "copy_int", ti = si; )
    14         TIMED( "clear_int", clear( &si ); )
    15         REPEAT_TIMED( "pop_int", N,
    16                 int xi = pop( &ti );
    17                 if ( xi > maxi ) { maxi = xi; } )
    18         REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); )
     14        REPEAT_TIMED( "push_int", N, push( s, val ); )
     15        TIMED( "copy_int", t = s; )
     16        TIMED( "clear_int", clear( s ); )
     17        REPEAT_TIMED( "pop_int", N, int x = pop( t ); max = max( x, max ); )
     18        REPEAT_TIMED( "print_int", N/2, out | val | ':' | val | endl; )
    1919
    20         pair(_Bool, char) maxp = { (_Bool)0, '\0' }, valp = { (_Bool)1, 'a' };
    21         stack(pair(_Bool, char)) sp, tp;
     20        pair( _Bool, char ) max = { (_Bool)false, '\0' }, val = { (_Bool)true, 'a' };
     21        stack( pair( _Bool, char ) ) s, t;
    2222
    23         REPEAT_TIMED( "push_pair", N, push( &sp, valp ); )
    24         TIMED( "copy_pair", tp = sp; )
    25         TIMED( "clear_pair", clear( &sp ); )
    26         REPEAT_TIMED( "pop_pair", N,
    27                 pair(_Bool, char) xp = pop( &tp );
    28                 if ( xp > maxp ) { maxp = xp; } )
    29         REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); )
    30         fclose(out);
     23        REPEAT_TIMED( "push_pair", N, push( s, val ); )
     24        TIMED( "copy_pair", t = s; )
     25        TIMED( "clear_pair", clear( s ); )
     26        REPEAT_TIMED( "pop_pair", N, pair(_Bool, char) x = pop( t ); max = max( x, max ); )
     27        REPEAT_TIMED( "print_pair", N/2, out | val | ':' | val | endl; )
    3128}
  • doc/papers/general/evaluation/cfa-pair.c

    r094476d rcaa649b  
    11#include "cfa-pair.h"
     2#include "fstream"
    23
    3 forall(otype R, otype S 
     4forall(otype R, otype S
    45        | { int ?==?(R, R); int ?<?(R, R); int ?<?(S, S); })
    56int ?<?(pair(R, S) p, pair(R, S) q) {
     
    78}
    89
    9 forall(otype R, otype S 
     10forall(otype R, otype S
    1011        | { int ?==?(R, R); int ?<?(R, R); int ?<=?(S, S); })
    1112int ?<=?(pair(R, S) p, pair(R, S) q) {
     
    2324}
    2425
    25 forall(otype R, otype S 
     26forall(otype R, otype S
    2627        | { int ?==?(R, R); int ?>?(R, R); int ?>?(S, S); })
    2728int ?>?(pair(R, S) p, pair(R, S) q) {
     
    2930}
    3031
    31 forall(otype R, otype S 
     32forall(otype R, otype S
    3233        | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); })
    3334int ?>=?(pair(R, S) p, pair(R, S) q) {
    3435        return p.first > q.first || ( p.first == q.first && p.second >= q.second );
    3536}
     37
     38forall(otype R, otype S)
     39forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S );  })
     40ostype & ?|?( ostype & os, pair(R, S) p ) {
     41        return os | '[' | p.first | ',' | p.second | ']';
     42} // ?|?
  • doc/papers/general/evaluation/cfa-pair.h

    r094476d rcaa649b  
    11#pragma once
     2
     3#include "iostream"
    24
    35forall(otype R, otype S) struct pair {
     
    2729        | { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); })
    2830int ?>=?(pair(R, S) p, pair(R, S) q);
     31
     32forall(otype R, otype S)
     33forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, pair(R, S) ); })
     34ostype & ?|?( ostype & os, pair(R, S) );
  • doc/papers/general/evaluation/cfa-stack.c

    r094476d rcaa649b  
    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 }; /***/
    15                 stack_node(T)* acrnt = *crnt;
     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 );
     19                stack_node(T)* new_node = ((stack_node(T)*)malloc());
     20                (*new_node){ next->value }; /***/
     21                *crnt = new_node;
     22                stack_node(T) * acrnt = *crnt;
    1623                crnt = &acrnt->next;
    1724        }
     
    1926}
    2027
    21 forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t) {
    22         if ( s->head == t.head ) return *s;
    23         clear(s);
     28forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t ) {
     29        if ( s.head == t.head ) return s;
     30        clear( s );
    2431        s{ t };
    25         return *s;
     32        return s;
    2633}
    2734
    28 forall(otype T) void ^?{}(stack(T)* s) { clear(s); }
     35forall(otype T) void ^?{}( stack(T) & s) { clear( s ); }
    2936
    30 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; }
    3138
    32 forall(otype T) void push(stack(T)* s, T value) {
    33         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 );
     41        stack_node(T)* new_node = ((stack_node(T)*)malloc());
     42        (*new_node){ value, s.head }; /***/
     43        s.head = new_node;
    3444}
    3545
    36 forall(otype T) T pop(stack(T)* s) {
    37         stack_node(T)* n = s->head;
    38         s->head = n->next;
    39         T x = n->value;
    40         ^n{};
    41         free(n);
    42         return x;
     46forall(otype T) T pop( stack(T) & s ) {
     47        stack_node(T) * n = s.head;
     48        s.head = n->next;
     49        T v = n->value;
     50        delete( n );
     51        return v;
    4352}
    4453
    45 forall(otype T) void clear(stack(T)* s) {
    46     for ( stack_node(T)* next = s->head; next; ) {
    47                 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;
    4857                next = crnt->next;
    49                 delete(crnt);
     58                delete( crnt );
    5059        }
    51         s->head = 0;
     60        s.head = 0;
    5261}
  • doc/papers/general/evaluation/cfa-stack.h

    r094476d rcaa649b  
    33forall(otype T) struct stack_node;
    44forall(otype T) struct stack {
    5         stack_node(T)* head;
     5        stack_node(T) * head;
    66};
    77
    8 forall(otype T) void ?{}(stack(T)* s);
    9 forall(otype T) void ?{}(stack(T)* s, stack(T) t);
    10 forall(otype T) stack(T) ?=?(stack(T)* s, stack(T) t);
    11 forall(otype T) void ^?{}(stack(T)* s);
     8forall(otype T) void ?{}( stack(T) & s );
     9forall(otype T) void ?{}( stack(T) & s, stack(T) t );
     10forall(otype T) stack(T) ?=?( stack(T) & s, stack(T) t );
     11forall(otype T) void ^?{}( stack(T) & s);
    1212
    13 forall(otype T) _Bool empty(const stack(T)* s);
    14 forall(otype T) void push(stack(T)* s, T value);
    15 forall(otype T) T pop(stack(T)* s);
    16 forall(otype T) void clear(stack(T)* s);
     13forall(otype T) _Bool empty( const stack(T) & s );
     14forall(otype T) void push( stack(T) & s, T value );
     15forall(otype T) T pop( stack(T) & s );
     16forall(otype T) void clear( stack(T) & s );
Note: See TracChangeset for help on using the changeset viewer.