Ignore:
Timestamp:
Nov 13, 2023, 3:43:43 AM (23 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
25f2798
Parents:
0030b508 (diff), 2174191 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/BasicTypes-gen.cc

    r0030b508 rfc12f05  
    117117        // { LongDoubleImaginary, "LongDoubleImaginary", "LDI", "long double _Imaginary", "Ie", false, LongDoubleComplex, -1, -1, 17 },
    118118
    119         { uFloat128x, "uFloat128x", "_FBX", "_Float128x", "DF128x_", Floating, uFloat128xComplex, -1, -1, 18 }, 
     119        { uFloat128x, "uFloat128x", "_FBX", "_Float128x", "DF128x_", Floating, uFloat128xComplex, -1, -1, 18 },
    120120        { uFloat128xComplex, "uFloat128xComplex", "_FLDXC", "_Float128x _Complex", "CDF128x_", Floating, -1, -1, -1, 18 }
    121121}; // graph
     
    127127void generateCosts( int row ) {
    128128        bool seen[NUMBER_OF_BASIC_TYPES] = { false /*, ... */ };
    129        
     129
    130130        struct el_cost {
    131131                int i;
    132132                int path;
    133133                int sign;
    134                
     134
    135135                el_cost( int i = 0, int p = 0, int s = 0 ) : i(i), path(p), sign(s) {}
    136                
     136
    137137                // reverse the sense for use in largest-on-top priority queue
    138138                bool operator< (const el_cost& o) const {
     
    195195                        return;
    196196                } // if
    197                
     197
    198198                i = graph[col].middle;
    199199                if ( i == -1 ) assert("invalid ancestor assumption");
     
    272272        size_t start, end;
    273273
    274 
    275         #define TypeH TOP_SRCDIR "src/SynTree/Type.h"
    276         resetInput( file, TypeH, buffer, code, str );
    277 
    278         if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH );
     274        #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp"
     275        resetInput( file, TypeH_AST, buffer, code, str );
     276
     277        if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH_AST );
    279278        start += sizeof( STARTMK );                                                     // includes newline
    280279        code << str.substr( 0, start );
     
    284283        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    285284                code << "\t\t" << graph[r].name << "," << endl;
    286         } // for       
     285        } // for
    287286        code << "\t\tNUMBER_OF_BASIC_TYPES" << endl;
    288287        code << "\t} kind;" << endl;
    289288        code << "\t";                                                                           // indentation for end marker
    290289
    291         if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH );
     290        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST );
    292291        code << str.substr( start );
    293292
    294         output( file, TypeH, code );
     293        output( file, TypeH_AST, code );
    295294        // cout << code.str();
    296295
    297296
    298         #define TypeC TOP_SRCDIR "src/SynTree/Type.cc"
    299         resetInput( file, TypeC, buffer, code, str );
    300 
    301         if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC );
     297        #define TypeC_AST TOP_SRCDIR "src/AST/Type.cpp"
     298        resetInput( file, TypeC_AST, buffer, code, str );
     299
     300        if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC_AST );
    302301        start += sizeof( STARTMK );                                                     // includes newline
    303302        code << str.substr( 0, start );
     
    307306        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    308307                code << "\t\"" << graph[r].type << "\"," << endl;
    309         } // for       
    310         code << "};" << endl;
    311 
    312         if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeC );
    313         code << str.substr( start );
    314 
    315         output( file, TypeC, code );
    316         // cout << code.str();
    317 
    318 
    319         // TEMPORARY DURING CHANGE OVER
    320         #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp"
    321         resetInput( file, TypeH_AST, buffer, code, str );
    322 
    323         if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeH_AST );
    324         start += sizeof( STARTMK );                                                     // includes newline
    325         code << str.substr( 0, start );
    326 
    327         code << "\t" << BYMK << endl;
    328         code << "\tenum Kind {" << endl;
    329         for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    330                 code << "\t\t" << graph[r].name << "," << endl;
    331         } // for       
    332         code << "\t\tNUMBER_OF_BASIC_TYPES" << endl;
    333         code << "\t} kind;" << endl;
    334         code << "\t";                                                                           // indentation for end marker
    335 
    336         if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST );
    337         code << str.substr( start );
    338 
    339         output( file, TypeH_AST, code );
    340         // cout << code.str();
    341 
    342 
    343         #define TypeC_AST TOP_SRCDIR "src/AST/Type.cpp"
    344         resetInput( file, TypeC_AST, buffer, code, str );
    345 
    346         if ( (start = str.find( STARTMK )) == string::npos ) Abort( "start", TypeC_AST );
    347         start += sizeof( STARTMK );                                                     // includes newline
    348         code << str.substr( 0, start );
    349 
    350         code << BYMK << endl;
    351         code << "const char * BasicType::typeNames[] = {" << endl;
    352         for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    353                 code << "\t\"" << graph[r].type << "\"," << endl;
    354         } // for       
     308        } // for
    355309        code << "};" << endl;
    356310
     
    391345        end += sizeof( STARTMK );
    392346        code << str.substr( start, end - start );
    393        
     347
    394348        code << "\t" << BYMK << endl;
    395         code << "\tstatic const int costMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node" << 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
    396350                 << "\t\t/*           ";
    397351        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    411365        code << "\tstatic const int maxIntCost = " << *max_element(costMatrix[SignedInt], costMatrix[SignedInt] + NUMBER_OF_BASIC_TYPES) << ";" << endl;
    412366        code << "\t";                                                                           // indentation for end marker
    413        
     367
    414368        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", ConversionCost );
    415369        if ( (end = str.find( STARTMK, start + 1 )) == string::npos ) Abort( "start", ConversionCost );
     
    418372
    419373        code << "\t" << BYMK << endl;
    420         code << "\tstatic const int signMatrix[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion" << 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
    421375                 << "\t\t/*           ";
    422376        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    450404        enum { PER_ROW = 6 };
    451405        code << "\t" << BYMK << endl;
    452         code << "\t#define BT BasicType::" << endl;
    453         code << "\tstatic const BasicType::Kind commonTypes[BasicType::NUMBER_OF_BASIC_TYPES][BasicType::NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl
     406        code << "\t#define BT ast::BasicType::" << endl;
     407        code << "\tstatic const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl
    454408             << "\t\t/*\t\t ";
    455409        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    505459                "\t\t\t//   - \"Di\" char32_t\n"
    506460                "\t\t\t//   - \"Ds\" char16_t\n";
    507                
    508         code << "\t\t\tconst std::string basicTypes[BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;
     461
     462        code << "\t\t\tconst std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;
    509463        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    510464                code << "\t\t\t\t\"" << graph[r].mangled << "\"," << setw(9 - strlen(graph[r].mangled)) << ' ' << "// " << graph[r].type << endl;
    511         } // for       
     465        } // for
    512466        code << "\t\t\t}; // basicTypes" << endl;
    513467        code << "\t\t\t";                                                                       // indentation for end marker
Note: See TracChangeset for help on using the changeset viewer.