Changeset d3b7937 for src/examples


Ignore:
Timestamp:
Jan 29, 2016, 4:36:39 PM (10 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, string, with_gc
Children:
ae8b942
Parents:
f3fc8cbe
Message:

building runtime library (first attempt)

Location:
src/examples
Files:
2 added
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/examples/Makefile.am

    rf3fc8cbe rd3b7937  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Fri Nov 20 16:03:46 2015
    14 ## Update Count     : 24
     13## Last Modified On : Mon Jan 25 22:31:42 2016
     14## Update Count     : 25
    1515###############################################################################
    1616
     
    2020
    2121noinst_PROGRAMS = fstream_test vector_test # build but do not install
    22 fstream_test_SOURCES = iostream.c fstream.c fstream_test.c iterator.c
    23 vector_test_SOURCES = vector_int.c fstream.c iostream.c array.c iterator.c vector_test.c
     22fstream_test_SOURCES = fstream_test.c
     23vector_test_SOURCES = vector_int.c array.c vector_test.c
  • src/examples/Makefile.in

    rf3fc8cbe rd3b7937  
    4848CONFIG_CLEAN_VPATH_FILES =
    4949PROGRAMS = $(noinst_PROGRAMS)
    50 am_fstream_test_OBJECTS = iostream.$(OBJEXT) fstream.$(OBJEXT) \
    51         fstream_test.$(OBJEXT) iterator.$(OBJEXT)
     50am_fstream_test_OBJECTS = fstream_test.$(OBJEXT)
    5251fstream_test_OBJECTS = $(am_fstream_test_OBJECTS)
    5352fstream_test_LDADD = $(LDADD)
    54 am_vector_test_OBJECTS = vector_int.$(OBJEXT) fstream.$(OBJEXT) \
    55         iostream.$(OBJEXT) array.$(OBJEXT) iterator.$(OBJEXT) \
     53am_vector_test_OBJECTS = vector_int.$(OBJEXT) array.$(OBJEXT) \
    5654        vector_test.$(OBJEXT)
    5755vector_test_OBJECTS = $(am_vector_test_OBJECTS)
     
    176174top_builddir = @top_builddir@
    177175top_srcdir = @top_srcdir@
    178 fstream_test_SOURCES = iostream.c fstream.c fstream_test.c iterator.c
    179 vector_test_SOURCES = vector_int.c fstream.c iostream.c array.c iterator.c vector_test.c
     176fstream_test_SOURCES = fstream_test.c
     177vector_test_SOURCES = vector_int.c array.c vector_test.c
    180178all: all-am
    181179
     
    191189          esac; \
    192190        done; \
    193         echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/Makefile'; \
     191        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/examples/Makefile'; \
    194192        $(am__cd) $(top_srcdir) && \
    195           $(AUTOMAKE) --foreign src/examples/Makefile
     193          $(AUTOMAKE) --gnu src/examples/Makefile
    196194.PRECIOUS: Makefile
    197195Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    229227
    230228@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
    231 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream.Po@am__quote@
    232229@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstream_test.Po@am__quote@
    233 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iostream.Po@am__quote@
    234 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iterator.Po@am__quote@
    235230@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_int.Po@am__quote@
    236231@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_test.Po@am__quote@
  • src/examples/alloc.c

    rf3fc8cbe rd3b7937  
     1#if 0
    12extern "C" {
    23    typedef long unsigned int size_t;
     
    1516    return (T *)calloc( size, sizeof(T) );
    1617}
     18#endif
     19typedef int size_t;
    1720forall( type T ) T * realloc( T *ptr, size_t n ) {
    18     return (T *)(void *)realloc( ptr, sizeof(T) );
     21//    return (T *)(void *)realloc( ptr, sizeof(T) );
    1922}
    20 forall( type T ) T * realloc( T *ptr, size_t n, T c ) {
    21     return (T *)realloc( ptr, n );
    22 }
     23//forall( type T ) T * realloc( T *ptr, size_t n, T c ) {
     24//    return (T *)realloc( ptr, n );
     25//}
    2326
    24 int *foo( int *p, int c );
    25 int *bar( int *p, int c );
    26 int *baz( int *p, int c );
     27//int *foo( int *p, int c );
     28//int *bar( int *p, int c );
     29//int *baz( int *p, int c );
    2730
    2831int main( void ) {
    29     size_t size = 10;
    30     int * x = malloc();
    31     x = malloc();
    32     x = calloc( 10 );                                   // calloc: array set to 0
    33     x = realloc( x, 10 );
    34     x = realloc( x, 10, '\0' );
    35     x = malloc( 5 );
    36     float *fp = malloc() + 1;
     32    // size_t size = 10;
     33    //int * x = malloc();
     34    int * x;
     35    // x = malloc();
     36    // x = calloc( 10 );                                        // calloc: array set to 0
     37    // x = realloc( x, 10 );
     38    // x = realloc( x, 10, '\0' );
     39    // x = malloc( 5 );
     40    // float *fp = malloc() + 1;
    3741
    3842    struct St1 { int x; double y; };
    3943    struct St1 * st1;
    40     double *y;
     44//    double *y;
    4145    x = realloc( st1, 10 );                             // SHOULD FAIL!!
    4246#if 0
  • src/examples/array.h

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:10:32 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jan 26 17:09:29 2016
     13// Update Count     : 3
    1414//
    1515
     
    1717#define ARRAY_H
    1818
    19 //#include "iterator.h"
     19//#include <iterator>
    2020
    2121// An array has contiguous elements accessible in any order using integer indicies. The first
  • src/examples/constants.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 20:44:48 2015
    13 // Update Count     : 75
     12// Last Modified On : Mon Jan 25 23:44:12 2016
     13// Update Count     : 76
    1414//
    1515
     
    5454        L_"\x_ff_ee";
    5555        L"a_b\r\Qyc\u_00_40  x_y_z\xff_AA";
    56         L_"a_b\r\Qyc\u_00_40\   
     56        L_"a_b\r\Qyc\u_00_40\
    5757  x_y_z\xff_AA";
    5858        "abc" "def" "ghi";
  • src/examples/fstream_test.c

    rf3fc8cbe rd3b7937  
    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:30:39 2016
    13 // Update Count     : 41
     12// Last Modified On : Tue Jan 26 17:11:33 2016
     13// Update Count     : 42
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818int main( void ) {
  • src/examples/hello.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Nov 22 17:40:37 2015
    13 // Update Count     : 5
     12// Last Modified On : Tue Jan 26 17:11:49 2016
     13// Update Count     : 7
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818int main() {
     
    2424// Local Variables: //
    2525// tab-width: 4 //
    26 // compile-command: "cfa hello.c fstream.o iostream.o iterator.o" //
     26// compile-command: "cfa hello.c" //
    2727// End: //
  • src/examples/identity.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 23:38:05 2016
    13 // Update Count     : 6
     12// Last Modified On : Tue Jan 26 17:11:58 2016
     13// Update Count     : 8
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T )
     
    3737// Local Variables: //
    3838// tab-width: 4 //
    39 // compile-command: "cfa identity.c fstream.o iostream.o iterator.o" //
     39// compile-command: "cfa identity.c" //
    4040// End: //
  • src/examples/minmax.c

    rf3fc8cbe rd3b7937  
    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:40:51 2016
    13 // Update Count     : 26
     12// Last Modified On : Thu Jan 28 22:15:14 2016
     13// Update Count     : 42
    1414//
    1515
    16 #include "fstream.h"
    17 
    18 forall( type T | { int ?<?( T, T ); } )
    19 T min( const T t1, const T t2 ) {
    20         return t1 < t2 ? t1 : t2;
    21 } // min
     16#include <fstream>
     17#include <algorithm>
    2218
    2319int main( void ) {
    2420        ofstream *sout = ofstream_stdout();
    25         // char does not have less than.
     21        // char does not have less or greater than.
    2622        int ?<?( char op1, char op2 ) { return (int)op1 < (int)op2; }
     23        int ?>?( char op1, char op2 ) { return (int)op1 > (int)op2; }
    2724
    2825        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl;
     
    3633        sout | "double\t\t\t"                           | 4.0 | ' ' | 3.1 | "\tmin " | min( 4.0, 3.1 ) | endl;
    3734        sout | "long double\t\t"                        | 4.0l | ' ' | 3.1l | "\tmin " | min( 4.0l, 3.1l ) | endl;
     35        sout | endl;
     36        sout | "char\t\t\t"                                     | 'z' | ' ' | 'a' | "\tmax " | max( 'z', 'a' ) | endl;
     37        sout | "signed int\t\t"                         | 4 | ' ' | 3 | "\tmax " | max( 4, 3 ) | endl;
     38        sout | "unsigned int\t\t"                       | 4u | ' ' | 3u | "\tmax " | max( 4u, 3u ) | endl;
     39        sout | "signed long int\t\t"            | 4l | ' ' | 3l | "\tmax " | max( 4l, 3l ) | endl;
     40        sout | "unsigned long int\t"            | 4ul | ' ' | 3ul | "\tmax " | max( 4ul, 3ul ) | endl;
     41        sout | "signed long long int\t"         | 4ll | ' ' | 3ll | "\tmax " | max( 4ll, 3ll ) | endl;
     42        sout | "unsigned long long int\t"       | 4ull | ' ' | 3ull | "\tmax " | max( 4ull, 3ull ) | endl;
     43        sout | "float\t\t\t"                            | 4.0f | ' ' | 3.1f | "\tmax " | max( 4.0f, 3.1f ) | endl;
     44        sout | "double\t\t\t"                           | 4.0 | ' ' | 3.1 | "\tmax " | max( 4.0, 3.1 ) | endl;
     45        sout | "long double\t\t"                        | 4.0l | ' ' | 3.1l | "\tmax " | max( 4.0l, 3.1l ) | endl;
    3846} // main
    3947
    4048// Local Variables: //
    4149// tab-width: 4 //
    42 // compile-command: "cfa min.c fstream.o iostream.o iterator.o" //
     50// compile-command: "cfa minmax.c" //
    4351// End: //
  • src/examples/new.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:23:55 2015
    13 // Update Count     : 1
     12// Last Modified On : Mon Jan 25 23:33:55 2016
     13// Update Count     : 2
    1414//
    1515
     
    2525        t - 4;
    2626        t[7];
    27         7[t];
    2827}
    2928
  • src/examples/quad.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:26:36 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jan 26 17:13:48 2016
     13// Update Count     : 5
    1414//
    1515
    16 extern "C" {
    17 #include <stdio.h>
    18 }
     16#include <fstream>
    1917
    2018forall( type T | { T ?*?( T, T ); } )
     
    2927
    3028int main() {
     29        ofstream *sout = ofstream_stdout();
    3130        int N = 2;
    32         printf( "result of quad of %d is %d\n", N, quad( N ) );
     31        sout | "result of quad of " | N | " is " | quad( N ) | endl;
    3332}
    3433
  • src/examples/quoted_keyword.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  3 22:46:28 2016
    13 // Update Count     : 7
     12// Last Modified On : Tue Jan 26 17:13:58 2016
     13// Update Count     : 8
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818// test quoted keyword usage
  • src/examples/square.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan  5 18:08:20 2016
    13 // Update Count     : 21
     12// Last Modified On : Tue Jan 26 17:14:16 2016
     13// Update Count     : 25
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T | { T ?*?( T, T ); } )
     
    3535        sout | square( s ) | endl;
    3636#endif
    37         short int s = 9;
     37        short s = 9;
    3838        square( s );
    3939#if 0
     
    6969// Local Variables: //
    7070// tab-width: 4 //
    71 // compile-command: "cfa square.c fstream.o iostream.o iterator.o" //
     71// compile-command: "cfa square.c" //
    7272// End: //
  • src/examples/sum.c

    rf3fc8cbe rd3b7937  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  4 07:40:24 2016
    13 // Update Count     : 126
     12// Last Modified On : Thu Jan 28 17:05:53 2016
     13// Update Count     : 130
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818context sumable( type T ) {
     
    2222        T ++?( T * );
    2323        T ?++( T * );
    24 };
     24}; // sumable
    2525
    2626forall( type T | sumable( T ) )
     
    3030                total += a[i];                                                                  // select +
    3131        return total;
    32 }
     32} // sum
    3333
    3434// Required to satisfy sumable as char does not have addition.
     
    6161                 | sum( size, (int *)a ) | ", check " | (int)s | endl;
    6262
     63        float s = 0.0, a[size];
     64        float v = low / 10.0;
     65        for ( int i = 0; i < size; i += 1, v += 0.1f ) {
     66                s += (float)v;
     67                a[i] = (float)v;
     68        }
     69        sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is "
     70                 | sum( size, (float *)a ) | ", check " | (float)s | endl;
     71
    6372        double s = 0.0, a[size];
    6473        double v = low / 10.0;
     
    6978        sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is "
    7079                 | sum( size, (double *)a ) | ", check " | (double)s | endl;
    71 
    72         float s = 0.0, a[size];
    73         float v = low / 10.0;
    74         for ( int i = 0; i < size; i += 1, v += 0.1f ) {
    75                 s += (float)v;
    76                 a[i] = (float)v;
    77         }
    78         sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is "
    79                  | sum( size, (float *)a ) | ", check " | (float)s | endl;
    80 }
     80} // main
    8181
    8282// Local Variables: //
    8383// tab-width: 4 //
    84 // compile-command: "cfa sum.c fstream.o iostream.o iterator.o" //
     84// compile-command: "cfa sum.c" //
    8585// End: //
  • src/examples/swap.c

    rf3fc8cbe rd3b7937  
    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 : Tue Jan 26 16:49:41 2016
     13// Update Count     : 7
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T )
     
    3333// Local Variables: //
    3434// tab-width: 4 //
    35 // compile-command: "cfa swap.c fstream.o iostream.o iterator.o" //
     35// compile-command: "cfa swap.c" //
    3636// End: //
  • src/examples/twice.c

    rf3fc8cbe rd3b7937  
    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:04 2016
    13 // Update Count     : 10
     12// Last Modified On : Tue Jan 26 17:14:44 2016
     13// Update Count     : 12
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
    1717
    1818forall( type T | { T ?+?( T, T ); T ?++( T * ); [T] ?+=?( T *, T ); } )
     
    3333// Local Variables: //
    3434// tab-width: 4 //
    35 // compile-command: "cfa twice.c fstream.o iostream.o iterator.o" //
     35// compile-command: "cfa twice.c" //
    3636// End: //
  • src/examples/vector_test.c

    rf3fc8cbe rd3b7937  
    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:31:56 2016
    13 // Update Count     : 14
     12// Last Modified On : Tue Jan 26 17:14:52 2016
     13// Update Count     : 17
    1414//
    1515
    16 #include "fstream.h"
     16#include <fstream>
     17#include <iterator>
    1718#include "vector_int.h"
    1819#include "array.h"
    19 #include "iterator.h"
    2020
    2121int main( void ) {
     
    4646// Local Variables: //
    4747// tab-width: 4 //
    48 // compile-command: "cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o" //
     48// compile-command: "cfa vector_test.c vector_int.o array.o" //
    4949// End: //
Note: See TracChangeset for help on using the changeset viewer.