Ignore:
Timestamp:
Feb 9, 2016, 3:25:05 PM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7528ba1
Parents:
771b3c3 (diff), bd85400 (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' into ctor

Conflicts:

src/CodeGen/CodeGenerator.cc
src/GenPoly/Box.cc
src/Makefile.in
src/Parser/ParseNode.h
src/Parser/parser.cc
src/Parser/parser.yy
src/SymTab/Validate.cc
src/SynTree/Initializer.h
src/SynTree/ObjectDecl.cc
src/SynTree/Visitor.h
src/main.cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/swap.c

    r771b3c3 rd63eeb0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 11:32:25 2016
    13 // Update Count     : 5
     12// Last Modified On : Wed Feb  3 11:14:04 2016
     13// Update Count     : 63
    1414//
    1515
    16 #include "fstream.h"
    17 
    18 forall( type T )
    19 void swap( T *left, T *right ) {
    20         T temp = *left;
    21         *left = *right;
    22         *right = temp;
    23 }
     16#include <fstream>
     17#include <stdlib>                                                                               // swap
    2418
    2519int main( void ) {
    26         int x = 1, y = 2;
    2720        ofstream *sout = ofstream_stdout();
    28         sout | x | ' ' | y | endl;
    29         swap( &x, &y );
    30         sout | x | ' ' | y | endl;
    31 }
     21
     22        char c1 = 'a', c2 = 'b';
     23        sout | "char\t\t\t" | c1 | ' ' | c2 | "\t\t\tswap ";
     24        swap( &c1, &c2 );
     25        sout | '\t' | c1 | ' ' | c2 | endl;
     26
     27        signed int i1 = -1, i2 = -2;
     28        sout | "signed int\t\t" | i1 | ' ' | i2 | "\t\t\tswap ";
     29        swap( &i1, &i2 );
     30        sout | '\t' | i1 | ' ' | i2 | endl;
     31
     32        unsigned int ui1 = 1, ui2 = 2;
     33        sout | "unsigned int\t\t" | ui1 | ' ' | ui2 | "\t\t\tswap ";
     34        swap( &ui1, &ui2 );
     35        sout | '\t' | ui1 | ' ' | ui2 | endl;
     36
     37        signed long int li1 = -1, li2 = -2;
     38        sout | "signed long int\t\t" | li1 | ' ' | li2 | "\t\t\tswap ";
     39        swap( &li1, &li2 );
     40        sout | '\t' | li1 | ' ' | li2 | endl;
     41
     42        unsigned long int uli1 = 1, uli2 = 2;
     43        sout | "unsigned long int\t" | uli1 | ' ' | uli2 | "\t\t\tswap ";
     44        swap( &uli1, &uli2 );
     45        sout | '\t' | uli1 | ' ' | uli2 | endl;
     46
     47        signed long long int lli1 = -1, lli2 = -2;
     48        sout | "signed long long int\t" | lli1 | ' ' | lli2 | "\t\t\tswap ";
     49        swap( &lli1, &lli2 );
     50        sout | '\t' | lli1 | ' ' | lli2 | endl;
     51
     52        unsigned long long int ulli1 = 1, ulli2 = 2;
     53        sout | "unsigned long long int\t" | ulli1 | ' ' | ulli2 | "\t\t\tswap ";
     54        swap( &ulli1, &ulli2 );
     55        sout | '\t' | ulli1 | ' ' | ulli2 | endl;
     56
     57        float f1 = 1.5, f2 = 2.5;
     58        sout | "float\t\t\t" | f1 | ' ' | f2 | "\t\t\tswap ";
     59        swap( &f1, &f2 );
     60        sout | '\t' | f1 | ' ' | f2 | endl;
     61
     62        double d1 = 1.5, d2 = 2.5;
     63        sout | "double\t\t\t" | d1 | ' ' | d2 | "\t\t\tswap ";
     64        swap( &d1, &d2 );
     65        sout | '\t' | d1 | ' ' | d2 | endl;
     66
     67        long double ld1 = 1.5, ld2 = 2.5;
     68        sout | "long double\t\t" | ld1 | ' ' | ld2 | "\t\t\tswap ";
     69        swap( &ld1, &ld2 );
     70        sout | '\t' | ld1 | ' ' | ld2 | endl;
     71
     72        float _Complex fc1 = 1.5f+1.5if, fc2 = 2.5f+2.5if;
     73        sout | "float _Complex\t\t" | fc1 | ' ' | fc2 | "\tswap ";
     74        swap( &fc1, &fc2 );
     75        sout | '\t' | fc1 | ' ' | fc2 | endl;
     76
     77        double _Complex dc1 = 1.5d+1.5id, dc2 = 2.5d+2.5id;
     78        sout | "double _Complex\t\t" | dc1 | ' ' | dc2 | "\tswap ";
     79        swap( &dc1, &dc2 );
     80        sout | '\t' | dc1 | ' ' | dc2 | endl;
     81
     82        long double _Complex ldc1 = 1.5d+1.5il, ldc2 = 2.5d+2.5il;
     83        sout | "long double _Complex\t" | ldc1 | ' ' | ldc2 | "\tswap ";
     84        swap( &ldc1, &ldc2 );
     85        sout | '\t' | ldc1 | ' ' | ldc2 | endl;
     86
     87        struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 };
     88        ofstream * ?|?( ofstream * os, S s ) { return os | s.i | ' ' | s.j; }
     89        sout | "struct S\t\t" | s1 | "  " | s2 | "\t\tswap ";
     90        swap( &s1, &s2 );
     91        sout | '\t' | s1 | "  " | s2 | endl;
     92} // main
    3293
    3394// Local Variables: //
    3495// tab-width: 4 //
    35 // compile-command: "cfa swap.c fstream.o iostream.o iterator.o" //
     96// compile-command: "cfa swap.c" //
    3697// End: //
Note: See TracChangeset for help on using the changeset viewer.