mojoshader_compiler.c
changeset 987 109aeb1b6409
parent 986 805aa6eb75af
child 988 018e77a5ba67
equal deleted inserted replaced
986:805aa6eb75af 987:109aeb1b6409
  2640                     fail(ctx, "Too few arguments");
  2640                     fail(ctx, "Too few arguments");
  2641                     // !!! FIXME: replace AST here.
  2641                     // !!! FIXME: replace AST here.
  2642                     break;
  2642                     break;
  2643                 } // if
  2643                 } // if
  2644                 datatype2 = type_check_ast(ctx, arg->argument);
  2644                 datatype2 = type_check_ast(ctx, arg->argument);
  2645                 add_type_coercion(ctx, NULL, base_dt, &arg->argument, datatype2);
  2645 
       
  2646                 // "float4(float3(1,2,3),4)" is legal, so we need to see if
       
  2647                 //  we're a vector, and jump that number of parameters instead
       
  2648                 //  of doing type coercion.
       
  2649                 reduced = reduce_datatype(ctx, datatype2);
       
  2650                 if (reduced->type == MOJOSHADER_AST_DATATYPE_VECTOR)
       
  2651                 {
       
  2652                     // make sure things like float4(half3(1,2,3),1) convert that half3 to float3.
       
  2653                     const int count = reduced->vector.elements;
       
  2654                     datatype3 = vectype_from_base(ctx, base_dt->type, count);
       
  2655                     add_type_coercion(ctx, NULL, datatype3, &arg->argument, datatype2);
       
  2656                     i += count - 1;
       
  2657                 } // else
       
  2658                 else
       
  2659                 {
       
  2660                     add_type_coercion(ctx, NULL, base_dt, &arg->argument, datatype2);
       
  2661                 } // else
  2646                 prev = arg;
  2662                 prev = arg;
  2647                 arg = arg->next;
  2663                 arg = arg->next;
  2648             } // for
  2664             } // for
  2649 
  2665 
  2650             if (arg != NULL)
  2666             if (arg != NULL)