Changeset 7a780ad for src/AST/Expr.cpp


Ignore:
Timestamp:
Apr 18, 2024, 5:19:17 PM (6 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/AST/Expr.cpp

    r60c5b6d r7a780ad  
    246246ConstantExpr * ConstantExpr::from_bool( const CodeLocation & loc, bool b ) {
    247247        return new ConstantExpr{
    248                 loc, new BasicType{ BasicType::Bool }, b ? "1" : "0", (unsigned long long)b };
     248                loc, new BasicType{ BasicKind::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{ BasicType::SignedInt }, std::to_string( i ), (unsigned long long)i };
     253                loc, new BasicType{ BasicKind::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{ BasicType::LongUnsignedInt }, std::to_string( i ),
     258                loc, new BasicType{ BasicKind::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( BasicType::Char );
     263        const Type * charType = new BasicType( BasicKind::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{ BasicType::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
     279: Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
    280280
    281281SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * t )
    282 : Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
     282: Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
    283283
    284284// --- AlignofExpr
    285285
    286286AlignofExpr::AlignofExpr( const CodeLocation & loc, const Expr * e )
    287 : Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
     287: Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {}
    288288
    289289AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * t )
    290 : Expr( loc, new BasicType{ BasicType::LongUnsignedInt } ), expr( nullptr ), type( t ) {}
     290: Expr( loc, new BasicType{ BasicKind::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{ BasicType::LongUnsignedInt } ), type( ty ), member( mem ) {
     295: Expr( loc, new BasicType{ BasicKind::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{ BasicType::LongUnsignedInt }, nullptr, FixedLen, DynamicDim }
     304        new BasicType{ BasicKind::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{ BasicType::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}
     313: Expr( loc, new BasicType{ BasicKind::SignedInt } ), arg1( a1 ), arg2( a2 ), isAnd( ia ) {}
    314314
    315315// --- CommaExpr
Note: See TracChangeset for help on using the changeset viewer.