Changeset a493682 for src/libcfa
- Timestamp:
- Jul 17, 2017, 1:55:22 PM (7 years ago)
- 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:
- b46e3bd
- Parents:
- bf30ab3
- Location:
- src/libcfa
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream
rbf30ab3 ra493682 56 56 int fmt( ofstream *, const char fmt[], ... ); 57 57 58 void ?{}( ofstream *);58 void ?{}( ofstream & ); 59 59 60 60 extern ofstream * sout, * serr; -
src/libcfa/fstream.c
rbf30ab3 ra493682 29 29 #define IO_MSG "I/O error: " 30 30 31 void ?{}( ofstream *this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {32 this ->file = file;33 this ->sepDefault = sepDefault;34 this ->sepOnOff = sepOnOff;35 sepSet( this, separator );36 sepSetCur( this, sepGet(this ) );37 sepSetTuple( this, tupleSeparator );31 void ?{}( ofstream & this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) { 32 this.file = file; 33 this.sepDefault = sepDefault; 34 this.sepOnOff = sepOnOff; 35 sepSet( &this, separator ); 36 sepSetCur( &this, sepGet( &this ) ); 37 sepSetTuple( &this, tupleSeparator ); 38 38 } 39 39 … … 94 94 exit( EXIT_FAILURE ); 95 95 } // if 96 ?{}( os, file, true, false, " ", ", " );96 ?{}( *os, file, true, false, " ", ", " ); 97 97 } // open 98 98 -
src/libcfa/iterator
rbf30ab3 ra493682 19 19 trait iterator( otype iterator_type, otype elt_type ) { 20 20 // point to the next element 21 // iterator_type ?++( iterator_type *);22 iterator_type ++?( iterator_type *);23 iterator_type --?( iterator_type *);21 // iterator_type ?++( iterator_type & ); 22 iterator_type ++?( iterator_type & ); 23 iterator_type --?( iterator_type & ); 24 24 25 25 // can be tested for equality with other iterators -
src/libcfa/rational
rbf30ab3 ra493682 31 31 int ?>?( T, T ); 32 32 int ?>=?( T, T ); 33 void ?{}( T *, zero_t );34 void ?{}( T *, one_t );33 void ?{}( T &, zero_t ); 34 void ?{}( T &, one_t ); 35 35 T +?( T ); 36 36 T -?( T ); … … 54 54 55 55 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 56 void ?{}( Rational(RationalImpl) *r );56 void ?{}( Rational(RationalImpl) & r ); 57 57 58 58 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 59 void ?{}( Rational(RationalImpl) *r, RationalImpl n );59 void ?{}( Rational(RationalImpl) & r, RationalImpl n ); 60 60 61 61 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 62 void ?{}( Rational(RationalImpl) *r, RationalImpl n, RationalImpl d );62 void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d ); 63 63 64 64 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 65 void ?{}( Rational(RationalImpl) *r, zero_t );65 void ?{}( Rational(RationalImpl) & r, zero_t ); 66 66 67 67 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 68 void ?{}( Rational(RationalImpl) *r, one_t );68 void ?{}( Rational(RationalImpl) & r, one_t ); 69 69 70 70 // numerator/denominator getter … … 77 77 78 78 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 79 [ RationalImpl, RationalImpl ] ?=?( *[ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );79 [ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ); 80 80 81 81 // numerator/denominator setter -
src/libcfa/rational.c
rbf30ab3 ra493682 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // rational.c -- 8 // 6 // 7 // rational.c -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed Apr 6 17:54:28 2016 … … 12 12 // Last Modified On : Tue May 16 18:35:36 2017 13 13 // Update Count : 150 14 // 14 // 15 15 16 16 #include "rational" … … 47 47 48 48 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 49 void ?{}( Rational(RationalImpl) *r ) {49 void ?{}( Rational(RationalImpl) & r ) { 50 50 r{ (RationalImpl){0}, (RationalImpl){1} }; 51 51 } // rational 52 52 53 53 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 54 void ?{}( Rational(RationalImpl) *r, RationalImpl n ) {54 void ?{}( Rational(RationalImpl) & r, RationalImpl n ) { 55 55 r{ n, (RationalImpl){1} }; 56 56 } // rational 57 57 58 58 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 59 void ?{}( Rational(RationalImpl) *r, RationalImpl n, RationalImpl d ) {59 void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d ) { 60 60 RationalImpl t = simplify( &n, &d ); // simplify 61 61 r->numerator = n / t; … … 77 77 78 78 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 79 [ RationalImpl, RationalImpl ] ?=?( *[ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {79 [ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) { 80 80 return *dest = src.[ numerator, denominator ]; 81 81 } -
src/libcfa/stdlib.c
rbf30ab3 ra493682 41 41 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) 42 42 T * new( Params p ) { 43 return (malloc()){ p }; // run constructor43 return &(*malloc()){ p }; // run constructor 44 44 } // new 45 45 … … 67 67 T *arr = alloc( dim ); 68 68 for ( unsigned int i = 0; i < dim; i += 1 ) { 69 ( &arr[i]){ p }; // run constructor69 (arr[i]){ p }; // run constructor 70 70 } // for 71 71 return arr; … … 76 76 if ( arr ) { // ignore null 77 77 for ( int i = dim - 1; i >= 0; i -= 1 ) { // reverse allocation order, must be unsigned 78 ^( &arr[i]){}; // run destructor78 ^(arr[i]){}; // run destructor 79 79 } // for 80 80 free( arr ); … … 86 86 if ( arr ) { // ignore null 87 87 for ( int i = dim - 1; i >= 0; i -= 1 ) { // reverse allocation order, must be unsigned 88 ^( &arr[i]){}; // run destructor88 ^(arr[i]){}; // run destructor 89 89 } // for 90 90 free( arr );
Note: See TracChangeset
for help on using the changeset viewer.