mojoshader_compiler.c
changeset 1145 07f69ab909ec
parent 1111 7530b37979b8
child 1182 179ffe99c57f
equal deleted inserted replaced
1144:8ca4b4f3ef22 1145:07f69ab909ec
  1886                                         const MOJOSHADER_astDataType *rettype,
  1886                                         const MOJOSHADER_astDataType *rettype,
  1887                                         const int paramcount,
  1887                                         const int paramcount,
  1888                                         const MOJOSHADER_astDataType **params,
  1888                                         const MOJOSHADER_astDataType **params,
  1889                                         const int intrinsic)
  1889                                         const int intrinsic)
  1890 {
  1890 {
  1891     if ( ((paramcount > 0) && (params == NULL)) ||
  1891     const MOJOSHADER_astDataType **dtparams = NULL;
  1892          ((paramcount == 0) && (params != NULL)) )
  1892     void *ptr;
  1893         return NULL;
  1893 
  1894 
  1894     if (paramcount > 0)
  1895     // !!! FIXME: this is hacky.
  1895     {
  1896     const MOJOSHADER_astDataType **dtparams;
  1896         // !!! FIXME: this is hacky.
  1897     void *ptr = Malloc(ctx, sizeof (*params) * paramcount);
  1897         ptr = Malloc(ctx, sizeof (*params) * paramcount);
  1898     if (ptr == NULL)
  1898         if (ptr == NULL)
  1899         return NULL;
  1899             return NULL;
  1900     if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr)))
  1900         if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr)))
  1901     {
  1901         {
  1902         Free(ctx, ptr);
  1902             Free(ctx, ptr);
  1903         return NULL;
  1903             return NULL;
  1904     } // if
  1904         } // if
  1905     dtparams = (const MOJOSHADER_astDataType **) ptr;
  1905         dtparams = (const MOJOSHADER_astDataType **) ptr;
  1906     memcpy(dtparams, params, sizeof (*params) * paramcount);
  1906         memcpy(dtparams, params, sizeof (*params) * paramcount);
       
  1907     }
  1907 
  1908 
  1908     ptr = Malloc(ctx, sizeof (MOJOSHADER_astDataType));
  1909     ptr = Malloc(ctx, sizeof (MOJOSHADER_astDataType));
  1909     if (ptr == NULL)
  1910     if (ptr == NULL)
  1910         return NULL;
  1911         return NULL;
  1911     if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr)))
  1912     if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr)))