mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- added missing unsigned casts to the VM.
- make the pointer to string cast a bit more useful by using the actual object's type rather than 'Object' which can be a great asset when debugging. - fixed a few bad asserts.
This commit is contained in:
parent
f71aad4cdd
commit
24481781b4
4 changed files with 22 additions and 4 deletions
|
@ -871,7 +871,7 @@ ExpEmit FxIntCast::Emit(VMFunctionBuilder *build)
|
||||||
assert(basex->ValueType->GetRegType() == REGT_FLOAT);
|
assert(basex->ValueType->GetRegType() == REGT_FLOAT);
|
||||||
from.Free(build);
|
from.Free(build);
|
||||||
ExpEmit to(build, REGT_INT);
|
ExpEmit to(build, REGT_INT);
|
||||||
build->Emit(OP_CAST, to.RegNum, from.RegNum, CAST_F2I);
|
build->Emit(OP_CAST, to.RegNum, from.RegNum, ValueType == TypeUInt32? CAST_F2U : CAST_F2I);
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ ExpEmit FxFloatCast::Emit(VMFunctionBuilder *build)
|
||||||
assert(basex->ValueType->GetRegType() == REGT_INT);
|
assert(basex->ValueType->GetRegType() == REGT_INT);
|
||||||
from.Free(build);
|
from.Free(build);
|
||||||
ExpEmit to(build, REGT_FLOAT);
|
ExpEmit to(build, REGT_FLOAT);
|
||||||
build->Emit(OP_CAST, to.RegNum, from.RegNum, CAST_I2F);
|
build->Emit(OP_CAST, to.RegNum, from.RegNum, basex->ValueType == TypeUInt32? CAST_U2F : CAST_I2F);
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3554,7 +3554,7 @@ ExpEmit FxShift::Emit(VMFunctionBuilder *build)
|
||||||
assert(!op2.Konst);
|
assert(!op2.Konst);
|
||||||
instr = InstrMap[index][1];
|
instr = InstrMap[index][1];
|
||||||
}
|
}
|
||||||
assert(instr > 0);
|
assert(instr != 0);
|
||||||
ExpEmit to(build, REGT_INT);
|
ExpEmit to(build, REGT_INT);
|
||||||
build->Emit(instr, to.RegNum, op1.RegNum, rop);
|
build->Emit(instr, to.RegNum, op1.RegNum, rop);
|
||||||
return to;
|
return to;
|
||||||
|
|
|
@ -111,7 +111,10 @@ enum
|
||||||
{
|
{
|
||||||
CAST_I2F,
|
CAST_I2F,
|
||||||
CAST_I2S,
|
CAST_I2S,
|
||||||
|
CAST_U2F,
|
||||||
|
CAST_U2S,
|
||||||
CAST_F2I,
|
CAST_F2I,
|
||||||
|
CAST_F2U,
|
||||||
CAST_F2S,
|
CAST_F2S,
|
||||||
CAST_P2S,
|
CAST_P2S,
|
||||||
CAST_S2I,
|
CAST_S2I,
|
||||||
|
|
|
@ -381,15 +381,18 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
|
||||||
switch (code[i].c)
|
switch (code[i].c)
|
||||||
{
|
{
|
||||||
case CAST_I2F:
|
case CAST_I2F:
|
||||||
|
case CAST_U2F:
|
||||||
mode = MODE_AF | MODE_BI | MODE_CUNUSED;
|
mode = MODE_AF | MODE_BI | MODE_CUNUSED;
|
||||||
break;
|
break;
|
||||||
case CAST_Co2S:
|
case CAST_Co2S:
|
||||||
case CAST_So2S:
|
case CAST_So2S:
|
||||||
case CAST_N2S:
|
case CAST_N2S:
|
||||||
case CAST_I2S:
|
case CAST_I2S:
|
||||||
|
case CAST_U2S:
|
||||||
mode = MODE_AS | MODE_BI | MODE_CUNUSED;
|
mode = MODE_AS | MODE_BI | MODE_CUNUSED;
|
||||||
break;
|
break;
|
||||||
case CAST_F2I:
|
case CAST_F2I:
|
||||||
|
case CAST_F2U:
|
||||||
mode = MODE_AI | MODE_BF | MODE_CUNUSED;
|
mode = MODE_AI | MODE_BF | MODE_CUNUSED;
|
||||||
break;
|
break;
|
||||||
case CAST_F2S:
|
case CAST_F2S:
|
||||||
|
|
|
@ -1658,15 +1658,27 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
||||||
ASSERTF(a); ASSERTD(b);
|
ASSERTF(a); ASSERTD(b);
|
||||||
reg.f[a] = reg.d[b];
|
reg.f[a] = reg.d[b];
|
||||||
break;
|
break;
|
||||||
|
case CAST_U2F:
|
||||||
|
ASSERTF(a); ASSERTD(b);
|
||||||
|
reg.f[a] = unsigned(reg.d[b]);
|
||||||
|
break;
|
||||||
case CAST_I2S:
|
case CAST_I2S:
|
||||||
ASSERTS(a); ASSERTD(b);
|
ASSERTS(a); ASSERTD(b);
|
||||||
reg.s[a].Format("%d", reg.d[b]);
|
reg.s[a].Format("%d", reg.d[b]);
|
||||||
break;
|
break;
|
||||||
|
case CAST_U2S:
|
||||||
|
ASSERTS(a); ASSERTD(b);
|
||||||
|
reg.s[a].Format("%u", reg.d[b]);
|
||||||
|
break;
|
||||||
|
|
||||||
case CAST_F2I:
|
case CAST_F2I:
|
||||||
ASSERTD(a); ASSERTF(b);
|
ASSERTD(a); ASSERTF(b);
|
||||||
reg.d[a] = (int)reg.f[b];
|
reg.d[a] = (int)reg.f[b];
|
||||||
break;
|
break;
|
||||||
|
case CAST_F2U:
|
||||||
|
ASSERTD(a); ASSERTF(b);
|
||||||
|
reg.d[a] = (int)(unsigned)reg.f[b];
|
||||||
|
break;
|
||||||
case CAST_F2S:
|
case CAST_F2S:
|
||||||
ASSERTS(a); ASSERTD(b);
|
ASSERTS(a); ASSERTD(b);
|
||||||
reg.s[a].Format("%.14g", reg.f[b]);
|
reg.s[a].Format("%.14g", reg.f[b]);
|
||||||
|
@ -1674,7 +1686,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
||||||
|
|
||||||
case CAST_P2S:
|
case CAST_P2S:
|
||||||
ASSERTS(a); ASSERTA(b);
|
ASSERTS(a); ASSERTA(b);
|
||||||
reg.s[a].Format("%s<%p>", reg.atag[b] == ATAG_OBJECT ? "Object" : "Pointer", reg.a[b]);
|
reg.s[a].Format("%s<%p>", reg.atag[b] == ATAG_OBJECT ? (reg.a[b] == nullptr? "Object" : ((DObject*)reg.a[b])->GetClass()->TypeName.GetChars() ) : "Pointer", reg.a[b]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAST_S2I:
|
case CAST_S2I:
|
||||||
|
|
Loading…
Reference in a new issue