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