From 30a7199165e96728ee8ab899209fe83ed775454d Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Sun, 30 Jan 2022 17:23:40 +0100 Subject: [PATCH] * make the VMT symbol and type def of the corresponding class or object instead of having them be global * bump PPU version to avoid potential compilation errors due to this Based on code by Blaise.ru --- compiler/ncgvmt.pas | 3 ++- compiler/nobj.pas | 7 ++++--- compiler/ppu.pas | 2 +- compiler/symconst.pas | 2 -- compiler/symdef.pas | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/compiler/ncgvmt.pas b/compiler/ncgvmt.pas index 03c34bbe23..036082b4fb 100644 --- a/compiler/ncgvmt.pas +++ b/compiler/ncgvmt.pas @@ -1083,8 +1083,9 @@ implementation { reuse the type created in nobj, so we get internal consistency checking for free } - vmttypesym:=try_search_current_module_type(internaltypeprefixName[itp_vmtdef]+_class.mangledparaname); + vmttypesym:=ttypesym(_class.symtable.find('vmtdef')); if not assigned(vmttypesym) or + (vmttypesym.typ<>typesym) or (vmttypesym.typedef.typ<>recorddef) then internalerror(2015071403); vmtdef:=trecorddef(vmttypesym.typedef); diff --git a/compiler/nobj.pas b/compiler/nobj.pas index dc32ceb145..48f2b27c55 100644 --- a/compiler/nobj.pas +++ b/compiler/nobj.pas @@ -831,10 +831,11 @@ implementation exit; { create VMT type definition } - vmtdef:=crecorddef.create_global_internal( - internaltypeprefixName[itp_vmtdef]+_class.mangledparaname, + vmtdef:=crecorddef.create_internal( + '$vmtdef', 0, - target_info.alignment.recordalignmin); + target_info.alignment.recordalignmin, + _class.symtable); {$ifdef llvm} { in case of a class declared in the implementation section of unit whose method is called from an inline routine -- LLVM needs to be able diff --git a/compiler/ppu.pas b/compiler/ppu.pas index 6b262a1abc..11b8a611f2 100644 --- a/compiler/ppu.pas +++ b/compiler/ppu.pas @@ -48,7 +48,7 @@ const CurrentPPUVersion = 208; { for any other changes to the ppu format, increase this version number (it's a cardinal) } - CurrentPPULongVersion = 15; + CurrentPPULongVersion = 16; { unit flags } uf_big_endian = $000004; diff --git a/compiler/symconst.pas b/compiler/symconst.pas index d0cd60fd1c..aa34ad7e56 100644 --- a/compiler/symconst.pas +++ b/compiler/symconst.pas @@ -755,7 +755,6 @@ type itp_1byte, itp_emptyrec, itp_llvmstruct, - itp_vmtdef, itp_vmt_tstringmesssagetable, itp_vmt_msgint_table_entries, itp_vmt_tmethod_name_table, @@ -909,7 +908,6 @@ inherited_objectoptions : tobjectoptions = [oo_has_virtual,oo_has_private,oo_has '$1byte$', '$emptyrec', '$llvmstruct$', - '$vmtdef$', '$vmt_TStringMesssageTable$', '$vmt_msgint_table_entries$', '$vmt_tmethod_name_table$', diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 6a48d9b774..7a83399edd 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -8104,8 +8104,7 @@ implementation begin if not is_unique_objpasdef then begin - where:=get_top_level_symtable(true); - vmttypesym:=where.Find('vmtdef$'+mangledparaname); + vmttypesym:=symtable.Find('vmtdef'); if not assigned(vmttypesym) or (vmttypesym.typ<>symconst.typesym) or (ttypesym(vmttypesym).typedef.typ<>recorddef) then