Fixed: clearscope should also clear the inherited scope (through struct member access chain); Fixed: struct member access chain should ONLY work for structs (forgot that FxClassMember inherits FxStructMember)
This commit is contained in:
parent
723f9770a4
commit
c9a994a885
7 changed files with 42 additions and 36 deletions
|
|
@ -6879,7 +6879,7 @@ FxExpression *FxStructMember::Resolve(FCompileContext &ctx)
|
|||
}
|
||||
|
||||
BarrierSide = scopeBarrier.sidelast;
|
||||
if (classx->ExprType == EFX_StructMember) // note: only do this for structs now
|
||||
if (classx->ExprType == EFX_StructMember && ExprType == EFX_StructMember) // note: only do this for structs now
|
||||
{
|
||||
FxStructMember* pmember = (FxStructMember*)classx;
|
||||
if (BarrierSide == FScopeBarrier::Side_PlainData && pmember)
|
||||
|
|
@ -8175,11 +8175,14 @@ isresolved:
|
|||
innerside = FScopeBarrier::SideFromObjectFlags(cls->ObjectFlags);
|
||||
innerflags = FScopeBarrier::FlagsFromSide(innerside);
|
||||
}
|
||||
if (Self->ExprType == EFX_StructMember)
|
||||
else if (innerside != FScopeBarrier::Side_Clear)
|
||||
{
|
||||
FxStructMember* pmember = (FxStructMember*)Self;
|
||||
if (innerside == FScopeBarrier::Side_PlainData)
|
||||
innerflags = FScopeBarrier::ChangeSideInFlags(innerflags, pmember->BarrierSide);
|
||||
if (Self->ExprType == EFX_StructMember)
|
||||
{
|
||||
FxStructMember* pmember = (FxStructMember*)Self;
|
||||
if (innerside == FScopeBarrier::Side_PlainData)
|
||||
innerflags = FScopeBarrier::ChangeSideInFlags(innerflags, pmember->BarrierSide);
|
||||
}
|
||||
}
|
||||
FScopeBarrier scopeBarrier(outerflags, innerflags, MethodName.GetChars());
|
||||
if (!scopeBarrier.callable)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ struct FScopeBarrier
|
|||
Side_PlainData = 0,
|
||||
Side_UI = 1,
|
||||
Side_Play = 2,
|
||||
Side_Virtual = 3 // do NOT change the value
|
||||
Side_Virtual = 3, // do NOT change the value
|
||||
Side_Clear = 4
|
||||
};
|
||||
int sidefrom;
|
||||
int sidelast;
|
||||
|
|
@ -103,6 +104,8 @@ struct FScopeBarrier
|
|||
return Side_Play;
|
||||
if (flags & VARF_VirtualScope)
|
||||
return Side_Virtual;
|
||||
if (flags & VARF_ClearScope)
|
||||
return Side_Clear;
|
||||
return Side_PlainData;
|
||||
}
|
||||
|
||||
|
|
@ -127,6 +130,8 @@ struct FScopeBarrier
|
|||
return VARF_UI;
|
||||
case Side_Virtual:
|
||||
return VARF_VirtualScope;
|
||||
case Side_Clear:
|
||||
return VARF_ClearScope;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -144,7 +149,9 @@ struct FScopeBarrier
|
|||
case Side_Play:
|
||||
return "play";
|
||||
case Side_Virtual:
|
||||
return "virtual"; // should not happen!
|
||||
return "virtualscope"; // should not happen!
|
||||
case Side_Clear:
|
||||
return "clearscope"; // should not happen!
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
|
|
@ -153,7 +160,7 @@ struct FScopeBarrier
|
|||
// this modifies VARF_ flags and sets the side properly.
|
||||
static int ChangeSideInFlags(int flags, int side)
|
||||
{
|
||||
flags &= ~(VARF_UI | VARF_Play | VARF_VirtualScope);
|
||||
flags &= ~(VARF_UI | VARF_Play | VARF_VirtualScope | VARF_ClearScope);
|
||||
flags |= FlagsFromSide(side);
|
||||
return flags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2135,7 +2135,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
if (f->Flags & ZCC_Play)
|
||||
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_Play);
|
||||
if (f->Flags & ZCC_ClearScope)
|
||||
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_PlainData);
|
||||
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_Clear);
|
||||
if (f->Flags & ZCC_VirtualScope)
|
||||
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_Virtual);
|
||||
|
||||
|
|
@ -2405,12 +2405,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
|||
if (sym->Variants[0].Implementation != nullptr)
|
||||
{
|
||||
// [ZZ] unspecified virtual function inherits old scope. virtual function scope can't be changed.
|
||||
if (varflags & VARF_UI)
|
||||
sym->Variants[0].Implementation->BarrierSide = FScopeBarrier::Side_UI;
|
||||
if (varflags & VARF_Play)
|
||||
sym->Variants[0].Implementation->BarrierSide = FScopeBarrier::Side_Play;
|
||||
if (varflags & VARF_VirtualScope)
|
||||
sym->Variants[0].Implementation->BarrierSide = FScopeBarrier::Side_Virtual;
|
||||
sym->Variants[0].Implementation->BarrierSide = FScopeBarrier::SideFromFlags(varflags);
|
||||
}
|
||||
|
||||
PClass *clstype = static_cast<PClass *>(c->Type());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue