From c2b37aeeea85a3774a5c19c3411f466fa62773c1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 22 Oct 2016 19:43:53 +0200 Subject: [PATCH] - fixed a conversion warning with the pointer-type AActor fields. - added master and tracer to the list of exported variables. - fixed: 'none' as class type must map to the real null pointer so that it won't get rejected by the stricter type checks. - added handling for member function calls to zcc_compile.cpp. - fixed: FxMemberFunctionCall may not delete the self expression if it gets passed on to the actual function call. --- src/dobjtype.h | 2 +- src/namedef.h | 2 ++ src/scripting/codegeneration/codegen.cpp | 8 +++++++- src/scripting/thingdef_data.cpp | 2 ++ src/scripting/zscript/zcc_compile.cpp | 6 +++++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dobjtype.h b/src/dobjtype.h index c5d96972b..f3e043bd9 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -574,7 +574,7 @@ class PField : public PSymbol public: PField(FName name, PType *type) : PSymbol(name), Offset(0), Type(type), Flags(0) {} PField(FName name, PType *type, DWORD flags) : PSymbol(name), Offset(0), Type(type), Flags(flags) {} - PField(FName name, PType *type, DWORD flags, unsigned offset) : PSymbol(name), Offset(offset), Type(type), Flags(flags) {} + PField(FName name, PType *type, DWORD flags, size_t offset) : PSymbol(name), Offset(unsigned(offset)), Type(type), Flags(flags) {} unsigned int Offset; PType *Type; diff --git a/src/namedef.h b/src/namedef.h index d512a7948..973557874 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -437,6 +437,8 @@ xx(ScaleX) xx(ScaleY) xx(Floatbobphase) xx(Target) +xx(Master) +xx(Tracer) xx(Blocking) xx(Blockmonsters) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index c4a466873..c7cd6e524 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -4975,6 +4975,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx) auto self = !(afd->Variants[0].Flags & VARF_Static) ? Self : nullptr; auto x = new FxVMFunctionCall(self, afd, ArgList, ScriptPosition, staticonly); ArgList = nullptr; + if (Self == self) Self = nullptr; delete this; return x->Resolve(ctx); } @@ -6226,6 +6227,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) { FName clsname = static_cast(basex)->GetValue().GetName(); PClass *cls = NULL; + FxExpression *x; if (clsname != NAME_None) { @@ -6248,8 +6250,12 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) } ScriptPosition.Message(MSG_DEBUG, "resolving '%s' as class name", clsname.GetChars()); } + x = new FxConstant(cls, ScriptPosition); + } + else + { + x = new FxConstant(ScriptPosition); // create a genuine null pointer to get past the type checks. } - FxExpression *x = new FxConstant(cls, ScriptPosition); delete this; return x; } diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 260cc6408..7e0668a0f 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -677,4 +677,6 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_VisibleEndAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndAngle))); symt.AddSymbol(new PField(NAME_VisibleEndPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndPitch))); symt.AddSymbol(new PField(NAME_Target, TypeActor, VARF_Native, myoffsetof(AActor, target))); + symt.AddSymbol(new PField(NAME_Master, TypeActor, VARF_Native, myoffsetof(AActor, master))); + symt.AddSymbol(new PField(NAME_Tracer, TypeActor, VARF_Native, myoffsetof(AActor, tracer))); } diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index e702f7d2a..5d309bedc 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2381,7 +2381,11 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast) return new FxFunctionCall(static_cast(fcall->Function)->Identifier, NAME_None, ConvertNodeList(fcall->Parameters), *ast); case AST_ExprMemberAccess: - break; + { + auto ema = static_cast(fcall->Function); + Printf("Member call to %s\n", FName(ema->Right).GetChars()); + return new FxMemberFunctionCall(ConvertNode(ema->Left), ema->Right, ConvertNodeList(fcall->Parameters), *ast); + } case AST_ExprBinary: // Array syntax for randoms. They are internally stored as ExprBinary with both an identifier on the left and right side.