Browse Source

* 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

Sven/Sarah Barth 3 years ago
parent
commit
30a7199165
5 changed files with 8 additions and 9 deletions
  1. 2 1
      compiler/ncgvmt.pas
  2. 4 3
      compiler/nobj.pas
  3. 1 1
      compiler/ppu.pas
  4. 0 2
      compiler/symconst.pas
  5. 1 2
      compiler/symdef.pas

+ 2 - 1
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);

+ 4 - 3
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

+ 1 - 1
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;

+ 0 - 2
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$',

+ 1 - 2
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