From 0a7aebae93589d7cdb2009724647b915e821c855 Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Sat, 4 Mar 2017 20:55:59 +0200 Subject: [PATCH] Fixed const method qualifier. Also, fixed: const is not clearscope, treat differently. --- src/scripting/zscript/zcc_compile.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index f8e9980a25..5519d21664 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2128,8 +2128,8 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool varflags |= VARF_UI; if (c->Type()->ObjectFlags & OF_Play) varflags |= VARF_Play; - if (f->Flags & ZCC_FuncConst) - varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_PlainData); // const implies clearscope. this is checked a bit later to also not have ZCC_Play/ZCC_UIFlag. + //if (f->Flags & ZCC_FuncConst) + // varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_PlainData); // const implies clearscope. this is checked a bit later to also not have ZCC_Play/ZCC_UIFlag. if (f->Flags & ZCC_UIFlag) varflags = FScopeBarrier::ChangeSideInFlags(varflags, FScopeBarrier::Side_UI); if (f->Flags & ZCC_Play) @@ -2216,13 +2216,6 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool Error(f, "'VirtualScope' on a static method is not supported"); } - // you can't have a const function belonging to either ui or play. - // const is intended for plain data to signify that you can call a method on readonly variable. - if ((f->Flags & ZCC_FuncConst) && (f->Flags & (ZCC_UIFlag | ZCC_Play | ZCC_VirtualScope))) - { - Error(f, "Invalid combination of qualifiers %s on function %s", FlagsToString(f->Flags&(ZCC_FuncConst | ZCC_UIFlag | ZCC_Play | ZCC_VirtualScope)).GetChars(), FName(f->Name).GetChars()); - } - static int excludescope[] = { ZCC_UIFlag, ZCC_Play, ZCC_ClearScope, ZCC_VirtualScope }; excludeflags = 0; fc = 0; @@ -2458,9 +2451,9 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool Error(f, "Attempt to change scope for virtual function %s", FName(f->Name).GetChars()); } // you can't change const qualifier for a virtual method - if (oldfunc->FuncConst != sym->Variants[0].Implementation->FuncConst) + if (sym->Variants[0].Implementation->FuncConst && !oldfunc->FuncConst) { - Error(f, "Attempt to change const qualifier for virtual function %s", FName(f->Name).GetChars()); + Error(f, "Attempt to add const qualifier to virtual function %s", FName(f->Name).GetChars()); } // inherit scope of original function if override not specified sym->Variants[0].Implementation->BarrierSide = oldfunc->BarrierSide;