Changes in / [262a864:9a01745]


Ignore:
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/enums.md

    r262a864 r9a01745  
    88--------------
    99Because Cforall enumerations are encoded using their position, it can be
    10 difficult to give them a stable encoding, this is important in seperate
    11 compilation.
     10difficult to give them a stable encoding. The
    1211
    1312The example (provided by Gregor Richards), is a system header that defines
     
    4241Arrays that use an enumeration as their index. The entire enumeration type
    4342(instead of a subset of int) is used in the index operation.
    44 
    45 ```cfa
    46 enum() Colour {
    47   Red,
    48   Violet,
    49   Blue,
    50   Green
    51   Yellow,
    52   Orange,
    53 };
    54 
    55 // Declare an array with an index of an enumeration:
    56 int jarsOfPaint[Colour] = {0};
    57 
    58 // Index the array:
    59 printf("I have %d jars of blue paint.\n", jarsOfPaint[Blue]);
    60 jarsOfPaint[Green] = 3;
    61 jarsOfPaint[Red] += 1;
    62 
    63 // Use the function for higher order programming:
    64 int (*lookup)(int collection[Colour], Colour key) = ?[?];
    65 
    66 // ERROR! Use the enumeration index for safety:
    67 jarsOfPaint[0] = 0;
    68 ```
    6943
    7044Although described differently, this is actually a generalization of typed
     
    10680Or one of the new safer Cforall arrays, as the features could be combined.
    10781
    108 (Previously, a combined declaration to declare both an enumeration and
     82(Previously, a compined declaration to declare both an enumeration and
    10983an enumerated array was proposed. That only covers the simple case that
    11084typed enumerations already cover.)
     
    11690generalized to work with the other features of ranges, such as going over
    11791just part of the enumeration (see Ranges in doc/proposals/iterators.md).
    118 
    119 This will work best with some alias labels that mark out the beginning of
    120 ranges. That is the ranges within the enum will often have to be an
    121 intended part of the interface.
    122 
    123 ```cfa
    124 for ( kind : DataKind.BeginIntegers +~ DataKind.EndIntegers ) { ... }
    125 ```
    126 
    127 Writing the declaration is a bit tricker, because of the lack of aliasing,
    128 but this should echo a common C pattern.
    12992
    13093Flag Set Enumerations
     
    146109  Vertical = Up | Down,
    147110};
    148 ```
    149 
    150 Some example usages:
    151 ```cfa
    152 // If it is exactly Up/Upwards, then set exactly Down
    153 if ( Upwards == dirs ) {
    154   dirs = Down
    155 // Otherwise, if a vertical is set, unset them:
    156 } else if ( Vertical & dirs ) {
    157   dirs = dirs & ~Vertical;
    158 // Otherwise, if any direction is set then also set Up:
    159 } else if ( dirs ) {
    160   dirs |= Up;
    161 }
    162111```
    163112
     
    183132
    184133Note: Scoping rules are also waiting on the namespacing and module system.
    185 
    186 Feature (and Storage) Control
    187 -----------------------------
    188 Right now features are very coursely grouped. You have exactly three options
    189 for your enumeration. However since there are more than two features this
    190 means there are some combinations you cannot have.
    191 
    192 For instance, labels (which are mostly useful for generating debug output)
    193 are not available for C style enum, but for both of the new Cforall enums,
    194 opaque and typed. However, there is no innate connection between the
    195 additional type safety of the opaque enum or the associated values/payloads
    196 of the typed enums.
    197 
    198 Enumerations do interact with on feature that shows this orthagonality,
    199 and that is the scoping "no export" marker, that can be applied to any
    200 enumeration to change the visibility rules of the enumeration and does not
    201 change anything else.
    202 
    203 This is not urgent, just not using the features you don't want is almost as
    204 clear and the compile-time, binary-size and runtime costs are all good enough
    205 for now (and some day all of those may have to be improved even when the
    206 feature is being used). Isolating independent features is just good design.
  • src/CodeGen/OperatorTable.cpp

    r262a864 r9a01745  
    7676        }
    7777
    78         // Filter out non-operator names:
    79         if ( inputName.find_first_of( "?^*+-!", 0, 1 ) == std::string::npos ) return nullptr;
    80         auto entry = inputTable.find( inputName );
     78        if ( inputName.find_first_of( "?^*+-!", 0, 1 ) == std::string::npos ) return nullptr; // prefilter
     79        const OperatorInfo * ret = inputTable.find( inputName )->second;
    8180        // This can only happen if an invalid identifier name has been used.
    82         assertf( entry != inputTable.end(), "Not a real operator: %s\n", inputName.c_str() );
    83         const OperatorInfo * ret = entry->second;
    8481        assert( ret );
    8582        return ret;
  • src/Validate/ReplaceTypedef.cpp

    r262a864 r9a01745  
    1010// Created On       : Tue Jun 29 14:59:00 2022
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 20:50:42 2024
    13 // Update Count     : 5
     12// Last Modified On : Thu Dec 14 16:11:51 2023
     13// Update Count     : 4
    1414//
    1515
     
    135135};
    136136static bool dimensionPresenceMismatched( const ast::Type * t0, const ast::Type * t1) {
    137         std::vector<const ast::ArrayType *> at0s = ast::Pass<ArrayTypeExtractor>::read( t0 );
    138         std::vector<const ast::ArrayType *> at1s = ast::Pass<ArrayTypeExtractor>::read( t1 );
     137        std::vector<const ast::ArrayType *> at0s = std::move(
     138                ast::Pass<ArrayTypeExtractor>::read( t0 ) );
     139        std::vector<const ast::ArrayType *> at1s = std::move(
     140                ast::Pass<ArrayTypeExtractor>::read( t1 ) );
    139141        assert( at0s.size() == at1s.size() );
    140142        for (size_t i = 0; i < at0s.size(); i++) {
  • tests/.expect/attributes.arm64.txt

    r262a864 r9a01745  
    13371337    return _X4_retS3Vad_1;
    13381338}
    1339 __attribute__ (( noreturn )) void _X4fredFv___1(void){
    1340     __attribute__ ((unused)) signed int _X1ii_2;
    1341     switch ( 3 ) {
    1342         case 2:
    1343             {
    1344                 {
    1345                     ((void)4);
    1346                 }
    1347 
    1348             }
    1349         case 1:
    1350             {
    1351                 {
    1352                     ((void)3);
    1353                 }
    1354 
    1355             }
    1356     }
    1357 
    1358 }
    1359 __attribute__ ((noreturn)) void _X4maryFv___1(void){
    1360     struct __attribute__ ((aligned(64))) S {
    1361         signed int _X1ii_2;
    1362     };
    1363     inline void _X12_constructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){
    1364         {
    1365             ((void)((*_X4_dstS1S_2)._X1ii_2) /* ?{} */);
    1366         }
    1367 
    1368     }
    1369     inline void _X12_constructorFv_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){
    1370         {
    1371             ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2) /* ?{} */);
    1372         }
    1373 
    1374     }
    1375     inline void _X11_destructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){
    1376         {
    1377             ((void)((*_X4_dstS1S_2)._X1ii_2) /* ^?{} */);
    1378         }
    1379 
    1380     }
    1381     inline struct S _X16_operator_assignFS1S_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){
    1382         __attribute__ ((unused)) struct S _X4_retS1S_2;
    1383         {
    1384             ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2));
    1385         }
    1386 
    1387         {
    1388             ((void)_X12_constructorFv_S1SS1S_autogen___2((&_X4_retS1S_2), (*_X4_dstS1S_2)));
    1389         }
    1390 
    1391         return _X4_retS1S_2;
    1392     }
    1393     inline void _X12_constructorFv_S1Si_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, signed int _X1ii_2){
    1394         {
    1395             ((void)((*_X4_dstS1S_2)._X1ii_2=_X1ii_2) /* ?{} */);
    1396         }
    1397 
    1398     }
    1399     __attribute__ ((unused)) signed int _X1ii_2;
    1400     switch ( 3 ) {
    1401         case 2:
    1402             {
    1403                 {
    1404                     ((void)4);
    1405                 }
    1406 
    1407             }
    1408         case 1:
    1409             {
    1410                 {
    1411                     ((void)3);
    1412                 }
    1413 
    1414             }
    1415     }
    1416 
    1417 }
  • tests/.expect/attributes.x86.txt

    r262a864 r9a01745  
    13371337    return _X4_retS3Vad_1;
    13381338}
    1339 __attribute__ (( noreturn )) void _X4fredFv___1(void){
    1340     __attribute__ ((unused)) signed int _X1ii_2;
    1341     switch ( 3 ) {
    1342         case 2:
    1343             {
    1344                 {
    1345                     ((void)4);
    1346                 }
    1347 
    1348             }
    1349         case 1:
    1350             {
    1351                 {
    1352                     ((void)3);
    1353                 }
    1354 
    1355             }
    1356     }
    1357 
    1358 }
    1359 __attribute__ ((noreturn)) void _X4maryFv___1(void){
    1360     struct __attribute__ ((aligned(64))) S {
    1361         signed int _X1ii_2;
    1362     };
    1363     inline void _X12_constructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){
    1364         {
    1365             ((void)((*_X4_dstS1S_2)._X1ii_2) /* ?{} */);
    1366         }
    1367 
    1368     }
    1369     inline void _X12_constructorFv_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){
    1370         {
    1371             ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2) /* ?{} */);
    1372         }
    1373 
    1374     }
    1375     inline void _X11_destructorFv_S1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2){
    1376         {
    1377             ((void)((*_X4_dstS1S_2)._X1ii_2) /* ^?{} */);
    1378         }
    1379 
    1380     }
    1381     inline struct S _X16_operator_assignFS1S_S1SS1S_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, __attribute__ ((unused)) struct S _X4_srcS1S_2){
    1382         __attribute__ ((unused)) struct S _X4_retS1S_2;
    1383         {
    1384             ((void)((*_X4_dstS1S_2)._X1ii_2=_X4_srcS1S_2._X1ii_2));
    1385         }
    1386 
    1387         {
    1388             ((void)_X12_constructorFv_S1SS1S_autogen___2((&_X4_retS1S_2), (*_X4_dstS1S_2)));
    1389         }
    1390 
    1391         return _X4_retS1S_2;
    1392     }
    1393     inline void _X12_constructorFv_S1Si_autogen___2(__attribute__ ((unused)) struct S *_X4_dstS1S_2, signed int _X1ii_2){
    1394         {
    1395             ((void)((*_X4_dstS1S_2)._X1ii_2=_X1ii_2) /* ?{} */);
    1396         }
    1397 
    1398     }
    1399     __attribute__ ((unused)) signed int _X1ii_2;
    1400     switch ( 3 ) {
    1401         case 2:
    1402             {
    1403                 {
    1404                     ((void)4);
    1405                 }
    1406 
    1407             }
    1408         case 1:
    1409             {
    1410                 {
    1411                     ((void)3);
    1412                 }
    1413 
    1414             }
    1415     }
    1416 
    1417 }
Note: See TracChangeset for help on using the changeset viewer.