Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rf685679 r6f4b7f2  
    397397                ThrowStmt::Kind kind;
    398398                switch (node->kind) {
    399                 case ast::ThrowStmt::Terminate:
     399                case ast::ExceptionKind::Terminate:
    400400                        kind = ThrowStmt::Terminate;
    401401                        break;
    402                 case ast::ThrowStmt::Resume:
     402                case ast::ExceptionKind::Resume:
    403403                        kind = ThrowStmt::Resume;
    404404                        break;
     
    429429                CatchStmt::Kind kind;
    430430                switch (node->kind) {
    431                 case ast::CatchStmt::Terminate:
     431                case ast::ExceptionKind::Terminate:
    432432                        kind = CatchStmt::Terminate;
    433433                        break;
    434                 case ast::CatchStmt::Resume:
     434                case ast::ExceptionKind::Resume:
    435435                        kind = CatchStmt::Resume;
    436436                        break;
     
    704704        }
    705705
    706         bool isIntlikeConstantType(const ast::Type *t) {
    707                 if ( const ast::BasicType * basicType = dynamic_cast< const ast::BasicType * >( t ) ) {
    708                         if ( basicType->isInteger() ) {
    709                                 return true;
    710                         }
    711                 } else if ( dynamic_cast< const ast::OneType * >( t ) ) {
    712                         return true;
    713                 } else if ( dynamic_cast< const ast::ZeroType * >( t ) ) {
    714                         return true;
    715                 } else if ( dynamic_cast< const ast::PointerType * >( t ) ) {
    716                         // null pointer constants, with zero int-values
    717                         return true;
    718                 }
    719                 return false;
    720         }
    721 
    722         bool isFloatlikeConstantType(const ast::Type *t) {
    723                 if ( const ast::BasicType * bty = dynamic_cast< const ast::BasicType * >( t ) ) {
    724                         if ( ! bty->isInteger() ) {
    725                                 return true;
    726                         }
    727                 }
    728                 return false;
    729         }
    730 
    731         bool isStringlikeConstantType(const ast::Type *t) {
    732                 if ( const ast::ArrayType * aty = dynamic_cast< const ast::ArrayType * >( t ) ) {
    733                         if ( const ast::BasicType * bty = aty->base.as<ast::BasicType>() ) {
    734                            if ( bty->kind == ast::BasicType::Kind::Char ) {
    735                                    return true;
    736                            }
    737                         }
    738                 }
    739                 return false;
    740         }
    741 
    742706        const ast::Expr * visit( const ast::ConstantExpr * node ) override final {
    743707                ConstantExpr *rslt = nullptr;
    744                 if (isIntlikeConstantType(node->result)) {
    745                         rslt = new ConstantExpr(Constant(
    746                                 get<Type>().accept1(node->result),
     708                switch ( node->kind ) {
     709                case ast::ConstantExpr::Integer:
     710                        rslt = new ConstantExpr{Constant{
     711                                get<Type>().accept1( node->result ),
    747712                                node->rep,
    748713                                (unsigned long long) node->intValue()
    749                         ));
    750                 } else if (isFloatlikeConstantType(node->result)) {
    751                         rslt = new ConstantExpr(Constant(
     714                        }};
     715                        break;
     716                case ast::ConstantExpr::FloatingPoint:
     717                        rslt = new ConstantExpr{Constant{
    752718                                get<Type>().accept1(node->result),
    753719                                node->rep,
    754720                                (double) node->floatValue()
    755                         ));
    756                 } else if (isStringlikeConstantType(node->result)) {
    757                         rslt = new ConstantExpr(Constant::from_string(
    758                                 node->rep
    759                         ));
     721                        }};
     722                        break;
     723                case ast::ConstantExpr::String:
     724                        rslt = new ConstantExpr{Constant::from_string( node->rep )};
     725                        break;
    760726                }
    761727                assert(rslt);
     
    17731739        virtual void visit( ThrowStmt * old ) override final {
    17741740                if ( inCache( old ) ) return;
    1775                 ast::ThrowStmt::Kind kind;
     1741                ast::ExceptionKind kind;
    17761742                switch (old->kind) {
    17771743                case ThrowStmt::Terminate:
    1778                         kind = ast::ThrowStmt::Terminate;
     1744                        kind = ast::ExceptionKind::Terminate;
    17791745                        break;
    17801746                case ThrowStmt::Resume:
    1781                         kind = ast::ThrowStmt::Resume;
     1747                        kind = ast::ExceptionKind::Resume;
    17821748                        break;
    17831749                default:
     
    18091775        virtual void visit( CatchStmt * old ) override final {
    18101776                if ( inCache( old ) ) return;
    1811                 ast::CatchStmt::Kind kind;
     1777                ast::ExceptionKind kind;
    18121778                switch (old->kind) {
    18131779                case CatchStmt::Terminate:
    1814                         kind = ast::CatchStmt::Terminate;
     1780                        kind = ast::ExceptionKind::Terminate;
    18151781                        break;
    18161782                case CatchStmt::Resume:
    1817                         kind = ast::CatchStmt::Resume;
     1783                        kind = ast::ExceptionKind::Resume;
    18181784                        break;
    18191785                default:
Note: See TracChangeset for help on using the changeset viewer.