Ignore:
Timestamp:
Apr 18, 2024, 5:19:17 PM (4 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
38093ae
Parents:
60c5b6d
Message:

Moved ast::BasicType::Kind to ast::BasicKind? in its own hearder. This is more consistent with other utility enums (although we still use this as a enum class) and reduces what some files need to include. Also did a upgrade in a comment with MAX_INTEGER_TYPE, it is now part of the enum.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/BasicTypes-gen.cc

    r60c5b6d r7a780ad  
    249249                } // for
    250250        } // for
     251        int lastInteger = NUMBER_OF_BASIC_TYPES;
    251252
    252253        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // perform breath-first traversal to generate cost graph
     
    259260                } // for
    260261        } // for
     262
     263        // Find the last integer type.
     264        // Assumes at least 1, and all come before the floating types.
     265        for ( int i = 1 ; i < NUMBER_OF_BASIC_TYPES ; i += 1 ) {
     266                if ( Floating == graph[i].sign ) {
     267                        lastInteger = (i - 1);
     268                        break;
     269                }
     270        }
    261271
    262272        #define STARTMK "// GENERATED START, DO NOT EDIT"
     
    272282        size_t start, end;
    273283
    274         #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp"
     284        #define TypeH_AST TOP_SRCDIR "src/AST/BasicKind.hpp"
    275285        resetInput( file, TypeH_AST, buffer, code, str );
    276286
     
    279289        code << str.substr( 0, start );
    280290
    281         code << "\t" << BYMK << endl;
    282         code << "\tenum Kind {" << endl;
     291        code << BYMK << endl;
     292        code << "enum BasicKind {" << endl;
    283293        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    284                 code << "\t\t" << graph[r].name << "," << endl;
    285         } // for
    286         code << "\t\tNUMBER_OF_BASIC_TYPES" << endl;
    287         code << "\t} kind;" << endl;
    288         code << "\t";                                                                           // indentation for end marker
     294                code << "\t" << graph[r].name << "," << endl;
     295        } // for
     296        code << "\tNUMBER_OF_BASIC_TYPES," << endl;
     297        code << "\tMAX_INTEGER_TYPE = " << graph[lastInteger].name << "," << endl;
     298        code << "};" << endl;
    289299
    290300        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST );
     
    347357
    348358        code << "\t" << BYMK << endl;
    349         code << "\tstatic const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl
     359        code << "\tstatic const int costMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << endl
    350360                 << "\t\t/*           ";
    351361        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    372382
    373383        code << "\t" << BYMK << endl;
    374         code << "\tstatic const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl
     384        code << "\tstatic const int signMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << endl
    375385                 << "\t\t/*           ";
    376386        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    404414        enum { PER_ROW = 6 };
    405415        code << "\t" << BYMK << endl;
    406         code << "\t#define BT ast::BasicType::" << endl;
     416        code << "\t#define BT ast::BasicKind::" << endl;
    407417        code << "\tstatic const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl
    408418             << "\t\t/*\t\t ";
     
    460470                "//   - \"Ds\" char16_t\n";
    461471
    462         code << "const std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;
     472        code << "const std::string basicTypes[ast::BasicKind::NUMBER_OF_BASIC_TYPES] = {" << endl;
    463473        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    464474                code << "\t\"" << graph[r].mangled << "\"," << setw(9 - strlen(graph[r].mangled)) << ' ' << "// " << graph[r].type << endl;
Note: See TracChangeset for help on using the changeset viewer.