Skip to content

Commit

Permalink
add unsafe clearscope, to allow declaring clearscope fields outside o…
Browse files Browse the repository at this point in the history
…f gzdoom.pk3
  • Loading branch information
RicardoLuis0 committed Feb 7, 2025
1 parent 8c821a1 commit adfefdc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/common/scripting/frontend/zcc-parse.lemon
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ decl_flag(X) ::= VARARG(T). { X.Int = ZCC_VarArg; X.SourceLoc = T.SourceLoc;
decl_flag(X) ::= UI(T). { X.Int = ZCC_UIFlag; X.SourceLoc = T.SourceLoc; }
decl_flag(X) ::= PLAY(T). { X.Int = ZCC_Play; X.SourceLoc = T.SourceLoc; }
decl_flag(X) ::= CLEARSCOPE(T). { X.Int = ZCC_ClearScope; X.SourceLoc = T.SourceLoc; }
decl_flag(X) ::= UNSAFE(T) LPAREN CLEARSCOPE RPAREN. { X.Int = ZCC_UnsafeClearScope; X.SourceLoc = T.SourceLoc; }
decl_flag(X) ::= VIRTUALSCOPE(T). { X.Int = ZCC_VirtualScope; X.SourceLoc = T.SourceLoc; }

func_const(X) ::= . { X.Int = 0; X.SourceLoc = stat->sc->GetMessageLine(); }
Expand Down
4 changes: 2 additions & 2 deletions src/common/scripting/frontend/zcc_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ bool ZCCCompiler::CompileFields(PContainerType *type, TArray<ZCC_VarDeclarator *
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_UI);
if (field->Flags & ZCC_Play)
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_Play);
if (field->Flags & ZCC_ClearScope)
if (field->Flags & (ZCC_ClearScope | ZCC_UnsafeClearScope))
varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_PlainData);
}
else
Expand Down Expand Up @@ -2315,7 +2315,7 @@ void ZCCCompiler::SetImplicitArgs(TArray<PType*>* args, TArray<uint32_t>* argfla
if (funcflags & VARF_Method)
{
// implied self pointer
if (args != nullptr) args->Push(NewPointer(cls, !!(funcflags & VARF_ReadOnly)));
if (args != nullptr) args->Push(NewPointer(cls, (funcflags & VARF_SafeConst)));
if (argflags != nullptr) argflags->Push(VARF_Implicit | VARF_ReadOnly);
if (argnames != nullptr) argnames->Push(NAME_self);
}
Expand Down
51 changes: 26 additions & 25 deletions src/common/scripting/frontend/zcc_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,32 @@ struct ZCCToken
// Variable / Function / Class modifiers
enum
{
ZCC_Native = 1 << 0,
ZCC_Static = 1 << 1,
ZCC_Private = 1 << 2,
ZCC_Protected = 1 << 3,
ZCC_Latent = 1 << 4,
ZCC_Final = 1 << 5,
ZCC_Meta = 1 << 6,
ZCC_Action = 1 << 7,
ZCC_Deprecated = 1 << 8,
ZCC_ReadOnly = 1 << 9,
ZCC_FuncConst = 1 << 10,
ZCC_Abstract = 1 << 11,
ZCC_Extension = 1 << 12,
ZCC_Virtual = 1 << 13,
ZCC_Override = 1 << 14,
ZCC_Transient = 1 << 15,
ZCC_VarArg = 1 << 16,
ZCC_UIFlag = 1 << 17, // there's also token called ZCC_UI
ZCC_Play = 1 << 18,
ZCC_ClearScope = 1 << 19,
ZCC_VirtualScope = 1 << 20,
ZCC_Version = 1 << 21,
ZCC_Internal = 1 << 22,
ZCC_Sealed = 1 << 23,
ZCC_FuncConstUnsafe = 1 << 24,
ZCC_Native = 1 << 0,
ZCC_Static = 1 << 1,
ZCC_Private = 1 << 2,
ZCC_Protected = 1 << 3,
ZCC_Latent = 1 << 4,
ZCC_Final = 1 << 5,
ZCC_Meta = 1 << 6,
ZCC_Action = 1 << 7,
ZCC_Deprecated = 1 << 8,
ZCC_ReadOnly = 1 << 9,
ZCC_FuncConst = 1 << 10,
ZCC_Abstract = 1 << 11,
ZCC_Extension = 1 << 12,
ZCC_Virtual = 1 << 13,
ZCC_Override = 1 << 14,
ZCC_Transient = 1 << 15,
ZCC_VarArg = 1 << 16,
ZCC_UIFlag = 1 << 17, // there's also token called ZCC_UI
ZCC_Play = 1 << 18,
ZCC_ClearScope = 1 << 19,
ZCC_VirtualScope = 1 << 20,
ZCC_Version = 1 << 21,
ZCC_Internal = 1 << 22,
ZCC_Sealed = 1 << 23,
ZCC_FuncConstUnsafe = 1 << 24,
ZCC_UnsafeClearScope = 1 << 25,
};

// Function parameter modifiers
Expand Down

0 comments on commit adfefdc

Please sign in to comment.