Use VMFunctionBuilder::EmitParamInt in thingdef_expression.cpp

This commit is contained in:
Randy Heit 2013-07-27 21:38:35 -05:00
parent 0603295822
commit 6cf0916f72

View file

@ -320,19 +320,6 @@ FxExpression *FxParameter::Resolve(FCompileContext& ctx)
return this; return this;
} }
static void EmitConstantInt(VMFunctionBuilder *build, int val)
{
// If it fits in 24 bits, use PARAMI instead of PARAM.
if (((val << 8) >> 8) == val)
{
build->Emit(OP_PARAMI, val);
}
else
{
build->Emit(OP_PARAM, 0, REGT_INT | REGT_KONST, build->GetConstantInt(val));
}
}
ExpEmit FxParameter::Emit(VMFunctionBuilder *build) ExpEmit FxParameter::Emit(VMFunctionBuilder *build)
{ {
if (Operand->isConstant()) if (Operand->isConstant())
@ -340,7 +327,7 @@ ExpEmit FxParameter::Emit(VMFunctionBuilder *build)
ExpVal val = Operand->EvalExpression(NULL); ExpVal val = Operand->EvalExpression(NULL);
if (val.Type == VAL_Int || val.Type == VAL_Sound || val.Type == VAL_Name || val.Type == VAL_Color) if (val.Type == VAL_Int || val.Type == VAL_Sound || val.Type == VAL_Name || val.Type == VAL_Color)
{ {
EmitConstantInt(build, val.Int); build->EmitParamInt(val.Int);
} }
else if (val.Type == VAL_Float) else if (val.Type == VAL_Float)
{ {
@ -3439,14 +3426,14 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
{ {
assert(argex->ValueType == VAL_Name); assert(argex->ValueType == VAL_Name);
assert(argex->isConstant()); assert(argex->isConstant());
EmitConstantInt(build, -argex->EvalExpression(NULL).GetName()); build->EmitParamInt(-argex->EvalExpression(NULL).GetName());
} }
else else
{ {
assert(argex->ValueType == VAL_Int); assert(argex->ValueType == VAL_Int);
if (argex->isConstant()) if (argex->isConstant())
{ {
EmitConstantInt(build, argex->EvalExpression(NULL).GetInt()); build->EmitParamInt(argex->EvalExpression(NULL).GetInt());
} }
else else
{ {
@ -3920,7 +3907,7 @@ ExpEmit FxMultiNameState::Emit(VMFunctionBuilder *build)
build->Emit(OP_PARAM, 0, REGT_POINTER, 1); // pass stateowner build->Emit(OP_PARAM, 0, REGT_POINTER, 1); // pass stateowner
for (unsigned i = 0; i < names.Size(); ++i) for (unsigned i = 0; i < names.Size(); ++i)
{ {
EmitConstantInt(build, names[i]); build->EmitParamInt(names[i]);
} }
// For one name, use the DecoFindSingleNameState function. For more than // For one name, use the DecoFindSingleNameState function. For more than