- native meta variables are not needed anymore. They were only a temporary aid to properly handle this, but now all have been redone.

This commit is contained in:
Christoph Oelckers 2017-02-28 14:38:50 +01:00
parent bc0ffc4185
commit 168627f549
3 changed files with 21 additions and 29 deletions

View file

@ -6871,7 +6871,7 @@ ExpEmit FxStructMember::Emit(VMFunctionBuilder *build)
{ {
obj.Free(build); obj.Free(build);
ExpEmit meta(build, REGT_POINTER); ExpEmit meta(build, REGT_POINTER);
build->Emit(membervar->Flags & VARF_Native? OP_CLSS : OP_META, meta.RegNum, obj.RegNum); build->Emit(OP_META, meta.RegNum, obj.RegNum);
obj = meta; obj = meta;
} }

View file

@ -827,14 +827,7 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul
if (i > 0) sc.MustGetStringName(","); if (i > 0) sc.MustGetStringName(",");
if (f->Flags & VARF_Meta) if (f->Flags & VARF_Meta)
{ {
if (f->Flags & VARF_Native) addr = ((char*)bag.Info->Meta) + f->Offset;
{
addr = ((char*)bag.Info) + f->Offset;
}
else
{
addr = ((char*)bag.Info->Meta) + f->Offset;
}
} }
else else
{ {

View file

@ -1095,22 +1095,28 @@ bool ZCCCompiler::CompileFields(PStruct *type, TArray<ZCC_VarDeclarator *> &Fiel
if (varflags & VARF_Native) if (varflags & VARF_Native)
{ {
auto querytype = (varflags & VARF_Meta) ? type->GetClass() : type; if (varflags & VARF_Meta)
fd = FindField(querytype, FName(name->Name).GetChars());
if (fd == nullptr)
{ {
Error(field, "The member variable '%s.%s' has not been exported from the executable.", type->TypeName.GetChars(), FName(name->Name).GetChars()); Error(field, "Native meta variable %s not allowed", FName(name->Name).GetChars());
} }
else if (thisfieldtype->Size != fd->FieldSize && fd->BitValue == 0)
{
Error(field, "The member variable '%s.%s' has mismatching sizes in internal and external declaration. (Internal = %d, External = %d)", type->TypeName.GetChars(), FName(name->Name).GetChars(), fd->FieldSize, thisfieldtype->Size);
}
// Q: Should we check alignment, too? A mismatch may be an indicator for bad assumptions.
else else
{ {
// for bit fields the type must point to the source variable. fd = FindField(type, FName(name->Name).GetChars());
if (fd->BitValue != 0) thisfieldtype = fd->FieldSize == 1 ? TypeUInt8 : fd->FieldSize == 2 ? TypeUInt16 : TypeUInt32; if (fd == nullptr)
type->AddNativeField(name->Name, thisfieldtype, fd->FieldOffset, varflags, fd->BitValue); {
Error(field, "The member variable '%s.%s' has not been exported from the executable.", type->TypeName.GetChars(), FName(name->Name).GetChars());
}
else if (thisfieldtype->Size != fd->FieldSize && fd->BitValue == 0)
{
Error(field, "The member variable '%s.%s' has mismatching sizes in internal and external declaration. (Internal = %d, External = %d)", type->TypeName.GetChars(), FName(name->Name).GetChars(), fd->FieldSize, thisfieldtype->Size);
}
// Q: Should we check alignment, too? A mismatch may be an indicator for bad assumptions.
else
{
// for bit fields the type must point to the source variable.
if (fd->BitValue != 0) thisfieldtype = fd->FieldSize == 1 ? TypeUInt8 : fd->FieldSize == 2 ? TypeUInt16 : TypeUInt32;
type->AddNativeField(name->Name, thisfieldtype, fd->FieldOffset, varflags, fd->BitValue);
}
} }
} }
else if (hasnativechildren) else if (hasnativechildren)
@ -1694,14 +1700,7 @@ void ZCCCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *prop
if (f->Flags & VARF_Meta) if (f->Flags & VARF_Meta)
{ {
if (f->Flags & VARF_Native) addr = ((char*)bag.Info->Meta) + f->Offset;
{
addr = ((char*)bag.Info) + f->Offset;
}
else
{
addr = ((char*)bag.Info->Meta) + f->Offset;
}
} }
else else
{ {