Changes in src/AST/Convert.cpp [f685679:6f4b7f2]
- File:
-
- 1 edited
-
src/AST/Convert.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rf685679 r6f4b7f2 397 397 ThrowStmt::Kind kind; 398 398 switch (node->kind) { 399 case ast:: ThrowStmt::Terminate:399 case ast::ExceptionKind::Terminate: 400 400 kind = ThrowStmt::Terminate; 401 401 break; 402 case ast:: ThrowStmt::Resume:402 case ast::ExceptionKind::Resume: 403 403 kind = ThrowStmt::Resume; 404 404 break; … … 429 429 CatchStmt::Kind kind; 430 430 switch (node->kind) { 431 case ast:: CatchStmt::Terminate:431 case ast::ExceptionKind::Terminate: 432 432 kind = CatchStmt::Terminate; 433 433 break; 434 case ast:: CatchStmt::Resume:434 case ast::ExceptionKind::Resume: 435 435 kind = CatchStmt::Resume; 436 436 break; … … 704 704 } 705 705 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-values717 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 742 706 const ast::Expr * visit( const ast::ConstantExpr * node ) override final { 743 707 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 ), 747 712 node->rep, 748 713 (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{ 752 718 get<Type>().accept1(node->result), 753 719 node->rep, 754 720 (double) node->floatValue() 755 ));756 } else if (isStringlikeConstantType(node->result)) {757 rslt = new ConstantExpr(Constant::from_string(758 node->rep759 ));721 }}; 722 break; 723 case ast::ConstantExpr::String: 724 rslt = new ConstantExpr{Constant::from_string( node->rep )}; 725 break; 760 726 } 761 727 assert(rslt); … … 1773 1739 virtual void visit( ThrowStmt * old ) override final { 1774 1740 if ( inCache( old ) ) return; 1775 ast:: ThrowStmt::Kind kind;1741 ast::ExceptionKind kind; 1776 1742 switch (old->kind) { 1777 1743 case ThrowStmt::Terminate: 1778 kind = ast:: ThrowStmt::Terminate;1744 kind = ast::ExceptionKind::Terminate; 1779 1745 break; 1780 1746 case ThrowStmt::Resume: 1781 kind = ast:: ThrowStmt::Resume;1747 kind = ast::ExceptionKind::Resume; 1782 1748 break; 1783 1749 default: … … 1809 1775 virtual void visit( CatchStmt * old ) override final { 1810 1776 if ( inCache( old ) ) return; 1811 ast:: CatchStmt::Kind kind;1777 ast::ExceptionKind kind; 1812 1778 switch (old->kind) { 1813 1779 case CatchStmt::Terminate: 1814 kind = ast:: CatchStmt::Terminate;1780 kind = ast::ExceptionKind::Terminate; 1815 1781 break; 1816 1782 case CatchStmt::Resume: 1817 kind = ast:: CatchStmt::Resume;1783 kind = ast::ExceptionKind::Resume; 1818 1784 break; 1819 1785 default:
Note:
See TracChangeset
for help on using the changeset viewer.