Changes in / [02c80cdc:d4264e8]


Ignore:
Location:
src
Files:
1 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r02c80cdc rd4264e8  
    246246ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) {
    247247        return new ConstantExpr{
    248                 loc, new BasicType{ BasicKind::Bool }, b ? "1" : "0", (unsigned long long)b };
     248                loc, new BasicType{ BasicType::Bool }, b ? "1" : "0", (unsigned long long)b };
    249249}
    250250
    251251ConstantExpr * ConstantExpr::from_int( const CodeLocation & loc, int i ) {
    252252        return new ConstantExpr{
    253                 loc, new BasicType{ BasicKind::SignedInt }, std::to_string( i ), (unsigned long long)i };
     253                loc, new BasicType{ BasicType::SignedInt }, std::to_string( i ), (unsigned long long)i };
    254254}
    255255
    256256ConstantExpr * ConstantExpr::from_ulong( const CodeLocation & loc, unsigned long i ) {
    257257        return new ConstantExpr{
    258                 loc, new BasicType{ BasicKind::LongUnsignedInt }, std::to_string( i ),
     258                loc, new BasicType{ BasicType::LongUnsignedInt }, std::to_string( i ),
    259259                (unsigned long long)i };
    260260}
    261261
    262262ConstantExpr * ConstantExpr::from_string( const CodeLocation & loc, const std::string & str ) {
    263         const Type * charType = new BasicType( BasicKind::Char );
     263        const Type * charType = new BasicType( BasicType::Char );
    264264        // Adjust the length of the string for the terminator.
    265265        const Expr * strSize = from_ulong( loc, str.size() + 1 );
     
    277277
    278278SizeofExpr::SizeofExpr( const CodeLocation & loc, const Expr * e )
    279 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
     279: Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
    280280
    281281SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * t )
    282 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
     282: Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
    283283
    284284// --- AlignofExpr
    285285
    286286AlignofExpr::AlignofExpr( const CodeLocation & loc, const Expr * e )
    287 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
     287: Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
    288288
    289289AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * t )
    290 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
     290: Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
    291291
    292292// --- OffsetofExpr
    293293
    294294OffsetofExpr::OffsetofExpr( const CodeLocation & loc, const Type * ty, const DeclWithType * mem )
    295 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( ty ), member( mem ) {
     295: Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), type( ty ), member( mem ) {
    296296        assert( type );
    297297        assert( member );
     
    302302OffsetPackExpr::OffsetPackExpr( const CodeLocation & loc, const StructInstType * ty )
    303303: Expr( loc, new ArrayType{
    304         new BasicType{ BasicKind::LongUnsignedInt }, nullptr, FixedLen, DynamicDim }
     304        new BasicType{ BasicType::LongUnsignedInt }, nullptr, FixedLen, DynamicDim }
    305305), type( ty ) {
    306306        assert( type );
     
    311311LogicalExpr::LogicalExpr(
    312312        const CodeLocation & loc, const Expr * a1, const Expr * a2, LogicalFlag ia )
    313 : Expr( loc, new BasicType{ BasicKind::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}
     313: Expr( loc, new BasicType{ BasicType::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}
    314314
    315315// --- CommaExpr
  • src/AST/Pass.impl.hpp

    r02c80cdc rd4264e8  
    477477                                CodeLocation{}, "__func__",
    478478                                new ast::ArrayType{
    479                                         new ast::BasicType{ ast::BasicKind::Char, ast::CV::Const },
     479                                        new ast::BasicType{ ast::BasicType::Char, ast::CV::Const },
    480480                                        nullptr, VariableLen, DynamicDim
    481481                                },
  • src/AST/Type.hpp

    r02c80cdc rd4264e8  
    2222#include <vector>
    2323
    24 #include "BasicKind.hpp"     // for BasicKind
    2524#include "CVQualifiers.hpp"
    2625#include "Decl.hpp"          // for AggregateDecl subclasses
     
    115114class BasicType final : public Type {
    116115public:
    117         BasicKind kind;
     116        // GENERATED START, DO NOT EDIT
     117        // GENERATED BY BasicTypes-gen.cc
     118        enum Kind {
     119                Bool,
     120                Char,
     121                SignedChar,
     122                UnsignedChar,
     123                ShortSignedInt,
     124                ShortUnsignedInt,
     125                SignedInt,
     126                UnsignedInt,
     127                LongSignedInt,
     128                LongUnsignedInt,
     129                LongLongSignedInt,
     130                LongLongUnsignedInt,
     131                SignedInt128,
     132                UnsignedInt128,
     133                uFloat16,
     134                uFloat16Complex,
     135                uFloat32,
     136                uFloat32Complex,
     137                Float,
     138                FloatComplex,
     139                uFloat32x,
     140                uFloat32xComplex,
     141                uFloat64,
     142                uFloat64Complex,
     143                Double,
     144                DoubleComplex,
     145                uFloat64x,
     146                uFloat64xComplex,
     147                uuFloat80,
     148                uFloat128,
     149                uFloat128Complex,
     150                uuFloat128,
     151                LongDouble,
     152                LongDoubleComplex,
     153                uFloat128x,
     154                uFloat128xComplex,
     155                NUMBER_OF_BASIC_TYPES
     156        } kind;
     157        // GENERATED END
     158
     159        /// xxx -- MAX_INTEGER_TYPE should probably be in BasicTypes-gen.cc, rather than hardcoded here
     160        enum { MAX_INTEGER_TYPE = UnsignedInt128 };
    118161
    119162        /// string names of basic types; generated to match with Kind
    120163        static const char *typeNames[];
    121164
    122         BasicType( BasicKind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
     165        BasicType( Kind k, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    123166        : Type(q, std::move(as)), kind(k) {}
    124167
    125168        /// Check if this type represents an integer type
    126         bool isInteger() const { return kind <= MAX_INTEGER_TYPE; }
     169        bool isInteger() const { return (unsigned)kind <= (unsigned)MAX_INTEGER_TYPE; }
    127170
    128171        const Type * accept( Visitor & v ) const override { return v.visit( this ); }
  • src/AST/module.mk

    r02c80cdc rd4264e8  
    1818        AST/Attribute.cpp \
    1919        AST/Attribute.hpp \
    20         AST/BasicKind.hpp \
    2120        AST/Bitfield.hpp \
    2221        AST/Chain.hpp \
  • src/BasicTypes-gen.cc

    r02c80cdc rd4264e8  
    249249                } // for
    250250        } // for
    251         int lastInteger = NUMBER_OF_BASIC_TYPES;
    252251
    253252        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // perform breath-first traversal to generate cost graph
     
    260259                } // for
    261260        } // 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         }
    271261
    272262        #define STARTMK "// GENERATED START, DO NOT EDIT"
     
    282272        size_t start, end;
    283273
    284         #define TypeH_AST TOP_SRCDIR "src/AST/BasicKind.hpp"
     274        #define TypeH_AST TOP_SRCDIR "src/AST/Type.hpp"
    285275        resetInput( file, TypeH_AST, buffer, code, str );
    286276
     
    289279        code << str.substr( 0, start );
    290280
    291         code << BYMK << endl;
    292         code << "enum BasicKind {" << endl;
     281        code << "\t" << BYMK << endl;
     282        code << "\tenum Kind {" << endl;
    293283        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    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;
     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
    299289
    300290        if ( (start = str.find( ENDMK, start + 1 )) == string::npos ) Abort( "end", TypeH_AST );
     
    357347
    358348        code << "\t" << BYMK << 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
     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
    360350                 << "\t\t/*           ";
    361351        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    382372
    383373        code << "\t" << BYMK << 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
     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
    385375                 << "\t\t/*           ";
    386376        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) { // titles
     
    414404        enum { PER_ROW = 6 };
    415405        code << "\t" << BYMK << endl;
    416         code << "\t#define BT ast::BasicKind::" << endl;
     406        code << "\t#define BT ast::BasicType::" << endl;
    417407        code << "\tstatic const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor" << endl
    418408             << "\t\t/*\t\t ";
     
    470460                "//   - \"Ds\" char16_t\n";
    471461
    472         code << "const std::string basicTypes[ast::BasicKind::NUMBER_OF_BASIC_TYPES] = {" << endl;
     462        code << "const std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {" << endl;
    473463        for ( int r = 0; r < NUMBER_OF_BASIC_TYPES; r += 1 ) {
    474464                code << "\t\"" << graph[r].mangled << "\"," << setw(9 - strlen(graph[r].mangled)) << ' ' << "// " << graph[r].type << endl;
  • src/CodeGen/FixMain.cc

    r02c80cdc rd4264e8  
    5252ast::ObjectDecl * makeIntObj(){
    5353        return new ast::ObjectDecl( CodeLocation(), "",
    54                 new ast::BasicType( ast::BasicKind::SignedInt ) );
     54                new ast::BasicType( ast::BasicType::SignedInt ) );
    5555}
    5656
     
    5959                new ast::PointerType(
    6060                        new ast::PointerType(
    61                                 new ast::BasicType( ast::BasicKind::Char ) ) ) );
     61                                new ast::BasicType( ast::BasicType::Char ) ) ) );
    6262}
    6363
  • src/CodeGen/GenType.cc

    r02c80cdc rd4264e8  
    8787
    8888void GenType::postvisit( ast::BasicType const * type ) {
    89         ast::BasicKind kind = type->kind;
    90         assert( 0 <= kind && kind < ast::BasicKind::NUMBER_OF_BASIC_TYPES );
     89        ast::BasicType::Kind kind = type->kind;
     90        assert( 0 <= kind && kind < ast::BasicType::NUMBER_OF_BASIC_TYPES );
    9191        result = std::string( ast::BasicType::typeNames[kind] ) + " " + result;
    9292        handleQualifiers( type );
  • src/Common/ResolvProtoDump.cpp

    r02c80cdc rd4264e8  
    229229        void previsit( const ast::EnumInstType * ) {
    230230                // TODO: Add the meaningful text representation of typed enum
    231                 ss << (int)ast::BasicKind::SignedInt;
     231                ss << (int)ast::BasicType::SignedInt;
    232232        }
    233233
     
    255255        // TODO: Support 0 and 1 with their type names and conversions.
    256256        void previsit( const ast::ZeroType * ) {
    257                 ss << (int)ast::BasicKind::SignedInt;
     257                ss << (int)ast::BasicType::SignedInt;
    258258        }
    259259
    260260        void previsit( const ast::OneType * ) {
    261                 ss << (int)ast::BasicKind::SignedInt;
     261                ss << (int)ast::BasicType::SignedInt;
    262262        }
    263263
     
    366366        // TODO: Extra expression to resolve argument.
    367367        void previsit( const ast::SizeofExpr * ) {
    368                 ss << (int)ast::BasicKind::LongUnsignedInt;
     368                ss << (int)ast::BasicType::LongUnsignedInt;
    369369                visit_children = false;
    370370        }
    371371        void previsit( const ast::AlignofExpr * ) {
    372                 ss << (int)ast::BasicKind::LongUnsignedInt;
     372                ss << (int)ast::BasicType::LongUnsignedInt;
    373373                visit_children = false;
    374374        }
    375375        void previsit( const ast::UntypedOffsetofExpr * ) {
    376                 ss << (int)ast::BasicKind::LongUnsignedInt;
     376                ss << (int)ast::BasicType::LongUnsignedInt;
    377377                visit_children = false;
    378378        }
     
    753753                // &? Address of operator.
    754754                out << "#$ptr<T> $addr T" << std::endl;
    755                 const int intId = (int)ast::BasicKind::SignedInt;
     755                const int intId = (int)ast::BasicType::SignedInt;
    756756                // ?&&? ?||? ?: Logical operators.
    757757                out << intId << " $and " << intId << ' ' << intId << std::endl;
  • src/Concurrency/Corun.cpp

    r02c80cdc rd4264e8  
    130130                new ObjectDecl( loc,
    131131                    numProcsName,
    132                     new BasicType( BasicKind::UnsignedInt ),
     132                    new BasicType( BasicType::Kind::UnsignedInt ),
    133133                    new SingleInit( loc,
    134134                        new UntypedExpr( loc,
     
    146146                new ObjectDecl( loc,
    147147                    currProcsName,
    148                     new BasicType( BasicKind::UnsignedInt ),
     148                    new BasicType( BasicType::Kind::UnsignedInt ),
    149149                    new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) )
    150150                )
  • src/Concurrency/Waitfor.cpp

    r02c80cdc rd4264e8  
    244244        ast::ObjectDecl * flag = new ast::ObjectDecl( location,
    245245                namer_flg.newName(),
    246                 new ast::BasicType( ast::BasicKind::Bool ),
     246                new ast::BasicType( ast::BasicType::Bool ),
    247247                new ast::SingleInit( location,
    248248                        ast::ConstantExpr::from_ulong( location, 0 )
     
    349349        ast::ObjectDecl * timeout = new ast::ObjectDecl( topLocation,
    350350                namer_tim.newName(),
    351                 new ast::BasicType( ast::BasicKind::LongLongUnsignedInt ),
     351                new ast::BasicType( ast::BasicType::LongLongUnsignedInt ),
    352352                new ast::SingleInit( topLocation,
    353353                        ast::ConstantExpr::from_int( topLocation, -1 )
     
    397397        ast::ObjectDecl * index = new ast::ObjectDecl( location,
    398398                namer_idx.newName(),
    399                 new ast::BasicType( ast::BasicKind::ShortSignedInt ),
     399                new ast::BasicType( ast::BasicType::ShortSignedInt ),
    400400                new ast::SingleInit( location,
    401401                        ast::ConstantExpr::from_int( location, -1 )
  • src/Concurrency/Waituntil.cpp

    r02c80cdc rd4264e8  
    498498            rightExpr = genPredExpr( loc, currNode->right, idx, genLeaf );
    499499            return new LogicalExpr( loc,
    500                 new CastExpr( loc, leftExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ),
    501                 new CastExpr( loc, rightExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ),
     500                new CastExpr( loc, leftExpr, new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast ),
     501                new CastExpr( loc, rightExpr, new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast ),
    502502                LogicalFlag::AndExpr
    503503            );
     
    507507            rightExpr = genPredExpr( loc, currNode->right, idx, genLeaf );
    508508            return new LogicalExpr( loc,
    509                 new CastExpr( loc, leftExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ),
    510                 new CastExpr( loc, rightExpr, new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast ),
     509                new CastExpr( loc, leftExpr, new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast ),
     510                new CastExpr( loc, rightExpr, new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast ),
    511511                LogicalFlag::OrExpr );
    512512            break;
     
    556556            new ObjectDecl( loc,
    557557                "clause_statuses",
    558                 new PointerType( new BasicType( BasicKind::LongUnsignedInt ) )
     558                new PointerType( new BasicType( BasicType::Kind::LongUnsignedInt ) )
    559559            )
    560560        },
     
    562562            new ObjectDecl( loc,
    563563                "sat_ret",
    564                 new BasicType( BasicKind::Bool )
     564                new BasicType( BasicType::Kind::Bool )
    565565            )
    566566        },
     
    766766                new ObjectDecl( loc,
    767767                    idxName,
    768                     new BasicType( BasicKind::SignedInt ),
     768                    new BasicType( BasicType::Kind::SignedInt ),
    769769                    new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) )
    770770                )
     
    893893                    new ObjectDecl( cLoc,
    894894                        currClause->whenName,
    895                         new BasicType( BasicKind::Bool ),
     895                        new BasicType( BasicType::Kind::Bool ),
    896896                        new SingleInit( cLoc, ast::deepCopy( stmt->clauses.at(i)->when_cond ) )
    897897                    )
     
    915915                new ObjectDecl( stmt->else_cond->location,
    916916                    elseWhenName,
    917                     new BasicType( BasicKind::Bool ),
     917                    new BasicType( BasicType::Kind::Bool ),
    918918                    new SingleInit( stmt->else_cond->location, ast::deepCopy( stmt->else_cond ) )
    919919                )
     
    945945                    new CastExpr( cLoc,
    946946                        new AddressExpr( cLoc, new NameExpr( cLoc, data.at(i)->nodeName ) ),
    947                         new BasicType( BasicKind::LongUnsignedInt ), GeneratedFlag::ExplicitCast
     947                        new BasicType( BasicType::Kind::LongUnsignedInt ), GeneratedFlag::ExplicitCast
    948948                    )
    949949                }
     
    986986                    new CastExpr( cLoc,
    987987                        new NameExpr( cLoc, elseWhenName ),
    988                         new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     988                        new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    989989                    ),
    990990                    new CastExpr( cLoc,
    991991                        raceFnCall,
    992                         new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     992                        new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    993993                    ),
    994994                    LogicalFlag::AndExpr
     
    10161016            new CastExpr( cLoc,
    10171017                new NameExpr( cLoc, data.at(idx)->whenName ),
    1018                 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1018                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    10191019            ),
    10201020            new CastExpr( cLoc,
    10211021                baseCond,
    1022                 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1022                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    10231023            ),
    10241024            LogicalFlag::AndExpr
     
    10341034                        new NameExpr( cLoc, data.at(idx)->nodeName ),
    10351035                        new AddressExpr( cLoc, new NameExpr( cLoc, data.at(idx)->statusName ) ),
    1036                         ConstantExpr::null( cLoc, new PointerType( new BasicType( BasicKind::SignedInt ) ) )
     1036                        ConstantExpr::null( cLoc, new PointerType( new BasicType( BasicType::Kind::SignedInt ) ) )
    10371037                    }
    10381038                )
     
    10961096        new ObjectDecl( loc,
    10971097            statusName,
    1098             new BasicType( BasicKind::LongUnsignedInt ),
     1098            new BasicType( BasicType::Kind::LongUnsignedInt ),
    10991099            new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) )
    11001100        )
     
    11141114            new NameExpr( cLoc, "?!=?" ),
    11151115            {
    1116                 ConstantExpr::null( cLoc, new PointerType( new BasicType( BasicKind::LongUnsignedInt ) ) ),
     1116                ConstantExpr::null( cLoc, new PointerType( new BasicType( BasicType::Kind::LongUnsignedInt ) ) ),
    11171117                new UntypedExpr( cLoc,
    11181118                    new NameExpr( cLoc, "__get_clause_status" ),
     
    11281128                new CastExpr( cLoc,
    11291129                    new NameExpr( cLoc, clauseData.at(i)->whenName ),
    1130                     new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1130                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    11311131                ),
    11321132                new CastExpr( cLoc,
    11331133                    statusPtrCheck,
    1134                     new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1134                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    11351135                ),
    11361136                LogicalFlag::AndExpr
     
    11621162                new CastExpr( loc,
    11631163                    new NameExpr( loc, clauseData.at( whenIndices.at(i) )->whenName ),
    1164                     new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1164                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    11651165                ),
    11661166                new CastExpr( loc,
    11671167                    lastExpr,
    1168                     new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1168                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    11691169                ),
    11701170                LogicalFlag::OrExpr
     
    12201220        new ObjectDecl( loc,
    12211221            pCountName,
    1222             new BasicType( BasicKind::SignedInt ),
     1222            new BasicType( BasicType::Kind::SignedInt ),
    12231223            new SingleInit( loc, ConstantExpr::from_int( loc, 0 ) )
    12241224        )
     
    12291229        new ObjectDecl( loc,
    12301230            statusArrName,
    1231             new ArrayType( new BasicType( BasicKind::LongUnsignedInt ), ConstantExpr::from_int( loc, numClauses ), LengthFlag::FixedLen, DimensionFlag::DynamicDim ),
     1231            new ArrayType( new BasicType( BasicType::Kind::LongUnsignedInt ), ConstantExpr::from_int( loc, numClauses ), LengthFlag::FixedLen, DimensionFlag::DynamicDim ),
    12321232            new ListInit( loc,
    12331233                {
     
    13311331            new CastExpr( cLoc,
    13321332                statusExpr,
    1333                 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1333                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    13341334            ),
    13351335            new CastExpr( cLoc,
    13361336                genSelectTraitCall( stmt->clauses.at(i), clauseData.at(i), "unregister_select" ),
    1337                 new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1337                new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    13381338            ),
    13391339            LogicalFlag::AndExpr
     
    13461346                new CastExpr( cLoc,
    13471347                    new NameExpr( cLoc, clauseData.at(i)->whenName ),
    1348                     new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1348                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    13491349                ),
    13501350                new CastExpr( cLoc,
    13511351                    statusExpr,
    1352                     new BasicType( BasicKind::Bool ), GeneratedFlag::ExplicitCast
     1352                    new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast
    13531353                ),
    13541354                LogicalFlag::AndExpr
  • src/ControlStruct/ExceptDecl.cpp

    r02c80cdc rd4264e8  
    9999                createExceptionInstType( exceptionName, params ) ) );
    100100        type->returns.push_back( new ast::PointerType(
    101                 new ast::BasicType( ast::BasicKind::Char, ast::CV::Const ) ) );
     101                new ast::BasicType( ast::BasicType::Char, ast::CV::Const ) ) );
    102102        return type;
    103103}
     
    344344                                "",
    345345                                new ast::PointerType(
    346                                         new ast::BasicType( ast::BasicKind::Char, ast::CV::Const ) )
     346                                        new ast::BasicType( ast::BasicType::Char, ast::CV::Const ) )
    347347                        ),
    348348                },
  • src/ControlStruct/ExceptTranslate.cpp

    r02c80cdc rd4264e8  
    182182                location,
    183183                "__handler_index",
    184                 new ast::BasicType( ast::BasicKind::SignedInt )
     184                new ast::BasicType( ast::BasicType::SignedInt )
    185185                );
    186186}
     
    201201                location,
    202202                "__ret_bool",
    203                 new ast::BasicType( ast::BasicKind::Bool ),
     203                new ast::BasicType( ast::BasicType::Bool ),
    204204                nullptr, //init
    205205                ast::Storage::Classes{},
     
    231231                location,
    232232                "__handler_index",
    233                 new ast::BasicType( ast::BasicKind::SignedInt ),
     233                new ast::BasicType(ast::BasicType::SignedInt),
    234234                nullptr,
    235235                ast::Storage::Classes{},
  • src/GenPoly/Box.cpp

    r02c80cdc rd4264e8  
    4343/// The layout type is used to represent sizes, alignments and offsets.
    4444ast::BasicType * makeLayoutType() {
    45         return new ast::BasicType( ast::BasicKind::LongUnsignedInt );
     45        return new ast::BasicType( ast::BasicType::LongUnsignedInt );
    4646}
    4747
    4848/// Fixed version of layout type (just adding a 'C' in C++ style).
    4949ast::BasicType * makeLayoutCType() {
    50         return new ast::BasicType( ast::BasicKind::LongUnsignedInt,
     50        return new ast::BasicType( ast::BasicType::LongUnsignedInt,
    5151                ast::CV::Qualifiers( ast::CV::Const ) );
    5252}
     
    16171617ast::Type * polyToMonoType( CodeLocation const & location,
    16181618                ast::Type const * declType ) {
    1619         auto charType = new ast::BasicType( ast::BasicKind::Char );
     1619        auto charType = new ast::BasicType( ast::BasicType::Char );
    16201620        auto size = new ast::NameExpr( location,
    16211621                sizeofName( Mangle::mangleType( declType ) ) );
  • src/InitTweak/FixInit.cpp

    r02c80cdc rd4264e8  
    847847
    848848                        // static bool __objName_uninitialized = true
    849                         auto boolType = new ast::BasicType( ast::BasicKind::Bool );
     849                        auto boolType = new ast::BasicType( ast::BasicType::Kind::Bool );
    850850                        auto boolInitExpr = new ast::SingleInit(loc, ast::ConstantExpr::from_int(loc, 1 ) );
    851851                        auto isUninitializedVar = new ast::ObjectDecl(loc, objDecl->mangleName + "_uninitialized", boolType, boolInitExpr, ast::Storage::Static, ast::Linkage::Cforall);
  • src/Makefile.am

    r02c80cdc rd4264e8  
    5353include Virtual/module.mk
    5454
    55 $(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/AST/BasicKind.hpp
     55$(addprefix $(srcdir)/, ResolvExpr/ConversionCost.cc ResolvExpr/CommonType.cc SymTab/ManglerCommon.cc) : $(srcdir)/AST/Type.hpp
    5656
    57 $(srcdir)/AST/BasicKind.hpp : BasicTypes-gen.cc
     57$(srcdir)/AST/Type.hpp : BasicTypes-gen.cc
    5858        ${AM_V_GEN}${CXXCOMPILE} $< -o BasicTypes-gen -Wall -Wextra -Werror=return-type
    5959        @./BasicTypes-gen
  • src/Parser/ExpressionNode.cc

    r02c80cdc rd4264e8  
    2323#include <string>                  // for string, operator+, operator==
    2424
    25 #include "AST/BasicKind.hpp"       // for BasicKind
    2625#include "AST/Expr.hpp"            // for NameExpr
    27 #include "AST/Type.hpp"            // for Type, LengthFlag, DimentionFlag
     26#include "AST/Type.hpp"            // for BaseType, SueInstType
    2827#include "Common/SemanticError.h"  // for SemanticError
    2928#include "Common/utility.h"        // for maybeMoveBuild, maybeBuild, CodeLo...
     
    127126ast::Expr * build_constantInteger(
    128127                const CodeLocation & location, string & str ) {
    129         static const ast::BasicKind kind[2][6] = {
     128        static const ast::BasicType::Kind kind[2][6] = {
    130129                // short (h) must be before char (hh) because shorter type has the longer suffix
    131                 { ast::BasicKind::ShortSignedInt, ast::BasicKind::SignedChar, ast::BasicKind::SignedInt, ast::BasicKind::LongSignedInt, ast::BasicKind::LongLongSignedInt, /* BasicKind::SignedInt128 */ ast::BasicKind::LongLongSignedInt, },
    132                 { ast::BasicKind::ShortUnsignedInt, ast::BasicKind::UnsignedChar, ast::BasicKind::UnsignedInt, ast::BasicKind::LongUnsignedInt, ast::BasicKind::LongLongUnsignedInt, /* BasicKind::UnsignedInt128 */ ast::BasicKind::LongLongUnsignedInt, },
     130                { ast::BasicType::ShortSignedInt, ast::BasicType::SignedChar, ast::BasicType::SignedInt, ast::BasicType::LongSignedInt, ast::BasicType::LongLongSignedInt, /* BasicType::SignedInt128 */ ast::BasicType::LongLongSignedInt, },
     131                { ast::BasicType::ShortUnsignedInt, ast::BasicType::UnsignedChar, ast::BasicType::UnsignedInt, ast::BasicType::LongUnsignedInt, ast::BasicType::LongLongUnsignedInt, /* BasicType::UnsignedInt128 */ ast::BasicType::LongLongUnsignedInt, },
    133132        };
    134133
     
    314313                if ( ltype == 6 ) {                                                             // int128, (int128)constant
    315314                        ret2 = new ast::ConstantExpr( location,
    316                                 new ast::BasicType( ast::BasicKind::LongLongSignedInt ),
     315                                new ast::BasicType( ast::BasicType::LongLongSignedInt ),
    317316                                str2,
    318317                                v2 );
     
    380379ast::Expr * build_constantFloat(
    381380                const CodeLocation & location, string & str ) {
    382         static const ast::BasicKind kind[2][12] = {
    383                 { ast::BasicKind::Float, ast::BasicKind::Double, ast::BasicKind::LongDouble, ast::BasicKind::uuFloat80, ast::BasicKind::uuFloat128, ast::BasicKind::uFloat16, ast::BasicKind::uFloat32, ast::BasicKind::uFloat32x, ast::BasicKind::uFloat64, ast::BasicKind::uFloat64x, ast::BasicKind::uFloat128, ast::BasicKind::uFloat128x },
    384                 { ast::BasicKind::FloatComplex, ast::BasicKind::DoubleComplex, ast::BasicKind::LongDoubleComplex, ast::BasicKind::NUMBER_OF_BASIC_TYPES, ast::BasicKind::NUMBER_OF_BASIC_TYPES, ast::BasicKind::uFloat16Complex, ast::BasicKind::uFloat32Complex, ast::BasicKind::uFloat32xComplex, ast::BasicKind::uFloat64Complex, ast::BasicKind::uFloat64xComplex, ast::BasicKind::uFloat128Complex, ast::BasicKind::uFloat128xComplex },
     381        static const ast::BasicType::Kind kind[2][12] = {
     382                { ast::BasicType::Float, ast::BasicType::Double, ast::BasicType::LongDouble, ast::BasicType::uuFloat80, ast::BasicType::uuFloat128, ast::BasicType::uFloat16, ast::BasicType::uFloat32, ast::BasicType::uFloat32x, ast::BasicType::uFloat64, ast::BasicType::uFloat64x, ast::BasicType::uFloat128, ast::BasicType::uFloat128x },
     383                { ast::BasicType::FloatComplex, ast::BasicType::DoubleComplex, ast::BasicType::LongDoubleComplex, ast::BasicType::NUMBER_OF_BASIC_TYPES, ast::BasicType::NUMBER_OF_BASIC_TYPES, ast::BasicType::uFloat16Complex, ast::BasicType::uFloat32Complex, ast::BasicType::uFloat32xComplex, ast::BasicType::uFloat64Complex, ast::BasicType::uFloat64xComplex, ast::BasicType::uFloat128Complex, ast::BasicType::uFloat128xComplex },
    385384        };
    386385
     
    448447
    449448        ast::Expr * ret = new ast::ConstantExpr( location,
    450                 new ast::BasicType( ast::BasicKind::Char ),
     449                new ast::BasicType( ast::BasicType::Char ),
    451450                str,
    452451                (unsigned long long int)(unsigned char)str[1] );
     
    483482        Default:                                                                                        // char default string type
    484483        default:
    485                 strtype = new ast::BasicType( ast::BasicKind::Char );
     484                strtype = new ast::BasicType( ast::BasicType::Char );
    486485        } // switch
    487486        ast::ArrayType * at = new ast::ArrayType(
     
    665664                member->name
    666665        );
    667         ret->result = new ast::BasicType( ast::BasicKind::LongUnsignedInt );
     666        ret->result = new ast::BasicType( ast::BasicType::LongUnsignedInt );
    668667        delete member;
    669668        return ret;
  • src/Parser/TypeData.cc

    r02c80cdc rd4264e8  
    1919#include <ostream>                 // for operator<<, ostream, basic_ostream
    2020
     21#include "AST/Decl.hpp"            // for AggregateDecl, ObjectDecl, TypeDe...
    2122#include "AST/Attribute.hpp"       // for Attribute
    22 #include "AST/Decl.hpp"            // for AggregateDecl, ObjectDecl, TypeDe...
    2323#include "AST/Init.hpp"            // for SingleInit, ListInit
    2424#include "AST/Print.hpp"           // for print
    25 #include "AST/Type.hpp"            // for Type
    2625#include "Common/SemanticError.h"  // for SemanticError
    2726#include "Common/utility.h"        // for splice, spliceBegin
     
    10111010                // fill in implicit int
    10121011                return new ast::BasicType(
    1013                         ast::BasicKind::SignedInt,
     1012                        ast::BasicType::SignedInt,
    10141013                        buildQualifiers( td )
    10151014                );
     
    10961095
    10971096ast::Type * buildBasicType( const TypeData * td ) {
    1098         ast::BasicKind ret;
     1097        ast::BasicType::Kind ret;
    10991098
    11001099        switch ( td->basictype ) {
     
    11171116                } // if
    11181117
    1119                 ret = ast::BasicKind::Bool;
     1118                ret = ast::BasicType::Bool;
    11201119                break;
    11211120
     
    11241123                // character types. The implementation shall define char to have the same range, representation, and behavior as
    11251124                // either signed char or unsigned char.
    1126                 static ast::BasicKind chartype[] = { ast::BasicKind::SignedChar, ast::BasicKind::UnsignedChar, ast::BasicKind::Char };
     1125                static ast::BasicType::Kind chartype[] = { ast::BasicType::SignedChar, ast::BasicType::UnsignedChar, ast::BasicType::Char };
    11271126
    11281127                if ( td->length != TypeData::NoLength ) {
     
    11341133
    11351134        case TypeData::Int:
    1136                 static ast::BasicKind inttype[2][4] = {
    1137                         { ast::BasicKind::ShortSignedInt, ast::BasicKind::LongSignedInt, ast::BasicKind::LongLongSignedInt, ast::BasicKind::SignedInt },
    1138                         { ast::BasicKind::ShortUnsignedInt, ast::BasicKind::LongUnsignedInt, ast::BasicKind::LongLongUnsignedInt, ast::BasicKind::UnsignedInt },
     1135                static ast::BasicType::Kind inttype[2][4] = {
     1136                        { ast::BasicType::ShortSignedInt, ast::BasicType::LongSignedInt, ast::BasicType::LongLongSignedInt, ast::BasicType::SignedInt },
     1137                        { ast::BasicType::ShortUnsignedInt, ast::BasicType::LongUnsignedInt, ast::BasicType::LongLongUnsignedInt, ast::BasicType::UnsignedInt },
    11391138                };
    11401139
     
    11471146
    11481147        case TypeData::Int128:
    1149                 ret = td->signedness == TypeData::Unsigned ? ast::BasicKind::UnsignedInt128 : ast::BasicKind::SignedInt128;
     1148                ret = td->signedness == TypeData::Unsigned ? ast::BasicType::UnsignedInt128 : ast::BasicType::SignedInt128;
    11501149                if ( td->length != TypeData::NoLength ) {
    11511150                        genTSError( TypeData::lengthNames[ td->length ], td->basictype );
     
    11651164        case TypeData::uFloat128:
    11661165        case TypeData::uFloat128x:
    1167                 static ast::BasicKind floattype[2][12] = {
    1168                         { ast::BasicKind::FloatComplex, ast::BasicKind::DoubleComplex, ast::BasicKind::LongDoubleComplex, (ast::BasicKind)-1, (ast::BasicKind)-1, ast::BasicKind::uFloat16Complex, ast::BasicKind::uFloat32Complex, ast::BasicKind::uFloat32xComplex, ast::BasicKind::uFloat64Complex, ast::BasicKind::uFloat64xComplex, ast::BasicKind::uFloat128Complex, ast::BasicKind::uFloat128xComplex, },
    1169                         { ast::BasicKind::Float, ast::BasicKind::Double, ast::BasicKind::LongDouble, ast::BasicKind::uuFloat80, ast::BasicKind::uuFloat128, ast::BasicKind::uFloat16, ast::BasicKind::uFloat32, ast::BasicKind::uFloat32x, ast::BasicKind::uFloat64, ast::BasicKind::uFloat64x, ast::BasicKind::uFloat128, ast::BasicKind::uFloat128x, },
     1166                static ast::BasicType::Kind floattype[2][12] = {
     1167                        { ast::BasicType::FloatComplex, ast::BasicType::DoubleComplex, ast::BasicType::LongDoubleComplex, (ast::BasicType::Kind)-1, (ast::BasicType::Kind)-1, ast::BasicType::uFloat16Complex, ast::BasicType::uFloat32Complex, ast::BasicType::uFloat32xComplex, ast::BasicType::uFloat64Complex, ast::BasicType::uFloat64xComplex, ast::BasicType::uFloat128Complex, ast::BasicType::uFloat128xComplex, },
     1168                        { ast::BasicType::Float, ast::BasicType::Double, ast::BasicType::LongDouble, ast::BasicType::uuFloat80, ast::BasicType::uuFloat128, ast::BasicType::uFloat16, ast::BasicType::uFloat32, ast::BasicType::uFloat32x, ast::BasicType::uFloat64, ast::BasicType::uFloat64x, ast::BasicType::uFloat128, ast::BasicType::uFloat128x, },
    11701169                };
    11711170
     
    12141213
    12151214static ast::Type * buildDefaultType( const TypeData * td ) {
    1216         return ( td ) ? typebuild( td ) : new ast::BasicType( ast::BasicKind::SignedInt );
     1215        return ( td ) ? typebuild( td ) : new ast::BasicType( ast::BasicType::SignedInt );
    12171216} // buildDefaultType
    12181217
     
    15801579                        td->location,
    15811580                        "",
    1582                         new ast::BasicType( ast::BasicKind::SignedInt ),
     1581                        new ast::BasicType( ast::BasicType::SignedInt ),
    15831582                        (ast::Init *)nullptr,
    15841583                        ast::Storage::Classes(),
     
    16681667        } else {
    16691668                ft->returns.push_back(
    1670                         new ast::BasicType( ast::BasicKind::SignedInt ) );
     1669                        new ast::BasicType( ast::BasicType::SignedInt ) );
    16711670        } // if
    16721671        return ft;
  • src/Parser/TypeData.h

    r02c80cdc rd4264e8  
    2020#include <string>                                   // for string
    2121
    22 #include "AST/CVQualifiers.hpp"                     // for CV
    23 #include "AST/Fwd.hpp"                              // for Type
     22#include "AST/Type.hpp"                             // for Type
    2423#include "DeclarationNode.h"                        // for DeclarationNode
    2524
  • src/Parser/parser.yy

    r02c80cdc rd4264e8  
    5555#include "TypedefTable.h"
    5656#include "TypeData.h"
    57 #include "AST/Type.hpp"                                 // for BasicType, BasicKind
    5857#include "Common/SemanticError.h"                                               // error_str
    5958#include "Common/utility.h"                                                             // for maybeMoveBuild, maybeBuild, CodeLo...
     
    261260        ast::ConstantExpr * constant = dynamic_cast<ast::ConstantExpr *>(type->expr.get());
    262261        if ( constant && (constant->rep == "0" || constant->rep == "1") ) {
    263                 type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::BasicKind::SignedInt ) ) );
     262                type = new ExpressionNode( new ast::CastExpr( location, maybeMoveBuild(type), new ast::BasicType( ast::BasicType::SignedInt ) ) );
    264263        } // if
    265264        DeclarationNode * initDecl = distAttr(
  • src/ResolvExpr/CandidateFinder.cpp

    r02c80cdc rd4264e8  
    513513                                        // add new result
    514514                                        assert( common );
     515                                        // auto attrType = common.as<ast::EnumAttrType>();
     516                                        // if ( attrType && ( attrType->attr == ast::EnumAttribute::Value ) ) {
     517                                        //      auto callExpr = new ast::UntypedExpr(
     518                                        //              expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
     519                                        //      CandidateFinder finder( context, env );
     520                                        //      finder.find( callExpr );
     521                                        //      CandidateList winners = findMinCost( finder.candidates );
     522                                        //      if (winners.size() != 1) {
     523                                        //              SemanticError( callExpr, "Ambiguous expression in valueE" );
     524                                        //      }
     525                                        //      CandidateRef & choice = winners.front();
     526                                        //      choice->expr = referenceToRvalueConversion( choice->expr, choice->cost );
     527
     528                                        //      results.emplace_back(
     529                                        //              i, choice->expr,
     530                                        //              std::move( env ), std::move( need ), std::move( have ), std::move( open ),
     531                                        //              nextArg + 1, nTuples, expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     532                                        // } else {
    515533                                                results.emplace_back(
    516534                                                        i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ),
     
    903921                                CandidateList winners = findMinCost( finder.candidates );
    904922                                if (winners.size() != 1) {
    905                                         SemanticError( callExpr, "Ambiguous expression in valueE..." );
     923                                        SemanticError( callExpr, "Ambiguous expression in valueE" );
    906924                                }
    907925                                CandidateRef & choice = winners.front();
    908                                 choice->cost.incVar();
     926                                // choice->cost.incSafe();
    909927                                candidates.emplace_back( std::move(choice) );
    910928                        }
     
    17821800                                                        CandidateList winners = findMinCost( finder.candidates );
    17831801                                                        if (winners.size() != 1) {
    1784                                                                 SemanticError( callExpr, "Ambiguous expression in valueE..." );
     1802                                                                SemanticError( callExpr, "Ambiguous expression in valueE" );
    17851803                                                        }
    17861804                                                        CandidateRef & choice = winners.front();
     
    21322150}
    21332151
    2134 // get the valueE(...) ApplicationExpr that returns the enum value
    2135 const ast::Expr * getValueEnumCall(
    2136         const ast::Expr * expr,
    2137         const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ) {
    2138                 auto callExpr = new ast::UntypedExpr(
    2139                         expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
    2140                 CandidateFinder finder( context, env );
    2141                 finder.find( callExpr );
    2142                 CandidateList winners = findMinCost( finder.candidates );
    2143                 if (winners.size() != 1) {
    2144                         SemanticError( callExpr, "Ambiguous expression in valueE..." );
    2145                 }
    2146                 CandidateRef & choice = winners.front();
    2147                 return choice->expr;
     2152const ast::Expr * getValueEnumCall( const ast::Expr * expr,
     2153                const ResolveContext & context, const ast::TypeEnvironment & env ) {
     2154        auto callExpr = new ast::UntypedExpr(
     2155                expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
     2156        CandidateFinder finder( context, env );
     2157        finder.find( callExpr );
     2158        CandidateList winners = findMinCost( finder.candidates );
     2159        if (winners.size() != 1) {
     2160                SemanticError( callExpr, "Ambiguous expression in valueE" );
     2161        }
     2162        CandidateRef & choice = winners.front();
     2163        return choice->expr;
    21482164}
    21492165
     
    21602176                        }
    21612177                ),
    2162                 new ast::BasicType( ast::BasicKind::SignedInt )
     2178                new ast::BasicType( ast::BasicType::SignedInt )
    21632179        );
    21642180}
  • src/ResolvExpr/CommonType.cc

    r02c80cdc rd4264e8  
    3838        // GENERATED START, DO NOT EDIT
    3939        // GENERATED BY BasicTypes-gen.cc
    40         #define BT ast::BasicKind::
    41         static const ast::BasicKind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor
     40        #define BT ast::BasicType::
     41        static const BT Kind commonTypes[BT NUMBER_OF_BASIC_TYPES][BT NUMBER_OF_BASIC_TYPES] = { // nearest common ancestor
    4242                /*                                      B                       C                      SC                      UC                      SI                     SUI
    4343                                                        I                      UI                      LI                     LUI                     LLI                    LLUI
     
    339339        // GENERATED END
    340340        static_assert(
    341                 sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES,
     341                sizeof(commonTypes)/sizeof(commonTypes[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
    342342                "Each basic type kind should have a corresponding row in the combined type matrix"
    343343        );
     
    366366        void postvisit( const ast::BasicType * basic ) {
    367367                if ( auto basic2 = dynamic_cast< const ast::BasicType * >( type2 ) ) {
    368                         ast::BasicKind kind;
     368                        ast::BasicType::Kind kind;
    369369                        if (basic->kind != basic2->kind && !widen.first && !widen.second) return;
    370370                        else if (!widen.first) kind = basic->kind; // widen.second
     
    386386                        const ast::EnumDecl* enumDecl = enumInst->base;
    387387                        if ( !enumDecl->base ) {
    388                                 ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
     388                                ast::BasicType::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];
    389389                                if (
    390390                                        ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     
    398398                } else if ( auto type2AsAttr = dynamic_cast< const ast::EnumAttrType * >( type2 ) ) {
    399399            if ( type2AsAttr->attr == ast::EnumAttribute::Posn ) {
    400                             ast::BasicKind kind = commonTypes[ basic->kind ][ ast::BasicKind::SignedInt ];
     400                            ast::BasicType::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];
    401401                            if (
    402402                                    ( ( kind == basic->kind && basic->qualifiers >= type2->qualifiers )
     
    649649        void postvisit( const ast::EnumInstType * enumInst ) {
    650650                if ( enumInst->base && !enumInst->base->base ) {
    651                         auto basicType = new ast::BasicType( ast::BasicKind::UnsignedInt );
     651                        auto basicType = new ast::BasicType( ast::BasicType::UnsignedInt );
    652652                        result = commonType( basicType, type2, tenv, need, have, open, widen);
    653653                }
     
    674674                } else if ( widen.second && dynamic_cast< const ast::OneType * >( type2 ) ) {
    675675                        result = new ast::BasicType{
    676                                 ast::BasicKind::SignedInt, zero->qualifiers | type2->qualifiers };
     676                                ast::BasicType::SignedInt, zero->qualifiers | type2->qualifiers };
    677677                } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
    678678                        const ast::EnumDecl * enumDecl = enumInst->base;
     
    695695                } else if ( widen.second && dynamic_cast< const ast::ZeroType * >( type2 ) ) {
    696696                        result = new ast::BasicType{
    697                                 ast::BasicKind::SignedInt, one->qualifiers | type2->qualifiers };
     697                                ast::BasicType::SignedInt, one->qualifiers | type2->qualifiers };
    698698                } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
    699699                        const ast::EnumDecl * enumDecl = enumInst->base;
  • src/ResolvExpr/ConversionCost.cc

    r02c80cdc rd4264e8  
    5959        // GENERATED START, DO NOT EDIT
    6060        // GENERATED BY BasicTypes-gen.cc
    61         static const int costMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
     61        static const int costMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // path length from root to node
    6262                /*               B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    6363                /*      B */ {   0,   1,   1,   2,   2,   3,   3,   4,   4,   5,   5,   6,   6,   7,   7,   8,   8,   9,   9,  10,  10,  11,  11,  12,  12,  13,  13,  14,  14,  15,  15,  16,  17,  16,  18,  17, },
     
    101101        // GENERATED END
    102102        static_assert(
    103                 sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES,
     103                sizeof(costMatrix)/sizeof(costMatrix[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
    104104                "Missing row in the cost matrix"
    105105        );
     
    107107        // GENERATED START, DO NOT EDIT
    108108        // GENERATED BY BasicTypes-gen.cc
    109         static const int signMatrix[ast::BasicKind::NUMBER_OF_BASIC_TYPES][ast::BasicKind::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
     109        static const int signMatrix[ast::BasicType::NUMBER_OF_BASIC_TYPES][ast::BasicType::NUMBER_OF_BASIC_TYPES] = { // number of sign changes in safe conversion
    110110                /*               B    C   SC   UC   SI  SUI    I   UI   LI  LUI  LLI LLUI   IB  UIB  _FH  _FH   _F  _FC    F   FC  _FX _FXC   FD _FDC    D   DC F80X_FDXC  F80  _FB_FLDC   FB   LD  LDC _FBX_FLDXC */
    111111                /*      B */ {   0,   0,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, },
     
    148148        // GENERATED END
    149149        static_assert(
    150                 sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES * ast::BasicKind::NUMBER_OF_BASIC_TYPES,
     150                sizeof(signMatrix)/sizeof(signMatrix[0][0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES * ast::BasicType::NUMBER_OF_BASIC_TYPES,
    151151                "Missing row in the sign matrix"
    152152        );
     
    279279                conversionCostFromBasicToBasic( basicType, dstAsBasic );
    280280        } else if ( dynamic_cast< const ast::EnumAttrType *>(dst) ) {
    281                 static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
     281                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    282282                cost = costCalc( basicType, integer, srcIsLvalue, symtab, env );
    283283        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
     
    362362
    363363void ConversionCost::postvisit( const ast::EnumInstType * inst ) {
    364         if ( auto dstAsInst = dynamic_cast<const ast::EnumInstType *>( dst ) ) {
    365                 if (inst->base && dstAsInst->base) {
    366                         if (inst->base->name == dstAsInst->base->name) {
    367                                 cost = Cost::zero;
    368                                 return;
     364        if ( inst->base && inst->base->base ) {
     365                if ( auto dstAsAttr = dynamic_cast<const ast::EnumAttrType *>( dst ) ) {
     366                        auto instAsAttr = ast::EnumAttrType( inst, dstAsAttr->attr );
     367                        if ( instAsAttr.match(dstAsAttr) ) {
     368                                cost.incUnsafe();
     369                        }
     370
     371                } else if ( auto dstAsInst = dynamic_cast<const ast::EnumInstType *>( dst ) ) {
     372                        if (inst->base && dstAsInst->base) {
     373                                if (inst->base == dstAsInst->base) {
     374                                        cost.incUnsafe();
     375                                }
     376                        }
     377                } else {
     378                        auto instAsVal = ast::EnumAttrType( inst, ast::EnumAttribute::Value );
     379                        cost = costCalc( &instAsVal, dst, srcIsLvalue, symtab, env );
     380                        if ( cost < Cost::infinity ) {
     381                                cost.incUnsafe();
    369382                        }
    370383                }
    371384                return;
    372         }
    373         static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
     385        } 
     386        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    374387        cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    375388        if ( cost < Cost::unsafe ) {
     
    380393void ConversionCost::postvisit( const ast::EnumAttrType * src ) {
    381394    auto dstAsEnumAttrType = dynamic_cast<const ast::EnumAttrType *>(dst);
    382         assert( src->attr != ast::EnumAttribute::Label );
    383     if ( src->attr == ast::EnumAttribute::Value ) {
     395    if ( src->attr == ast::EnumAttribute::Label ) {
     396        if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Label ) {
     397            cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env );
     398        }
     399        // Add Conversion To String
     400    } else if ( src->attr == ast::EnumAttribute::Value ) {
    384401        if ( dstAsEnumAttrType && dstAsEnumAttrType->attr == ast::EnumAttribute::Value) {
    385402            cost = costCalc( src->instance, dstAsEnumAttrType->instance, srcIsLvalue, symtab, env );
     
    396413                    if ( cost < Cost::unsafe ) cost.incSafe();
    397414            } else {
    398                     static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
     415                    static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    399416                    cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    400417                    if ( cost < Cost::unsafe ) {
     
    461478        } else if ( const ast::BasicType * dstAsBasic =
    462479                        dynamic_cast< const ast::BasicType * >( dst ) ) {
    463                 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ];
     480                int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
    464481                if ( -1 == tableResult ) {
    465482                        cost = Cost::unsafe;
     
    467484                        cost = Cost::zero;
    468485                        cost.incSafe( tableResult + 1 );
    469                         cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] );
     486                        cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
    470487                }
    471488                // this has the effect of letting any expr such as x+0, x+1 to be typed
     
    493510        } else if ( const ast::BasicType * dstAsBasic =
    494511                        dynamic_cast< const ast::BasicType * >( dst ) ) {
    495                 int tableResult = costMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ];
     512                int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
    496513                if ( -1 == tableResult ) {
    497514                        cost = Cost::unsafe;
     
    499516                        cost = Cost::zero;
    500517                        cost.incSafe( tableResult + 1 );
    501                         cost.incSign( signMatrix[ ast::BasicKind::SignedInt ][ dstAsBasic->kind ] );
     518                        cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
    502519                }
    503520        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
  • src/ResolvExpr/PtrsCastable.cc

    r02c80cdc rd4264e8  
    100100                                result = 1;
    101101                        } else if ( auto bt = dynamic_cast< const ast::BasicType * >( dst ) ) {
    102                                 if ( bt->kind == ast::BasicKind::SignedInt ) {
     102                                if ( bt->kind == ast::BasicType::SignedInt ) {
    103103                                        result = 0;
    104104                                } else {
  • src/ResolvExpr/ResolveTypeof.cc

    r02c80cdc rd4264e8  
    6363                        if ( newType.as< ast::EnumInstType >() ) {
    6464                                newType = new ast::BasicType(
    65                                         ast::BasicKind::SignedInt, newType->qualifiers, copy(newType->attributes) );
     65                                        ast::BasicType::SignedInt, newType->qualifiers, copy(newType->attributes) );
    6666                        }
    6767                        reset_qualifiers(
     
    9191                auto mutType = mutate(arrayType);
    9292                auto globalSizeType = context.global.sizeType;
    93                 ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType( ast::BasicKind::LongUnsignedInt );
     93                ast::ptr<ast::Type> sizetype = globalSizeType ? globalSizeType : new ast::BasicType(ast::BasicType::LongUnsignedInt);
    9494                mutType->dimension = findSingleExpression(arrayType->dimension, sizetype, context );
    9595
  • src/ResolvExpr/Resolver.cc

    r02c80cdc rd4264e8  
    351351        bool isCharType( const ast::Type * t ) {
    352352                if ( auto bt = dynamic_cast< const ast::BasicType * >( t ) ) {
    353                         return bt->kind == ast::BasicKind::Char
    354                                 || bt->kind == ast::BasicKind::SignedChar
    355                                 || bt->kind == ast::BasicKind::UnsignedChar;
     353                        return bt->kind == ast::BasicType::Char
     354                                || bt->kind == ast::BasicType::SignedChar
     355                                || bt->kind == ast::BasicType::UnsignedChar;
    356356                }
    357357                return false;
     
    458458                        if (attr->params.size() == 1) {
    459459                                auto arg = attr->params.front();
    460                                 auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::BasicKind::LongLongSignedInt ), context );
     460                                auto resolved = ResolvExpr::findSingleExpression( arg, new ast::BasicType( ast::BasicType::LongLongSignedInt ), context );
    461461                                auto result = eval(arg);
    462462
     
    624624                        objectDecl = fixObjectType( objectDecl, context );
    625625                        currentObject = ast::CurrentObject{
    626                                 objectDecl->location, new ast::BasicType{ ast::BasicKind::SignedInt } };
     626                                objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } };
    627627                }
    628628        } else {
     
    10951095                // resolve the timeout as a size_t, the conditions like IfStmt, and stmts normally
    10961096                ast::ptr< ast::Type > target =
    1097                         new ast::BasicType{ ast::BasicKind::LongLongUnsignedInt };
     1097                        new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
    10981098                auto timeout_time = findSingleExpression( stmt->timeout_time, target, context );
    10991099                auto timeout_cond = findCondExpression( stmt->timeout_cond, context );
  • src/SymTab/GenImplicitCall.cpp

    r02c80cdc rd4264e8  
    133133
    134134        ast::ptr< ast::DeclWithType > index = new ast::ObjectDecl(
    135                 loc, indexName.newName(), new ast::BasicType( ast::BasicKind::SignedInt ),
     135                loc, indexName.newName(), new ast::BasicType( ast::BasicType::SignedInt ),
    136136                new ast::SingleInit( loc, begin ) );
    137137        ast::ptr< ast::Expr > indexVar = new ast::VariableExpr( loc, index );
  • src/SymTab/Mangler.cc

    r02c80cdc rd4264e8  
    142142void Mangler::postvisit( const ast::BasicType * basicType ) {
    143143        printQualifiers( basicType );
    144         assertf( basicType->kind < ast::BasicKind::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind );
     144        assertf( basicType->kind < ast::BasicType::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind );
    145145        mangleName += Encoding::basicTypes[ basicType->kind ];
    146146}
  • src/SymTab/ManglerCommon.cc

    r02c80cdc rd4264e8  
    4141//   - "Di" char32_t
    4242//   - "Ds" char16_t
    43 const std::string basicTypes[ast::BasicKind::NUMBER_OF_BASIC_TYPES] = {
     43const std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {
    4444        "b",        // _Bool
    4545        "c",        // char
     
    8181// GENERATED END
    8282static_assert(
    83         sizeof(basicTypes) / sizeof(basicTypes[0]) == ast::BasicKind::NUMBER_OF_BASIC_TYPES,
     83        sizeof(basicTypes) / sizeof(basicTypes[0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES,
    8484        "Each basic type kind should have a corresponding mangler letter"
    8585);
  • src/Tuples/TupleExpansion.cpp

    r02c80cdc rd4264e8  
    106106                        assignUnq = commaExpr->arg1;
    107107                }
    108                 auto finished = new ast::ObjectDecl( loc, toString( "_unq", id, "_finished_" ), new ast::BasicType( ast::BasicKind::Bool ),
     108                auto finished = new ast::ObjectDecl( loc, toString( "_unq", id, "_finished_" ), new ast::BasicType( ast::BasicType::Kind::Bool ),
    109109                        new ast::SingleInit( loc, ast::ConstantExpr::from_int( loc, 0 ) ), {}, ast::Linkage::Cforall );
    110110                declsToAddBefore.push_back( finished );
     
    175175                        new ast::ObjectDecl( location,
    176176                                "dummy",
    177                                 new ast::BasicType( ast::BasicKind::SignedInt ),
     177                                new ast::BasicType( ast::BasicType::SignedInt ),
    178178                                nullptr,
    179179                                ast::Storage::Classes(),
  • src/Validate/GenericParameter.cpp

    r02c80cdc rd4264e8  
    289289                return new ast::TypeExpr( expr->location,
    290290                        new ast::ArrayType(
    291                                 new ast::BasicType( ast::BasicKind::Char ),
     291                                new ast::BasicType( ast::BasicType::Char ),
    292292                                expr,
    293293                                ast::VariableLen,
  • src/Validate/ImplementEnumFunc.cpp

    r02c80cdc rd4264e8  
    156156                                         const ast::ObjectDecl* dstParam,
    157157                                         const ast::ObjectDecl* srcParam) {
     158        // const CodeLocation& location = func->location;
     159        // auto& params = func->params;
     160        // assert(2 == params.size());
     161        // auto dstParam = params.front().strict_as<ast::ObjectDecl>();
     162        // auto srcParam = params.back().strict_as<ast::ObjectDecl>();
    158163        return new ast::CompoundStmt(
    159164            location,
     
    296301        {new ast::ObjectDecl(getLocation(), "_i", new ast::EnumInstType(decl))},
    297302        {new ast::ObjectDecl(getLocation(), "_ret",
    298             new ast::BasicType(ast::BasicKind::UnsignedInt))});
     303                             new ast::EnumAttrType(new ast::EnumInstType(decl),
     304                                                   ast::EnumAttribute::Posn))});
    299305}
    300306
     
    305311        {new ast::ObjectDecl(
    306312            getLocation(), "_ret",
    307             new ast::PointerType(new ast::BasicType{ast::BasicKind::Char}))});
     313            new ast::PointerType(new ast::BasicType{ast::BasicType::Char}))});
    308314}
    309315
     
    358364        attr == ast::EnumAttribute::Value
    359365            ? decl->base
    360             : new ast::PointerType(new ast::BasicType{ast::BasicKind::Char}),
     366            : new ast::PointerType(new ast::BasicType{ast::BasicType::Char}),
    361367        ast::ConstantExpr::from_int(decl->location, decl->members.size()),
    362368        ast::LengthFlag::FixedLen, ast::DimensionFlag::DynamicDim);
     
    434440
    435441    auto addOneExpr = ast::UntypedExpr::createCall( location,
    436         succ? "?+?": "?-?",
     442        "?+?",
    437443        {new ast::VariableExpr(location, param),
    438444        ast::ConstantExpr::from_int(location, 1)}
  • src/Validate/ReplaceTypedef.cpp

    r02c80cdc rd4264e8  
    349349                // Perhaps this should be a warning instead.
    350350                translationUnit.global.sizeType =
    351                         new ast::BasicType( ast::BasicKind::LongUnsignedInt );
     351                        new ast::BasicType( ast::BasicType::LongUnsignedInt );
    352352        }
    353353}
  • src/main.cc

    r02c80cdc rd4264e8  
    382382                DUMP( exprp, std::move( transUnit ) );
    383383                PASS( "Replace Pseudo Func", Validate::replacePseudoFunc, transUnit );
     384                DUMP( reppseu, std::move( transUnit ) );
    384385                PASS( "Fix Init", InitTweak::fix, transUnit, buildingLibrary() ); // Here
    385386                PASS( "Erase With", ResolvExpr::eraseWith, transUnit );
     
    533534        { "instgen", genericsp, true, "print AST after instantiate generics" },
    534535        { "bbox", bboxp, true, "print AST before box pass" },
    535         { "bcodegen", bcodegenp, true, "print AST before code generation" }
     536        { "bcodegen", bcodegenp, true, "print AST before code generation" },
     537        { "reppseu", reppseu, true, "print AST after replacing pseudo functions" }
    536538};
    537539enum { printoptsSize = sizeof( printopts ) / sizeof( printopts[0] ) };
Note: See TracChangeset for help on using the changeset viewer.