Changeset 062467b
- Timestamp:
- Jul 2, 2024, 3:18:37 PM (3 months ago)
- Branches:
- master
- Children:
- 597f284
- Parents:
- bc48c0d
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.cfa
rbc48c0d r062467b 10 10 int args = fmt( is, "%255s", val ); 11 11 if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data ); 12 for ( s; E ) {13 if ( val == label( s ) ) { e = s; break; }14 } else {15 fprintf( stderr, "invalid enumeration constant\n" );16 abort(); // cannot use abort stream17 } // for12 // for ( s; E ) { 13 // if ( val == label( s ) ) { e = s; break; } 14 // } else { 15 // fprintf( stderr, "invalid enumeration constant\n" ); 16 // abort(); // cannot use abort stream 17 // } // for 18 18 return is; 19 19 } … … 32 32 OSTYPE_VOID_IMPL( E ) 33 33 } 34 35 forall( E, V | CfaEnum( E, V ) ) { // relational operators36 int ?==?( E l, E r ) { return posn( l ) == posn( r ); }37 int ?!=?( E l, E r ) { return posn( l ) != posn( r ); }38 int ?<?( E l, E r ) { return posn( l ) < posn( r ); }39 int ?<=?( E l, E r ) { return posn( l ) <= posn( r ); }40 int ?>?( E l, E r ) { return posn( l ) > posn( r ); }41 int ?>=?( E l, E r ) { return posn( l ) >= posn( r ); }42 43 E ++?( E & l ) {44 l = succ( l );45 return l;46 }47 48 E ?++( E & l ) {49 E ret = l;50 l = succ( l );51 return ret;52 }53 54 E --?( E & l ) {55 l = pred( l );56 return l;57 }58 59 E ?--( E & l ) {60 E ret = l;61 l = pred( l );62 return ret;63 }64 } -
libcfa/src/enum.hfa
rbc48c0d r062467b 47 47 // }; 48 48 49 forall( E, V | CfaEnum( E, V ) ) { // relational operators 50 int ?==?( E, E ); 51 int ?!=?( E, E ); 52 int ?<?( E, E ); 53 int ?<=?( E, E ); 54 int ?>?( E, E ); 55 int ?>=?( E, E ); 49 static inline 50 forall( E, V | CfaEnum( E, V ) ) { 51 int ?==?( E l, E r ) { return posn( l ) == posn( r ); } // relational operators 52 int ?!=?( E l, E r ) { return posn( l ) != posn( r ); } 53 int ?<?( E l, E r ) { return posn( l ) < posn( r ); } 54 int ?<=?( E l, E r ) { return posn( l ) <= posn( r ); } 55 int ?>?( E l, E r ) { return posn( l ) > posn( r ); } 56 int ?>=?( E l, E r ) { return posn( l ) >= posn( r ); } 56 57 57 int ++?( E &); 58 int ?++( E &); 59 int --?( E &); 60 int ?--( E &); 58 E ++?( E & l ) { // increment operators 59 l = succ( l ); 60 return l; 61 } 62 63 E ?++( E & l ) { 64 E ret = l; 65 l = succ( l ); 66 return ret; 67 } 68 69 E --?( E & l ) { 70 l = pred( l ); 71 return l; 72 } 73 74 E ?--( E & l ) { 75 E ret = l; 76 l = pred( l ); 77 return ret; 78 } 61 79 }
Note: See TracChangeset
for help on using the changeset viewer.