Browse Source

+ add a constructor for trecorddef to declare an internal record type as part of a specific other type

Based on code by Blaise.ru
Sven/Sarah Barth 3 years ago
parent
commit
5cf15be434
1 changed files with 13 additions and 5 deletions
  1. 13 5
      compiler/symdef.pas

+ 13 - 5
compiler/symdef.pas

@@ -389,6 +389,7 @@ interface
           isunion       : boolean;
           isunion       : boolean;
           constructor create(const n:string; p:TSymtable);virtual;
           constructor create(const n:string; p:TSymtable);virtual;
           constructor create_global_internal(const n: string; packrecords, recordalignmin: shortint); virtual;
           constructor create_global_internal(const n: string; packrecords, recordalignmin: shortint); virtual;
+          constructor create_internal(const n: string; packrecords, recordalignmin: shortint; where: tsymtable); virtual;
           function add_field_by_def(const optionalname: TIDString; def: tdef): tsym;
           function add_field_by_def(const optionalname: TIDString; def: tdef): tsym;
           procedure add_fields_from_deflist(fieldtypes: tfplist);
           procedure add_fields_from_deflist(fieldtypes: tfplist);
           constructor ppuload(ppufile:tcompilerppufile);
           constructor ppuload(ppufile:tcompilerppufile);
@@ -5092,12 +5093,11 @@ implementation
       end;
       end;
 
 
 
 
-    constructor trecorddef.create_global_internal(const n: string; packrecords, recordalignmin: shortint);
+    constructor trecorddef.create_internal(const n: string; packrecords, recordalignmin: shortint; where: tsymtable);
       var
       var
         name : string;
         name : string;
         pname : pshortstring;
         pname : pshortstring;
         oldsymtablestack: tsymtablestack;
         oldsymtablestack: tsymtablestack;
-        where : tsymtable;
         ts: ttypesym;
         ts: ttypesym;
       begin
       begin
         { construct name }
         { construct name }
@@ -5118,9 +5118,6 @@ implementation
         symtable.defowner:=self;
         symtable.defowner:=self;
         isunion:=false;
         isunion:=false;
         inherited create(pname^,recorddef,true);
         inherited create(pname^,recorddef,true);
-        where:=current_module.localsymtable;
-        if not assigned(where) then
-          where:=current_module.globalsymtable;
         where.insertdef(self);
         where.insertdef(self);
         { if we specified a name, then we'll probably want to look up the
         { if we specified a name, then we'll probably want to look up the
           type again by name too -> create typesym }
           type again by name too -> create typesym }
@@ -5140,6 +5137,17 @@ implementation
       end;
       end;
 
 
 
 
+    constructor trecorddef.create_global_internal(const n: string; packrecords, recordalignmin: shortint);
+      var
+        where : tsymtable;
+      begin
+        where:=current_module.localsymtable;
+        if not assigned(where) then
+          where:=current_module.globalsymtable;
+        create_internal(n,packrecords,recordalignmin,where);
+      end;
+
+
     function trecorddef.add_field_by_def(const optionalname: TIDString; def: tdef): tsym;
     function trecorddef.add_field_by_def(const optionalname: TIDString; def: tdef): tsym;
       var
       var
         sym: tfieldvarsym;
         sym: tfieldvarsym;