mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-11 21:00:53 +00:00
- added type checks for DynArray.Copy and Move and fixed parameter processing.
This commit is contained in:
parent
96b2cb0a45
commit
f77a528e13
1 changed files with 14 additions and 5 deletions
|
@ -7781,18 +7781,27 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
||||||
{
|
{
|
||||||
// Copy and Move must turn their parameter into a pointer to the backing struct type.
|
// Copy and Move must turn their parameter into a pointer to the backing struct type.
|
||||||
auto backingtype = static_cast<PDynArray*>(a->ValueType)->BackingType;
|
auto backingtype = static_cast<PDynArray*>(a->ValueType)->BackingType;
|
||||||
|
if (elementType != static_cast<PDynArray*>(a->ValueType)->ElementType)
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "Type mismatch in function argument");
|
||||||
|
delete this;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
bool writable;
|
||||||
|
if (!a->RequestAddress(ctx, &writable))
|
||||||
|
{
|
||||||
|
ScriptPosition.Message(MSG_ERROR, "Unable to dereference array variable");
|
||||||
|
delete this;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
a->ValueType = NewPointer(backingtype);
|
a->ValueType = NewPointer(backingtype);
|
||||||
|
|
||||||
// Also change the field's type so the code generator can work with this (actually this requires swapping out the entire field.)
|
// Also change the field's type so the code generator can work with this (actually this requires swapping out the entire field.)
|
||||||
if (Self->ExprType == EFX_StructMember || Self->ExprType == EFX_ClassMember || Self->ExprType == EFX_StackVariable)
|
if (Self->ExprType == EFX_StructMember || Self->ExprType == EFX_ClassMember || Self->ExprType == EFX_StackVariable)
|
||||||
{
|
{
|
||||||
auto member = static_cast<FxMemberBase*>(a);
|
auto member = static_cast<FxMemberBase*>(Self);
|
||||||
auto newfield = new PField(NAME_None, backingtype, 0, member->membervar->Offset);
|
auto newfield = new PField(NAME_None, backingtype, 0, member->membervar->Offset);
|
||||||
member->membervar = newfield;
|
member->membervar = newfield;
|
||||||
Self = nullptr;
|
|
||||||
delete this;
|
|
||||||
member->ValueType = TypeUInt32;
|
|
||||||
return member;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (a->IsPointer() && Self->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
|
else if (a->IsPointer() && Self->ValueType->IsKindOf(RUNTIME_CLASS(PPointer)))
|
||||||
|
|
Loading…
Reference in a new issue