Ignore:
Timestamp:
Dec 12, 2018, 9:16:12 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
5ebb1368
Parents:
3d99498
Message:

add auto newline to sout, change endl to nl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/raii/dtor-early-exit.c

    r3d99498 r200fcb3  
    1010// Created On       : Wed Aug 17 08:26:25 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 11 07:58:39 2018
    13 // Update Count     : 8
     12// Last Modified On : Tue Dec 11 22:05:24 2018
     13// Update Count     : 9
    1414//
    1515
     
    2525// don't want these called
    2626void ?{}(A & a) { assert( false ); }
    27 void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name | endl; a.x = (int*)malloc(); }
     27void ?{}(A & a, const char * name) { a.name = name; sout | "construct " | name; a.x = (int*)malloc(); }
    2828void ?{}(A & a, const char * name, int * ptr) { assert( false ); }
    2929
    3030A ?=?(A & a, A b) {  sout | "assign " | a.name | " " | b.name; return a; }
    31 void ?{}(A & a, A b) { sout | "copy construct " | b.name | endl; a.x = (int*)malloc(); }
    32 void ^?{}(A & a) { sout | "destruct " | a.name | endl; free(a.x); }
     31void ?{}(A & a, A b) { sout | "copy construct " | b.name; a.x = (int*)malloc(); }
     32void ^?{}(A & a) { sout | "destruct " | a.name; free(a.x); }
    3333
    3434// test returns
    3535void f(int i) {
    36         sout | "f i=" | i | endl;
     36        sout | "f i=" | i;
    3737        A x = { "x" };  // construct x
    3838        {
     
    5555void g() {
    5656        for (int i = 0; i < 10; i++) {
    57                 sout | "g for i=" | i | endl;
     57                sout | "g for i=" | i;
    5858                A x = { "x" };
    5959                // construct x
    6060                // destruct x
    6161        }
    62         sout | endl;
     62        sout | nl;
    6363        {
    6464                int i = 0;
    6565                while (i < 10) {
    66                         sout | "g while i=" | i | endl;
     66                        sout | "g while i=" | i;
    6767                        A x = { "x" };
    6868                        // construct x
     
    7171                }
    7272        }
    73         sout | endl;
     73        sout;
    7474        for (int i = 0; i < 10; i++) {
    7575                switch(10) {
     
    7878                        case 10: {
    7979                                A y = { "y" };
    80                                 sout | "g switch i=" | i | endl;
     80                                sout | "g switch i=" | i;
    8181                                // construct y
    8282                                break; // destruct y
    8383                        }
    8484                        default: {
    85                                 sout | "g switch i=" | i | endl;
     85                                sout | "g switch i=" | i;
    8686                                A x = { "x" };
    8787                                // construct x
     
    9090                }
    9191        }
    92         sout | endl;
     92        sout | nl;
    9393        for (int k = 0; k < 2; k++) {
    94                 sout | "g for k=" | k | endl;
     94                sout | "g for k=" | k;
    9595                L1: for (int i = 0; i < 10; i++) {
    96                         sout | "g for i=" | i | endl;
     96                        sout | "g for i=" | i;
    9797
    9898                        A x = { "x" };
    9999                        if (i == 2) {
    100                                 sout | "continue L1" | endl;
     100                                sout | "continue L1";
    101101                                continue;  // destruct x
    102102                        } else if (i == 3) {
    103                                 sout | "break L1" | endl;
     103                                sout | "break L1";
    104104                                break;  // destruct x
    105105                        }
    106106
    107107                        L2: for (int j = 0; j < 10; j++) {
    108                                 sout | "g for j=" | j | endl;
     108                                sout | "g for j=" | j;
    109109                                A y = { "y" };
    110110                                if (j == 0) {
    111                                         sout | "continue L2" | endl;
     111                                        sout | "continue L2";
    112112                                        continue; // destruct y - missing because object that needs to be destructed is not a part of this block, it's a part of the for's block
    113113                                } else if (j == 1) {
    114                                         sout | "break L2" | endl;
     114                                        sout | "break L2";
    115115                                        break;  // destruct y
    116116                                } else if (i == 1) {
    117                                         sout | "continue L1" | endl;
     117                                        sout | "continue L1";
    118118                                        continue L1; // destruct x,y - note: continue takes you to destructors for block, so only generate destructor for y
    119119                                } else if (k == 1) {
    120                                         sout | "break L1" | endl;
     120                                        sout | "break L1";
    121121                                        break L1;  // destruct x,y
    122122                                }
     
    125125        }
    126126
    127         sout | endl;
     127        sout | nl;
    128128        L3: if( 3 ) {
    129129                A w = { "w" };
    130130                if( 4 ) {
    131131                        A v = { "v" };
    132                         sout | "break L3" | endl;
     132                        sout | "break L3";
    133133                        break L3;
    134134                }
     
    144144        // * if S_L-S_G is non-empty, error
    145145        // * emit destructors for all variables in S_G-S_L
    146         sout | "h" | endl;
     146        sout | "h";
    147147        {
    148148                L0: ;
     
    152152                        A y = { "y" };
    153153                        // S_L1 = { y }
    154                 L1: sout | "L1" | endl;
     154                L1: sout | "L1";
    155155                        A x = { "x" };
    156156                        // S_L2 = { y, x }
    157                 L2: sout | "L2" | endl;
     157                L2: sout | "L2";
    158158                        if (i == 0) {
    159159                                ++i;
    160                                 sout | "goto L1" | endl;
     160                                sout | "goto L1";
    161161                                // S_G = { y, x }
    162162                                goto L1;  // jump back, destruct b/c before x definition
     
    165165                        } else if (i == 1) {
    166166                                ++i;
    167                                 sout | "goto L2" | endl;
     167                                sout | "goto L2";
    168168                                // S_G = { y, x }
    169169                                goto L2;  // jump back, do not destruct
     
    172172                        } else if (i == 2) {
    173173                                ++i;
    174                                 sout | "goto L3" | endl;
     174                                sout | "goto L3";
    175175                                // S_G = { y, x }
    176176                                goto L3;  // jump ahead, do not destruct
     
    180180                                ++i;
    181181                                A z = { "z" };
    182                                 sout | "goto L3-2" | endl;
     182                                sout | "goto L3-2";
    183183                                // S_G = { z, y, x }
    184184                                goto L3;
     
    187187                        } else {
    188188                                ++i;
    189                                 sout | "goto L4" | endl;
     189                                sout | "goto L4";
    190190                                // S_G = { y, x }
    191191                                goto L4;  // jump ahead, destruct b/c left block x was defined in
     
    194194                        }
    195195                        // S_L3 = { y, x }
    196                 L3: sout | "L3" | endl;
    197                         sout | "goto L2-2" | endl;
     196                L3: sout | "L3";
     197                        sout | "goto L2-2";
    198198                        // S_G = { y, x }
    199199                        goto L2; // jump back, do not destruct
     
    202202        }
    203203        // S_L4 = {}
    204         L4: sout | "L4" | endl;
     204        L4: sout | "L4";
    205205        if (i == 4) {
    206                 sout | "goto L0" | endl;
     206                sout | "goto L0";
    207207                // S_G = {}
    208208                goto L0;
     
    240240                f(i);
    241241        }
    242         sout | endl;
     242        sout | nl;
    243243        g();
    244         sout | endl;
     244        sout | nl;
    245245        h();
    246246
Note: See TracChangeset for help on using the changeset viewer.