Changeset 7b91c0e for libcfa/prelude/builtins.c
- Timestamp:
- Jan 21, 2021, 2:24:01 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7d01186d
- Parents:
- 5869cea (diff), 1adab3e (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
r5869cea r7b91c0e 18 18 // type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions 19 19 // Note: needs to occur early, because it is used to generate destructor calls during code generation 20 forall( dtype T)20 forall(T &) 21 21 struct __Destructor { 22 22 T * object; … … 25 25 26 26 // defined destructor in the case that non-generated code wants to use __Destructor 27 forall( dtype T)27 forall(T &) 28 28 static inline void ^?{}(__Destructor(T) & x) { 29 29 if (x.object && x.dtor) { … … 34 34 // easy interface into __Destructor's destructor for easy codegen purposes 35 35 extern "C" { 36 forall( dtype T)36 forall(T &) 37 37 static inline void __destroy_Destructor(__Destructor(T) * dtor) { 38 38 ^(*dtor){}; … … 51 51 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 52 52 53 forall( dtype T)53 forall(T &) 54 54 static inline T & identity(T & i) { 55 55 return i; … … 64 64 static inline void ^?{}($generator &) {} 65 65 66 trait is_generator( dtype T) {66 trait is_generator(T &) { 67 67 void main(T & this); 68 68 $generator * get_generator(T & this); 69 69 }; 70 70 71 forall( dtype T| is_generator(T))71 forall(T & | is_generator(T)) 72 72 static inline T & resume(T & gen) { 73 73 main(gen); … … 78 78 79 79 static inline { 80 forall( dtype DT| { DT & ?+=?( DT &, one_t ); } )80 forall( DT & | { DT & ?+=?( DT &, one_t ); } ) 81 81 DT & ++?( DT & x ) { return x += 1; } 82 82 83 forall( dtype DT| sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?+=?( DT &, one_t ); } )83 forall( DT & | sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?+=?( DT &, one_t ); } ) 84 84 DT & ?++( DT & x ) { DT tmp = x; x += 1; return tmp; } 85 85 86 forall( dtype DT| { DT & ?-=?( DT &, one_t ); } )86 forall( DT & | { DT & ?-=?( DT &, one_t ); } ) 87 87 DT & --?( DT & x ) { return x -= 1; } 88 88 89 forall( dtype DT| sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?-=?( DT &, one_t ); } )89 forall( DT & | sized(DT) | { void ?{}( DT &, DT ); void ^?{}( DT & ); DT & ?-=?( DT &, one_t ); } ) 90 90 DT & ?--( DT & x ) { DT tmp = x; x -= 1; return tmp; } 91 91 92 forall( dtype DT| { int ?!=?( const DT &, zero_t ); } )92 forall( DT & | { int ?!=?( const DT &, zero_t ); } ) 93 93 int !?( const DT & x ) { return !( x != 0 ); } 94 94 } // distribution 95 95 96 96 // universal typed pointer constant 97 static inline forall( dtype DT) DT * intptr( uintptr_t addr ) { return (DT *)addr; }97 static inline forall( DT & ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 98 98 static inline forall( ftype FT ) FT * intptr( uintptr_t addr ) { return (FT *)addr; } 99 99 … … 156 156 #define __CFA_EXP_OVERFLOW__() 157 157 158 static inline forall( otypeOT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {158 static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) { 159 159 OT ?\?( OT ep, unsigned int y ) { __CFA_EXP__(); } 160 160 OT ?\?( OT ep, unsigned long int y ) { __CFA_EXP__(); }
Note: See TracChangeset
for help on using the changeset viewer.