Changeset 58fe85a for libcfa/prelude/builtins.c
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
r3c64c668 r58fe85a 9 9 // Author : Peter A. Buhr 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T hu Nov 21 16:31:39 201913 // Update Count : 1 0111 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 27 14:42:00 2020 13 // Update Count : 111 14 14 // 15 16 #define __cforall_builtins__ 15 17 16 18 // type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions … … 49 51 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 50 52 53 forall(dtype T) 54 static inline T & identity(T & i) { 55 return i; 56 } 57 58 // generator support 59 struct $generator { 60 inline int; 61 }; 62 63 static inline void ?{}($generator & this) { ((int&)this) = 0; } 64 static inline void ^?{}($generator &) {} 65 66 trait is_generator(dtype T) { 67 void main(T & this); 68 $generator * get_generator(T & this); 69 }; 70 71 forall(dtype T | is_generator(T)) 72 static inline T & resume(T & gen) { 73 main(gen); 74 return gen; 75 } 76 51 77 // implicit increment, decrement if += defined, and implicit not if != defined 52 78 … … 70 96 // universal typed pointer constant 71 97 static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 98 static inline forall( ftype FT ) FT * intptr( uintptr_t addr ) { return (FT *)addr; } 99 100 #if defined(__SIZEOF_INT128__) 101 // constructor for 128-bit numbers (all constants are unsigned as +/- are operators) 102 static inline void ?{}( unsigned int128 & this, unsigned long int h, unsigned long int l ) { 103 this = (unsigned int128)h << 64 | (unsigned int128)l; 104 } // ?{} 105 #endif // __SIZEOF_INT128__ 72 106 73 107 // exponentiation operator implementation
Note:
See TracChangeset
for help on using the changeset viewer.