mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- removed ATAGs from the function builder.
This commit is contained in:
parent
e551ef52f8
commit
5464336035
5 changed files with 12 additions and 35 deletions
|
@ -126,7 +126,7 @@ void VMFunctionBuilder::MakeFunction(VMScriptFunction *func)
|
|||
}
|
||||
if (AddressConstantList.Size() > 0)
|
||||
{
|
||||
FillAddressConstants(func->KonstA, func->KonstATags());
|
||||
FillAddressConstants(func->KonstA);
|
||||
}
|
||||
if (StringConstantList.Size() > 0)
|
||||
{
|
||||
|
@ -175,10 +175,9 @@ void VMFunctionBuilder::FillFloatConstants(double *konst)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void VMFunctionBuilder::FillAddressConstants(FVoidObj *konst, VM_ATAG *tags)
|
||||
void VMFunctionBuilder::FillAddressConstants(FVoidObj *konst)
|
||||
{
|
||||
memcpy(konst, &AddressConstantList[0], sizeof(void*) * AddressConstantList.Size());
|
||||
memcpy(tags, &AtagConstantList[0], sizeof(VM_ATAG) * AtagConstantList.Size());
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -258,7 +257,7 @@ unsigned VMFunctionBuilder::GetConstantString(FString val)
|
|||
}
|
||||
else
|
||||
{
|
||||
int loc = StringConstantList.Push(val);
|
||||
unsigned loc = StringConstantList.Push(val);
|
||||
StringConstantMap.Insert(val, loc);
|
||||
return loc;
|
||||
}
|
||||
|
@ -275,20 +274,16 @@ unsigned VMFunctionBuilder::GetConstantString(FString val)
|
|||
|
||||
unsigned VMFunctionBuilder::GetConstantAddress(void *ptr)
|
||||
{
|
||||
AddrKonst *locp = AddressConstantMap.CheckKey(ptr);
|
||||
unsigned *locp = AddressConstantMap.CheckKey(ptr);
|
||||
if (locp != NULL)
|
||||
{
|
||||
// There should only be one tag associated with a memory location. Exceptions are made for null pointers that got allocated through constant arrays.
|
||||
return locp->KonstNum;
|
||||
return *locp;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned locc = AddressConstantList.Push(ptr);
|
||||
AtagConstantList.Push(0);
|
||||
|
||||
AddrKonst loc = { locc, 0 };
|
||||
unsigned loc = AddressConstantList.Push(ptr);
|
||||
AddressConstantMap.Insert(ptr, loc);
|
||||
return loc.KonstNum;
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,13 +320,10 @@ unsigned VMFunctionBuilder::AllocConstantsFloat(unsigned count, double *values)
|
|||
unsigned VMFunctionBuilder::AllocConstantsAddress(unsigned count, void **ptrs)
|
||||
{
|
||||
unsigned addr = AddressConstantList.Reserve(count);
|
||||
AtagConstantList.Reserve(count);
|
||||
memcpy(&AddressConstantList[addr], ptrs, count * sizeof(void *));
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
AtagConstantList[addr + i] = 0;
|
||||
AddrKonst loc = { addr+i, 0 };
|
||||
AddressConstantMap.Insert(ptrs[i], loc);
|
||||
AddressConstantMap.Insert(ptrs[i], addr+i);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
// Write out complete constant tables.
|
||||
void FillIntConstants(int *konst);
|
||||
void FillFloatConstants(double *konst);
|
||||
void FillAddressConstants(FVoidObj *konst, VM_ATAG *tags);
|
||||
void FillAddressConstants(FVoidObj *konst);
|
||||
void FillStringConstants(FString *strings);
|
||||
|
||||
// PARAM increases ActiveParam; CALL decreases it.
|
||||
|
@ -96,24 +96,17 @@ public:
|
|||
TArray<FxLocalVariableDeclaration *> ConstructedStructs;
|
||||
|
||||
private:
|
||||
struct AddrKonst
|
||||
{
|
||||
unsigned KonstNum;
|
||||
VM_ATAG Tag;
|
||||
};
|
||||
|
||||
TArray<FStatementInfo> LineNumbers;
|
||||
TArray<FxExpression *> StatementStack;
|
||||
|
||||
TArray<int> IntConstantList;
|
||||
TArray<double> FloatConstantList;
|
||||
TArray<void *> AddressConstantList;
|
||||
TArray<VM_ATAG> AtagConstantList;
|
||||
TArray<FString> StringConstantList;
|
||||
// These map from the constant value to its position in the constant table.
|
||||
TMap<int, unsigned> IntConstantMap;
|
||||
TMap<double, unsigned> FloatConstantMap;
|
||||
TMap<void *, AddrKonst> AddressConstantMap;
|
||||
TMap<void *, unsigned> AddressConstantMap;
|
||||
TMap<FString, unsigned> StringConstantMap;
|
||||
|
||||
int MaxParam;
|
||||
|
|
|
@ -243,7 +243,7 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func)
|
|||
{
|
||||
for (j = 0, k = i; j < 4 && k < func->NumKonstA; j++, k += kk)
|
||||
{
|
||||
mysnprintf(tmp, countof(tmp), "%3d. %p:%d", k, func->KonstA[k].v, func->KonstATags()[k]);
|
||||
mysnprintf(tmp, countof(tmp), "%3d. %p", k, func->KonstA[k].v);
|
||||
printf_wrapper(out, "%-22s", tmp);
|
||||
}
|
||||
printf_wrapper(out, "\n");
|
||||
|
|
|
@ -692,9 +692,6 @@ public:
|
|||
~VMScriptFunction();
|
||||
void Alloc(int numops, int numkonstd, int numkonstf, int numkonsts, int numkonsta, int numlinenumbers);
|
||||
|
||||
VM_ATAG *KonstATags() { return (VM_UBYTE *)(KonstA + NumKonstA); }
|
||||
const VM_ATAG *KonstATags() const { return (VM_UBYTE *)(KonstA + NumKonstA); }
|
||||
|
||||
VMOP *Code;
|
||||
FStatementInfo *LineInfo;
|
||||
FString SourceFileName;
|
||||
|
|
|
@ -20,7 +20,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
|||
const double *konstf;
|
||||
const FString *konsts;
|
||||
const FVoidObj *konsta;
|
||||
const VM_ATAG *konstatag;
|
||||
|
||||
if (f->Func != NULL && !(f->Func->VarFlags & VARF_Native))
|
||||
{
|
||||
|
@ -29,7 +28,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
|||
konstf = sfunc->KonstF;
|
||||
konsts = sfunc->KonstS;
|
||||
konsta = sfunc->KonstA;
|
||||
konstatag = sfunc->KonstATags();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -38,7 +36,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
|||
konstf = NULL;
|
||||
konsts = NULL;
|
||||
konsta = NULL;
|
||||
konstatag = NULL;
|
||||
}
|
||||
|
||||
void *ptr;
|
||||
|
@ -81,7 +78,6 @@ begin:
|
|||
OP(LKP):
|
||||
ASSERTA(a); ASSERTKA(BC);
|
||||
reg.a[a] = konsta[BC].v;
|
||||
reg.atag[a] = konstatag[BC];
|
||||
NEXTOP;
|
||||
|
||||
OP(LK_R) :
|
||||
|
@ -100,7 +96,6 @@ begin:
|
|||
ASSERTA(a); ASSERTD(B);
|
||||
b = reg.d[B] + C;
|
||||
reg.a[a] = konsta[b].v;
|
||||
reg.atag[a] = konstatag[b];
|
||||
NEXTOP;
|
||||
|
||||
OP(LFP):
|
||||
|
@ -603,7 +598,7 @@ begin:
|
|||
break;
|
||||
case REGT_POINTER | REGT_KONST:
|
||||
assert(C < sfunc->NumKonstA);
|
||||
::new(param) VMValue(konsta[C].v, konstatag[C]);
|
||||
::new(param) VMValue(konsta[C].v, ATAG_GENERIC);
|
||||
break;
|
||||
case REGT_FLOAT:
|
||||
assert(C < f->NumRegF);
|
||||
|
|
Loading…
Reference in a new issue