mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 13:31:07 +00:00
- Added type coercion for action function parameters.
- I add PARAMI, and then I don't even do it right... SVN r1919 (scripting)
This commit is contained in:
parent
126c738116
commit
3cbac657d6
4 changed files with 18 additions and 3 deletions
|
@ -303,7 +303,7 @@ static void FinishThingdef()
|
|||
VMScriptFunction *func = buildit.MakeFunction();
|
||||
#if 1
|
||||
const char *marks = "=======================================================";
|
||||
char label[40];
|
||||
char label[64];
|
||||
int labellen = mysnprintf(label, countof(label), "Function %s.States[%d] (*%d)",
|
||||
tcall->ActorInfo->Class->TypeName.GetChars(),
|
||||
tcall->FirstState, tcall->NumStates);
|
||||
|
|
|
@ -365,7 +365,7 @@ FxExpression *FxParameter::Resolve(FCompileContext& ctx)
|
|||
static void EmitConstantInt(VMFunctionBuilder *build, int val)
|
||||
{
|
||||
// If it fits in 24 bits, use PARAMI instead of PARAM.
|
||||
if ((val << 8) >> 8)
|
||||
if (((val << 8) >> 8) == val)
|
||||
{
|
||||
build->Emit(OP_PARAMI, val);
|
||||
}
|
||||
|
|
|
@ -151,6 +151,21 @@ FxExpression *ParseParameter(FScanner &sc, PClass *cls, char type, bool constant
|
|||
{
|
||||
sc.ScriptError("Default parameter must be constant.");
|
||||
}
|
||||
// Do automatic coercion between ints and floats.
|
||||
if (type == 'x' || type == 'X')
|
||||
{
|
||||
if (x->ValueType != VAL_Int)
|
||||
{
|
||||
x = new FxIntCast(x);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x->ValueType != VAL_Float)
|
||||
{
|
||||
x = new FxFloatCast(x);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -217,7 +217,7 @@ void VMDisasm(FILE *out, const VM_UBYTE *code, int codesize, const VMScriptFunct
|
|||
break;
|
||||
|
||||
case OP_PARAMI:
|
||||
col = printf_wrapper(out, "%d", i + 4 + ABCs(&code[i]));
|
||||
col = printf_wrapper(out, "%d", ABCs(&code[i]));
|
||||
break;
|
||||
|
||||
case OP_RET:
|
||||
|
|
Loading…
Reference in a new issue