Changeset 532c0cd for libcfa/prelude/builtins.c
- Timestamp:
- Dec 12, 2024, 11:59:42 AM (6 days ago)
- Branches:
- master
- Children:
- f979f0ba
- Parents:
- bad15f7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
rbad15f7 r532c0cd 180 180 }; 181 181 182 static inline forall( E | Serial( E ) ) {183 E fromInt( int i );184 E succ( E e );185 E pred( E e );186 int Countof( E );187 }188 189 182 forall( E ) trait CfaEnum { 190 183 const char * label( E e ); … … 196 189 }; 197 190 198 static inline {191 static inline 199 192 forall( E | Serial( E ) ) { 200 193 E fromInt( int i ) { … … 228 221 } 229 222 } 230 }231 223 232 224 static inline 233 forall( E | CfaEnum( E ) | Serial( E )) {234 int ?==?( E l, E r ) { return posn( l ) == posn( r ); } // relational operators225 forall( E | CfaEnum( E ) ) { 226 int ?==?( E l, E r ) { return posn( l ) == posn( r ); } 235 227 int ?!=?( E l, E r ) { return posn( l ) != posn( r ); } 236 228 int ?<?( E l, E r ) { return posn( l ) < posn( r ); } … … 238 230 int ?>?( E l, E r ) { return posn( l ) > posn( r ); } 239 231 int ?>=?( E l, E r ) { return posn( l ) >= posn( r ); } 240 241 E ++?( E & l ) { // increment operators 242 int pos = posn( l ); 232 } 233 234 static inline 235 forall( E | Serial( E ) ) { 236 E ++?( E & l ) { 237 int pos = fromInstance( l ); 243 238 l = fromInt_unsafe( pos + 1 ); 244 239 return l; … … 246 241 247 242 E --?( E & l ) { 248 int pos = posn( l );243 int pos = fromInstance( l ); 249 244 l = fromInt_unsafe( pos - 1 ); 250 245 return l; … … 252 247 253 248 E ?+=?( E & l, one_t ) { 254 int pos = posn( l );249 int pos = fromInstance( l ); 255 250 l = fromInt_unsafe( pos + 1 ); 256 251 return l; … … 258 253 259 254 E ?-=?( E & l, one_t ) { 260 int pos = posn( l );255 int pos = fromInstance( l ); 261 256 l = fromInt_unsafe( pos - 1 ); 262 257 return l; … … 264 259 265 260 E ?+=?( E & l, int i ) { 266 int pos = posn( l );261 int pos = fromInstance( l ); 267 262 l = fromInt_unsafe( pos + i ); 268 263 return l; … … 270 265 271 266 E ?-=?( E & l, int i ) { 272 int pos = posn( l );267 int pos = fromInstance( l ); 273 268 l = fromInt_unsafe( pos - i ); 274 269 return l; … … 276 271 277 272 E ?++( E & l ) { 278 int pos = posn( l );273 int pos = fromInstance( l ); 279 274 l = fromInt_unsafe( pos + 1 ); 280 275 return fromInt_unsafe( pos ); … … 282 277 283 278 E ?--( E & l ) { 284 int pos = posn( l );279 int pos = fromInstance( l ); 285 280 l = fromInt_unsafe( pos - 1 ); 286 281 return fromInt_unsafe( pos );
Note: See TracChangeset
for help on using the changeset viewer.