Allow vector fastcall constructor to work with 3-4 arguments with 4-wide vectors (#511)

This commit is contained in:
Petri Häkkinen 2022-06-09 19:41:52 +03:00 committed by GitHub
parent 9619f036ac
commit b44912cd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -1018,18 +1018,20 @@ static int luauF_tunpack(lua_State* L, StkId res, TValue* arg0, int nresults, St
static int luauF_vector(lua_State* L, StkId res, TValue* arg0, int nresults, StkId args, int nparams)
{
#if LUA_VECTOR_SIZE == 4
if (nparams >= 4 && nresults <= 1 && ttisnumber(arg0) && ttisnumber(args) && ttisnumber(args + 1) && ttisnumber(args + 2))
#else
if (nparams >= 3 && nresults <= 1 && ttisnumber(arg0) && ttisnumber(args) && ttisnumber(args + 1))
#endif
{
double x = nvalue(arg0);
double y = nvalue(args);
double z = nvalue(args + 1);
#if LUA_VECTOR_SIZE == 4
double w = nvalue(args + 2);
double w = 0.0;
if (nparams >= 4)
{
if (!ttisnumber(args + 2))
return -1;
w = nvalue(args + 2);
}
setvvalue(res, float(x), float(y), float(z), float(w));
#else
setvvalue(res, float(x), float(y), float(z), 0.0f);