- pass a proper self pointer to BuiltinCallActionSpecial instead of making bogus assumptions about a function's parameters.

This commit is contained in:
Christoph Oelckers 2016-12-11 21:32:19 +01:00
parent b43609c701
commit e61ae9a1f9

View file

@ -7083,7 +7083,7 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
delete this; delete this;
return nullptr; return nullptr;
} }
FxExpression *self = (ctx.Function && ctx.Function->Variants[0].Flags & VARF_Method) ? new FxSelf(ScriptPosition) : nullptr; FxExpression *self = (ctx.Function && ctx.Function->Variants[0].Flags & VARF_Method) ? new FxSelf(ScriptPosition) : (FxExpression*)new FxConstant(ScriptPosition);
FxExpression *x = new FxActionSpecialCall(self, special, ArgList, ScriptPosition); FxExpression *x = new FxActionSpecialCall(self, special, ArgList, ScriptPosition);
delete this; delete this;
return x->Resolve(ctx); return x->Resolve(ctx);
@ -7655,9 +7655,9 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
unsigned i = 0; unsigned i = 0;
build->Emit(OP_PARAMI, abs(Special)); // pass special number build->Emit(OP_PARAMI, abs(Special)); // pass special number
// fixme: This really should use the Self pointer that got passed to this class instead of just using the first argument from the function.
// Once static functions are possible, or specials can be called through a member access operator this won't work anymore. ExpEmit selfemit(Self->Emit(build));
build->Emit(OP_PARAM, 0, REGT_POINTER, 0); // pass self build->Emit(OP_PARAM, 0, selfemit.Konst ? REGT_POINTER | REGT_KONST : REGT_POINTER, selfemit.RegNum); // pass special number
for (; i < ArgList.Size(); ++i) for (; i < ArgList.Size(); ++i)
{ {
FxExpression *argex = ArgList[i]; FxExpression *argex = ArgList[i];