Changeset aca65621
- Timestamp:
- Jul 12, 2017, 4:40:02 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:
- 0698aa1
- Parents:
- 469f709
- Location:
- src/libcfa
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/maybe
r469f709 raca65621 29 29 30 30 forall(otype T) 31 void ?{}(maybe(T) *this);31 void ?{}(maybe(T) & this); 32 32 33 33 forall(otype T) 34 void ?{}(maybe(T) *this, T value);34 void ?{}(maybe(T) & this, T value); 35 35 36 36 forall(otype T) 37 void ?{}(maybe(T) *this, maybe(T) other);37 void ?{}(maybe(T) & this, maybe(T) other); 38 38 39 39 forall(otype T) 40 void ^?{}(maybe(T) *this);40 void ^?{}(maybe(T) & this); 41 41 42 42 forall(otype T) 43 maybe(T) ?=?(maybe(T) *this, maybe(T) other);43 maybe(T) ?=?(maybe(T) & this, maybe(T) other); 44 44 45 45 forall(otype T) -
src/libcfa/containers/maybe.c
r469f709 raca65621 19 19 20 20 forall(otype T) 21 void ?{}(maybe(T) *this) {22 this ->has_value = false;21 void ?{}(maybe(T) & this) { 22 this.has_value = false; 23 23 } 24 24 25 25 forall(otype T) 26 void ?{}(maybe(T) *this, T value) {27 this ->has_value = true;28 ( &this->value){value};26 void ?{}(maybe(T) & this, T value) { 27 this.has_value = true; 28 (this.value){value}; 29 29 } 30 30 31 31 forall(otype T) 32 void ?{}(maybe(T) *this, maybe(T) other) {33 this ->has_value = other.has_value;32 void ?{}(maybe(T) & this, maybe(T) other) { 33 this.has_value = other.has_value; 34 34 if (other.has_value) { 35 ( &this->value){other.value};35 (this.value){other.value}; 36 36 } 37 37 } 38 38 39 39 forall(otype T) 40 maybe(T) ?=?(maybe(T) *this, maybe(T) that) {41 if (this ->has_value & that.has_value) {42 this ->value = that.value;43 } else if (this ->has_value) {44 ^( &this->value){};45 this ->has_value = false;40 maybe(T) ?=?(maybe(T) & this, maybe(T) that) { 41 if (this.has_value & that.has_value) { 42 this.value = that.value; 43 } else if (this.has_value) { 44 ^(this.value){}; 45 this.has_value = false; 46 46 } else if (that.has_value) { 47 this ->has_value = true;48 ( &this->value){that.value};47 this.has_value = true; 48 (this.value){that.value}; 49 49 } 50 return this; 50 51 } 51 52 52 53 forall(otype T) 53 void ^?{}(maybe(T) *this) {54 if (this ->has_value) {55 ^( &this->value){};54 void ^?{}(maybe(T) & this) { 55 if (this.has_value) { 56 ^(this.value){}; 56 57 } 57 58 } … … 89 90 } else { 90 91 this->has_value = true; 91 ( &this->value){value};92 (this->value){value}; 92 93 } 93 94 } … … 97 98 if (this->has_value) { 98 99 this->has_value = false; 99 ^( &this->value){};100 ^(this->value){}; 100 101 } 101 102 } -
src/libcfa/containers/vector
r469f709 raca65621 31 31 32 32 forall(otype T) 33 void ?{}(heap_allocator(T) *this);33 void ?{}(heap_allocator(T)& this); 34 34 35 35 forall(otype T) 36 void ?{}(heap_allocator(T) *this, heap_allocator(T) rhs);36 void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs); 37 37 38 38 forall(otype T) 39 heap_allocator(T) ?=?(heap_allocator(T) *this, heap_allocator(T) rhs);39 heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs); 40 40 41 41 forall(otype T) 42 void ^?{}(heap_allocator(T) *this);42 void ^?{}(heap_allocator(T)& this); 43 43 44 44 forall(otype T) … … 65 65 //Initialization 66 66 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 67 void ?{}(vector(T, allocator_t) *this);67 void ?{}(vector(T, allocator_t)& this); 68 68 69 69 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 70 void ?{}(vector(T, allocator_t) *this, vector(T, allocator_t) rhs);70 void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs); 71 71 72 72 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 73 vector(T, allocator_t) ?=?(vector(T, allocator_t) *this, vector(T, allocator_t) rhs);73 vector(T, allocator_t) ?=?(vector(T, allocator_t)& this, vector(T, allocator_t) rhs); 74 74 75 75 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 76 void ^?{}(vector(T, allocator_t) *this);76 void ^?{}(vector(T, allocator_t)& this); 77 77 78 78 forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t)) -
src/libcfa/containers/vector.c
r469f709 raca65621 24 24 //Initialization 25 25 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 26 void ?{}(vector(T, allocator_t) *this)26 void ?{}(vector(T, allocator_t)& this) 27 27 { 28 ( &this->storage){};29 this ->size = 0;28 (this.storage){}; 29 this.size = 0; 30 30 } 31 31 32 32 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 33 void ?{}(vector(T, allocator_t) *this, vector(T, allocator_t) rhs)33 void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs) 34 34 { 35 ( &this->storage){ rhs.storage };36 copy_internal( this, &rhs);35 (this.storage){ rhs.storage }; 36 copy_internal(&this, &rhs); 37 37 } 38 38 … … 46 46 47 47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 48 void ^?{}(vector(T, allocator_t) *this)48 void ^?{}(vector(T, allocator_t)& this) 49 49 { 50 clear( this);51 ^( &this->storage){};50 clear(&this); 51 ^(this.storage){}; 52 52 } 53 53 … … 66 66 { 67 67 this->size--; 68 ^( &data(&this->storage)[this->size]){};68 ^(data(&this->storage)[this->size]){}; 69 69 } 70 70 … … 74 74 for(size_t i = 0; i < this->size; i++) 75 75 { 76 ^( &data(&this->storage)[this->size]){};76 ^(data(&this->storage)[this->size]){}; 77 77 } 78 78 this->size = 0; … … 87 87 this->size = other->size; 88 88 for(size_t i = 0; i < this->size; i++) { 89 ( &data(&this->storage)[this->size]){ data(&other->storage)[other->size] };89 (data(&this->storage)[this->size]){ data(&other->storage)[other->size] }; 90 90 } 91 91 } … … 94 94 //Allocator 95 95 forall(otype T) 96 void ?{}(heap_allocator(T) *this)96 void ?{}(heap_allocator(T)& this) 97 97 { 98 this ->storage = 0;99 this ->capacity = 0;98 this.storage = 0; 99 this.capacity = 0; 100 100 } 101 101 102 102 forall(otype T) 103 void ?{}(heap_allocator(T) *this, heap_allocator(T) rhs)103 void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs) 104 104 { 105 this ->capacity = rhs.capacity;106 this ->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));105 this.capacity = rhs.capacity; 106 this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T)); 107 107 } 108 108 109 109 forall(otype T) 110 heap_allocator(T) ?=?(heap_allocator(T) *this, heap_allocator(T) rhs)110 heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs) 111 111 { 112 this ->capacity = rhs.capacity;113 this ->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));114 return *this;112 this.capacity = rhs.capacity; 113 this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T)); 114 return this; 115 115 } 116 116 117 117 forall(otype T) 118 void ^?{}(heap_allocator(T) *this)118 void ^?{}(heap_allocator(T)& this) 119 119 { 120 free(this ->storage);120 free(this.storage); 121 121 } 122 122 -
src/libcfa/interpose.c
r469f709 raca65621 10 10 // Author : Thierry Delisle 11 11 // Created On : Wed Mar 29 16:10:31 2017 12 // Last Modified By : 13 // Last Modified On : 12 // Last Modified By : 13 // Last Modified On : 14 14 // Update Count : 0 15 15 // … … 50 50 51 51 union { generic_fptr_t fptr; void* ptr; } originalFunc; 52 52 53 53 #if defined( _GNU_SOURCE ) 54 54 if ( version ) { … … 60 60 originalFunc.ptr = dlsym( library, symbol ); 61 61 #endif // _GNU_SOURCE 62 62 63 63 error = dlerror(); 64 if ( error ) abortf( "interpose_symbol : internal error, %s\n", error ); 64 if ( error ) abortf( "interpose_symbol : internal error, %s\n", error ); 65 65 66 66 return originalFunc.fptr; … … 75 75 forall(dtype T) 76 76 static inline void assign_ptr( T** symbol_ptr, const char * symbol_name, const char * version) { 77 union { 77 union { 78 78 generic_fptr_t gp; 79 T* tp; 79 T* tp; 80 80 } u; 81 81 -
src/libcfa/stdlib
r469f709 raca65621 135 135 136 136 // allocation/deallocation and constructor/destructor, non-array types 137 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * new( Params p );138 forall( dtype T | { void ^?{}( T *); } ) void delete( T * ptr );139 forall( dtype T, ttype Params | { void ^?{}( T *); void delete( Params ); } ) void delete( T * ptr, Params rest );137 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * new( Params p ); 138 forall( dtype T | { void ^?{}( T & ); } ) void delete( T * ptr ); 139 forall( dtype T, ttype Params | { void ^?{}( T & ); void delete( Params ); } ) void delete( T * ptr, Params rest ); 140 140 141 141 // allocation/deallocation and constructor/destructor, array types 142 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } ) T * anew( size_t dim, Params p );143 forall( dtype T | sized(T) | { void ^?{}( T *); } ) void adelete( size_t dim, T arr[] );144 forall( dtype T | sized(T) | { void ^?{}( T *); }, ttype Params | { void adelete( Params ); } ) void adelete( size_t dim, T arr[], Params rest );142 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) T * anew( size_t dim, Params p ); 143 forall( dtype T | sized(T) | { void ^?{}( T & ); } ) void adelete( size_t dim, T arr[] ); 144 forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params ); } ) void adelete( size_t dim, T arr[], Params rest ); 145 145 146 146 //--------------------------------------- … … 201 201 double abs( double _Complex ); 202 202 long double abs( long double _Complex ); 203 forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )203 forall( otype T | { void ?{}( T &, zero_t ); int ?<?( T, T ); T -?( T ); } ) 204 204 T abs( T ); 205 205 -
src/libcfa/stdlib.c
r469f709 raca65621 34 34 if ( nlen > olen ) { // larger ? 35 35 memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage 36 } // 36 } // 37 37 return (T *)nptr; 38 38 } // alloc 39 39 40 40 // allocation/deallocation and constructor/destructor, non-array types 41 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } )41 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) 42 42 T * new( Params p ) { 43 43 return (malloc()){ p }; // run constructor 44 44 } // new 45 45 46 forall( dtype T | { void ^?{}( T *); } )46 forall( dtype T | { void ^?{}( T & ); } ) 47 47 void delete( T * ptr ) { 48 48 if ( ptr ) { // ignore null … … 52 52 } // delete 53 53 54 forall( dtype T, ttype Params | { void ^?{}( T *); void delete( Params ); } )54 forall( dtype T, ttype Params | { void ^?{}( T & ); void delete( Params ); } ) 55 55 void delete( T * ptr, Params rest ) { 56 56 if ( ptr ) { // ignore null … … 63 63 64 64 // allocation/deallocation and constructor/destructor, array types 65 forall( dtype T | sized(T), ttype Params | { void ?{}( T *, Params ); } )65 forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } ) 66 66 T * anew( size_t dim, Params p ) { 67 67 T *arr = alloc( dim ); … … 72 72 } // anew 73 73 74 forall( dtype T | sized(T) | { void ^?{}( T *); } )74 forall( dtype T | sized(T) | { void ^?{}( T & ); } ) 75 75 void adelete( size_t dim, T arr[] ) { 76 76 if ( arr ) { // ignore null … … 82 82 } // adelete 83 83 84 forall( dtype T | sized(T) | { void ^?{}( T *); }, ttype Params | { void adelete( Params ); } )84 forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params ); } ) 85 85 void adelete( size_t dim, T arr[], Params rest ) { 86 86 if ( arr ) { // ignore null
Note: See TracChangeset
for help on using the changeset viewer.