- Backend update from Raze.
This is mainly code cleanup from setting the compiler to a stricter warning level.
This commit is contained in:
parent
6aea7694bc
commit
1c517d19fa
102 changed files with 493 additions and 590 deletions
|
|
@ -522,10 +522,10 @@ FxExpression *FxConstant::MakeConstant(PSymbol *sym, const FScriptPosition &pos)
|
|||
}
|
||||
else
|
||||
{
|
||||
PSymbolConstString *csym = dyn_cast<PSymbolConstString>(sym);
|
||||
if (csym != nullptr)
|
||||
PSymbolConstString *csymbol = dyn_cast<PSymbolConstString>(sym);
|
||||
if (csymbol != nullptr)
|
||||
{
|
||||
x = new FxConstant(csym->Str, pos);
|
||||
x = new FxConstant(csymbol->Str, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2436,7 +2436,7 @@ ExpEmit FxAssign::Emit(VMFunctionBuilder *build)
|
|||
|
||||
ExpEmit result;
|
||||
bool intconst = false;
|
||||
int intconstval;
|
||||
int intconstval = 0;
|
||||
|
||||
if (Right->isConstant() && Right->ValueType->GetRegType() == REGT_INT)
|
||||
{
|
||||
|
|
@ -4396,7 +4396,7 @@ ExpEmit FxBinaryLogical::Emit(VMFunctionBuilder *build)
|
|||
build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 1 : 0);
|
||||
build->Emit(OP_JMP, 1);
|
||||
build->BackpatchListToHere(no);
|
||||
auto ctarget = build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 0 : 1);
|
||||
build->Emit(OP_LI, to.RegNum, (Operator == TK_AndAnd) ? 0 : 1);
|
||||
list.DeleteAndClear();
|
||||
list.ShrinkToFit();
|
||||
return to;
|
||||
|
|
@ -5134,7 +5134,7 @@ ExpEmit FxNew::Emit(VMFunctionBuilder *build)
|
|||
int outerside = -1;
|
||||
if (!val->isConstant())
|
||||
{
|
||||
int outerside = FScopeBarrier::SideFromFlags(CallingFunction->Variants[0].Flags);
|
||||
outerside = FScopeBarrier::SideFromFlags(CallingFunction->Variants[0].Flags);
|
||||
if (outerside == FScopeBarrier::Side_Virtual)
|
||||
outerside = FScopeBarrier::SideFromObjectFlags(CallingFunction->OwningClass->ScopeFlags);
|
||||
}
|
||||
|
|
@ -5569,8 +5569,6 @@ FxExpression *FxRandomPick::Resolve(FCompileContext &ctx)
|
|||
|
||||
ExpEmit FxRandomPick::Emit(VMFunctionBuilder *build)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
assert(choices.Size() > 0);
|
||||
|
||||
// Call BuiltinRandom to generate a random number.
|
||||
|
|
@ -5603,7 +5601,7 @@ ExpEmit FxRandomPick::Emit(VMFunctionBuilder *build)
|
|||
|
||||
// Allocate space for the jump table.
|
||||
size_t jumptable = build->Emit(OP_JMP, 0);
|
||||
for (i = 1; i < choices.Size(); ++i)
|
||||
for (unsigned i = 1; i < choices.Size(); ++i)
|
||||
{
|
||||
build->Emit(OP_JMP, 0);
|
||||
}
|
||||
|
|
@ -5639,7 +5637,7 @@ ExpEmit FxRandomPick::Emit(VMFunctionBuilder *build)
|
|||
}
|
||||
}
|
||||
// Backpatch each case (except the last, since it ends here) to jump to here.
|
||||
for (i = 0; i < choices.Size() - 1; ++i)
|
||||
for (unsigned i = 0; i < choices.Size() - 1; ++i)
|
||||
{
|
||||
build->BackpatchToHere(finishes[i]);
|
||||
}
|
||||
|
|
@ -7855,8 +7853,8 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
|
|||
}
|
||||
else if (!ArgList.Size())
|
||||
{
|
||||
auto cls = static_cast<PClassType*>(ctx.Class)->Descriptor;
|
||||
ArgList.Push(new FxConstant(cls, NewClassPointer(cls), ScriptPosition));
|
||||
auto clss = static_cast<PClassType*>(ctx.Class)->Descriptor;
|
||||
ArgList.Push(new FxConstant(clss, NewClassPointer(clss), ScriptPosition));
|
||||
}
|
||||
|
||||
func = new FxNew(ArgList[0]);
|
||||
|
|
@ -8036,7 +8034,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
}
|
||||
// No need to create a dedicated node here, all builtins map directly to trivial operations.
|
||||
Self->ValueType = TypeSInt32; // all builtins treat the texture index as integer.
|
||||
FxExpression *x;
|
||||
FxExpression *x = nullptr;
|
||||
switch (MethodName.GetIndex())
|
||||
{
|
||||
case NAME_IsValid:
|
||||
|
|
@ -8369,8 +8367,8 @@ isresolved:
|
|||
if (!novirtual || !(afd->Variants[0].Flags & VARF_Virtual))
|
||||
{
|
||||
auto clstype = PType::toClass(ctx.Class);
|
||||
auto ccls = PType::toClass(cls);
|
||||
if (clstype == nullptr || ccls == nullptr || !clstype->Descriptor->IsDescendantOf(ccls->Descriptor))
|
||||
auto cclss = PType::toClass(cls);
|
||||
if (clstype == nullptr || cclss == nullptr || !clstype->Descriptor->IsDescendantOf(cclss->Descriptor))
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Cannot call non-static function %s::%s from here", cls->TypeName.GetChars(), MethodName.GetChars());
|
||||
delete this;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ template<class T, int fill = 1> void ArrayResize(T *self, int amount)
|
|||
{
|
||||
// This must ensure that all new entries get cleared.
|
||||
const int fillCount = int(self->Size() - oldSize);
|
||||
if (fillCount > 0) memset(&(*self)[oldSize], 0, sizeof(*self)[0] * fillCount);
|
||||
if (fillCount > 0) memset((void*)&(*self)[oldSize], 0, sizeof(*self)[0] * fillCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func)
|
|||
|
||||
void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction *func)
|
||||
{
|
||||
VMFunction *callfunc;
|
||||
VMFunction *callfunc = nullptr;
|
||||
const char *name;
|
||||
int col;
|
||||
int mode;
|
||||
|
|
@ -526,7 +526,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
|
|||
{
|
||||
printf_wrapper(out, ",%d\n", code[++i].i24);
|
||||
}
|
||||
else if (code[i].op == OP_CALL_K)
|
||||
else if (code[i].op == OP_CALL_K && callfunc)
|
||||
{
|
||||
printf_wrapper(out, " [%s]\n", callfunc->PrintableName.GetChars());
|
||||
}
|
||||
|
|
@ -665,7 +665,6 @@ static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const
|
|||
default:
|
||||
return col+printf_wrapper(out, "$%d", arg);
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ ZCCCompiler::ZCCCompiler(ZCC_AST &ast, DObject *_outer, PSymbolTable &_symbols,
|
|||
if (ast.TopNode != NULL)
|
||||
{
|
||||
ZCC_TreeNode *node = ast.TopNode;
|
||||
PSymbolTreeNode *tnode;
|
||||
PSymbolTreeNode *tnode = nullptr;
|
||||
|
||||
// [pbeta] Anything that must be processed before classes, structs, etc. should go here.
|
||||
do
|
||||
|
|
@ -606,7 +606,6 @@ PSymbolTreeNode *ZCCCompiler::AddTreeNode(FName name, ZCC_TreeNode *node, PSymbo
|
|||
else
|
||||
{
|
||||
auto sy = Create<PSymbolTreeNode>(name, node);
|
||||
FString name;
|
||||
treenodes->AddSymbol(sy);
|
||||
return sy;
|
||||
}
|
||||
|
|
@ -1930,19 +1929,19 @@ PType *ZCCCompiler::ResolveArraySize(PType *baseType, ZCC_Expression *arraysize,
|
|||
if (mVersion >= MakeVersion(3, 7, 2))
|
||||
{
|
||||
TArray<ZCC_Expression *> fixedIndices;
|
||||
for (auto node : indices)
|
||||
for (auto index : indices)
|
||||
{
|
||||
fixedIndices.Insert (0, node);
|
||||
fixedIndices.Insert (0, index);
|
||||
}
|
||||
|
||||
indices = std::move(fixedIndices);
|
||||
}
|
||||
|
||||
FCompileContext ctx(OutNamespace, cls, false);
|
||||
for (auto node : indices)
|
||||
for (auto index : indices)
|
||||
{
|
||||
// There is no float->int casting here.
|
||||
FxExpression *ex = ConvertNode(node);
|
||||
FxExpression *ex = ConvertNode(index);
|
||||
ex = ex->Resolve(ctx);
|
||||
|
||||
if (ex == nullptr) return TypeError;
|
||||
|
|
@ -2425,17 +2424,17 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
|
||||
auto parentfunc = clstype->ParentClass? dyn_cast<PFunction>(clstype->ParentClass->VMType->Symbols.FindSymbol(sym->SymbolName, true)) : nullptr;
|
||||
|
||||
int vindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], parentfunc, exactReturnType);
|
||||
int virtindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], parentfunc, exactReturnType);
|
||||
// specifying 'override' is necessary to prevent one of the biggest problem spots with virtual inheritance: Mismatching argument types.
|
||||
if (varflags & VARF_Override)
|
||||
{
|
||||
if (vindex == -1)
|
||||
if (virtindex == -1)
|
||||
{
|
||||
Error(f, "Attempt to override non-existent virtual function %s", FName(f->Name).GetChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto oldfunc = clstype->Virtuals[vindex];
|
||||
auto oldfunc = clstype->Virtuals[virtindex];
|
||||
if (parentfunc && parentfunc->mVersion > mVersion)
|
||||
{
|
||||
Error(f, "Attempt to override function %s which is incompatible with version %d.%d.%d", FName(f->Name).GetChars(), mVersion.major, mVersion.minor, mVersion.revision);
|
||||
|
|
@ -2467,8 +2466,8 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
if (oldfunc->VarFlags & VARF_Protected)
|
||||
sym->Variants[0].Flags |= VARF_Protected;
|
||||
|
||||
clstype->Virtuals[vindex] = sym->Variants[0].Implementation;
|
||||
sym->Variants[0].Implementation->VirtualIndex = vindex;
|
||||
clstype->Virtuals[virtindex] = sym->Variants[0].Implementation;
|
||||
sym->Variants[0].Implementation->VirtualIndex = virtindex;
|
||||
sym->Variants[0].Implementation->VarFlags = sym->Variants[0].Flags;
|
||||
|
||||
// Defaults must be identical to parent class
|
||||
|
|
@ -2493,7 +2492,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
}
|
||||
else
|
||||
{
|
||||
if (vindex != -1)
|
||||
if (virtindex != -1)
|
||||
{
|
||||
Error(f, "Function %s attempts to override parent function without 'override' qualifier", FName(f->Name).GetChars());
|
||||
}
|
||||
|
|
@ -2507,8 +2506,8 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
}
|
||||
else if (forclass)
|
||||
{
|
||||
int vindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], nullptr, exactReturnType);
|
||||
if (vindex != -1)
|
||||
int virtindex = clstype->FindVirtualIndex(sym->SymbolName, &sym->Variants[0], nullptr, exactReturnType);
|
||||
if (virtindex != -1)
|
||||
{
|
||||
Error(f, "Function %s attempts to override parent function without 'override' qualifier", FName(f->Name).GetChars());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -831,10 +831,10 @@ public:
|
|||
if (result)
|
||||
{
|
||||
IMAGEHLP_LINE64 line64;
|
||||
DWORD displacement = 0;
|
||||
DWORD displacement1 = 0;
|
||||
memset(&line64, 0, sizeof(IMAGEHLP_LINE64));
|
||||
line64.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
result = SymGetLineFromAddr64(GetCurrentProcess(), (DWORD64)frame, &displacement, &line64);
|
||||
result = SymGetLineFromAddr64(GetCurrentProcess(), (DWORD64)frame, &displacement1, &line64);
|
||||
if (result)
|
||||
{
|
||||
s.Format("Called from %s at %s, line %d\n", symbol64->Name, line64.FileName, (int)line64.LineNumber);
|
||||
|
|
|
|||
|
|
@ -692,7 +692,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
{
|
||||
VMFunction *call = (VMFunction *)ptr;
|
||||
VMReturn returns[MAX_RETURNS];
|
||||
int numret;
|
||||
int numret1;
|
||||
|
||||
b = B;
|
||||
FillReturns(reg, f, returns, pc+1, C);
|
||||
|
|
@ -701,7 +701,7 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
try
|
||||
{
|
||||
VMCycles[0].Unclock();
|
||||
numret = static_cast<VMNativeFunction *>(call)->NativeCall(VM_INVOKE(reg.param + f->NumParam - b, b, returns, C, call->RegTypes));
|
||||
numret1 = static_cast<VMNativeFunction *>(call)->NativeCall(VM_INVOKE(reg.param + f->NumParam - b, b, returns, C, call->RegTypes));
|
||||
VMCycles[0].Clock();
|
||||
}
|
||||
catch (CVMAbortException &err)
|
||||
|
|
@ -714,10 +714,10 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto sfunc = static_cast<VMScriptFunction *>(call);
|
||||
numret = sfunc->ScriptCall(sfunc, reg.param + f->NumParam - b, b, returns, C);
|
||||
auto sfunc1 = static_cast<VMScriptFunction *>(call);
|
||||
numret1 = sfunc1->ScriptCall(sfunc1, reg.param + f->NumParam - b, b, returns, C);
|
||||
}
|
||||
assert(numret == C && "Number of parameters returned differs from what was expected by the caller");
|
||||
assert(numret1 == C && "Number of parameters returned differs from what was expected by the caller");
|
||||
f->NumParam -= B;
|
||||
pc += C; // Skip RESULTs
|
||||
}
|
||||
|
|
@ -858,31 +858,31 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
// chosen to conserve a few opcodes by condensing all the
|
||||
// string comparisons into a single one.
|
||||
{
|
||||
const FString *b, *c;
|
||||
const FString *b1, *c1;
|
||||
int test, method;
|
||||
bool cmp;
|
||||
|
||||
if (a & CMP_BK)
|
||||
{
|
||||
ASSERTKS(B);
|
||||
b = &konsts[B];
|
||||
b1 = &konsts[B];
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERTS(B);
|
||||
b = ®.s[B];
|
||||
b1 = ®.s[B];
|
||||
}
|
||||
if (a & CMP_CK)
|
||||
{
|
||||
ASSERTKS(C);
|
||||
c = &konsts[C];
|
||||
c1 = &konsts[C];
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERTS(C);
|
||||
c = ®.s[C];
|
||||
c1 = ®.s[C];
|
||||
}
|
||||
test = (a & CMP_APPROX) ? b->CompareNoCase(*c) : b->Compare(*c);
|
||||
test = (a & CMP_APPROX) ? b1->CompareNoCase(*c1) : b1->Compare(*c1);
|
||||
method = a & CMP_METHOD_MASK;
|
||||
if (method == CMP_EQ)
|
||||
{
|
||||
|
|
@ -1302,12 +1302,10 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
ASSERTF(a); ASSERTF(B); ASSERTKF(C);
|
||||
fb = reg.f[B]; fc = konstf[C];
|
||||
goto Do_MODF;
|
||||
NEXTOP;
|
||||
OP(MODF_KR):
|
||||
ASSERTF(a); ASSERTKF(B); ASSERTF(C);
|
||||
fb = konstf[B]; fc = reg.f[C];
|
||||
goto Do_MODF;
|
||||
NEXTOP;
|
||||
|
||||
OP(POWF_RR):
|
||||
ASSERTF(a); ASSERTF(B); ASSERTF(C);
|
||||
|
|
@ -1712,7 +1710,6 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
// PrintParameters(reg.param + f->NumParam - B, B);
|
||||
throw;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static double DoFLOP(int flop, double v)
|
||||
|
|
|
|||
|
|
@ -694,7 +694,6 @@ void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...)
|
|||
va_list ap;
|
||||
va_start(ap, moreinfo);
|
||||
throw CVMAbortException(reason, moreinfo, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...)
|
||||
|
|
@ -706,7 +705,6 @@ void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException
|
|||
|
||||
err.stacktrace.AppendFormat("Called from %s at %s, line %d\n", sfunc->PrintableName.GetChars(), sfunc->SourceFileName.GetChars(), sfunc->PCToLine(line));
|
||||
throw err;
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DObject, ThrowAbortException)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue