From dd92a972f5d007cf02033015ccb6ac196cdd9820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 4 Mar 2025 08:59:03 -0300 Subject: [PATCH] rename vm internal structs to make room for compilation-unit-internal structs/classes --- src/common/scripting/core/types.h | 2 +- src/common/scripting/frontend/zcc-parse.lemon | 12 ++-- src/common/scripting/frontend/zcc_compile.cpp | 6 +- src/common/scripting/frontend/zcc_parser.h | 49 +++++++------- wadsrc/static/zscript/engine/base.zs | 6 +- wadsrc/static/zscript/engine/dynarrays.zs | 16 ++--- wadsrc/static/zscript/engine/maps.zs | 64 +++++++++---------- 7 files changed, 78 insertions(+), 77 deletions(-) diff --git a/src/common/scripting/core/types.h b/src/common/scripting/core/types.h index 9b840c1f6..8ae8b92ea 100644 --- a/src/common/scripting/core/types.h +++ b/src/common/scripting/core/types.h @@ -109,7 +109,7 @@ public: EScopeFlags ScopeFlags = (EScopeFlags)0; bool SizeKnown = true; - bool TypeInternal = false; + bool VMInternalStruct = false; PType * LocalType = nullptr; diff --git a/src/common/scripting/frontend/zcc-parse.lemon b/src/common/scripting/frontend/zcc-parse.lemon index 10db694b9..eb136bde5 100644 --- a/src/common/scripting/frontend/zcc-parse.lemon +++ b/src/common/scripting/frontend/zcc-parse.lemon @@ -427,12 +427,12 @@ struct_def(X) ::= EXTEND STRUCT(T) IDENTIFIER(A) LBRACE opt_struct_body(B) RBRAC } %type struct_flags{ClassFlagsBlock} -struct_flags(X) ::= . { X.Flags = 0; X.Version = {0, 0}; } -struct_flags(X) ::= struct_flags(A) UI. { X.Flags = A.Flags | ZCC_UIFlag; } -struct_flags(X) ::= struct_flags(A) PLAY. { X.Flags = A.Flags | ZCC_Play; } -struct_flags(X) ::= struct_flags(A) CLEARSCOPE. { X.Flags = A.Flags | ZCC_ClearScope; } -struct_flags(X) ::= struct_flags(A) NATIVE. { X.Flags = A.Flags | ZCC_Native; } -struct_flags(X) ::= struct_flags(A) INTERNAL. { X.Flags = A.Flags | ZCC_Internal; } +struct_flags(X) ::= . { X.Flags = 0; X.Version = {0, 0}; } +struct_flags(X) ::= struct_flags(A) UI. { X.Flags = A.Flags | ZCC_UIFlag; X.Version = A.Version; } +struct_flags(X) ::= struct_flags(A) PLAY. { X.Flags = A.Flags | ZCC_Play; X.Version = A.Version; } +struct_flags(X) ::= struct_flags(A) CLEARSCOPE. { X.Flags = A.Flags | ZCC_ClearScope; X.Version = A.Version; } +struct_flags(X) ::= struct_flags(A) NATIVE. { X.Flags = A.Flags | ZCC_Native; X.Version = A.Version; } +struct_flags(X) ::= struct_flags(A) UNSAFE LPAREN INTERNAL RPAREN. { X.Flags = A.Flags | ZCC_VMInternalStruct; X.Version = A.Version; } struct_flags(X) ::= struct_flags(A) VERSION LPAREN STRCONST(C) RPAREN. { X.Flags = A.Flags | ZCC_Version; X.Version = C.String->GetChars(); } opt_struct_body(X) ::= . { X = NULL; } diff --git a/src/common/scripting/frontend/zcc_compile.cpp b/src/common/scripting/frontend/zcc_compile.cpp index e097c8f50..52163d772 100644 --- a/src/common/scripting/frontend/zcc_compile.cpp +++ b/src/common/scripting/frontend/zcc_compile.cpp @@ -751,11 +751,11 @@ void ZCCCompiler::CreateStructTypes() s->strct->Type->mVersion = s->strct->Version; } - if (s->strct->Flags & ZCC_Internal) + if (s->strct->Flags & ZCC_VMInternalStruct) { if(fileSystem.GetFileContainer(Lump) == 0) { - s->strct->Type->TypeInternal = true; + s->strct->Type->VMInternalStruct = true; } else { @@ -2191,7 +2191,7 @@ PType *ZCCCompiler::ResolveUserType(PType *outertype, ZCC_BasicType *type, ZCC_I } //only allow references to internal types inside internal types - if (ptype->TypeInternal && !outertype->TypeInternal) + if (ptype->VMInternalStruct && !outertype->VMInternalStruct) { Error(type, "Type %s not accessible", FName(type->UserType->Id).GetChars()); return TypeError; diff --git a/src/common/scripting/frontend/zcc_parser.h b/src/common/scripting/frontend/zcc_parser.h index d0b6264da..bf20f5cac 100644 --- a/src/common/scripting/frontend/zcc_parser.h +++ b/src/common/scripting/frontend/zcc_parser.h @@ -41,30 +41,31 @@ 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_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_VMInternalStruct = 1 << 24, }; // Function parameter modifiers diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index 14cedaed4..33c14eef6 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -189,7 +189,7 @@ struct Vector3 } */ -struct _ native internal // These are the global variables, the struct is only here to avoid extending the parser for this. +struct _ native unsafe(internal) // These are the global variables, the struct is only here to avoid extending the parser for this. { native readonly Array AllClasses; native internal readonly Map AllServices; @@ -903,7 +903,7 @@ enum EmptyTokenType // Although String is a builtin type, this is a convenient way to attach methods to it. // All of these methods are available on strings -struct StringStruct native internal +struct StringStruct native unsafe(internal) { native static vararg String Format(String fmt, ...); native vararg void AppendFormat(String fmt, ...); @@ -952,7 +952,7 @@ struct Translation version("2.4") } // Convenient way to attach functions to Quat -struct QuatStruct native internal +struct QuatStruct native unsafe(internal) { native static Quat SLerp(Quat from, Quat to, double t); native static Quat NLerp(Quat from, Quat to, double t); diff --git a/wadsrc/static/zscript/engine/dynarrays.zs b/wadsrc/static/zscript/engine/dynarrays.zs index 28f36b313..d21c70e1a 100644 --- a/wadsrc/static/zscript/engine/dynarrays.zs +++ b/wadsrc/static/zscript/engine/dynarrays.zs @@ -1,7 +1,7 @@ // The VM uses 7 integral data types, so for dynamic array support we need one specific set of functions for each of these types. // Do not use these structs directly, they are incomplete and only needed to create prototypes for the needed functions. -struct DynArray_I8 native internal +struct DynArray_I8 native unsafe(internal) { native readonly int Size; @@ -21,7 +21,7 @@ struct DynArray_I8 native internal native void Clear (); } -struct DynArray_I16 native internal +struct DynArray_I16 native unsafe(internal) { native readonly int Size; @@ -41,7 +41,7 @@ struct DynArray_I16 native internal native void Clear (); } -struct DynArray_I32 native internal +struct DynArray_I32 native unsafe(internal) { native readonly int Size; @@ -62,7 +62,7 @@ struct DynArray_I32 native internal native void Clear (); } -struct DynArray_F32 native internal +struct DynArray_F32 native unsafe(internal) { native readonly int Size; @@ -82,7 +82,7 @@ struct DynArray_F32 native internal native void Clear (); } -struct DynArray_F64 native internal +struct DynArray_F64 native unsafe(internal) { native readonly int Size; @@ -102,7 +102,7 @@ struct DynArray_F64 native internal native void Clear (); } -struct DynArray_Ptr native internal +struct DynArray_Ptr native unsafe(internal) { native readonly int Size; @@ -122,7 +122,7 @@ struct DynArray_Ptr native internal native void Clear (); } -struct DynArray_Obj native internal +struct DynArray_Obj native unsafe(internal) { native readonly int Size; @@ -142,7 +142,7 @@ struct DynArray_Obj native internal native void Clear (); } -struct DynArray_String native internal +struct DynArray_String native unsafe(internal) { native readonly int Size; diff --git a/wadsrc/static/zscript/engine/maps.zs b/wadsrc/static/zscript/engine/maps.zs index 0e71c3b05..dbc2f4dad 100644 --- a/wadsrc/static/zscript/engine/maps.zs +++ b/wadsrc/static/zscript/engine/maps.zs @@ -1,5 +1,5 @@ -struct Map_I32_I8 native internal +struct Map_I32_I8 native unsafe(internal) { native void Copy(Map_I32_I8 other); native void Move(Map_I32_I8 other); @@ -18,7 +18,7 @@ struct Map_I32_I8 native internal native void Remove(int key); } -struct MapIterator_I32_I8 native internal +struct MapIterator_I32_I8 native unsafe(internal) { native bool Init(Map_I32_I8 other); native bool ReInit(); @@ -31,7 +31,7 @@ struct MapIterator_I32_I8 native internal native void SetValue(int value); } -struct Map_I32_I16 native internal +struct Map_I32_I16 native unsafe(internal) { native void Copy(Map_I32_I16 other); native void Move(Map_I32_I16 other); @@ -50,7 +50,7 @@ struct Map_I32_I16 native internal native void Remove(int key); } -struct MapIterator_I32_I16 native internal +struct MapIterator_I32_I16 native unsafe(internal) { native bool Init(Map_I32_I16 other); native bool ReInit(); @@ -63,7 +63,7 @@ struct MapIterator_I32_I16 native internal native void SetValue(int value); } -struct Map_I32_I32 native internal +struct Map_I32_I32 native unsafe(internal) { native void Copy(Map_I32_I32 other); native void Move(Map_I32_I32 other); @@ -82,7 +82,7 @@ struct Map_I32_I32 native internal native void Remove(int key); } -struct MapIterator_I32_I32 native internal +struct MapIterator_I32_I32 native unsafe(internal) { native bool Init(Map_I32_I32 other); native bool ReInit(); @@ -95,7 +95,7 @@ struct MapIterator_I32_I32 native internal native void SetValue(int value); } -struct Map_I32_F32 native internal +struct Map_I32_F32 native unsafe(internal) { native void Copy(Map_I32_F32 other); native void Move(Map_I32_F32 other); @@ -114,7 +114,7 @@ struct Map_I32_F32 native internal native void Remove(int key); } -struct MapIterator_I32_F32 native internal +struct MapIterator_I32_F32 native unsafe(internal) { native bool Init(Map_I32_F32 other); native bool ReInit(); @@ -127,7 +127,7 @@ struct MapIterator_I32_F32 native internal native void SetValue(double value); } -struct Map_I32_F64 native internal +struct Map_I32_F64 native unsafe(internal) { native void Copy(Map_I32_F64 other); native void Move(Map_I32_F64 other); @@ -146,7 +146,7 @@ struct Map_I32_F64 native internal native void Remove(int key); } -struct MapIterator_I32_F64 native internal +struct MapIterator_I32_F64 native unsafe(internal) { native bool Init(Map_I32_F64 other); native bool ReInit(); @@ -159,7 +159,7 @@ struct MapIterator_I32_F64 native internal native void SetValue(double value); } -struct Map_I32_Obj native internal +struct Map_I32_Obj native unsafe(internal) { native void Copy(Map_I32_Obj other); native void Move(Map_I32_Obj other); @@ -178,7 +178,7 @@ struct Map_I32_Obj native internal native void Remove(int key); } -struct MapIterator_I32_Obj native internal +struct MapIterator_I32_Obj native unsafe(internal) { native bool Init(Map_I32_Obj other); native bool ReInit(); @@ -191,7 +191,7 @@ struct MapIterator_I32_Obj native internal native void SetValue(Object value); } -struct Map_I32_Ptr native internal +struct Map_I32_Ptr native unsafe(internal) { native void Copy(Map_I32_Ptr other); native void Move(Map_I32_Ptr other); @@ -210,7 +210,7 @@ struct Map_I32_Ptr native internal native void Remove(int key); } -struct MapIterator_I32_Ptr native internal +struct MapIterator_I32_Ptr native unsafe(internal) { native bool Init(Map_I32_Ptr other); native bool Next(); @@ -220,7 +220,7 @@ struct MapIterator_I32_Ptr native internal native void SetValue(voidptr value); } -struct Map_I32_Str native internal +struct Map_I32_Str native unsafe(internal) { native void Copy(Map_I32_Str other); native void Move(Map_I32_Str other); @@ -239,7 +239,7 @@ struct Map_I32_Str native internal native void Remove(int key); } -struct MapIterator_I32_Str native internal +struct MapIterator_I32_Str native unsafe(internal) { native bool Init(Map_I32_Str other); native bool ReInit(); @@ -254,7 +254,7 @@ struct MapIterator_I32_Str native internal // --------------- -struct Map_Str_I8 native internal +struct Map_Str_I8 native unsafe(internal) { native void Copy(Map_Str_I8 other); native void Move(Map_Str_I8 other); @@ -273,7 +273,7 @@ struct Map_Str_I8 native internal native void Remove(String key); } -struct MapIterator_Str_I8 native internal +struct MapIterator_Str_I8 native unsafe(internal) { native bool Init(Map_Str_I8 other); native bool ReInit(); @@ -286,7 +286,7 @@ struct MapIterator_Str_I8 native internal native void SetValue(int value); } -struct Map_Str_I16 native internal +struct Map_Str_I16 native unsafe(internal) { native void Copy(Map_Str_I16 other); native void Move(Map_Str_I16 other); @@ -305,7 +305,7 @@ struct Map_Str_I16 native internal native void Remove(String key); } -struct MapIterator_Str_I16 native internal +struct MapIterator_Str_I16 native unsafe(internal) { native bool Init(Map_Str_I16 other); native bool ReInit(); @@ -318,7 +318,7 @@ struct MapIterator_Str_I16 native internal native void SetValue(int value); } -struct Map_Str_I32 native internal +struct Map_Str_I32 native unsafe(internal) { native void Copy(Map_Str_I32 other); native void Move(Map_Str_I32 other); @@ -337,7 +337,7 @@ struct Map_Str_I32 native internal native void Remove(String key); } -struct MapIterator_Str_I32 native internal +struct MapIterator_Str_I32 native unsafe(internal) { native bool Init(Map_Str_I32 other); native bool ReInit(); @@ -350,7 +350,7 @@ struct MapIterator_Str_I32 native internal native void SetValue(int value); } -struct Map_Str_F32 native internal +struct Map_Str_F32 native unsafe(internal) { native void Copy(Map_Str_F32 other); native void Move(Map_Str_F32 other); @@ -369,7 +369,7 @@ struct Map_Str_F32 native internal native void Remove(String key); } -struct MapIterator_Str_F32 native internal +struct MapIterator_Str_F32 native unsafe(internal) { native bool Init(Map_Str_F32 other); native bool ReInit(); @@ -382,7 +382,7 @@ struct MapIterator_Str_F32 native internal native void SetValue(double value); } -struct Map_Str_F64 native internal +struct Map_Str_F64 native unsafe(internal) { native void Copy(Map_Str_F64 other); native void Move(Map_Str_F64 other); @@ -401,7 +401,7 @@ struct Map_Str_F64 native internal native void Remove(String key); } -struct MapIterator_Str_F64 native internal +struct MapIterator_Str_F64 native unsafe(internal) { native bool Init(Map_Str_F64 other); native bool ReInit(); @@ -414,7 +414,7 @@ struct MapIterator_Str_F64 native internal native void SetValue(double value); } -struct Map_Str_Obj native internal +struct Map_Str_Obj native unsafe(internal) { native void Copy(Map_Str_Obj other); native void Move(Map_Str_Obj other); @@ -433,7 +433,7 @@ struct Map_Str_Obj native internal native void Remove(String key); } -struct MapIterator_Str_Obj native internal +struct MapIterator_Str_Obj native unsafe(internal) { native bool Init(Map_Str_Obj other); native bool ReInit(); @@ -446,7 +446,7 @@ struct MapIterator_Str_Obj native internal native void SetValue(Object value); } -struct Map_Str_Ptr native internal +struct Map_Str_Ptr native unsafe(internal) { native void Copy(Map_Str_Ptr other); native void Move(Map_Str_Ptr other); @@ -465,7 +465,7 @@ struct Map_Str_Ptr native internal native void Remove(String key); } -struct MapIterator_Str_Ptr native internal +struct MapIterator_Str_Ptr native unsafe(internal) { native bool Init(Map_Str_Ptr other); native bool ReInit(); @@ -478,7 +478,7 @@ struct MapIterator_Str_Ptr native internal native void SetValue(voidptr value); } -struct Map_Str_Str native internal +struct Map_Str_Str native unsafe(internal) { native void Copy(Map_Str_Str other); native void Move(Map_Str_Str other); @@ -497,7 +497,7 @@ struct Map_Str_Str native internal native void Remove(String key); } -struct MapIterator_Str_Str native internal +struct MapIterator_Str_Str native unsafe(internal) { native bool Init(Map_Str_Str other); native bool ReInit();