| 8 | |
| 9 | |
| 10 | inline Type MulIntrinsicType( ASTNode* call, int argIndex ) |
| 11 | { |
| 12 | ASTNode* arg0 = call->GetChildOrNull( 0 ); |
| 13 | ASTNode* arg1 = call->GetChildOrNull( 1 ); |
| 14 | if( arg0 == nullptr || arg1 == nullptr ) |
| 15 | { |
| 16 | Type type; |
| 17 | type.FromTokenType( OP_VOID ); |
| 18 | return type; |
| 19 | } |
| 20 | Type t0 = arg0->GetType(); |
| 21 | Type t1 = arg1->GetType(); |
| 22 | if( !t0.IsScalarOrVector() || !t1.IsScalarOrVector() ) |
| 23 | { |
| 24 | Type type; |
| 25 | type.FromTokenType( OP_VOID ); |
| 26 | return type; |
| 27 | } |
| 28 | bool isScalar0 = t0.width == 1 && t0.height == 1; |
| 29 | bool isScalar1 = t1.width == 1 && t1.height == 1; |
| 30 | bool isVector0 = t0.width > 1 && t0.height == 1; |
| 31 | bool isVector1 = t1.width > 1 && t1.height == 1; |
| 32 | bool isMatrix0 = t0.width > 1 && t0.height > 1; |
| 33 | bool isMatrix1 = t1.width > 1 && t1.height > 1; |
| 34 | if( GetNumericTypePrecedence( t1.builtInType ) > GetNumericTypePrecedence( t0.builtInType ) ) |
| 35 | { |
| 36 | t0.builtInType = t1.builtInType; |
| 37 | } |
| 38 | else |
| 39 | { |
| 40 | t1.builtInType = t0.builtInType; |
| 41 | } |
| 42 | if( isScalar0 && isScalar1 ) |
| 43 | { |
| 44 | return t0; |
| 45 | } |
| 46 | if( isScalar0 && isVector1 ) |
| 47 | { |
| 48 | switch( argIndex ) |
| 49 | { |
| 50 | case 0: |
| 51 | return t0; |
| 52 | case 1: |
| 53 | return t1; |
| 54 | default: |
| 55 | return t1; |
| 56 | } |
| 57 | } |
| 58 | if( isScalar0 && isMatrix1 ) |
| 59 | { |
| 60 | switch( argIndex ) |
| 61 | { |
| 62 | case 0: |
| 63 | return t0; |
| 64 | case 1: |
| 65 | return t1; |
| 66 | default: |
| 67 | return t1; |
nothing calls this directly
no test coverage detected