mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-06-04 19:10:59 +00:00
- added two new integral types SpriteID and TextureID, both are needed to allow proper serialization as they require something different to be written out than a regular integer.
This commit is contained in:
parent
7c122d03e9
commit
7d99552903
10 changed files with 164 additions and 17 deletions
|
@ -3825,6 +3825,8 @@ ExpEmit FxConcat::Emit(VMFunctionBuilder *build)
|
|||
else if (left->ValueType == TypeName) cast = CAST_N2S;
|
||||
else if (left->ValueType == TypeSound) cast = CAST_So2S;
|
||||
else if (left->ValueType == TypeColor) cast = CAST_Co2S;
|
||||
else if (left->ValueType == TypeSpriteID) cast = CAST_SID2S;
|
||||
else if (left->ValueType == TypeTextureID) cast = CAST_TID2S;
|
||||
else if (op1.RegType == REGT_POINTER) cast = CAST_P2S;
|
||||
else if (op1.RegType == REGT_INT) cast = CAST_I2S;
|
||||
else assert(false && "Bad type for string concatenation");
|
||||
|
@ -3856,6 +3858,8 @@ ExpEmit FxConcat::Emit(VMFunctionBuilder *build)
|
|||
else if (right->ValueType == TypeName) cast = CAST_N2S;
|
||||
else if (right->ValueType == TypeSound) cast = CAST_So2S;
|
||||
else if (right->ValueType == TypeColor) cast = CAST_Co2S;
|
||||
else if (right->ValueType == TypeSpriteID) cast = CAST_SID2S;
|
||||
else if (right->ValueType == TypeTextureID) cast = CAST_TID2S;
|
||||
else if (op2.RegType == REGT_POINTER) cast = CAST_P2S;
|
||||
else if (op2.RegType == REGT_INT) cast = CAST_I2S;
|
||||
else assert(false && "Bad type for string concatenation");
|
||||
|
@ -6880,6 +6884,8 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
|
|||
case NAME_Color:
|
||||
case NAME_Sound:
|
||||
case NAME_State:
|
||||
case NAME_SpriteID:
|
||||
case NAME_TextureID:
|
||||
if (CheckArgSize(MethodName, ArgList, 1, 1, ScriptPosition))
|
||||
{
|
||||
PType *type =
|
||||
|
@ -6889,6 +6895,8 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
|
|||
MethodName == NAME_Float ? TypeFloat64 :
|
||||
MethodName == NAME_Double ? TypeFloat64 :
|
||||
MethodName == NAME_Name ? TypeName :
|
||||
MethodName == NAME_SpriteID ? TypeSpriteID :
|
||||
MethodName == NAME_TextureID ? TypeTextureID :
|
||||
MethodName == NAME_State ? TypeState :
|
||||
MethodName == NAME_Color ? TypeColor : (PType*)TypeSound;
|
||||
|
||||
|
|
|
@ -127,6 +127,8 @@ enum
|
|||
CAST_So2S,
|
||||
CAST_V22S,
|
||||
CAST_V32S,
|
||||
CAST_SID2S,
|
||||
CAST_TID2S,
|
||||
};
|
||||
|
||||
// Register types for VMParam
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include <s_sound.h>
|
||||
#include "dobject.h"
|
||||
#include "xs_Float.h"
|
||||
#include "r_state.h"
|
||||
#include "textures/textures.h"
|
||||
#include "math/cmath.h"
|
||||
|
||||
#define IMPLEMENT_VMEXEC
|
||||
|
|
|
@ -1695,6 +1695,19 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
reg.s[a] = S_sfx[reg.d[b]].name;
|
||||
break;
|
||||
|
||||
case CAST_SID2S:
|
||||
ASSERTS(a); ASSERTD(b);
|
||||
reg.s[a] = unsigned(reg.d[b]) >= sprites.Size() ? "TNT1" : sprites[reg.d[b]].name;
|
||||
break;
|
||||
|
||||
case CAST_TID2S:
|
||||
{
|
||||
ASSERTS(a); ASSERTD(b);
|
||||
auto tex = TexMan[*(FTextureID*)&(reg.d[b])];
|
||||
reg.s[a] = tex == nullptr ? "(null)" : tex->Name.GetChars();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
|
|
@ -1367,19 +1367,19 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n
|
|||
switch (btype->Type)
|
||||
{
|
||||
case ZCC_SInt8:
|
||||
retval = TypeSInt8;
|
||||
retval = formember? TypeSInt8 : (PType*)TypeError;
|
||||
break;
|
||||
|
||||
case ZCC_UInt8:
|
||||
retval = TypeUInt8;
|
||||
retval = formember ? TypeUInt8 : (PType*)TypeError;
|
||||
break;
|
||||
|
||||
case ZCC_SInt16:
|
||||
retval = TypeSInt16;
|
||||
retval = formember ? TypeSInt16 : (PType*)TypeError;
|
||||
break;
|
||||
|
||||
case ZCC_UInt16:
|
||||
retval = TypeUInt16;
|
||||
retval = formember ? TypeUInt16 : (PType*)TypeError;
|
||||
break;
|
||||
|
||||
case ZCC_SInt32:
|
||||
|
@ -1395,11 +1395,9 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n
|
|||
retval = TypeBool;
|
||||
break;
|
||||
|
||||
// Do we really want to allow single precision floats, despite all the problems they cause?
|
||||
// These are nearly guaranteed to desync between MSVC and GCC on x87, because GCC does not implement an IEEE compliant mode
|
||||
case ZCC_Float32:
|
||||
case ZCC_FloatAuto:
|
||||
//return TypeFloat32;
|
||||
retval = formember ? TypeFloat32 : TypeFloat64;
|
||||
|
||||
case ZCC_Float64:
|
||||
retval = TypeFloat64;
|
||||
break;
|
||||
|
@ -1433,14 +1431,24 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n
|
|||
break;
|
||||
|
||||
case ZCC_UserType:
|
||||
// statelabel is not a token - there really is no need to, it works just as well as an identifier. Maybe the same should be done for some other types, too?
|
||||
if (btype->UserType->Id == NAME_StateLabel)
|
||||
// statelabel et.al. are not tokens - there really is no need to, it works just as well as an identifier. Maybe the same should be done for some other types, too?
|
||||
switch (btype->UserType->Id)
|
||||
{
|
||||
case NAME_StateLabel:
|
||||
retval = TypeStateLabel;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
case NAME_SpriteID:
|
||||
retval = TypeSpriteID;
|
||||
break;
|
||||
|
||||
case NAME_TextureID:
|
||||
retval = TypeTextureID;
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = ResolveUserType(btype, &outertype->Symbols);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -113,13 +113,12 @@ enum EZCCBuiltinType
|
|||
ZCC_SInt8,
|
||||
ZCC_UInt8,
|
||||
ZCC_SInt16,
|
||||
ZCC_UInt16,
|
||||
ZCC_UInt16, // smaller than 32 bit types are only valid in structs, classes and arrays.
|
||||
ZCC_SInt32,
|
||||
ZCC_UInt32,
|
||||
ZCC_IntAuto, // for enums, autoselect appropriately sized int
|
||||
|
||||
ZCC_Bool,
|
||||
ZCC_Float32,
|
||||
ZCC_Float64,
|
||||
ZCC_FloatAuto, // 32-bit in structs/classes, 64-bit everywhere else
|
||||
ZCC_String,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue