| 702 | } |
| 703 | |
| 704 | bool GetCommonType( const Type& type0, const Type& type1, Type& type ) |
| 705 | { |
| 706 | int casts = 0; |
| 707 | if( !type1.CanImplicitCast( type0, casts ) && !type0.CanImplicitCast( type1, casts ) ) |
| 708 | { |
| 709 | return false; |
| 710 | } |
| 711 | if( type0.symbol ) |
| 712 | { |
| 713 | type = type0; |
| 714 | return true; |
| 715 | } |
| 716 | if( type1.symbol ) |
| 717 | { |
| 718 | type = type1; |
| 719 | return true; |
| 720 | } |
| 721 | //static const int typePrecedence[] = { OP_BOOL, OP_INT, OP_UINT, OP_HALF, OP_FLOAT, OP_DOUBLE }; |
| 722 | int prec0 = GetNumericTypePrecedence( type0.builtInType ); |
| 723 | int prec1 = GetNumericTypePrecedence( type1.builtInType ); |
| 724 | if( prec0 == -1 ) |
| 725 | { |
| 726 | type = type0; |
| 727 | return true; |
| 728 | } |
| 729 | if( prec1 == -1 ) |
| 730 | { |
| 731 | type = type1; |
| 732 | return true; |
| 733 | } |
| 734 | if( prec0 > prec1 ) |
| 735 | { |
| 736 | type = type0; |
| 737 | } |
| 738 | else |
| 739 | { |
| 740 | type = type1; |
| 741 | } |
| 742 | if( type0.width == 1 || type1.width == 1 ) |
| 743 | { |
| 744 | type.width = std::max( type0.width, type1.width ); |
| 745 | } |
| 746 | else |
| 747 | { |
| 748 | type.width = std::min( type0.width, type1.width ); |
| 749 | } |
| 750 | if( type0.height == 1 || type1.height == 1 ) |
| 751 | { |
| 752 | type.height = std::max( type0.height, type1.height ); |
| 753 | } |
| 754 | else |
| 755 | { |
| 756 | type.height = std::min( type0.height, type1.height ); |
| 757 | } |
| 758 | return true; |
| 759 | } |
| 760 | |
| 761 | int GetNumericTypePrecedence( int type ) |
no test coverage detected