mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 23:21:41 +00:00
Remove FxParameter and use a single function instead
This commit is contained in:
parent
fb8d8dc775
commit
92f74634d6
3 changed files with 16 additions and 61 deletions
|
@ -219,17 +219,6 @@ public:
|
||||||
bool isresolved;
|
bool isresolved;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FxParameter : public FxExpression
|
|
||||||
{
|
|
||||||
FxExpression *Operand;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FxParameter(FxExpression*);
|
|
||||||
~FxParameter();
|
|
||||||
FxExpression *Resolve(FCompileContext&);
|
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
|
||||||
};
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// FxIdentifier
|
// FxIdentifier
|
||||||
|
|
|
@ -225,45 +225,13 @@ void FxExpression::RequestAddress()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FxParameter::FxParameter(FxExpression *operand)
|
static void EmitParameter(VMFunctionBuilder *build, FxExpression *operand, const FScriptPosition &pos)
|
||||||
: FxExpression(operand->ScriptPosition)
|
|
||||||
{
|
{
|
||||||
Operand = operand;
|
ExpEmit where = operand->Emit(build);
|
||||||
ValueType = operand->ValueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FxParameter::~FxParameter()
|
|
||||||
{
|
|
||||||
SAFE_DELETE(Operand);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FxExpression *FxParameter::Resolve(FCompileContext& ctx)
|
|
||||||
{
|
|
||||||
CHECKRESOLVED();
|
|
||||||
SAFE_RESOLVE(Operand, ctx);
|
|
||||||
ValueType = Operand->ValueType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExpEmit FxParameter::Emit(VMFunctionBuilder *build)
|
|
||||||
{
|
|
||||||
ExpEmit where = Operand->Emit(build);
|
|
||||||
|
|
||||||
if (where.RegType == REGT_NIL)
|
if (where.RegType == REGT_NIL)
|
||||||
{
|
{
|
||||||
ScriptPosition.Message(MSG_ERROR, "Attempted to pass a non-value");
|
pos.Message(MSG_ERROR, "Attempted to pass a non-value");
|
||||||
build->Emit(OP_PARAM, 0, where.RegType, where.RegNum);
|
build->Emit(OP_PARAM, 0, where.RegType, where.RegNum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -276,7 +244,6 @@ ExpEmit FxParameter::Emit(VMFunctionBuilder *build)
|
||||||
build->Emit(OP_PARAM, 0, regtype, where.RegNum);
|
build->Emit(OP_PARAM, 0, regtype, where.RegNum);
|
||||||
where.Free(build);
|
where.Free(build);
|
||||||
}
|
}
|
||||||
return ExpEmit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -2251,8 +2218,8 @@ FxRandom::FxRandom(FRandom * r, FxExpression *mi, FxExpression *ma, const FScrip
|
||||||
{
|
{
|
||||||
if (mi != NULL && ma != NULL)
|
if (mi != NULL && ma != NULL)
|
||||||
{
|
{
|
||||||
min = new FxParameter(new FxIntCast(mi));
|
min = new FxIntCast(mi);
|
||||||
max = new FxParameter(new FxIntCast(ma));
|
max = new FxIntCast(ma);
|
||||||
}
|
}
|
||||||
else min = max = NULL;
|
else min = max = NULL;
|
||||||
rng = r;
|
rng = r;
|
||||||
|
@ -2336,8 +2303,8 @@ ExpEmit FxRandom::Emit(VMFunctionBuilder *build)
|
||||||
build->Emit(OP_PARAM, 0, REGT_POINTER | REGT_KONST, build->GetConstantAddress(rng, ATAG_RNG));
|
build->Emit(OP_PARAM, 0, REGT_POINTER | REGT_KONST, build->GetConstantAddress(rng, ATAG_RNG));
|
||||||
if (min != NULL && max != NULL)
|
if (min != NULL && max != NULL)
|
||||||
{
|
{
|
||||||
min->Emit(build);
|
EmitParameter(build, min, ScriptPosition);
|
||||||
max->Emit(build);
|
EmitParameter(build, max, ScriptPosition);
|
||||||
build->Emit(OP_CALL_K, build->GetConstantAddress(callfunc, ATAG_OBJECT), 3, 1);
|
build->Emit(OP_CALL_K, build->GetConstantAddress(callfunc, ATAG_OBJECT), 3, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2523,8 +2490,8 @@ FxFRandom::FxFRandom(FRandom *r, FxExpression *mi, FxExpression *ma, const FScri
|
||||||
{
|
{
|
||||||
if (mi != NULL && ma != NULL)
|
if (mi != NULL && ma != NULL)
|
||||||
{
|
{
|
||||||
min = new FxParameter(new FxFloatCast(mi));
|
min = new FxFloatCast(mi);
|
||||||
max = new FxParameter(new FxFloatCast(ma));
|
max = new FxFloatCast(ma);
|
||||||
}
|
}
|
||||||
ValueType = TypeFloat64;
|
ValueType = TypeFloat64;
|
||||||
}
|
}
|
||||||
|
@ -2572,8 +2539,8 @@ ExpEmit FxFRandom::Emit(VMFunctionBuilder *build)
|
||||||
build->Emit(OP_PARAM, 0, REGT_POINTER | REGT_KONST, build->GetConstantAddress(rng, ATAG_RNG));
|
build->Emit(OP_PARAM, 0, REGT_POINTER | REGT_KONST, build->GetConstantAddress(rng, ATAG_RNG));
|
||||||
if (min != NULL && max != NULL)
|
if (min != NULL && max != NULL)
|
||||||
{
|
{
|
||||||
min->Emit(build);
|
EmitParameter(build, min, ScriptPosition);
|
||||||
max->Emit(build);
|
EmitParameter(build, max, ScriptPosition);
|
||||||
build->Emit(OP_CALL_K, build->GetConstantAddress(callfunc, ATAG_OBJECT), 3, 1);
|
build->Emit(OP_CALL_K, build->GetConstantAddress(callfunc, ATAG_OBJECT), 3, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2597,7 +2564,6 @@ FxRandom2::FxRandom2(FRandom *r, FxExpression *m, const FScriptPosition &pos)
|
||||||
rng = r;
|
rng = r;
|
||||||
if (m) mask = new FxIntCast(m);
|
if (m) mask = new FxIntCast(m);
|
||||||
else mask = new FxConstant(-1, pos);
|
else mask = new FxConstant(-1, pos);
|
||||||
mask = new FxParameter(mask);
|
|
||||||
ValueType = TypeSInt32;
|
ValueType = TypeSInt32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2642,7 +2608,7 @@ ExpEmit FxRandom2::Emit(VMFunctionBuilder *build)
|
||||||
callfunc = ((PSymbolVMFunction *)sym)->Function;
|
callfunc = ((PSymbolVMFunction *)sym)->Function;
|
||||||
|
|
||||||
build->Emit(OP_PARAM, 0, REGT_POINTER | REGT_KONST, build->GetConstantAddress(rng, ATAG_RNG));
|
build->Emit(OP_PARAM, 0, REGT_POINTER | REGT_KONST, build->GetConstantAddress(rng, ATAG_RNG));
|
||||||
mask->Emit(build);
|
EmitParameter(build, mask, ScriptPosition);
|
||||||
build->Emit(OP_CALL_K, build->GetConstantAddress(callfunc, ATAG_OBJECT), 2, 1);
|
build->Emit(OP_CALL_K, build->GetConstantAddress(callfunc, ATAG_OBJECT), 2, 1);
|
||||||
ExpEmit out(build, REGT_INT);
|
ExpEmit out(build, REGT_INT);
|
||||||
build->Emit(OP_RESULT, 0, REGT_INT, out.RegNum);
|
build->Emit(OP_RESULT, 0, REGT_INT, out.RegNum);
|
||||||
|
@ -3407,7 +3373,7 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build, bool tailcall)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < ArgList->Size(); ++i)
|
for (unsigned i = 0; i < ArgList->Size(); ++i)
|
||||||
{
|
{
|
||||||
(*ArgList)[i]->Emit(build);
|
EmitParameter(build, (*ArgList)[i], ScriptPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get a constant register for this function
|
// Get a constant register for this function
|
||||||
|
|
|
@ -77,7 +77,7 @@ FxVMFunctionCall *DoActionSpecials(FScanner &sc, FState & state, Baggage &bag)
|
||||||
if (special > 0 && min_args >= 0)
|
if (special > 0 && min_args >= 0)
|
||||||
{
|
{
|
||||||
FArgumentList *args = new FArgumentList;
|
FArgumentList *args = new FArgumentList;
|
||||||
args->Push(new FxParameter(new FxConstant(special, sc)));
|
args->Push(new FxConstant(special, sc));
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// Make this consistent with all other parameter parsing
|
// Make this consistent with all other parameter parsing
|
||||||
|
@ -85,7 +85,7 @@ FxVMFunctionCall *DoActionSpecials(FScanner &sc, FState & state, Baggage &bag)
|
||||||
{
|
{
|
||||||
while (i < 5)
|
while (i < 5)
|
||||||
{
|
{
|
||||||
args->Push(new FxParameter(new FxIntCast(ParseExpression(sc, bag.Info))));
|
args->Push(new FxIntCast(ParseExpression(sc, bag.Info)));
|
||||||
i++;
|
i++;
|
||||||
if (!sc.CheckToken (',')) break;
|
if (!sc.CheckToken (',')) break;
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
|
||||||
// Use the generic parameter parser for everything else
|
// Use the generic parameter parser for everything else
|
||||||
x = ParseParameter(sc, cls, params[pnum], false);
|
x = ParseParameter(sc, cls, params[pnum], false);
|
||||||
}
|
}
|
||||||
out_params.Push(new FxParameter(x));
|
out_params.Push(x);
|
||||||
pnum++;
|
pnum++;
|
||||||
numparams--;
|
numparams--;
|
||||||
if (numparams > 0)
|
if (numparams > 0)
|
||||||
|
|
Loading…
Reference in a new issue