瀏覽代碼

* symtable change to classes
* range check generation and errors fixed, make cycle DEBUG=1 works
* memory leaks fixed

peter 24 年之前
父節點
當前提交
a7cf57524e
共有 100 個文件被更改,包括 7099 次插入7133 次删除
  1. 106 112
      compiler/aasm.pas
  2. 7 2
      compiler/assemble.pas
  3. 215 214
      compiler/browcol.pas
  4. 78 73
      compiler/browlog.pas
  5. 415 324
      compiler/cclasses.pas
  6. 11 3
      compiler/compiler.pas
  7. 7 2
      compiler/cresstr.pas
  8. 7 2
      compiler/export.pas
  9. 7 2
      compiler/finput.pas
  10. 20 15
      compiler/fmodule.pas
  11. 8 3
      compiler/gdb.pas
  12. 12 7
      compiler/gendef.pas
  13. 7 31
      compiler/globals.pas
  14. 306 251
      compiler/hcgdata.pas
  15. 23 18
      compiler/hcodegen.pas
  16. 96 84
      compiler/htypechk.pas
  17. 25 20
      compiler/i386/ag386att.pas
  18. 29 24
      compiler/i386/ag386bin.pas
  19. 23 18
      compiler/i386/ag386int.pas
  20. 22 17
      compiler/i386/ag386nsm.pas
  21. 181 177
      compiler/i386/cgai386.pas
  22. 31 26
      compiler/i386/cpuasm.pas
  23. 11 7
      compiler/i386/cpubase.pas
  24. 32 27
      compiler/i386/daopt386.pas
  25. 57 52
      compiler/i386/n386add.pas
  26. 15 10
      compiler/i386/n386bas.pas
  27. 161 179
      compiler/i386/n386cal.pas
  28. 59 76
      compiler/i386/n386cnv.pas
  29. 15 10
      compiler/i386/n386con.pas
  30. 25 20
      compiler/i386/n386flw.pas
  31. 25 20
      compiler/i386/n386ic.pas
  32. 114 135
      compiler/i386/n386inl.pas
  33. 95 94
      compiler/i386/n386ld.pas
  34. 14 9
      compiler/i386/n386mat.pas
  35. 56 57
      compiler/i386/n386mem.pas
  36. 9 4
      compiler/i386/n386opt.pas
  37. 16 11
      compiler/i386/n386set.pas
  38. 60 55
      compiler/i386/n386util.pas
  39. 25 20
      compiler/i386/popt386.pas
  40. 81 78
      compiler/i386/ra386.pas
  41. 48 45
      compiler/i386/ra386att.pas
  42. 40 36
      compiler/i386/ra386dir.pas
  43. 54 51
      compiler/i386/ra386int.pas
  44. 7 2
      compiler/i386/tgcpu.pas
  45. 7 2
      compiler/impdef.pas
  46. 9 3
      compiler/import.pas
  47. 7 2
      compiler/link.pas
  48. 1 1
      compiler/mdppc386.bat
  49. 92 76
      compiler/nadd.pas
  50. 8 3
      compiler/nbas.pas
  51. 148 141
      compiler/ncal.pas
  52. 8 3
      compiler/ncgbas.pas
  53. 76 91
      compiler/ncnv.pas
  54. 29 25
      compiler/ncon.pas
  55. 22 17
      compiler/nflw.pas
  56. 70 66
      compiler/ninl.pas
  57. 59 54
      compiler/nld.pas
  58. 39 41
      compiler/nmat.pas
  59. 69 64
      compiler/nmem.pas
  60. 8 5
      compiler/node.pas
  61. 8 3
      compiler/nopt.pas
  62. 21 16
      compiler/nset.pas
  63. 27 23
      compiler/ogbase.pas
  64. 46 41
      compiler/ogcoff.pas
  65. 33 28
      compiler/ogelf.pas
  66. 11 4
      compiler/options.pas
  67. 30 11
      compiler/parser.pas
  68. 8 17
      compiler/pass_1.pas
  69. 18 13
      compiler/pass_2.pas
  70. 15 10
      compiler/pbase.pas
  71. 91 89
      compiler/pdecl.pas
  72. 172 302
      compiler/pdecobj.pas
  73. 581 620
      compiler/pdecsub.pas
  74. 93 88
      compiler/pdecvar.pas
  75. 19 14
      compiler/pexports.pas
  76. 190 187
      compiler/pexpr.pas
  77. 129 146
      compiler/pmodules.pas
  78. 5 2
      compiler/ppheap.pas
  79. 97 101
      compiler/pstatmnt.pas
  80. 107 108
      compiler/psub.pas
  81. 88 83
      compiler/psystem.pas
  82. 99 94
      compiler/ptconst.pas
  83. 66 61
      compiler/ptype.pas
  84. 162 162
      compiler/rautils.pas
  85. 89 85
      compiler/regvars.pas
  86. 49 44
      compiler/scandir.inc
  87. 72 69
      compiler/scanner.pas
  88. 19 17
      compiler/script.pas
  89. 102 69
      compiler/symbase.pas
  90. 14 10
      compiler/symconst.pas
  91. 303 285
      compiler/symdef.pas
  92. 34 31
      compiler/symppu.pas
  93. 242 281
      compiler/symsym.pas
  94. 600 877
      compiler/symtable.pas
  95. 97 95
      compiler/symtype.pas
  96. 12 7
      compiler/targets/t_fbsd.pas
  97. 8 3
      compiler/targets/t_go32v1.pas
  98. 10 5
      compiler/targets/t_go32v2.pas
  99. 12 7
      compiler/targets/t_linux.pas
  100. 13 8
      compiler/targets/t_nwm.pas

+ 106 - 112
compiler/aasm.pas

@@ -27,7 +27,7 @@ unit aasm;
 interface
 interface
 
 
     uses
     uses
-       cutils,cobjects,cclasses,
+       cutils,cclasses,
        globtype,globals,systems;
        globtype,globals,systems;
 
 
     type
     type
@@ -99,8 +99,7 @@ interface
 
 
        TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
        TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
 
 
-       pasmsymbol = ^tasmsymbol;
-       tasmsymbol = object(tnamedindexobject)
+       tasmsymbol = class(TNamedIndexItem)
          defbind,
          defbind,
          bind      : TAsmsymbind;
          bind      : TAsmsymbind;
          typ       : TAsmsymtype;
          typ       : TAsmsymtype;
@@ -114,20 +113,19 @@ interface
          refs    : longint;
          refs    : longint;
          { alternate symbol which can be used for 'renaming' needed for
          { alternate symbol which can be used for 'renaming' needed for
            inlining }
            inlining }
-         altsymbol : pasmsymbol;
+         altsymbol : tasmsymbol;
          { is the symbol local for a procedure/function }
          { is the symbol local for a procedure/function }
          proclocal : boolean;
          proclocal : boolean;
          { is the symbol in the used list }
          { is the symbol in the used list }
          inusedlist : boolean;
          inusedlist : boolean;
-         constructor init(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
+         constructor create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
          procedure reset;
          procedure reset;
          function  is_used:boolean;
          function  is_used:boolean;
          procedure setaddress(sec:tsection;offset,len:longint);
          procedure setaddress(sec:tsection;offset,len:longint);
          procedure GenerateAltSymbol;
          procedure GenerateAltSymbol;
        end;
        end;
 
 
-       pasmlabel = ^tasmlabel;
-       tasmlabel = object(tasmsymbol)
+       tasmlabel = class(tasmsymbol)
 {$ifdef PACKENUMFIXED}
 {$ifdef PACKENUMFIXED}
          { this is set by the tai_label.Init }
          { this is set by the tai_label.Init }
          is_set,
          is_set,
@@ -140,10 +138,10 @@ interface
          is_set,
          is_set,
          is_addr : boolean;
          is_addr : boolean;
 {$endif}
 {$endif}
-         constructor init;
-         constructor initdata;
-         constructor initaddr;
-         function name:string;virtual;
+         constructor create;
+         constructor createdata;
+         constructor createaddr;
+         function getname:string;override;
        end;
        end;
 
 
 
 
@@ -177,12 +175,12 @@ interface
 {$ifdef PACKENUMFIXED}
 {$ifdef PACKENUMFIXED}
           is_global : boolean;
           is_global : boolean;
 {$endif}
 {$endif}
-          sym : pasmsymbol;
+          sym : tasmsymbol;
           size : longint;
           size : longint;
 {$ifndef PACKENUMFIXED}
 {$ifndef PACKENUMFIXED}
           is_global : boolean;
           is_global : boolean;
 {$endif}
 {$endif}
-          constructor Create(_sym:PAsmSymbol;siz:longint);
+          constructor Create(_sym:tasmsymbol;siz:longint);
           constructor Createname(const _name : string;siz:longint);
           constructor Createname(const _name : string;siz:longint);
           constructor Createname_global(const _name : string;siz:longint);
           constructor Createname_global(const _name : string;siz:longint);
           constructor Createdataname(const _name : string;siz:longint);
           constructor Createdataname(const _name : string;siz:longint);
@@ -190,8 +188,8 @@ interface
        end;
        end;
 
 
        tai_symbol_end = class(tai)
        tai_symbol_end = class(tai)
-          sym : pasmsymbol;
-          constructor Create(_sym:PAsmSymbol);
+          sym : tasmsymbol;
+          constructor Create(_sym:tasmsymbol);
           constructor Createname(const _name : string);
           constructor Createname(const _name : string);
        end;
        end;
 
 
@@ -199,11 +197,11 @@ interface
 {$ifdef PACKENUMFIXED}
 {$ifdef PACKENUMFIXED}
           is_global : boolean;
           is_global : boolean;
 {$endif}
 {$endif}
-          l : pasmlabel;
+          l : tasmlabel;
 {$ifndef PACKENUMFIXED}
 {$ifndef PACKENUMFIXED}
           is_global : boolean;
           is_global : boolean;
 {$endif}
 {$endif}
-          constructor Create(_l : pasmlabel);
+          constructor Create(_l : tasmlabel);
        end;
        end;
 
 
        tai_direct = class(tai)
        tai_direct = class(tai)
@@ -248,7 +246,7 @@ interface
 {$ifdef PACKENUMFIXED}
 {$ifdef PACKENUMFIXED}
           is_global : boolean;
           is_global : boolean;
 {$endif}
 {$endif}
-          sym  : pasmsymbol;
+          sym  : tasmsymbol;
           size : longint;
           size : longint;
 {$ifndef PACKENUMFIXED}
 {$ifndef PACKENUMFIXED}
           is_global : boolean;
           is_global : boolean;
@@ -267,11 +265,11 @@ interface
        end;
        end;
 
 
        tai_const_symbol = class(tai)
        tai_const_symbol = class(tai)
-          sym    : pasmsymbol;
+          sym    : tasmsymbol;
           offset : longint;
           offset : longint;
-          constructor Create(_sym:PAsmSymbol);
-          constructor Create_offset(_sym:PAsmSymbol;ofs:longint);
-          constructor Create_rva(_sym:PAsmSymbol);
+          constructor Create(_sym:tasmsymbol);
+          constructor Create_offset(_sym:tasmsymbol;ofs:longint);
+          constructor Create_rva(_sym:tasmsymbol);
           constructor Createname(const name:string);
           constructor Createname(const name:string);
           constructor Createname_offset(const name:string;ofs:longint);
           constructor Createname_offset(const name:string;ofs:longint);
           constructor Createname_rva(const name:string);
           constructor Createname_rva(const name:string);
@@ -368,8 +366,8 @@ type
       resourcesection,rttilist,
       resourcesection,rttilist,
       resourcestringlist         : taasmoutput;
       resourcestringlist         : taasmoutput;
     { asm symbol list }
     { asm symbol list }
-      asmsymbollist : pdictionary;
-      usedasmsymbollist : psinglelist;
+      asmsymbollist : tdictionary;
+      usedasmsymbollist : tsinglelist;
 
 
     const
     const
       nextaltnr   : longint = 1;
       nextaltnr   : longint = 1;
@@ -377,22 +375,22 @@ type
       countlabelref : boolean = true;
       countlabelref : boolean = true;
 
 
     { make l as a new label }
     { make l as a new label }
-    procedure getlabel(var l : pasmlabel);
+    procedure getlabel(var l : tasmlabel);
     { make l as a new label and flag is_addr }
     { make l as a new label and flag is_addr }
-    procedure getaddrlabel(var l : pasmlabel);
+    procedure getaddrlabel(var l : tasmlabel);
     { make l as a new label and flag is_data }
     { make l as a new label and flag is_data }
-    procedure getdatalabel(var l : pasmlabel);
+    procedure getdatalabel(var l : tasmlabel);
     {just get a label number }
     {just get a label number }
     procedure getlabelnr(var l : longint);
     procedure getlabelnr(var l : longint);
 
 
-    function  newasmsymbol(const s : string) : pasmsymbol;
-    function  newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:TAsmsymtype) : pasmsymbol;
-    function  getasmsymbol(const s : string) : pasmsymbol;
-    function  renameasmsymbol(const sold, snew : string):pasmsymbol;
+    function  newasmsymbol(const s : string) : tasmsymbol;
+    function  newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:TAsmsymtype) : tasmsymbol;
+    function  getasmsymbol(const s : string) : tasmsymbol;
+    function  renameasmsymbol(const sold, snew : string):tasmsymbol;
 
 
     procedure CreateUsedAsmSymbolList;
     procedure CreateUsedAsmSymbolList;
     procedure DestroyUsedAsmSymbolList;
     procedure DestroyUsedAsmSymbolList;
-    procedure UsedAsmSymbolListInsert(p:pasmsymbol);
+    procedure UsedAsmSymbolListInsert(p:tasmsymbol);
     procedure UsedAsmSymbolListReset;
     procedure UsedAsmSymbolListReset;
     procedure UsedAsmSymbolListResetAltSym;
     procedure UsedAsmSymbolListResetAltSym;
     procedure UsedAsmSymbolListCheckUndefined;
     procedure UsedAsmSymbolListCheckUndefined;
@@ -465,13 +463,13 @@ uses
                                TAI_SYMBOL
                                TAI_SYMBOL
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_symbol.Create(_sym:PAsmSymbol;siz:longint);
+    constructor tai_symbol.Create(_sym:tasmsymbol;siz:longint);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_symbol;
          typ:=ait_symbol;
          sym:=_sym;
          sym:=_sym;
          size:=siz;
          size:=siz;
-         is_global:=(sym^.defbind=AB_GLOBAL);
+         is_global:=(sym.defbind=AB_GLOBAL);
       end;
       end;
 
 
     constructor tai_symbol.Createname(const _name : string;siz:longint);
     constructor tai_symbol.Createname(const _name : string;siz:longint);
@@ -515,7 +513,7 @@ uses
                                TAI_SYMBOL
                                TAI_SYMBOL
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_symbol_end.Create(_sym:PAsmSymbol);
+    constructor tai_symbol_end.Create(_sym:tasmsymbol);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_symbol_end;
          typ:=ait_symbol_end;
@@ -563,34 +561,34 @@ uses
                                TAI_CONST_SYMBOL_OFFSET
                                TAI_CONST_SYMBOL_OFFSET
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_const_symbol.Create(_sym:PAsmSymbol);
+    constructor tai_const_symbol.Create(_sym:tasmsymbol);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_const_symbol;
          typ:=ait_const_symbol;
          sym:=_sym;
          sym:=_sym;
          offset:=0;
          offset:=0;
          { update sym info }
          { update sym info }
-         inc(sym^.refs);
+         inc(sym.refs);
       end;
       end;
 
 
-    constructor tai_const_symbol.Create_offset(_sym:PAsmSymbol;ofs:longint);
+    constructor tai_const_symbol.Create_offset(_sym:tasmsymbol;ofs:longint);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_const_symbol;
          typ:=ait_const_symbol;
          sym:=_sym;
          sym:=_sym;
          offset:=ofs;
          offset:=ofs;
          { update sym info }
          { update sym info }
-         inc(sym^.refs);
+         inc(sym.refs);
       end;
       end;
 
 
-    constructor tai_const_symbol.Create_rva(_sym:PAsmSymbol);
+    constructor tai_const_symbol.Create_rva(_sym:tasmsymbol);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_const_rva;
          typ:=ait_const_rva;
          sym:=_sym;
          sym:=_sym;
          offset:=0;
          offset:=0;
          { update sym info }
          { update sym info }
-         inc(sym^.refs);
+         inc(sym.refs);
       end;
       end;
 
 
     constructor tai_const_symbol.Createname(const name:string);
     constructor tai_const_symbol.Createname(const name:string);
@@ -600,7 +598,7 @@ uses
          sym:=newasmsymbol(name);
          sym:=newasmsymbol(name);
          offset:=0;
          offset:=0;
          { update sym info }
          { update sym info }
-         inc(sym^.refs);
+         inc(sym.refs);
       end;
       end;
 
 
     constructor tai_const_symbol.Createname_offset(const name:string;ofs:longint);
     constructor tai_const_symbol.Createname_offset(const name:string;ofs:longint);
@@ -610,7 +608,7 @@ uses
          sym:=newasmsymbol(name);
          sym:=newasmsymbol(name);
          offset:=ofs;
          offset:=ofs;
          { update sym info }
          { update sym info }
-         inc(sym^.refs);
+         inc(sym.refs);
       end;
       end;
 
 
     constructor tai_const_symbol.Createname_rva(const name:string);
     constructor tai_const_symbol.Createname_rva(const name:string);
@@ -620,7 +618,7 @@ uses
          sym:=newasmsymbol(name);
          sym:=newasmsymbol(name);
          offset:=0;
          offset:=0;
          { update sym info }
          { update sym info }
-         inc(sym^.refs);
+         inc(sym.refs);
       end;
       end;
 
 
 
 
@@ -719,13 +717,13 @@ uses
                                TAI_LABEL
                                TAI_LABEL
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_label.create(_l : pasmlabel);
+    constructor tai_label.create(_l : tasmlabel);
       begin
       begin
         inherited Create;
         inherited Create;
         typ:=ait_label;
         typ:=ait_label;
         l:=_l;
         l:=_l;
-        l^.is_set:=true;
-        is_global:=(l^.defbind=AB_GLOBAL);
+        l.is_set:=true;
+        is_global:=(l.defbind=AB_GLOBAL);
       end;
       end;
 
 
 
 
@@ -885,9 +883,9 @@ uses
                                   AsmSymbol
                                   AsmSymbol
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tasmsymbol.Init(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
+    constructor tasmsymbol.create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
       begin;
       begin;
-        inherited initname(s);
+        inherited createname(s);
         reset;
         reset;
         defbind:=_bind;
         defbind:=_bind;
         typ:=_typ;
         typ:=_typ;
@@ -900,9 +898,9 @@ uses
       begin
       begin
         if not assigned(altsymbol) then
         if not assigned(altsymbol) then
          begin
          begin
-           new(altsymbol,init(name+'_'+tostr(nextaltnr),bind,typ));
+           altsymbol:=tasmsymbol.create(name+'_'+tostr(nextaltnr),bind,typ);
            { also copy the amount of references }
            { also copy the amount of references }
-           altsymbol^.refs:=refs;
+           altsymbol.refs:=refs;
            inc(nextaltnr);
            inc(nextaltnr);
          end;
          end;
       end;
       end;
@@ -939,41 +937,41 @@ uses
                                   AsmLabel
                                   AsmLabel
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tasmlabel.Init;
+    constructor tasmlabel.create;
       begin;
       begin;
         labelnr:=nextlabelnr;
         labelnr:=nextlabelnr;
         inc(nextlabelnr);
         inc(nextlabelnr);
-        inherited init(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_FUNCTION);
+        inherited create(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_FUNCTION);
         proclocal:=true;
         proclocal:=true;
         is_set:=false;
         is_set:=false;
         is_addr := false;
         is_addr := false;
       end;
       end;
 
 
 
 
-    constructor tasmlabel.Initdata;
+    constructor tasmlabel.createdata;
       begin;
       begin;
         labelnr:=nextlabelnr;
         labelnr:=nextlabelnr;
         inc(nextlabelnr);
         inc(nextlabelnr);
         if (cs_create_smart in aktmoduleswitches) or
         if (cs_create_smart in aktmoduleswitches) or
            target_asm.labelprefix_only_inside_procedure then
            target_asm.labelprefix_only_inside_procedure then
-          inherited init('_$'+current_module.modulename^+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA)
+          inherited create('_$'+current_module.modulename^+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA)
         else
         else
-          inherited init(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_DATA);
+          inherited create(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_DATA);
         is_set:=false;
         is_set:=false;
         is_addr := false;
         is_addr := false;
         { write it always }
         { write it always }
         refs:=1;
         refs:=1;
       end;
       end;
 
 
-    constructor tasmlabel.Initaddr;
+    constructor tasmlabel.createaddr;
       begin;
       begin;
-        Init;
+        create;
         is_addr := true;
         is_addr := true;
       end;
       end;
 
 
-    function tasmlabel.name:string;
+    function tasmlabel.getname:string;
       begin
       begin
-        name:=inherited name;
+        getname:=inherited getname;
         inc(refs);
         inc(refs);
       end;
       end;
 
 
@@ -982,48 +980,48 @@ uses
                               AsmSymbolList helpers
                               AsmSymbolList helpers
 *****************************************************************************}
 *****************************************************************************}
 
 
-    function newasmsymbol(const s : string) : pasmsymbol;
+    function newasmsymbol(const s : string) : tasmsymbol;
       var
       var
-        hp : pasmsymbol;
+        hp : tasmsymbol;
       begin
       begin
-        hp:=pasmsymbol(asmsymbollist^.search(s));
+        hp:=tasmsymbol(asmsymbollist.search(s));
         if not assigned(hp) then
         if not assigned(hp) then
          begin
          begin
            { Not found, insert it as an External }
            { Not found, insert it as an External }
-           hp:=new(pasmsymbol,init(s,AB_EXTERNAL,AT_FUNCTION));
-           asmsymbollist^.insert(hp);
+           hp:=tasmsymbol.create(s,AB_EXTERNAL,AT_FUNCTION);
+           asmsymbollist.insert(hp);
          end;
          end;
         newasmsymbol:=hp;
         newasmsymbol:=hp;
       end;
       end;
 
 
 
 
-    function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : pasmsymbol;
+    function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : tasmsymbol;
       var
       var
-        hp : pasmsymbol;
+        hp : tasmsymbol;
       begin
       begin
-        hp:=pasmsymbol(asmsymbollist^.search(s));
+        hp:=tasmsymbol(asmsymbollist.search(s));
         if assigned(hp) then
         if assigned(hp) then
-         hp^.defbind:=_bind
+         hp.defbind:=_bind
         else
         else
          begin
          begin
            { Not found, insert it as an External }
            { Not found, insert it as an External }
-           hp:=new(pasmsymbol,init(s,_bind,_typ));
-           asmsymbollist^.insert(hp);
+           hp:=tasmsymbol.create(s,_bind,_typ);
+           asmsymbollist.insert(hp);
          end;
          end;
         newasmsymboltype:=hp;
         newasmsymboltype:=hp;
       end;
       end;
 
 
 
 
-    function getasmsymbol(const s : string) : pasmsymbol;
+    function getasmsymbol(const s : string) : tasmsymbol;
       begin
       begin
-        getasmsymbol:=pasmsymbol(asmsymbollist^.search(s));
+        getasmsymbol:=tasmsymbol(asmsymbollist.search(s));
       end;
       end;
 
 
 
 
     { renames an asmsymbol }
     { renames an asmsymbol }
-    function renameasmsymbol(const sold, snew : string):pasmsymbol;
+    function renameasmsymbol(const sold, snew : string):tasmsymbol;
       begin
       begin
-        renameasmsymbol:=pasmsymbol(asmsymbollist^.rename(sold,snew));
+        renameasmsymbol:=tasmsymbol(asmsymbollist.rename(sold,snew));
       end;
       end;
 
 
 
 
@@ -1035,74 +1033,74 @@ uses
       begin
       begin
         if assigned(usedasmsymbollist) then
         if assigned(usedasmsymbollist) then
          internalerror(78455782);
          internalerror(78455782);
-        new(usedasmsymbollist,init);
+        usedasmsymbollist:=TSingleList.create;
       end;
       end;
 
 
 
 
     procedure DestroyUsedAsmSymbolList;
     procedure DestroyUsedAsmSymbolList;
       begin
       begin
-        dispose(usedasmsymbollist,done);
+        usedasmsymbollist.destroy;
         usedasmsymbollist:=nil;
         usedasmsymbollist:=nil;
       end;
       end;
 
 
 
 
-    procedure UsedAsmSymbolListInsert(p:pasmsymbol);
+    procedure UsedAsmSymbolListInsert(p:tasmsymbol);
       begin
       begin
-        if not p^.inusedlist then
-         usedasmsymbollist^.insert(p);
-        p^.inusedlist:=true;
+        if not p.inusedlist then
+         usedasmsymbollist.insert(p);
+        p.inusedlist:=true;
       end;
       end;
 
 
 
 
     procedure UsedAsmSymbolListReset;
     procedure UsedAsmSymbolListReset;
       var
       var
-        hp : pasmsymbol;
+        hp : tasmsymbol;
       begin
       begin
-        hp:=pasmsymbol(usedasmsymbollist^.first);
+        hp:=tasmsymbol(usedasmsymbollist.first);
         while assigned(hp) do
         while assigned(hp) do
          begin
          begin
-           with hp^ do
+           with hp do
             begin
             begin
               reset;
               reset;
               inusedlist:=false;
               inusedlist:=false;
             end;
             end;
-           hp:=pasmsymbol(hp^.listnext);
+           hp:=tasmsymbol(hp.listnext);
          end;
          end;
       end;
       end;
 
 
 
 
     procedure UsedAsmSymbolListResetAltSym;
     procedure UsedAsmSymbolListResetAltSym;
       var
       var
-        hp : pasmsymbol;
+        hp : tasmsymbol;
       begin
       begin
-        hp:=pasmsymbol(usedasmsymbollist^.first);
+        hp:=tasmsymbol(usedasmsymbollist.first);
         while assigned(hp) do
         while assigned(hp) do
          begin
          begin
-           with hp^ do
+           with hp do
             begin
             begin
               altsymbol:=nil;
               altsymbol:=nil;
               inusedlist:=false;
               inusedlist:=false;
             end;
             end;
-           hp:=pasmsymbol(hp^.listnext);
+           hp:=tasmsymbol(hp.listnext);
          end;
          end;
       end;
       end;
 
 
 
 
     procedure UsedAsmSymbolListCheckUndefined;
     procedure UsedAsmSymbolListCheckUndefined;
       var
       var
-        hp : pasmsymbol;
+        hp : tasmsymbol;
       begin
       begin
-        hp:=pasmsymbol(usedasmsymbollist^.first);
+        hp:=tasmsymbol(usedasmsymbollist.first);
         while assigned(hp) do
         while assigned(hp) do
          begin
          begin
-           with hp^ do
+           with hp do
             begin
             begin
               if (refs>0) and
               if (refs>0) and
                  (section=Sec_none) and
                  (section=Sec_none) and
                  not(bind in [AB_EXTERNAL,AB_COMMON]) then
                  not(bind in [AB_EXTERNAL,AB_COMMON]) then
                Message1(asmw_e_undefined_label,name);
                Message1(asmw_e_undefined_label,name);
             end;
             end;
-           hp:=pasmsymbol(hp^.listnext);
+           hp:=tasmsymbol(hp.listnext);
          end;
          end;
       end;
       end;
 
 
@@ -1111,34 +1109,25 @@ uses
                               Label Helpers
                               Label Helpers
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure getlabel(var l : pasmlabel);
+    procedure getlabel(var l : tasmlabel);
       begin
       begin
-        l:=new(pasmlabel,init);
-        asmsymbollist^.insert(l);
+        l:=tasmlabel.create;
+        asmsymbollist.insert(l);
       end;
       end;
 
 
 
 
-    procedure getdatalabel(var l : pasmlabel);
+    procedure getdatalabel(var l : tasmlabel);
       begin
       begin
-        l:=new(pasmlabel,initdata);
-        asmsymbollist^.insert(l);
+        l:=tasmlabel.createdata;
+        asmsymbollist.insert(l);
       end;
       end;
 
 
-    procedure getaddrlabel(var l : pasmlabel);
+    procedure getaddrlabel(var l : tasmlabel);
       begin
       begin
-        l:=new(pasmlabel,initaddr);
-        asmsymbollist^.insert(l);
+        l:=tasmlabel.createaddr;
+        asmsymbollist.insert(l);
       end;
       end;
 
 
-    procedure RegenerateLabel(var l : pasmlabel);
-      begin
-        if l^.proclocal then
-         getlabel(pasmlabel(l^.altsymbol))
-        else
-         getdatalabel(pasmlabel(l^.altsymbol));
-      end;
-
-
     procedure getlabelnr(var l : longint);
     procedure getlabelnr(var l : longint);
       begin
       begin
          l:=nextlabelnr;
          l:=nextlabelnr;
@@ -1161,7 +1150,12 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-02-20 21:36:39  peter
+  Revision 1.17  2001-04-13 01:22:06  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.16  2001/02/20 21:36:39  peter
     * tasm/masm fixes merged
     * tasm/masm fixes merged
 
 
   Revision 1.15  2000/12/25 00:07:25  peter
   Revision 1.15  2000/12/25 00:07:25  peter

+ 7 - 2
compiler/assemble.pas

@@ -34,7 +34,7 @@ uses
   strings,
   strings,
   dos,
   dos,
 {$endif Delphi}
 {$endif Delphi}
-  cobjects,globtype,globals,aasm;
+  globtype,globals,aasm;
 
 
 const
 const
   AsmOutSize=32768;
   AsmOutSize=32768;
@@ -612,7 +612,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-03-13 18:42:39  peter
+  Revision 1.17  2001-04-13 01:22:06  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.16  2001/03/13 18:42:39  peter
     * don't create temporary smartlink dir for internalassembler
     * don't create temporary smartlink dir for internalassembler
 
 
   Revision 1.15  2001/03/05 21:39:11  peter
   Revision 1.15  2001/03/05 21:39:11  peter

File diff suppressed because it is too large
+ 215 - 214
compiler/browcol.pas


+ 78 - 73
compiler/browlog.pas

@@ -26,7 +26,7 @@ unit browlog;
 
 
 interface
 interface
 uses
 uses
-  cobjects,cclasses,
+  cclasses,
   globtype,
   globtype,
   fmodule,finput,
   fmodule,finput,
   symbase,symconst,symtype,symsym,symdef,symtable;
   symbase,symconst,symtype,symsym,symdef,symtable;
@@ -51,7 +51,7 @@ type
     procedure createlog;
     procedure createlog;
     procedure flushlog;
     procedure flushlog;
     procedure addlog(const s:string);
     procedure addlog(const s:string);
-    procedure addlogrefs(p:pref);
+    procedure addlogrefs(p:tref);
     procedure closelog;
     procedure closelog;
     procedure ident;
     procedure ident;
     procedure unident;
     procedure unident;
@@ -73,15 +73,15 @@ implementation
 
 
   uses
   uses
     cutils,comphook,
     cutils,comphook,
-    globals,systems,verbose,
+    globals,systems,
     ppu;
     ppu;
 
 
-    function get_file_line(ref:pref): string;
+    function get_file_line(ref:tref): string;
       var
       var
          inputfile : tinputfile;
          inputfile : tinputfile;
       begin
       begin
         get_file_line:='';
         get_file_line:='';
-        with ref^ do
+        with ref do
          begin
          begin
            inputfile:=get_source_file(moduleindex,posinfo.fileindex);
            inputfile:=get_source_file(moduleindex,posinfo.fileindex);
            if assigned(inputfile) then
            if assigned(inputfile) then
@@ -243,16 +243,16 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tbrowserlog.addlogrefs(p:pref);
+    procedure tbrowserlog.addlogrefs(p:tref);
       var
       var
-        ref : pref;
+        ref : tref;
       begin
       begin
         ref:=p;
         ref:=p;
         Ident;
         Ident;
         while assigned(ref) do
         while assigned(ref) do
          begin
          begin
            Browserlog.AddLog(get_file_line(ref));
            Browserlog.AddLog(get_file_line(ref));
-           ref:=ref^.nextref;
+           ref:=ref.nextref;
          end;
          end;
         Unident;
         Unident;
       end;
       end;
@@ -260,8 +260,8 @@ implementation
 
 
     procedure tbrowserlog.browse_symbol(const sr : string);
     procedure tbrowserlog.browse_symbol(const sr : string);
       var
       var
-         sym,symb : pstoredsym;
-         symt : psymtable;
+         sym,symb : tstoredsym;
+         symt : tsymtable;
          hp : tmodule;
          hp : tmodule;
          s,ss : string;
          s,ss : string;
          p : byte;
          p : byte;
@@ -290,20 +290,20 @@ implementation
          next_substring;
          next_substring;
          if assigned(symt) then
          if assigned(symt) then
            begin
            begin
-              sym:=pstoredsym(symt^.search(ss));
+              sym:=tstoredsym(symt.search(ss));
               if sym=nil then
               if sym=nil then
-                sym:=pstoredsym(symt^.search(upper(ss)));
+                sym:=tstoredsym(symt.search(upper(ss)));
            end
            end
          else
          else
            sym:=nil;
            sym:=nil;
-         if assigned(sym) and (sym^.typ=unitsym) and (s<>'') then
+         if assigned(sym) and (sym.typ=unitsym) and (s<>'') then
            begin
            begin
               addlog('Unitsym found !');
               addlog('Unitsym found !');
-              symt:=punitsym(sym)^.unitsymtable;
+              symt:=tunitsym(sym).unitsymtable;
               if assigned(symt) then
               if assigned(symt) then
                 begin
                 begin
                    next_substring;
                    next_substring;
-                   sym:=pstoredsym(symt^.search(ss));
+                   sym:=tstoredsym(symt.search(ss));
                 end
                 end
               else
               else
                 sym:=nil;
                 sym:=nil;
@@ -331,54 +331,54 @@ implementation
               else
               else
                 begin
                 begin
                    next_substring;
                    next_substring;
-                   sym:=pstoredsym(symt^.search(ss));
+                   sym:=tstoredsym(symt.search(ss));
                    if sym=nil then
                    if sym=nil then
-                     sym:=pstoredsym(symt^.search(upper(ss)));
+                     sym:=tstoredsym(symt.search(upper(ss)));
                 end;
                 end;
            end;
            end;
 
 
          while assigned(sym) and (s<>'') do
          while assigned(sym) and (s<>'') do
            begin
            begin
               next_substring;
               next_substring;
-              case sym^.typ of
+              case sym.typ of
                 typesym :
                 typesym :
                   begin
                   begin
-                     if ptypesym(sym)^.restype.def^.deftype in [recorddef,objectdef] then
+                     if ttypesym(sym).restype.def.deftype in [recorddef,objectdef] then
                        begin
                        begin
-                          if ptypesym(sym)^.restype.def^.deftype=recorddef then
-                            symt:=precorddef(ptypesym(sym)^.restype.def)^.symtable
+                          if ttypesym(sym).restype.def.deftype=recorddef then
+                            symt:=trecorddef(ttypesym(sym).restype.def).symtable
                           else
                           else
-                            symt:=pobjectdef(ptypesym(sym)^.restype.def)^.symtable;
-                          sym:=pstoredsym(symt^.search(ss));
+                            symt:=tobjectdef(ttypesym(sym).restype.def).symtable;
+                          sym:=tstoredsym(symt.search(ss));
                           if sym=nil then
                           if sym=nil then
-                            sym:=pstoredsym(symt^.search(upper(ss)));
+                            sym:=tstoredsym(symt.search(upper(ss)));
                        end;
                        end;
                   end;
                   end;
                 varsym :
                 varsym :
                   begin
                   begin
-                     if pvarsym(sym)^.vartype.def^.deftype in [recorddef,objectdef] then
+                     if tvarsym(sym).vartype.def.deftype in [recorddef,objectdef] then
                        begin
                        begin
-                          if pvarsym(sym)^.vartype.def^.deftype=recorddef then
-                            symt:=precorddef(pvarsym(sym)^.vartype.def)^.symtable
+                          if tvarsym(sym).vartype.def.deftype=recorddef then
+                            symt:=trecorddef(tvarsym(sym).vartype.def).symtable
                           else
                           else
-                            symt:=pobjectdef(pvarsym(sym)^.vartype.def)^.symtable;
-                          sym:=pstoredsym(symt^.search(ss));
+                            symt:=tobjectdef(tvarsym(sym).vartype.def).symtable;
+                          sym:=tstoredsym(symt.search(ss));
                           if sym=nil then
                           if sym=nil then
-                            sym:=pstoredsym(symt^.search(upper(ss)));
+                            sym:=tstoredsym(symt.search(upper(ss)));
                        end;
                        end;
                   end;
                   end;
                 procsym :
                 procsym :
                   begin
                   begin
-                     symt:=pprocsym(sym)^.definition^.parast;
-                     symb:=pstoredsym(symt^.search(ss));
+                     symt:=tprocsym(sym).definition.parast;
+                     symb:=tstoredsym(symt.search(ss));
                      if symb=nil then
                      if symb=nil then
-                       symb:=pstoredsym(symt^.search(upper(ss)));
+                       symb:=tstoredsym(symt.search(upper(ss)));
                      if not assigned(symb) then
                      if not assigned(symb) then
                        begin
                        begin
-                          symt:=pprocsym(sym)^.definition^.parast;
-                          sym:=pstoredsym(symt^.search(ss));
+                          symt:=tprocsym(sym).definition.parast;
+                          sym:=tstoredsym(symt.search(ss));
                           if symb=nil then
                           if symb=nil then
-                            symb:=pstoredsym(symt^.search(upper(ss)));
+                            symb:=tstoredsym(symt.search(upper(ss)));
                        end
                        end
                      else
                      else
                        sym:=symb;
                        sym:=symb;
@@ -387,10 +387,10 @@ implementation
            end;
            end;
            if assigned(sym) then
            if assigned(sym) then
             begin
             begin
-              if assigned(sym^.defref) then
+              if assigned(sym.defref) then
                begin
                begin
-                 browserlog.AddLog('***'+sym^.name+'***');
-                 browserlog.AddLogRefs(sym^.defref);
+                 browserlog.AddLog('***'+sym.name+'***');
+                 browserlog.AddLogRefs(sym.defref);
                end;
                end;
             end
             end
            else
            else
@@ -410,67 +410,67 @@ implementation
       end;
       end;
 
 
 
 
-    procedure writesymtable(p:psymtable);
+    procedure writesymtable(p:tsymtable);
       var
       var
-        hp : pstoredsym;
-        prdef : pprocdef;
+        hp : tstoredsym;
+        prdef : tprocdef;
       begin
       begin
         if cs_browser in aktmoduleswitches then
         if cs_browser in aktmoduleswitches then
          begin
          begin
-           if assigned(p^.name) then
-             Browserlog.AddLog('---Symtable '+p^.name^)
+           if assigned(p.name) then
+             Browserlog.AddLog('---Symtable '+p.name^)
            else
            else
              begin
              begin
-                if (p^.symtabletype=recordsymtable) and
-                   assigned(pdef(p^.defowner)^.typesym) then
-                  Browserlog.AddLog('---Symtable '+pdef(p^.defowner)^.typesym^.name)
+                if (p.symtabletype=recordsymtable) and
+                   assigned(tdef(p.defowner).typesym) then
+                  Browserlog.AddLog('---Symtable '+tdef(p.defowner).typesym.name)
                 else
                 else
                   Browserlog.AddLog('---Symtable with no name');
                   Browserlog.AddLog('---Symtable with no name');
              end;
              end;
            Browserlog.Ident;
            Browserlog.Ident;
-           hp:=pstoredsym(p^.symindex^.first);
+           hp:=tstoredsym(p.symindex.first);
            while assigned(hp) do
            while assigned(hp) do
             begin
             begin
-              if assigned(hp^.defref) then
+              if assigned(hp.defref) then
                begin
                begin
-                 browserlog.AddLog('***'+hp^.name+'***');
-                 browserlog.AddLogRefs(hp^.defref);
+                 browserlog.AddLog('***'+hp.name+'***');
+                 browserlog.AddLogRefs(hp.defref);
                end;
                end;
-              case hp^.typ of
+              case hp.typ of
                 typesym :
                 typesym :
                   begin
                   begin
-                    if (ptypesym(hp)^.restype.def^.deftype=recorddef) then
-                      writesymtable(precorddef(ptypesym(hp)^.restype.def)^.symtable);
-                    if (ptypesym(hp)^.restype.def^.deftype=objectdef) then
-                      writesymtable(pobjectdef(ptypesym(hp)^.restype.def)^.symtable);
+                    if (ttypesym(hp).restype.def.deftype=recorddef) then
+                      writesymtable(trecorddef(ttypesym(hp).restype.def).symtable);
+                    if (ttypesym(hp).restype.def.deftype=objectdef) then
+                      writesymtable(tobjectdef(ttypesym(hp).restype.def).symtable);
                   end;
                   end;
                 procsym :
                 procsym :
                   begin
                   begin
-                    prdef:=pprocsym(hp)^.definition;
+                    prdef:=tprocsym(hp).definition;
                     while assigned(prdef) do
                     while assigned(prdef) do
                      begin
                      begin
-                       if assigned(prdef^.defref) then
+                       if assigned(prdef.defref) then
                         begin
                         begin
-                          browserlog.AddLog('***'+prdef^.mangledname);
-                          browserlog.AddLogRefs(prdef^.defref);
+                          browserlog.AddLog('***'+prdef.mangledname);
+                          browserlog.AddLogRefs(prdef.defref);
                           if (current_module.flags and uf_local_browser)<>0 then
                           if (current_module.flags and uf_local_browser)<>0 then
                             begin
                             begin
-                               if assigned(prdef^.parast) then
-                                 writesymtable(prdef^.parast);
-                               if assigned(prdef^.localst) then
-                                 writesymtable(prdef^.localst);
+                               if assigned(prdef.parast) then
+                                 writesymtable(prdef.parast);
+                               if assigned(prdef.localst) then
+                                 writesymtable(prdef.localst);
                             end;
                             end;
                         end;
                         end;
-                       if assigned(pprocdef(prdef)^.defref) then
+                       if assigned(tprocdef(prdef).defref) then
                         begin
                         begin
-                          browserlog.AddLog('***'+pprocdef(prdef)^.name+'***');
-                          browserlog.AddLogRefs(pprocdef(prdef)^.defref);
+                          browserlog.AddLog('***'+tprocdef(prdef).name+'***');
+                          browserlog.AddLogRefs(tprocdef(prdef).defref);
                         end;
                         end;
-                       prdef:=pprocdef(prdef)^.nextoverloaded;
+                       prdef:=tprocdef(prdef).nextoverloaded;
                      end;
                      end;
                   end;
                   end;
               end;
               end;
-              hp:=pstoredsym(hp^.indexnext);
+              hp:=tstoredsym(hp.indexnext);
             end;
             end;
            browserlog.Unident;
            browserlog.Unident;
          end;
          end;
@@ -483,7 +483,7 @@ implementation
 
 
    procedure WriteBrowserLog;
    procedure WriteBrowserLog;
      var
      var
-       p : pstoredsymtable;
+       p : tstoredsymtable;
        hp : tmodule;
        hp : tmodule;
      begin
      begin
        browserlog.CreateLog;
        browserlog.CreateLog;
@@ -491,12 +491,12 @@ implementation
        hp:=tmodule(loaded_units.first);
        hp:=tmodule(loaded_units.first);
        while assigned(hp) do
        while assigned(hp) do
          begin
          begin
-            p:=pstoredsymtable(hp.globalsymtable);
+            p:=tstoredsymtable(hp.globalsymtable);
             if assigned(p) then
             if assigned(p) then
               writesymtable(p);
               writesymtable(p);
             if cs_local_browser in aktmoduleswitches then
             if cs_local_browser in aktmoduleswitches then
               begin
               begin
-                 p:=pstoredsymtable(hp.localsymtable);
+                 p:=tstoredsymtable(hp.localsymtable);
                  if assigned(p) then
                  if assigned(p) then
                    writesymtable(p);
                    writesymtable(p);
               end;
               end;
@@ -519,7 +519,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2000-12-25 00:07:25  peter
+  Revision 1.7  2001-04-13 01:22:06  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2000/12/25 00:07:25  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

File diff suppressed because it is too large
+ 415 - 324
compiler/cclasses.pas


+ 11 - 3
compiler/compiler.pas

@@ -99,7 +99,10 @@ uses
   cutils,cclasses,globals,options,fmodule,parser,symtable,
   cutils,cclasses,globals,options,fmodule,parser,symtable,
   link,import,export,tokens,pass_1,
   link,import,export,tokens,pass_1,
   { cpu overrides }
   { cpu overrides }
-  cpuswtch,cpunode
+  cpuswtch
+{$ifndef NOPASS2}
+  ,cpunode
+{$endif}
   ;
   ;
 
 
 function Compile(const cmd:string):longint;
 function Compile(const cmd:string):longint;
@@ -209,7 +212,7 @@ begin
   CompilerInitedAfterArgs:=true;
   CompilerInitedAfterArgs:=true;
 end;
 end;
 
 
-procedure minimal_stop;{$ifndef fpc}far;{$endif}
+procedure minimal_stop;
 begin
 begin
   DoneCompiler;
   DoneCompiler;
   olddo_stop{$ifdef FPCPROCVAR}(){$endif};
   olddo_stop{$ifdef FPCPROCVAR}(){$endif};
@@ -320,7 +323,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-04-02 21:20:29  peter
+  Revision 1.17  2001-04-13 01:22:06  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.16  2001/04/02 21:20:29  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.15  2000/12/26 15:57:25  peter
   Revision 1.15  2000/12/26 15:57:25  peter

+ 7 - 2
compiler/cresstr.pas

@@ -142,7 +142,7 @@ procedure TResourceStrings.CreateResourceStringList;
 
 
   Procedure AppendToAsmResList (P : TResourceStringItem);
   Procedure AppendToAsmResList (P : TResourceStringItem);
   Var
   Var
-    l1 : pasmlabel;
+    l1 : tasmlabel;
     s : pchar;
     s : pchar;
     l : longint;
     l : longint;
   begin
   begin
@@ -292,7 +292,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2001-02-24 10:44:55  peter
+  Revision 1.10  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.9  2001/02/24 10:44:55  peter
     * generate .rst from ppufilename instead of modulename
     * generate .rst from ppufilename instead of modulename
 
 
   Revision 1.8  2000/12/25 00:07:25  peter
   Revision 1.8  2000/12/25 00:07:25  peter

+ 7 - 2
compiler/export.pas

@@ -38,7 +38,7 @@ const
 
 
 type
 type
    texported_item = class(tlinkedlistitem)
    texported_item = class(tlinkedlistitem)
-      sym : psym;
+      sym : tsym;
       index : longint;
       index : longint;
       name : pstring;
       name : pstring;
       options : word;
       options : word;
@@ -239,7 +239,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-02-26 19:44:52  peter
+  Revision 1.13  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.12  2001/02/26 19:44:52  peter
     * merged generic m68k updates from fixes branch
     * merged generic m68k updates from fixes branch
 
 
   Revision 1.11  2001/02/03 00:09:02  peter
   Revision 1.11  2001/02/03 00:09:02  peter

+ 7 - 2
compiler/finput.pas

@@ -27,7 +27,7 @@ unit finput;
 interface
 interface
 
 
     uses
     uses
-      cutils,cobjects,cclasses;
+      cutils,cclasses;
 
 
     const
     const
        InputFileBufSize=32*1024;
        InputFileBufSize=32*1024;
@@ -683,7 +683,12 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2001-03-13 18:43:17  peter
+  Revision 1.8  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.7  2001/03/13 18:43:17  peter
     * made memdebug and heaptrc compilable again
     * made memdebug and heaptrc compilable again
 
 
   Revision 1.6  2000/12/25 00:07:25  peter
   Revision 1.6  2000/12/25 00:07:25  peter

+ 20 - 15
compiler/fmodule.pas

@@ -25,23 +25,24 @@ unit fmodule;
 {$i defines.inc}
 {$i defines.inc}
 
 
 {$ifdef go32v1}
 {$ifdef go32v1}
-  {$define SHORTASMPREFIX}
+  {$define SHORTASMprefix}
 {$endif}
 {$endif}
 {$ifdef go32v2}
 {$ifdef go32v2}
-  {$define SHORTASMPREFIX}
+  {$define SHORTASMprefix}
 {$endif}
 {$endif}
 {$ifdef OS2}
 {$ifdef OS2}
   { Allthough OS/2 supports long filenames I play it safe and
   { Allthough OS/2 supports long filenames I play it safe and
     use 8.3 filenames, because this allows the compiler to run
     use 8.3 filenames, because this allows the compiler to run
     on a FAT partition. (DM) }
     on a FAT partition. (DM) }
-  {$define SHORTASMPREFIX}
+  {$define SHORTASMprefix}
 {$endif}
 {$endif}
 
 
 interface
 interface
 
 
     uses
     uses
-       cutils,cobjects,cclasses,
-       globals,ppu,finput;
+       cutils,cclasses,
+       globals,ppu,finput,
+       symbase;
 
 
     const
     const
        maxunits = 1024;
        maxunits = 1024;
@@ -106,8 +107,8 @@ interface
           islibrary     : boolean;  { if it is a library (win32 dll) }
           islibrary     : boolean;  { if it is a library (win32 dll) }
           map           : punitmap; { mapping of all used units }
           map           : punitmap; { mapping of all used units }
           unitcount     : longint;  { local unit counter }
           unitcount     : longint;  { local unit counter }
-          globalsymtable,           { pointer to the local/static symtable of this unit }
-          localsymtable : pointer;  { pointer to the psymtable of this unit }
+          globalsymtable,           { pointer to the global symtable of this unit }
+          localsymtable : tsymtable;{ pointer to the local symtable of this unit }
           scanner       : pointer;  { scanner object used }
           scanner       : pointer;  { scanner object used }
           loaded_from   : tmodule;
           loaded_from   : tmodule;
           uses_imports  : boolean;  { Set if the module imports from DLL's.}
           uses_imports  : boolean;  { Set if the module imports from DLL's.}
@@ -187,7 +188,6 @@ uses
   dos,
   dos,
 {$endif}
 {$endif}
   globtype,verbose,systems,
   globtype,verbose,systems,
-  symbase,
   scanner;
   scanner;
 
 
 
 
@@ -614,12 +614,12 @@ uses
           pscannerfile(scanner)^.invalid:=true;
           pscannerfile(scanner)^.invalid:=true;
         if assigned(globalsymtable) then
         if assigned(globalsymtable) then
           begin
           begin
-            dispose(psymtable(globalsymtable),done);
+            globalsymtable.free;
             globalsymtable:=nil;
             globalsymtable:=nil;
           end;
           end;
         if assigned(localsymtable) then
         if assigned(localsymtable) then
           begin
           begin
-            dispose(psymtable(localsymtable),done);
+            localsymtable.free;
             localsymtable:=nil;
             localsymtable:=nil;
           end;
           end;
         if assigned(map) then
         if assigned(map) then
@@ -703,7 +703,7 @@ uses
          inherited create('Program');
          inherited create('Program');
         mainsource:=stringdup(s);
         mainsource:=stringdup(s);
         { Dos has the famous 8.3 limit :( }
         { Dos has the famous 8.3 limit :( }
-{$ifdef SHORTASMPREFIX}
+{$ifdef SHORTASMprefix}
         asmprefix:=stringdup(FixFileName('as'));
         asmprefix:=stringdup(FixFileName('as'));
 {$else}
 {$else}
         asmprefix:=stringdup(FixFileName(n));
         asmprefix:=stringdup(FixFileName(n));
@@ -815,13 +815,13 @@ uses
         d.init('symtable');
         d.init('symtable');
 {$endif}
 {$endif}
         if assigned(globalsymtable) then
         if assigned(globalsymtable) then
-          dispose(psymtable(globalsymtable),done);
+          globalsymtable.free;
         globalsymtable:=nil;
         globalsymtable:=nil;
         if assigned(localsymtable) then
         if assigned(localsymtable) then
-          dispose(psymtable(localsymtable),done);
+          localsymtable.free;
         localsymtable:=nil;
         localsymtable:=nil;
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
-        d.done;
+        d.free;
 {$endif}
 {$endif}
         inherited Destroy;
         inherited Destroy;
       end;
       end;
@@ -878,7 +878,12 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2001-04-02 21:20:29  peter
+  Revision 1.11  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.10  2001/04/02 21:20:29  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.9  2001/03/13 18:45:06  peter
   Revision 1.9  2001/03/13 18:45:06  peter

+ 8 - 3
compiler/gdb.pas

@@ -33,7 +33,7 @@ uses
   strings,
   strings,
 {$endif}
 {$endif}
   globtype,cpubase,
   globtype,cpubase,
-  cobjects,globals,aasm;
+  globals,aasm;
 
 
 {stab constants }
 {stab constants }
 Const
 Const
@@ -46,7 +46,7 @@ Const
     N_BssLine = $48;
     N_BssLine = $48;
     N_RSYM = $40; { register variable }
     N_RSYM = $40; { register variable }
     N_LSYM = $80;
     N_LSYM = $80;
-    N_PSYM = 160;
+    N_tsym = 160;
     N_SourceFile = $64;
     N_SourceFile = $64;
     N_IncludeFile = $84;
     N_IncludeFile = $84;
     N_BINCL = $82;
     N_BINCL = $82;
@@ -249,7 +249,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2000-12-25 00:07:26  peter
+  Revision 1.6  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.5  2000/12/25 00:07:26  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 12 - 7
compiler/gendef.pas

@@ -29,11 +29,10 @@ uses
   cclasses;
   cclasses;
 
 
 type
 type
-  pdeffile=^tdeffile;
-  tdeffile=object
+  tdeffile=class
     fname : string;
     fname : string;
-    constructor init(const fn:string);
-    destructor  done;
+    constructor create(const fn:string);
+    destructor  destroy;override;
     procedure addexport(const s:string);
     procedure addexport(const s:string);
     procedure addimport(const s:string);
     procedure addimport(const s:string);
     procedure writefile;
     procedure writefile;
@@ -44,6 +43,7 @@ type
     exportlist,
     exportlist,
     importlist   : tstringlist;
     importlist   : tstringlist;
   end;
   end;
+
 var
 var
   deffile : tdeffile;
   deffile : tdeffile;
 
 
@@ -57,7 +57,7 @@ uses
                                TDefFile
                                TDefFile
 ******************************************************************************}
 ******************************************************************************}
 
 
-constructor tdeffile.init(const fn:string);
+constructor tdeffile.create(const fn:string);
 begin
 begin
   fname:=fn;
   fname:=fn;
   WrittenOnDisk:=false;
   WrittenOnDisk:=false;
@@ -67,7 +67,7 @@ begin
 end;
 end;
 
 
 
 
-destructor tdeffile.done;
+destructor tdeffile.destroy;
 begin
 begin
   if WrittenOnDisk and
   if WrittenOnDisk and
      not(cs_link_extern in aktglobalswitches) then
      not(cs_link_extern in aktglobalswitches) then
@@ -160,7 +160,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2000-12-25 00:07:26  peter
+  Revision 1.6  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.5  2000/12/25 00:07:26  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 7 - 31
compiler/globals.pas

@@ -47,7 +47,7 @@ interface
       strings,
       strings,
       dos,
       dos,
 {$endif}
 {$endif}
-      cutils,cobjects,cclasses,
+      cutils,cclasses,
       globtype,version,systems;
       globtype,version,systems;
 
 
     const
     const
@@ -282,35 +282,6 @@ implementation
       end;
       end;
 
 
 
 
-    function ngraphsearchvalue(const s1,s2 : string) : double;
-      const
-         n = 3;
-      var
-         equals,i,j : longint;
-         hs : string;
-      begin
-         equals:=0;
-         { is the string long enough ? }
-         if min(length(s1),length(s2))-n+1<1 then
-           begin
-              ngraphsearchvalue:=0.0;
-              exit;
-           end;
-         for i:=1 to length(s1)-n+1 do
-           begin
-              hs:=copy(s1,i,n);
-              for j:=1 to length(s2)-n+1 do
-                if hs=copy(s2,j,n) then
-                  inc(equals);
-           end;
-{$ifdef fpc}
-         ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
-{$else}
-         ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
-{$endif}
-      end;
-
-
     function bstoslash(const s : string) : string;
     function bstoslash(const s : string) : string;
     {
     {
       return string s with all \ changed into /
       return string s with all \ changed into /
@@ -1341,7 +1312,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.29  2001-04-04 21:30:42  florian
+  Revision 1.30  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.29  2001/04/04 21:30:42  florian
     * applied several fixes to get the DD8 Delphi Unit compiled
     * applied several fixes to get the DD8 Delphi Unit compiled
      e.g. "forward"-interfaces are working now
      e.g. "forward"-interfaces are working now
 
 

File diff suppressed because it is too large
+ 306 - 251
compiler/hcgdata.pas


+ 23 - 18
compiler/hcodegen.pas

@@ -28,7 +28,7 @@ unit hcodegen;
 
 
     uses
     uses
       { common }
       { common }
-      cobjects,
+      cclasses,
       { global }
       { global }
       globals,verbose,
       globals,verbose,
       { symtable }
       { symtable }
@@ -55,16 +55,16 @@ unit hcodegen;
           { pointer to parent in nested procedures }
           { pointer to parent in nested procedures }
           parent : pprocinfo;
           parent : pprocinfo;
           { current class, if we are in a method }
           { current class, if we are in a method }
-          _class : pobjectdef;
+          _class : tobjectdef;
           { return type }
           { return type }
           returntype : ttype;
           returntype : ttype;
           { symbol of the function, and the sym for result variable }
           { symbol of the function, and the sym for result variable }
           resultfuncretsym,
           resultfuncretsym,
-          funcretsym : pfuncretsym;
+          funcretsym : tfuncretsym;
           funcret_state : tvarstate;
           funcret_state : tvarstate;
           { the definition of the proc itself }
           { the definition of the proc itself }
-          def : pprocdef;
-          sym : pprocsym;
+          def : tprocdef;
+          sym : tprocsym;
 
 
           { frame pointer offset }
           { frame pointer offset }
           framepointer_offset : longint;
           framepointer_offset : longint;
@@ -104,11 +104,11 @@ unit hcodegen;
 
 
        pregvarinfo = ^tregvarinfo;
        pregvarinfo = ^tregvarinfo;
        tregvarinfo = record
        tregvarinfo = record
-          regvars : array[1..maxvarregs] of pvarsym;
+          regvars : array[1..maxvarregs] of tvarsym;
           regvars_para : array[1..maxvarregs] of boolean;
           regvars_para : array[1..maxvarregs] of boolean;
           regvars_refs : array[1..maxvarregs] of longint;
           regvars_refs : array[1..maxvarregs] of longint;
 
 
-          fpuregvars : array[1..maxfpuvarregs] of pvarsym;
+          fpuregvars : array[1..maxfpuvarregs] of tvarsym;
           fpuregvars_para : array[1..maxfpuvarregs] of boolean;
           fpuregvars_para : array[1..maxfpuvarregs] of boolean;
           fpuregvars_refs : array[1..maxfpuvarregs] of longint;
           fpuregvars_refs : array[1..maxfpuvarregs] of longint;
        end;
        end;
@@ -119,19 +119,19 @@ unit hcodegen;
        procinfo : pprocinfo;
        procinfo : pprocinfo;
 
 
        { labels for BREAK and CONTINUE }
        { labels for BREAK and CONTINUE }
-       aktbreaklabel,aktcontinuelabel : pasmlabel;
+       aktbreaklabel,aktcontinuelabel : tasmlabel;
 
 
        { label when the result is true or false }
        { label when the result is true or false }
-       truelabel,falselabel : pasmlabel;
+       truelabel,falselabel : tasmlabel;
 
 
        { label to leave the sub routine }
        { label to leave the sub routine }
-       aktexitlabel : pasmlabel;
+       aktexitlabel : tasmlabel;
 
 
        { also an exit label, only used we need to clear only the stack }
        { also an exit label, only used we need to clear only the stack }
-       aktexit2label : pasmlabel;
+       aktexit2label : tasmlabel;
 
 
        { only used in constructor for fail or if getmem fails }
        { only used in constructor for fail or if getmem fails }
-       faillabel,quickexitlabel : pasmlabel;
+       faillabel,quickexitlabel : tasmlabel;
 
 
        { Boolean, wenn eine loadn kein Assembler erzeugt hat }
        { Boolean, wenn eine loadn kein Assembler erzeugt hat }
        simple_loadn : boolean;
        simple_loadn : boolean;
@@ -366,8 +366,8 @@ implementation
          exportssection:=nil;
          exportssection:=nil;
          resourcesection:=nil;
          resourcesection:=nil;
          { assembler symbols }
          { assembler symbols }
-         asmsymbollist:=new(pdictionary,init);
-         asmsymbollist^.usehash;
+         asmsymbollist:=tdictionary.create;
+         asmsymbollist.usehash;
          { resourcestrings }
          { resourcestrings }
          ResourceStrings:=TResourceStrings.Create;
          ResourceStrings:=TResourceStrings.Create;
       end;
       end;
@@ -400,15 +400,15 @@ implementation
          if assigned(resourcesection) then
          if assigned(resourcesection) then
           resourcesection.free;
           resourcesection.free;
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
-         d.done;
+         d.free;
 {$endif}
 {$endif}
          { assembler symbols }
          { assembler symbols }
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
          d.init('asmsymbol');
          d.init('asmsymbol');
 {$endif}
 {$endif}
-         dispose(asmsymbollist,done);
+         asmsymbollist.free;
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
-         d.done;
+         d.free;
 {$endif}
 {$endif}
          { resource strings }
          { resource strings }
          ResourceStrings.free;
          ResourceStrings.free;
@@ -437,7 +437,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2000-12-25 00:07:26  peter
+  Revision 1.10  2001-04-13 01:22:07  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.9  2000/12/25 00:07:26  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 96 - 84
compiler/htypechk.pas

@@ -77,16 +77,16 @@ interface
 
 
     { is overloading of this operator allowed for this
     { is overloading of this operator allowed for this
       binary operator }
       binary operator }
-    function isbinaryoperatoroverloadable(ld, rd,dd : pdef;
+    function isbinaryoperatoroverloadable(ld, rd,dd : tdef;
              treetyp : tnodetype) : boolean;
              treetyp : tnodetype) : boolean;
 
 
     { is overloading of this operator allowed for this
     { is overloading of this operator allowed for this
       unary operator }
       unary operator }
-    function isunaryoperatoroverloadable(rd,dd : pdef;
+    function isunaryoperatoroverloadable(rd,dd : tdef;
              treetyp : tnodetype) : boolean;
              treetyp : tnodetype) : boolean;
 
 
     { check operator args and result type }
     { check operator args and result type }
-    function isoperatoracceptable(pf : pprocdef; optoken : ttoken) : boolean;
+    function isoperatoracceptable(pf : tprocdef; optoken : ttoken) : boolean;
     function isbinaryoverloaded(var t : tnode) : boolean;
     function isbinaryoverloaded(var t : tnode) : boolean;
 
 
     { Register Allocation }
     { Register Allocation }
@@ -94,13 +94,13 @@ interface
     procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
     procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
 
 
     { subroutine handling }
     { subroutine handling }
-    procedure test_protected_sym(sym : psym);
+    procedure test_protected_sym(sym : tsym);
     procedure test_protected(p : tnode);
     procedure test_protected(p : tnode);
     function  valid_for_formal_var(p : tnode) : boolean;
     function  valid_for_formal_var(p : tnode) : boolean;
     function  valid_for_formal_const(p : tnode) : boolean;
     function  valid_for_formal_const(p : tnode) : boolean;
     function  is_procsym_load(p:tnode):boolean;
     function  is_procsym_load(p:tnode):boolean;
     function  is_procsym_call(p:tnode):boolean;
     function  is_procsym_call(p:tnode):boolean;
-    procedure test_local_to_procvar(from_def:pprocvardef;to_def:pdef);
+    procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
     function  valid_for_assign(p:tnode;allowprop:boolean):boolean;
     function  valid_for_assign(p:tnode;allowprop:boolean):boolean;
     { sets the callunique flag, if the node is a vecn, }
     { sets the callunique flag, if the node is a vecn, }
     { takes care of type casts etc.                 }
     { takes care of type casts etc.                 }
@@ -138,37 +138,37 @@ implementation
     { ld is the left type definition
     { ld is the left type definition
       rd the right type definition
       rd the right type definition
       dd the result type definition  or voiddef if unkown }
       dd the result type definition  or voiddef if unkown }
-    function isbinaryoperatoroverloadable(ld, rd, dd : pdef;
+    function isbinaryoperatoroverloadable(ld, rd, dd : tdef;
              treetyp : tnodetype) : boolean;
              treetyp : tnodetype) : boolean;
       begin
       begin
         isbinaryoperatoroverloadable:=
         isbinaryoperatoroverloadable:=
            (treetyp=starstarn) or
            (treetyp=starstarn) or
-           (ld^.deftype=recorddef) or
-           (rd^.deftype=recorddef) or
-           ((rd^.deftype=pointerdef) and
+           (ld.deftype=recorddef) or
+           (rd.deftype=recorddef) or
+           ((rd.deftype=pointerdef) and
             not(is_pchar(rd) and
             not(is_pchar(rd) and
                 (is_chararray(ld) or
                 (is_chararray(ld) or
-                 (ld^.deftype=stringdef) or
+                 (ld.deftype=stringdef) or
                  (treetyp=addn))) and
                  (treetyp=addn))) and
-            (not(ld^.deftype in [pointerdef,objectdef,classrefdef,procvardef]) or
+            (not(ld.deftype in [pointerdef,objectdef,classrefdef,procvardef]) or
              not (treetyp in [equaln,unequaln,gtn,gten,ltn,lten,subn])
              not (treetyp in [equaln,unequaln,gtn,gten,ltn,lten,subn])
             ) and
             ) and
             (not is_integer(ld) or not (treetyp in [addn,subn]))
             (not is_integer(ld) or not (treetyp in [addn,subn]))
            ) or
            ) or
-           ((ld^.deftype=pointerdef) and
+           ((ld.deftype=pointerdef) and
             not(is_pchar(ld) and
             not(is_pchar(ld) and
                 (is_chararray(rd) or
                 (is_chararray(rd) or
-                 (rd^.deftype=stringdef) or
+                 (rd.deftype=stringdef) or
                  (treetyp=addn))) and
                  (treetyp=addn))) and
-            (not(rd^.deftype in [stringdef,pointerdef,objectdef,classrefdef,procvardef]) and
-             ((not is_integer(rd) and (rd^.deftype<>objectdef)
-               and (rd^.deftype<>classrefdef)) or
+            (not(rd.deftype in [stringdef,pointerdef,objectdef,classrefdef,procvardef]) and
+             ((not is_integer(rd) and (rd.deftype<>objectdef)
+               and (rd.deftype<>classrefdef)) or
               not (treetyp in [equaln,unequaln,gtn,gten,ltn,lten,addn,subn])
               not (treetyp in [equaln,unequaln,gtn,gten,ltn,lten,addn,subn])
              )
              )
             )
             )
            ) or
            ) or
            { array def, but not mmx or chararray+[char,string,chararray] }
            { array def, but not mmx or chararray+[char,string,chararray] }
-           ((ld^.deftype=arraydef) and
+           ((ld.deftype=arraydef) and
             not((cs_mmx in aktlocalswitches) and
             not((cs_mmx in aktlocalswitches) and
                 is_mmx_able_array(ld)) and
                 is_mmx_able_array(ld)) and
             not(is_chararray(ld) and
             not(is_chararray(ld) and
@@ -176,25 +176,25 @@ implementation
                  is_pchar(rd) or
                  is_pchar(rd) or
                  { char array + int = pchar + int, fix for web bug 1377 (JM) }
                  { char array + int = pchar + int, fix for web bug 1377 (JM) }
                  is_integer(rd) or
                  is_integer(rd) or
-                 (rd^.deftype=stringdef) or
+                 (rd.deftype=stringdef) or
                  is_chararray(rd)))
                  is_chararray(rd)))
            ) or
            ) or
-           ((rd^.deftype=arraydef) and
+           ((rd.deftype=arraydef) and
             not((cs_mmx in aktlocalswitches) and
             not((cs_mmx in aktlocalswitches) and
                 is_mmx_able_array(rd)) and
                 is_mmx_able_array(rd)) and
             not(is_chararray(rd) and
             not(is_chararray(rd) and
                 (is_char(ld) or
                 (is_char(ld) or
                  is_pchar(ld) or
                  is_pchar(ld) or
-                 (ld^.deftype=stringdef) or
+                 (ld.deftype=stringdef) or
                  is_chararray(ld)))
                  is_chararray(ld)))
            ) or
            ) or
            { <> and = are defined for classes }
            { <> and = are defined for classes }
            (
            (
-            (ld^.deftype=objectdef) and
+            (ld.deftype=objectdef) and
             not((treetyp in [equaln,unequaln]) and is_class_or_interface(ld))
             not((treetyp in [equaln,unequaln]) and is_class_or_interface(ld))
            ) or
            ) or
            (
            (
-            (rd^.deftype=objectdef) and
+            (rd.deftype=objectdef) and
             not((treetyp in [equaln,unequaln]) and is_class_or_interface(rd))
             not((treetyp in [equaln,unequaln]) and is_class_or_interface(rd))
            )
            )
            or
            or
@@ -202,23 +202,23 @@ implementation
            (
            (
             (is_char(rd) or
             (is_char(rd) or
              is_pchar(rd) or
              is_pchar(rd) or
-             (rd^.deftype=stringdef) or
+             (rd.deftype=stringdef) or
              is_chararray(rd) or
              is_chararray(rd) or
              is_char(ld) or
              is_char(ld) or
              is_pchar(ld) or
              is_pchar(ld) or
-             (ld^.deftype=stringdef) or
+             (ld.deftype=stringdef) or
              is_chararray(ld)
              is_chararray(ld)
              ) and
              ) and
              not(treetyp in [addn,equaln,unequaln,gtn,gten,ltn,lten]) and
              not(treetyp in [addn,equaln,unequaln,gtn,gten,ltn,lten]) and
              not(is_pchar(ld) and
              not(is_pchar(ld) and
-                 (is_integer(rd) or (rd^.deftype=pointerdef)) and
+                 (is_integer(rd) or (rd.deftype=pointerdef)) and
                  (treetyp=subn)
                  (treetyp=subn)
                 )
                 )
             );
             );
       end;
       end;
 
 
 
 
-    function isunaryoperatoroverloadable(rd,dd : pdef;
+    function isunaryoperatoroverloadable(rd,dd : tdef;
              treetyp : tnodetype) : boolean;
              treetyp : tnodetype) : boolean;
       begin
       begin
         isunaryoperatoroverloadable:=false;
         isunaryoperatoroverloadable:=false;
@@ -233,7 +233,7 @@ implementation
         else if (treetyp=subn { unaryminusn }) then
         else if (treetyp=subn { unaryminusn }) then
           begin
           begin
             isunaryoperatoroverloadable:=
             isunaryoperatoroverloadable:=
-              not is_integer(rd) and not (rd^.deftype=floatdef)
+              not is_integer(rd) and not (rd.deftype=floatdef)
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
               and not ((cs_mmx in aktlocalswitches) and
               and not ((cs_mmx in aktlocalswitches) and
               is_mmx_able_array(rd))
               is_mmx_able_array(rd))
@@ -251,20 +251,20 @@ implementation
           end;
           end;
       end;
       end;
 
 
-    function isoperatoracceptable(pf : pprocdef; optoken : ttoken) : boolean;
+    function isoperatoracceptable(pf : tprocdef; optoken : ttoken) : boolean;
       var
       var
-        ld,rd,dd : pdef;
+        ld,rd,dd : tdef;
         i : longint;
         i : longint;
       begin
       begin
-        case pf^.parast^.symindex^.count of
+        case pf.parast.symindex.count of
           2 : begin
           2 : begin
                 isoperatoracceptable:=false;
                 isoperatoracceptable:=false;
                 for i:=1 to tok2nodes do
                 for i:=1 to tok2nodes do
                   if tok2node[i].tok=optoken then
                   if tok2node[i].tok=optoken then
                     begin
                     begin
-                      ld:=pvarsym(pf^.parast^.symindex^.first)^.vartype.def;
-                      rd:=pvarsym(pf^.parast^.symindex^.first^.indexnext)^.vartype.def;
-                      dd:=pf^.rettype.def;
+                      ld:=tvarsym(pf.parast.symindex.first).vartype.def;
+                      rd:=tvarsym(pf.parast.symindex.first.indexnext).vartype.def;
+                      dd:=pf.rettype.def;
                       isoperatoracceptable:=
                       isoperatoracceptable:=
                         tok2node[i].op_overloading_supported and
                         tok2node[i].op_overloading_supported and
                         isbinaryoperatoroverloadable(ld,rd,dd,tok2node[i].nod);
                         isbinaryoperatoroverloadable(ld,rd,dd,tok2node[i].nod);
@@ -272,8 +272,8 @@ implementation
                     end;
                     end;
               end;
               end;
           1 : begin
           1 : begin
-                rd:=pvarsym(pf^.parast^.symindex^.first)^.vartype.def;
-                dd:=pf^.rettype.def;
+                rd:=tvarsym(pf.parast.symindex.first).vartype.def;
+                dd:=pf.rettype.def;
                 for i:=1 to tok2nodes do
                 for i:=1 to tok2nodes do
                   if tok2node[i].tok=optoken then
                   if tok2node[i].tok=optoken then
                     begin
                     begin
@@ -292,7 +292,7 @@ implementation
     function isbinaryoverloaded(var t : tnode) : boolean;
     function isbinaryoverloaded(var t : tnode) : boolean;
 
 
      var
      var
-         rd,ld   : pdef;
+         rd,ld   : tdef;
          optoken : ttoken;
          optoken : ttoken;
          ht      : tnode;
          ht      : tnode;
       begin
       begin
@@ -359,7 +359,7 @@ implementation
                end
                end
              else
              else
                begin
                begin
-                  inc(tcallnode(ht).symtableprocentry^.refs);
+                  inc(tcallnode(ht).symtableprocentry.refs);
                   { we need copies, because the originals will be destroyed when we give a }
                   { we need copies, because the originals will be destroyed when we give a }
                   { changed node back to firstpass! (JM)                                   }
                   { changed node back to firstpass! (JM)                                   }
                   if assigned(tbinarynode(t).left) then
                   if assigned(tbinarynode(t).left) then
@@ -394,8 +394,8 @@ implementation
             typeconvn :
             typeconvn :
               make_not_regable(ttypeconvnode(p).left);
               make_not_regable(ttypeconvnode(p).left);
             loadn :
             loadn :
-              if tloadnode(p).symtableentry^.typ=varsym then
-                pvarsym(tloadnode(p).symtableentry)^.varoptions:=pvarsym(tloadnode(p).symtableentry)^.varoptions-[vo_regable,vo_fpuregable];
+              if tloadnode(p).symtableentry.typ=varsym then
+                tvarsym(tloadnode(p).symtableentry).varoptions:=tvarsym(tloadnode(p).symtableentry).varoptions-[vo_regable,vo_fpuregable];
          end;
          end;
       end;
       end;
 
 
@@ -464,12 +464,19 @@ implementation
   overloaded function
   overloaded function
   this is the reason why it is not in the parser, PM }
   this is the reason why it is not in the parser, PM }
 
 
-    procedure test_protected_sym(sym : psym);
+    procedure test_protected_sym(sym : tsym);
       begin
       begin
-         if (sp_protected in sym^.symoptions) and
-            ((sym^.owner^.symtabletype=unitsymtable) or
-             ((sym^.owner^.symtabletype=objectsymtable) and
-             (pobjectdef(sym^.owner^.defowner)^.owner^.symtabletype=unitsymtable))
+         if (sp_protected in sym.symoptions) and
+            (
+             (
+              (sym.owner.symtabletype=globalsymtable) and
+              (sym.owner.unitid<>0)
+             ) or
+             (
+              (sym.owner.symtabletype=objectsymtable) and
+              (tobjectdef(sym.owner.defowner).owner.symtabletype=globalsymtable) and
+              (tobjectdef(sym.owner.defowner).owner.unitid<>0)
+             )
             ) then
             ) then
           CGMessage(parser_e_cant_access_protected_member);
           CGMessage(parser_e_cant_access_protected_member);
       end;
       end;
@@ -496,7 +503,7 @@ implementation
      begin
      begin
         case p.nodetype of
         case p.nodetype of
          loadn :
          loadn :
-           v:=(tloadnode(p).symtableentry^.typ in [typedconstsym,varsym]);
+           v:=(tloadnode(p).symtableentry.typ in [typedconstsym,varsym]);
          typeconvn :
          typeconvn :
            v:=valid_for_formal_var(ttypeconvnode(p).left);
            v:=valid_for_formal_var(ttypeconvnode(p).left);
          derefn,
          derefn,
@@ -548,9 +555,9 @@ implementation
 
 
     function is_procsym_load(p:tnode):boolean;
     function is_procsym_load(p:tnode):boolean;
       begin
       begin
-         is_procsym_load:=((p.nodetype=loadn) and (tloadnode(p).symtableentry^.typ=procsym)) or
+         is_procsym_load:=((p.nodetype=loadn) and (tloadnode(p).symtableentry.typ=procsym)) or
                           ((p.nodetype=addrn) and (taddrnode(p).left.nodetype=loadn)
                           ((p.nodetype=addrn) and (taddrnode(p).left.nodetype=loadn)
-                          and (tloadnode(taddrnode(p).left).symtableentry^.typ=procsym)) ;
+                          and (tloadnode(taddrnode(p).left).symtableentry.typ=procsym)) ;
       end;
       end;
 
 
    { change a proc call to a procload for assignment to a procvar }
    { change a proc call to a procload for assignment to a procvar }
@@ -558,15 +565,15 @@ implementation
     function is_procsym_call(p:tnode):boolean;
     function is_procsym_call(p:tnode):boolean;
       begin
       begin
         is_procsym_call:=(p.nodetype=calln) and (tcallnode(p).left=nil) and
         is_procsym_call:=(p.nodetype=calln) and (tcallnode(p).left=nil) and
-             (((tcallnode(p).symtableprocentry^.typ=procsym) and (tcallnode(p).right=nil)) or
-             (assigned(tcallnode(p).right) and (tcallnode(tcallnode(p).right).symtableprocentry^.typ=varsym)));
+             (((tcallnode(p).symtableprocentry.typ=procsym) and (tcallnode(p).right=nil)) or
+             (assigned(tcallnode(p).right) and (tcallnode(tcallnode(p).right).symtableprocentry.typ=varsym)));
       end;
       end;
 
 
 
 
     { local routines can't be assigned to procvars }
     { local routines can't be assigned to procvars }
-    procedure test_local_to_procvar(from_def:pprocvardef;to_def:pdef);
+    procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
       begin
       begin
-         if (from_def^.symtablelevel>1) and (to_def^.deftype=procvardef) then
+         if (from_def.symtablelevel>1) and (to_def.deftype=procvardef) then
            CGMessage(type_e_cannot_local_proc_to_procvar);
            CGMessage(type_e_cannot_local_proc_to_procvar);
       end;
       end;
 
 
@@ -610,7 +617,7 @@ implementation
                end;
                end;
              typeconvn :
              typeconvn :
                begin
                begin
-                 case hp.resulttype.def^.deftype of
+                 case hp.resulttype.def.deftype of
                    pointerdef :
                    pointerdef :
                      gotpointer:=true;
                      gotpointer:=true;
                    objectdef :
                    objectdef :
@@ -621,7 +628,7 @@ implementation
                      begin
                      begin
                        { pointer -> array conversion is done then we need to see it
                        { pointer -> array conversion is done then we need to see it
                          as a deref, because a ^ is then not required anymore }
                          as a deref, because a ^ is then not required anymore }
-                       if (ttypeconvnode(hp).left.resulttype.def^.deftype=pointerdef) then
+                       if (ttypeconvnode(hp).left.resulttype.def.deftype=pointerdef) then
                         gotderef:=true;
                         gotderef:=true;
                      end;
                      end;
                  end;
                  end;
@@ -644,7 +651,7 @@ implementation
                begin
                begin
                  { Allow add/sub operators on a pointer, or an integer
                  { Allow add/sub operators on a pointer, or an integer
                    and a pointer typecast and deref has been found }
                    and a pointer typecast and deref has been found }
-                 if (hp.resulttype.def^.deftype=pointerdef) or
+                 if (hp.resulttype.def.deftype=pointerdef) or
                     (is_integer(hp.resulttype.def) and gotpointer and gotderef) then
                     (is_integer(hp.resulttype.def) and gotpointer and gotderef) then
                   valid_for_assign:=true
                   valid_for_assign:=true
                  else
                  else
@@ -667,7 +674,7 @@ implementation
              calln :
              calln :
                begin
                begin
                  { check return type }
                  { check return type }
-                 case hp.resulttype.def^.deftype of
+                 case hp.resulttype.def.deftype of
                    pointerdef :
                    pointerdef :
                      gotpointer:=true;
                      gotpointer:=true;
                    objectdef :
                    objectdef :
@@ -689,11 +696,11 @@ implementation
                end;
                end;
              loadn :
              loadn :
                begin
                begin
-                 case tloadnode(hp).symtableentry^.typ of
+                 case tloadnode(hp).symtableentry.typ of
                    absolutesym,
                    absolutesym,
                    varsym :
                    varsym :
                      begin
                      begin
-                       if (pvarsym(tloadnode(hp).symtableentry)^.varspez=vs_const) then
+                       if (tvarsym(tloadnode(hp).symtableentry).varspez=vs_const) then
                         begin
                         begin
                           { allow p^:= constructions with p is const parameter }
                           { allow p^:= constructions with p is const parameter }
                           if gotderef then
                           if gotderef then
@@ -704,17 +711,17 @@ implementation
                         end;
                         end;
                        { Are we at a with symtable, then we need to process the
                        { Are we at a with symtable, then we need to process the
                          withrefnode also to check for maybe a const load }
                          withrefnode also to check for maybe a const load }
-                       if (tloadnode(hp).symtable^.symtabletype=withsymtable) then
+                       if (tloadnode(hp).symtable.symtabletype=withsymtable) then
                         begin
                         begin
                           { continue with processing the withref node }
                           { continue with processing the withref node }
-                          hp:=tnode(pwithsymtable(tloadnode(hp).symtable)^.withrefnode);
+                          hp:=tnode(twithsymtable(tloadnode(hp).symtable).withrefnode);
                           gotwith:=true;
                           gotwith:=true;
                         end
                         end
                        else
                        else
                         begin
                         begin
                           { set the assigned flag for varsyms }
                           { set the assigned flag for varsyms }
-                          if (pvarsym(tloadnode(hp).symtableentry)^.varstate=vs_declared) then
-                           pvarsym(tloadnode(hp).symtableentry)^.varstate:=vs_assigned;
+                          if (tvarsym(tloadnode(hp).symtableentry).varstate=vs_declared) then
+                           tvarsym(tloadnode(hp).symtableentry).varstate:=vs_assigned;
                           valid_for_assign:=true;
                           valid_for_assign:=true;
                           exit;
                           exit;
                         end;
                         end;
@@ -739,7 +746,7 @@ implementation
 
 
     procedure set_varstate(p : tnode;must_be_valid : boolean);
     procedure set_varstate(p : tnode;must_be_valid : boolean);
       var
       var
-        hsym : pvarsym;
+        hsym : tvarsym;
       begin
       begin
         while assigned(p) do
         while assigned(p) do
          begin
          begin
@@ -765,7 +772,7 @@ implementation
              vecn:
              vecn:
                begin
                begin
                  set_varstate(tbinarynode(p).right,true);
                  set_varstate(tbinarynode(p).right,true);
-                 if not(tunarynode(p).left.resulttype.def^.deftype in [stringdef,arraydef]) then
+                 if not(tunarynode(p).left.resulttype.def.deftype in [stringdef,arraydef]) then
                   must_be_valid:=true;
                   must_be_valid:=true;
                  p:=tunarynode(p).left;
                  p:=tunarynode(p).left;
                end;
                end;
@@ -779,50 +786,50 @@ implementation
                end;
                end;
              loadn :
              loadn :
                begin
                begin
-                 if (tloadnode(p).symtableentry^.typ=varsym) then
+                 if (tloadnode(p).symtableentry.typ=varsym) then
                   begin
                   begin
-                    hsym:=pvarsym(tloadnode(p).symtableentry);
+                    hsym:=tvarsym(tloadnode(p).symtableentry);
                     if must_be_valid and (nf_first in p.flags) then
                     if must_be_valid and (nf_first in p.flags) then
                      begin
                      begin
-                       if (hsym^.varstate=vs_declared_and_first_found) or
-                          (hsym^.varstate=vs_set_but_first_not_passed) then
+                       if (hsym.varstate=vs_declared_and_first_found) or
+                          (hsym.varstate=vs_set_but_first_not_passed) then
                         begin
                         begin
-                          if (assigned(hsym^.owner) and
+                          if (assigned(hsym.owner) and
                              assigned(aktprocsym) and
                              assigned(aktprocsym) and
-                             (hsym^.owner = aktprocsym^.definition^.localst)) then
+                             (hsym.owner = aktprocsym.definition.localst)) then
                            begin
                            begin
-                             if tloadnode(p).symtable^.symtabletype=localsymtable then
-                              CGMessage1(sym_n_uninitialized_local_variable,hsym^.realname)
+                             if tloadnode(p).symtable.symtabletype=localsymtable then
+                              CGMessage1(sym_n_uninitialized_local_variable,hsym.realname)
                              else
                              else
-                              CGMessage1(sym_n_uninitialized_variable,hsym^.realname);
+                              CGMessage1(sym_n_uninitialized_variable,hsym.realname);
                            end;
                            end;
                         end;
                         end;
                      end;
                      end;
                     if (nf_first in p.flags) then
                     if (nf_first in p.flags) then
                      begin
                      begin
-                       if hsym^.varstate=vs_declared_and_first_found then
+                       if hsym.varstate=vs_declared_and_first_found then
                         begin
                         begin
                           { this can only happen at left of an assignment, no ? PM }
                           { this can only happen at left of an assignment, no ? PM }
                           if (parsing_para_level=0) and not must_be_valid then
                           if (parsing_para_level=0) and not must_be_valid then
-                           hsym^.varstate:=vs_assigned
+                           hsym.varstate:=vs_assigned
                           else
                           else
-                           hsym^.varstate:=vs_used;
+                           hsym.varstate:=vs_used;
                         end
                         end
                        else
                        else
-                        if hsym^.varstate=vs_set_but_first_not_passed then
-                         hsym^.varstate:=vs_used;
+                        if hsym.varstate=vs_set_but_first_not_passed then
+                         hsym.varstate:=vs_used;
                        exclude(p.flags,nf_first);
                        exclude(p.flags,nf_first);
                      end
                      end
                     else
                     else
                       begin
                       begin
-                        if (hsym^.varstate=vs_assigned) and
+                        if (hsym.varstate=vs_assigned) and
                            (must_be_valid or (parsing_para_level>0) or
                            (must_be_valid or (parsing_para_level>0) or
-                            (p.resulttype.def^.deftype=procvardef)) then
-                          hsym^.varstate:=vs_used;
-                        if (hsym^.varstate=vs_declared_and_first_found) and
+                            (p.resulttype.def.deftype=procvardef)) then
+                          hsym.varstate:=vs_used;
+                        if (hsym.varstate=vs_declared_and_first_found) and
                            (must_be_valid or (parsing_para_level>0) or
                            (must_be_valid or (parsing_para_level>0) or
-                           (p.resulttype.def^.deftype=procvardef)) then
-                          hsym^.varstate:=vs_set_but_first_not_passed;
+                           (p.resulttype.def.deftype=procvardef)) then
+                          hsym.varstate:=vs_set_but_first_not_passed;
                       end;
                       end;
                   end;
                   end;
                  break;
                  break;
@@ -914,7 +921,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2001-04-02 21:20:29  peter
+  Revision 1.24  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.23  2001/04/02 21:20:29  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.22  2001/02/20 21:46:26  peter
   Revision 1.22  2001/02/20 21:46:26  peter

+ 25 - 20
compiler/i386/ag386att.pas

@@ -27,7 +27,7 @@ unit ag386att;
 interface
 interface
 
 
     uses
     uses
-      cobjects,
+      cclasses,
       globals,
       globals,
       aasm,assemble;
       aasm,assemble;
 
 
@@ -168,7 +168,7 @@ interface
             else
             else
              s:='';
              s:='';
             if assigned(symbol) then
             if assigned(symbol) then
-             s:=s+symbol^.name;
+             s:=s+symbol.name;
             if offset<0 then
             if offset<0 then
              s:=s+tostr(offset)
              s:=s+tostr(offset)
             else
             else
@@ -218,7 +218,7 @@ interface
         top_symbol :
         top_symbol :
           begin
           begin
             if assigned(o.sym) then
             if assigned(o.sym) then
-              hs:='$'+o.sym^.name
+              hs:='$'+o.sym.name
             else
             else
               hs:='$';
               hs:='$';
             if o.symofs>0 then
             if o.symofs>0 then
@@ -249,7 +249,7 @@ interface
           getopstr_jmp:=tostr(o.val);
           getopstr_jmp:=tostr(o.val);
         top_symbol :
         top_symbol :
           begin
           begin
-            hs:=o.sym^.name;
+            hs:=o.sym.name;
             if o.symofs>0 then
             if o.symofs>0 then
              hs:=hs+'+'+tostr(o.symofs)
              hs:=hs+'+'+tostr(o.symofs)
             else
             else
@@ -496,7 +496,7 @@ interface
                 AsmWrite(#9'.comm'#9)
                 AsmWrite(#9'.comm'#9)
                else
                else
                 AsmWrite(#9'.lcomm'#9);
                 AsmWrite(#9'.lcomm'#9);
-               AsmWrite(tai_datablock(hp).sym^.name);
+               AsmWrite(tai_datablock(hp).sym.name);
                AsmWriteLn(','+tostr(tai_datablock(hp).size));
                AsmWriteLn(','+tostr(tai_datablock(hp).size));
              end;
              end;
 
 
@@ -522,7 +522,7 @@ interface
 
 
            ait_const_symbol :
            ait_const_symbol :
              begin
              begin
-               AsmWrite(#9'.long'#9+tai_const_symbol(hp).sym^.name);
+               AsmWrite(#9'.long'#9+tai_const_symbol(hp).sym.name);
                if tai_const_symbol(hp).offset>0 then
                if tai_const_symbol(hp).offset>0 then
                  AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
                  AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
                else if tai_const_symbol(hp).offset<0 then
                else if tai_const_symbol(hp).offset<0 then
@@ -531,7 +531,7 @@ interface
              end;
              end;
 
 
            ait_const_rva :
            ait_const_rva :
-             AsmWriteLn(#9'.rva'#9+tai_const_symbol(hp).sym^.name);
+             AsmWriteLn(#9'.rva'#9+tai_const_symbol(hp).sym.name);
 
 
            ait_real_80bit :
            ait_real_80bit :
              begin
              begin
@@ -645,14 +645,14 @@ interface
 
 
            ait_label :
            ait_label :
              begin
              begin
-               if (tai_label(hp).l^.is_used) then
+               if (tai_label(hp).l.is_used) then
                 begin
                 begin
-                  if tai_label(hp).l^.defbind=AB_GLOBAL then
+                  if tai_label(hp).l.defbind=AB_GLOBAL then
                    begin
                    begin
                      AsmWrite('.globl'#9);
                      AsmWrite('.globl'#9);
-                     AsmWriteLn(tai_label(hp).l^.name);
+                     AsmWriteLn(tai_label(hp).l.name);
                    end;
                    end;
-                  AsmWrite(tai_label(hp).l^.name);
+                  AsmWrite(tai_label(hp).l.name);
                   AsmWriteLn(':');
                   AsmWriteLn(':');
                 end;
                 end;
              end;
              end;
@@ -662,12 +662,12 @@ interface
                if tai_symbol(hp).is_global then
                if tai_symbol(hp).is_global then
                 begin
                 begin
                   AsmWrite('.globl'#9);
                   AsmWrite('.globl'#9);
-                  AsmWriteLn(tai_symbol(hp).sym^.name);
+                  AsmWriteLn(tai_symbol(hp).sym.name);
                 end;
                 end;
                if target_info.target=target_i386_linux then
                if target_info.target=target_i386_linux then
                 begin
                 begin
                    AsmWrite(#9'.type'#9);
                    AsmWrite(#9'.type'#9);
-                   AsmWrite(tai_symbol(hp).sym^.name);
+                   AsmWrite(tai_symbol(hp).sym.name);
                    if assigned(tai(hp.next)) and
                    if assigned(tai(hp.next)) and
                       (tai(hp.next).typ in [ait_const_symbol,ait_const_rva,
                       (tai(hp.next).typ in [ait_const_symbol,ait_const_rva,
                          ait_const_32bit,ait_const_16bit,ait_const_8bit,ait_datablock,
                          ait_const_32bit,ait_const_16bit,ait_const_8bit,ait_datablock,
@@ -675,15 +675,15 @@ interface
                     AsmWriteLn(',@object')
                     AsmWriteLn(',@object')
                    else
                    else
                     AsmWriteLn(',@function');
                     AsmWriteLn(',@function');
-                   if tai_symbol(hp).sym^.size>0 then
+                   if tai_symbol(hp).sym.size>0 then
                     begin
                     begin
                       AsmWrite(#9'.size'#9);
                       AsmWrite(#9'.size'#9);
-                      AsmWrite(tai_symbol(hp).sym^.name);
+                      AsmWrite(tai_symbol(hp).sym.name);
                       AsmWrite(', ');
                       AsmWrite(', ');
-                      AsmWriteLn(tostr(tai_symbol(hp).sym^.size));
+                      AsmWriteLn(tostr(tai_symbol(hp).sym.size));
                     end;
                     end;
                 end;
                 end;
-               AsmWrite(tai_symbol(hp).sym^.name);
+               AsmWrite(tai_symbol(hp).sym.name);
                AsmWriteLn(':');
                AsmWriteLn(':');
              end;
              end;
 
 
@@ -695,9 +695,9 @@ interface
                   inc(symendcount);
                   inc(symendcount);
                   AsmWriteLn(s+':');
                   AsmWriteLn(s+':');
                   AsmWrite(#9'.size'#9);
                   AsmWrite(#9'.size'#9);
-                  AsmWrite(tai_symbol(hp).sym^.name);
+                  AsmWrite(tai_symbol(hp).sym.name);
                   AsmWrite(', '+s+' - ');
                   AsmWrite(', '+s+' - ');
-                  AsmWriteLn(tai_symbol(hp).sym^.name);
+                  AsmWriteLn(tai_symbol(hp).sym.name);
                 end;
                 end;
              end;
              end;
 
 
@@ -892,7 +892,12 @@ interface
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2001-03-05 21:39:11  peter
+  Revision 1.5  2001-04-13 01:22:17  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.4  2001/03/05 21:39:11  peter
     * changed to class with common TAssembler also for internal assembler
     * changed to class with common TAssembler also for internal assembler
 
 
   Revision 1.3  2001/01/13 20:24:24  peter
   Revision 1.3  2001/01/13 20:24:24  peter

+ 29 - 24
compiler/i386/ag386bin.pas

@@ -29,7 +29,7 @@ unit ag386bin;
 interface
 interface
 
 
     uses
     uses
-      cobjects,
+      cclasses,
       globals,
       globals,
       cpubase,aasm,
       cpubase,aasm,
       fmodule,finput,
       fmodule,finput,
@@ -55,7 +55,7 @@ interface
         n_line       : byte;     { different types of source lines }
         n_line       : byte;     { different types of source lines }
         linecount,
         linecount,
         includecount : longint;
         includecount : longint;
-        funcname     : pasmsymbol;
+        funcname     : tasmsymbol;
         stabslastfileinfo : tfileposinfo;
         stabslastfileinfo : tfileposinfo;
         procedure convertstabs(p:pchar);
         procedure convertstabs(p:pchar);
         procedure emitlineinfostabs(nidx,line : longint);
         procedure emitlineinfostabs(nidx,line : longint);
@@ -100,7 +100,7 @@ implementation
         hp : pchar;
         hp : pchar;
         reloc : boolean;
         reloc : boolean;
         sec : tsection;
         sec : tsection;
-        ps : pasmsymbol;
+        ps : tasmsymbol;
         s : string;
         s : string;
       begin
       begin
         ofs:=0;
         ofs:=0;
@@ -187,8 +187,8 @@ implementation
                   internalerror(33006)
                   internalerror(33006)
                 else
                 else
                   begin
                   begin
-                    sec:=ps^.section;
-                    ofs:=ps^.address;
+                    sec:=ps.section;
+                    ofs:=ps.address;
                     reloc:=true;
                     reloc:=true;
                     UsedAsmSymbolListInsert(ps);
                     UsedAsmSymbolListInsert(ps);
                   end;
                   end;
@@ -209,9 +209,9 @@ implementation
                       internalerror(33007)
                       internalerror(33007)
                     else
                     else
                       begin
                       begin
-                        if ps^.section<>sec then
+                        if ps.section<>sec then
                           internalerror(33008);
                           internalerror(33008);
-                        ofs:=ofs-ps^.address;
+                        ofs:=ofs-ps.address;
                         reloc:=false;
                         reloc:=false;
                         UsedAsmSymbolListInsert(ps);
                         UsedAsmSymbolListInsert(ps);
                       end;
                       end;
@@ -219,7 +219,7 @@ implementation
               end;
               end;
           end;
           end;
         { external bss need speical handling (PM) }
         { external bss need speical handling (PM) }
-        if assigned(ps) and (ps^.section=sec_none) then
+        if assigned(ps) and (ps.section=sec_none) then
           begin
           begin
             if currpass=2 then
             if currpass=2 then
               begin
               begin
@@ -247,7 +247,7 @@ implementation
 
 
         if (nidx=n_textline) and assigned(funcname) and
         if (nidx=n_textline) and assigned(funcname) and
            (target_os.use_function_relative_addresses) then
            (target_os.use_function_relative_addresses) then
-          objectdata.WriteStabs(sec_code,objectdata.sectionsize(sec_code)-funcname^.address,
+          objectdata.WriteStabs(sec_code,objectdata.sectionsize(sec_code)-funcname.address,
               nil,nidx,0,line,false)
               nil,nidx,0,line,false)
         else
         else
           begin
           begin
@@ -273,7 +273,7 @@ implementation
     procedure TInternalAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
     procedure TInternalAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
       var
       var
         curr_n : byte;
         curr_n : byte;
-        hp : pasmsymbol;
+        hp : tasmsymbol;
         infile : tinputfile;
         infile : tinputfile;
       begin
       begin
         if not ((cs_debuginfo in aktmoduleswitches) or
         if not ((cs_debuginfo in aktmoduleswitches) or
@@ -292,7 +292,7 @@ implementation
            hp:=newasmsymboltype('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
            hp:=newasmsymboltype('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
            if currpass=1 then
            if currpass=1 then
              begin
              begin
-                hp^.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
+                hp.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
                 UsedAsmSymbolListInsert(hp);
                 UsedAsmSymbolListInsert(hp);
              end
              end
            else
            else
@@ -329,7 +329,7 @@ implementation
 
 
     procedure TInternalAssembler.EndFileLineInfo;
     procedure TInternalAssembler.EndFileLineInfo;
       var
       var
-        hp : pasmsymbol;
+        hp : tasmsymbol;
         store_sec : tsection;
         store_sec : tsection;
       begin
       begin
           if not ((cs_debuginfo in aktmoduleswitches) or
           if not ((cs_debuginfo in aktmoduleswitches) or
@@ -340,7 +340,7 @@ implementation
         hp:=newasmsymboltype('Letext',AB_LOCAL,AT_FUNCTION);
         hp:=newasmsymboltype('Letext',AB_LOCAL,AT_FUNCTION);
         if currpass=1 then
         if currpass=1 then
           begin
           begin
-            hp^.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
+            hp.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
             UsedAsmSymbolListInsert(hp);
             UsedAsmSymbolListInsert(hp);
           end
           end
         else
         else
@@ -430,9 +430,9 @@ implementation
              ait_section:
              ait_section:
                objectalloc.setsection(Tai_section(hp).sec);
                objectalloc.setsection(Tai_section(hp).sec);
              ait_symbol :
              ait_symbol :
-               Tai_symbol(hp).sym^.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
+               Tai_symbol(hp).sym.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
              ait_label :
              ait_label :
-               Tai_label(hp).l^.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
+               Tai_label(hp).l.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
              ait_string :
              ait_string :
                objectalloc.sectionalloc(Tai_string(hp).len);
                objectalloc.sectionalloc(Tai_string(hp).len);
              ait_instruction :
              ait_instruction :
@@ -487,10 +487,10 @@ implementation
                   begin
                   begin
                     if Tai_datablock(hp).is_global then
                     if Tai_datablock(hp).is_global then
                      begin
                      begin
-                       Tai_datablock(hp).sym^.setaddress(sec_none,Tai_datablock(hp).size,Tai_datablock(hp).size);
+                       Tai_datablock(hp).sym.setaddress(sec_none,Tai_datablock(hp).size,Tai_datablock(hp).size);
                        { force to be common/external, must be after setaddress as that would
                        { force to be common/external, must be after setaddress as that would
                          set it to AS_GLOBAL }
                          set it to AS_GLOBAL }
-                       Tai_datablock(hp).sym^.bind:=AB_COMMON;
+                       Tai_datablock(hp).sym.bind:=AB_COMMON;
                      end
                      end
                     else
                     else
                      begin
                      begin
@@ -499,7 +499,7 @@ implementation
                          objectalloc.sectionalign(4)
                          objectalloc.sectionalign(4)
                        else if l>1 then
                        else if l>1 then
                          objectalloc.sectionalign(2);
                          objectalloc.sectionalign(2);
-                       Tai_datablock(hp).sym^.setaddress(objectalloc.currsec,objectalloc.sectionsize,
+                       Tai_datablock(hp).sym.setaddress(objectalloc.currsec,objectalloc.sectionsize,
                          Tai_datablock(hp).size);
                          Tai_datablock(hp).size);
                        objectalloc.sectionalloc(Tai_datablock(hp).size);
                        objectalloc.sectionalloc(Tai_datablock(hp).size);
                      end;
                      end;
@@ -511,7 +511,7 @@ implementation
                        objectalloc.sectionalign(4)
                        objectalloc.sectionalign(4)
                      else if l>1 then
                      else if l>1 then
                        objectalloc.sectionalign(2);
                        objectalloc.sectionalign(2);
-                     Tai_datablock(hp).sym^.setaddress(objectalloc.currsec,objectalloc.sectionsize,Tai_datablock(hp).size);
+                     Tai_datablock(hp).sym.setaddress(objectalloc.currsec,objectalloc.sectionsize,Tai_datablock(hp).size);
                      objectalloc.sectionalloc(Tai_datablock(hp).size);
                      objectalloc.sectionalloc(Tai_datablock(hp).size);
                    end;
                    end;
                  UsedAsmSymbolListInsert(Tai_datablock(hp).sym);
                  UsedAsmSymbolListInsert(Tai_datablock(hp).sym);
@@ -570,20 +570,20 @@ implementation
 {$endif}
 {$endif}
              ait_symbol :
              ait_symbol :
                begin
                begin
-                 Tai_symbol(hp).sym^.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
+                 Tai_symbol(hp).sym.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
                  UsedAsmSymbolListInsert(Tai_symbol(hp).sym);
                  UsedAsmSymbolListInsert(Tai_symbol(hp).sym);
                end;
                end;
              ait_symbol_end :
              ait_symbol_end :
                begin
                begin
                  if target_info.target=target_i386_linux then
                  if target_info.target=target_i386_linux then
                   begin
                   begin
-                    Tai_symbol(hp).sym^.size:=objectalloc.sectionsize-Tai_symbol(hp).sym^.address;
+                    Tai_symbol(hp).sym.size:=objectalloc.sectionsize-Tai_symbol(hp).sym.address;
                     UsedAsmSymbolListInsert(Tai_symbol(hp).sym);
                     UsedAsmSymbolListInsert(Tai_symbol(hp).sym);
                   end;
                   end;
                 end;
                 end;
              ait_label :
              ait_label :
                begin
                begin
-                 Tai_label(hp).l^.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
+                 Tai_label(hp).l.setaddress(objectalloc.currsec,objectalloc.sectionsize,0);
                  UsedAsmSymbolListInsert(Tai_label(hp).l);
                  UsedAsmSymbolListInsert(Tai_label(hp).l);
                end;
                end;
              ait_string :
              ait_string :
@@ -1026,14 +1026,19 @@ implementation
         objectoutput.free;
         objectoutput.free;
         objectalloc.free;
         objectalloc.free;
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
-         d.done;
+         d.free;
 {$endif}
 {$endif}
       end;
       end;
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-03-11 22:58:51  peter
+  Revision 1.7  2001-04-13 01:22:17  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2001/03/11 22:58:51  peter
     * getsym redesign, removed the globals srsym,srsymtable
     * getsym redesign, removed the globals srsym,srsymtable
 
 
   Revision 1.5  2001/03/05 21:39:11  peter
   Revision 1.5  2001/03/05 21:39:11  peter

+ 23 - 18
compiler/i386/ag386int.pas

@@ -41,7 +41,7 @@ interface
 {$ifdef delphi}
 {$ifdef delphi}
       sysutils,
       sysutils,
 {$endif}
 {$endif}
-      cutils,globtype,globals,systems,cobjects,
+      cutils,globtype,globals,systems,cclasses,
       verbose,cpubase,cpuasm,finput,fmodule
       verbose,cpubase,cpuasm,finput,fmodule
       ;
       ;
 
 
@@ -137,7 +137,7 @@ interface
           begin
           begin
             if (aktoutputformat = as_i386_tasm) then
             if (aktoutputformat = as_i386_tasm) then
               s:=s+'dword ptr ';
               s:=s+'dword ptr ';
-            s:=s+symbol^.name;
+            s:=s+symbol.name;
             first:=false;
             first:=false;
           end;
           end;
          if (base<>R_NO) then
          if (base<>R_NO) then
@@ -180,7 +180,7 @@ interface
         top_symbol :
         top_symbol :
           begin
           begin
             if assigned(o.sym) then
             if assigned(o.sym) then
-              hs:='offset '+o.sym^.name
+              hs:='offset '+o.sym.name
             else
             else
               hs:='offset ';
               hs:='offset ';
             if o.symofs>0 then
             if o.symofs>0 then
@@ -242,7 +242,7 @@ interface
           getopstr_jmp:=tostr(o.val);
           getopstr_jmp:=tostr(o.val);
         top_symbol :
         top_symbol :
           begin
           begin
-            hs:=o.sym^.name;
+            hs:=o.sym.name;
             if o.symofs>0 then
             if o.symofs>0 then
              hs:=hs+'+'+tostr(o.symofs)
              hs:=hs+'+'+tostr(o.symofs)
             else
             else
@@ -425,8 +425,8 @@ interface
                      end;
                      end;
      ait_datablock : begin
      ait_datablock : begin
                        if tai_datablock(hp).is_global then
                        if tai_datablock(hp).is_global then
-                         AsmWriteLn(#9'PUBLIC'#9+tai_datablock(hp).sym^.name);
-                       AsmWriteLn(PadTabs(tai_datablock(hp).sym^.name,#0)+'DB'#9+tostr(tai_datablock(hp).size)+' DUP(?)');
+                         AsmWriteLn(#9'PUBLIC'#9+tai_datablock(hp).sym.name);
+                       AsmWriteLn(PadTabs(tai_datablock(hp).sym.name,#0)+'DB'#9+tostr(tai_datablock(hp).size)+' DUP(?)');
                      end;
                      end;
    ait_const_32bit,
    ait_const_32bit,
     ait_const_8bit,
     ait_const_8bit,
@@ -447,7 +447,7 @@ interface
                        AsmLn;
                        AsmLn;
                      end;
                      end;
   ait_const_symbol : begin
   ait_const_symbol : begin
-                       AsmWriteLn(#9#9'DD'#9'offset '+tai_const_symbol(hp).sym^.name);
+                       AsmWriteLn(#9#9'DD'#9'offset '+tai_const_symbol(hp).sym.name);
                        if tai_const_symbol(hp).offset>0 then
                        if tai_const_symbol(hp).offset>0 then
                          AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
                          AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
                        else if tai_const_symbol(hp).offset<0 then
                        else if tai_const_symbol(hp).offset<0 then
@@ -455,7 +455,7 @@ interface
                        AsmLn;
                        AsmLn;
                      end;
                      end;
      ait_const_rva : begin
      ait_const_rva : begin
-                       AsmWriteLn(#9#9'RVA'#9+tai_const_symbol(hp).sym^.name);
+                       AsmWriteLn(#9#9'RVA'#9+tai_const_symbol(hp).sym.name);
                      end;
                      end;
         ait_real_32bit : AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
         ait_real_32bit : AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
         ait_real_64bit : AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
         ait_real_64bit : AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
@@ -536,9 +536,9 @@ interface
                        AsmLn;
                        AsmLn;
                      end;
                      end;
          ait_label : begin
          ait_label : begin
-                       if tai_label(hp).l^.is_used then
+                       if tai_label(hp).l.is_used then
                         begin
                         begin
-                          AsmWrite(tai_label(hp).l^.name);
+                          AsmWrite(tai_label(hp).l.name);
                           if assigned(hp.next) and not(tai(hp.next).typ in
                           if assigned(hp.next) and not(tai(hp.next).typ in
                              [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                              [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                               ait_const_symbol,ait_const_rva,
                               ait_const_symbol,ait_const_rva,
@@ -552,8 +552,8 @@ interface
                      end;
                      end;
         ait_symbol : begin
         ait_symbol : begin
                        if tai_symbol(hp).is_global then
                        if tai_symbol(hp).is_global then
-                         AsmWriteLn(#9'PUBLIC'#9+tai_symbol(hp).sym^.name);
-                       AsmWrite(tai_symbol(hp).sym^.name);
+                         AsmWriteLn(#9'PUBLIC'#9+tai_symbol(hp).sym.name);
+                       AsmWrite(tai_symbol(hp).sym.name);
                        if assigned(hp.next) and not(tai(hp.next).typ in
                        if assigned(hp.next) and not(tai(hp.next).typ in
                           [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                           [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                            ait_const_symbol,ait_const_rva,
                            ait_const_symbol,ait_const_rva,
@@ -685,22 +685,22 @@ ait_stab_function_name : ;
     var
     var
       currentasmlist : TExternalAssembler;
       currentasmlist : TExternalAssembler;
 
 
-    procedure writeexternal(p:pnamedindexobject);
+    procedure writeexternal(p:tnamedindexitem);
       begin
       begin
-        if pasmsymbol(p)^.defbind=AB_EXTERNAL then
+        if tasmsymbol(p).defbind=AB_EXTERNAL then
           begin
           begin
             if (aktoutputformat = as_i386_masm) then
             if (aktoutputformat = as_i386_masm) then
-              currentasmlist.AsmWriteln(#9'EXTRN'#9+p^.name
+              currentasmlist.AsmWriteln(#9'EXTRN'#9+p.name
                 +': NEAR')
                 +': NEAR')
             else
             else
-              currentasmlist.AsmWriteln(#9'EXTRN'#9+p^.name);
+              currentasmlist.AsmWriteln(#9'EXTRN'#9+p.name);
           end;
           end;
       end;
       end;
 
 
     procedure T386IntelAssembler.WriteExternals;
     procedure T386IntelAssembler.WriteExternals;
       begin
       begin
         currentasmlist:=self;
         currentasmlist:=self;
-        AsmSymbolList^.foreach({$ifdef fpcprocvar}@{$endif}writeexternal);
+        AsmSymbolList.foreach_static({$ifdef fpcprocvar}@{$endif}writeexternal);
       end;
       end;
 
 
 
 
@@ -748,7 +748,12 @@ ait_stab_function_name : ;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2001-03-25 12:30:17  peter
+  Revision 1.9  2001-04-13 01:22:17  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.8  2001/03/25 12:30:17  peter
     * masm -al fix (merged)
     * masm -al fix (merged)
 
 
   Revision 1.7  2001/03/05 21:39:11  peter
   Revision 1.7  2001/03/05 21:39:11  peter

+ 22 - 17
compiler/i386/ag386nsm.pas

@@ -42,7 +42,7 @@ interface
 {$ifdef delphi}
 {$ifdef delphi}
       sysutils,
       sysutils,
 {$endif}
 {$endif}
-      cutils,globtype,globals,systems,cobjects,
+      cutils,globtype,globals,systems,cclasses,
       fmodule,finput,verbose,cpubase,cpuasm
       fmodule,finput,verbose,cpubase,cpuasm
       ;
       ;
 
 
@@ -161,7 +161,7 @@ interface
            s:='[';
            s:='[';
          if assigned(symbol) then
          if assigned(symbol) then
           begin
           begin
-            s:=s+symbol^.name;
+            s:=s+symbol.name;
             first:=false;
             first:=false;
           end;
           end;
          if (base<>R_NO) then
          if (base<>R_NO) then
@@ -238,7 +238,7 @@ interface
           top_symbol :
           top_symbol :
             begin
             begin
               if assigned(o.sym) then
               if assigned(o.sym) then
-               hs:='dword '+o.sym^.name
+               hs:='dword '+o.sym.name
               else
               else
                hs:='dword ';
                hs:='dword ';
               if o.symofs>0 then
               if o.symofs>0 then
@@ -283,7 +283,7 @@ interface
             getopstr_jmp:=tostr(o.val);
             getopstr_jmp:=tostr(o.val);
           top_symbol :
           top_symbol :
             begin
             begin
-              hs:=o.sym^.name;
+              hs:=o.sym.name;
               if o.symofs>0 then
               if o.symofs>0 then
                hs:=hs+'+'+tostr(o.symofs)
                hs:=hs+'+'+tostr(o.symofs)
               else
               else
@@ -454,9 +454,9 @@ interface
                if tai_datablock(hp).is_global then
                if tai_datablock(hp).is_global then
                 begin
                 begin
                   AsmWrite(#9'GLOBAL ');
                   AsmWrite(#9'GLOBAL ');
-                  AsmWriteLn(tai_datablock(hp).sym^.name);
+                  AsmWriteLn(tai_datablock(hp).sym.name);
                 end;
                 end;
-               AsmWrite(PadTabs(tai_datablock(hp).sym^.name,':'));
+               AsmWrite(PadTabs(tai_datablock(hp).sym.name,':'));
                AsmWriteLn('RESB'#9+tostr(tai_datablock(hp).size));
                AsmWriteLn('RESB'#9+tostr(tai_datablock(hp).size));
              end;
              end;
 
 
@@ -483,7 +483,7 @@ interface
            ait_const_symbol :
            ait_const_symbol :
              begin
              begin
                AsmWrite(#9#9'DD'#9);
                AsmWrite(#9#9'DD'#9);
-               AsmWrite(tai_const_symbol(hp).sym^.name);
+               AsmWrite(tai_const_symbol(hp).sym.name);
                if tai_const_symbol(hp).offset>0 then
                if tai_const_symbol(hp).offset>0 then
                  AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
                  AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
                else if tai_const_symbol(hp).offset<0 then
                else if tai_const_symbol(hp).offset<0 then
@@ -494,7 +494,7 @@ interface
            ait_const_rva :
            ait_const_rva :
              begin
              begin
                AsmWrite(#9#9'RVA'#9);
                AsmWrite(#9#9'RVA'#9);
-               AsmWriteLn(tai_const_symbol(hp).sym^.name);
+               AsmWriteLn(tai_const_symbol(hp).sym.name);
              end;
              end;
 
 
            ait_real_32bit :
            ait_real_32bit :
@@ -588,8 +588,8 @@ interface
 
 
            ait_label :
            ait_label :
              begin
              begin
-               if tai_label(hp).l^.is_used then
-                AsmWriteLn(tai_label(hp).l^.name+':');
+               if tai_label(hp).l.is_used then
+                AsmWriteLn(tai_label(hp).l.name+':');
              end;
              end;
 
 
            ait_direct :
            ait_direct :
@@ -603,9 +603,9 @@ interface
                if tai_symbol(hp).is_global then
                if tai_symbol(hp).is_global then
                 begin
                 begin
                   AsmWrite(#9'GLOBAL ');
                   AsmWrite(#9'GLOBAL ');
-                  AsmWriteLn(tai_symbol(hp).sym^.name);
+                  AsmWriteLn(tai_symbol(hp).sym.name);
                 end;
                 end;
-               AsmWrite(tai_symbol(hp).sym^.name);
+               AsmWrite(tai_symbol(hp).sym.name);
                if assigned(hp.next) and not(tai(hp.next).typ in
                if assigned(hp.next) and not(tai(hp.next).typ in
                   [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                   [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                    ait_const_symbol,ait_const_rva,
                    ait_const_symbol,ait_const_rva,
@@ -716,16 +716,16 @@ interface
     var
     var
       currentasmlist : TExternalAssembler;
       currentasmlist : TExternalAssembler;
 
 
-    procedure writeexternal(p:pnamedindexobject);
+    procedure writeexternal(p:tnamedindexitem);
       begin
       begin
-        if pasmsymbol(p)^.defbind=AB_EXTERNAL then
-         currentasmlist.AsmWriteln('EXTERN'#9+p^.name);
+        if tasmsymbol(p).defbind=AB_EXTERNAL then
+         currentasmlist.AsmWriteln('EXTERN'#9+p.name);
       end;
       end;
 
 
     procedure T386NasmAssembler.WriteExternals;
     procedure T386NasmAssembler.WriteExternals;
       begin
       begin
         currentasmlist:=self;
         currentasmlist:=self;
-        AsmSymbolList^.foreach({$ifdef fpcprocvar}@{$endif}writeexternal);
+        AsmSymbolList.foreach_static({$ifdef fpcprocvar}@{$endif}writeexternal);
       end;
       end;
 
 
 
 
@@ -773,7 +773,12 @@ interface
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-03-05 21:39:11  peter
+  Revision 1.7  2001-04-13 01:22:17  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2001/03/05 21:39:11  peter
     * changed to class with common TAssembler also for internal assembler
     * changed to class with common TAssembler also for internal assembler
 
 
   Revision 1.5  2001/02/20 21:36:39  peter
   Revision 1.5  2001/02/20 21:36:39  peter

File diff suppressed because it is too large
+ 181 - 177
compiler/i386/cgai386.pas


+ 31 - 26
compiler/i386/cpuasm.pas

@@ -40,7 +40,7 @@ unit cpuasm;
 interface
 interface
 
 
 uses
 uses
-  cobjects,cclasses,
+  cclasses,
   aasm,globals,verbose,
   aasm,globals,verbose,
   cpubase;
   cpubase;
 
 
@@ -97,15 +97,15 @@ type
      constructor op_const_reg_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : preference);
      constructor op_const_reg_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : preference);
 
 
      { this is for Jmp instructions }
      { this is for Jmp instructions }
-     constructor op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : pasmsymbol);
+     constructor op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
 
 
-     constructor op_sym(op : tasmop;_size : topsize;_op1 : pasmsymbol);
-     constructor op_sym_ofs(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint);
-     constructor op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : tregister);
-     constructor op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : preference);
+     constructor op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
+     constructor op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
+     constructor op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
+     constructor op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : preference);
 
 
      procedure loadconst(opidx:longint;l:longint);
      procedure loadconst(opidx:longint;l:longint);
-     procedure loadsymbol(opidx:longint;s:pasmsymbol;sofs:longint);
+     procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
      procedure loadref(opidx:longint;p:preference);
      procedure loadref(opidx:longint;p:preference);
      procedure loadreg(opidx:longint;r:tregister);
      procedure loadreg(opidx:longint;r:tregister);
      procedure loadoper(opidx:longint;o:toper);
      procedure loadoper(opidx:longint;o:toper);
@@ -140,7 +140,7 @@ type
      function  calcsize(p:PInsEntry):longint;
      function  calcsize(p:PInsEntry):longint;
      procedure gencode;
      procedure gencode;
      function  NeedAddrPrefix(opidx:byte):boolean;
      function  NeedAddrPrefix(opidx:byte):boolean;
-     procedure SwapOperands;
+     procedure Swatoperands;
 {$endif NOAG386BIN}
 {$endif NOAG386BIN}
   end;
   end;
 
 
@@ -240,7 +240,7 @@ uses
       end;
       end;
 
 
 
 
-    procedure taicpu.loadsymbol(opidx:longint;s:pasmsymbol;sofs:longint);
+    procedure taicpu.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
       begin
       begin
         if opidx>=ops then
         if opidx>=ops then
          ops:=opidx+1;
          ops:=opidx+1;
@@ -254,7 +254,7 @@ uses
          end;
          end;
         { Mark the symbol as used }
         { Mark the symbol as used }
         if assigned(s) then
         if assigned(s) then
-         inc(s^.refs);
+         inc(s.refs);
       end;
       end;
 
 
 
 
@@ -283,7 +283,7 @@ uses
                typ:=top_ref;
                typ:=top_ref;
                { mark symbol as used }
                { mark symbol as used }
                if assigned(ref^.symbol) then
                if assigned(ref^.symbol) then
-                 inc(ref^.symbol^.refs);
+                 inc(ref^.symbol.refs);
              end;
              end;
          end;
          end;
       end;
       end;
@@ -509,7 +509,7 @@ uses
       end;
       end;
 
 
 
 
-    constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : pasmsymbol);
+    constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
       begin
       begin
          inherited create;
          inherited create;
          init(op,_size);
          init(op,_size);
@@ -519,7 +519,7 @@ uses
       end;
       end;
 
 
 
 
-    constructor taicpu.op_sym(op : tasmop;_size : topsize;_op1 : pasmsymbol);
+    constructor taicpu.op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
       begin
       begin
          inherited create;
          inherited create;
          init(op,_size);
          init(op,_size);
@@ -528,7 +528,7 @@ uses
       end;
       end;
 
 
 
 
-    constructor taicpu.op_sym_ofs(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint);
+    constructor taicpu.op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
       begin
       begin
          inherited create;
          inherited create;
          init(op,_size);
          init(op,_size);
@@ -537,7 +537,7 @@ uses
       end;
       end;
 
 
 
 
-    constructor taicpu.op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : tregister);
+    constructor taicpu.op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
       begin
       begin
          inherited create;
          inherited create;
          init(op,_size);
          init(op,_size);
@@ -547,7 +547,7 @@ uses
       end;
       end;
 
 
 
 
-    constructor taicpu.op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : preference);
+    constructor taicpu.op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : preference);
       begin
       begin
          inherited create;
          inherited create;
          init(op,_size);
          init(op,_size);
@@ -566,7 +566,7 @@ uses
              top_ref:
              top_ref:
                dispose(oper[0].ref);
                dispose(oper[0].ref);
              top_symbol:
              top_symbol:
-               dec(Pasmsymbol(oper[0].sym)^.refs);
+               dec(tasmsymbol(oper[0].sym).refs);
            end;
            end;
            if (ops>1) then
            if (ops>1) then
             begin
             begin
@@ -682,7 +682,7 @@ uses
       end;
       end;
 
 
 
 
-    procedure taicpu.SwapOperands;
+    procedure taicpu.Swatoperands;
       var
       var
         p : TOper;
         p : TOper;
       begin
       begin
@@ -708,7 +708,7 @@ uses
       begin
       begin
         if FOperandOrder<>order then
         if FOperandOrder<>order then
          begin
          begin
-           SwapOperands;
+           Swatoperands;
            FOperandOrder:=order;
            FOperandOrder:=order;
          end;
          end;
       end;
       end;
@@ -821,11 +821,11 @@ begin
              l:=InsOffset-LastInsOffset;
              l:=InsOffset-LastInsOffset;
             inc(l,symofs);
             inc(l,symofs);
             if assigned(sym) then
             if assigned(sym) then
-             inc(l,sym^.address);
+             inc(l,sym.address);
             { instruction size will then always become 2 (PFV) }
             { instruction size will then always become 2 (PFV) }
             relsize:=(InsOffset+2)-l;
             relsize:=(InsOffset+2)-l;
             if (not assigned(sym) or
             if (not assigned(sym) or
-                ((sym^.bind<>AB_EXTERNAL) and (sym^.address<>0))) and
+                ((sym.bind<>AB_EXTERNAL) and (sym.address<>0))) and
                (relsize>=-128) and (relsize<=127) then
                (relsize>=-128) and (relsize<=127) then
              ot:=OT_IMM32 or OT_SHORT
              ot:=OT_IMM32 or OT_SHORT
             else
             else
@@ -930,7 +930,7 @@ begin
    { we can leave because the size for all operands is forced to be
    { we can leave because the size for all operands is forced to be
      the same
      the same
      but not if IF_SB IF_SW or IF_SD is set PM }
      but not if IF_SB IF_SW or IF_SD is set PM }
-     if asize= $ffffffff then
+     if asize=-1 then
        exit;
        exit;
      siz[0]:=asize;
      siz[0]:=asize;
      siz[1]:=asize;
      siz[1]:=asize;
@@ -1189,7 +1189,7 @@ const
 var
 var
   j     : longint;
   j     : longint;
   i,b   : tregister;
   i,b   : tregister;
-  sym   : pasmsymbol;
+  sym   : tasmsymbol;
   md,s  : byte;
   md,s  : byte;
   base,index,scalefactor,
   base,index,scalefactor,
   o     : longint;
   o     : longint;
@@ -1463,7 +1463,7 @@ procedure taicpu.GenCode;
 
 
 var
 var
   currval : longint;
   currval : longint;
-  currsym : pasmsymbol;
+  currsym : tasmsymbol;
 
 
   procedure getvalsym(opidx:longint);
   procedure getvalsym(opidx:longint);
   begin
   begin
@@ -1652,7 +1652,7 @@ begin
           getvalsym(c-40);
           getvalsym(c-40);
           data:=currval-insend;
           data:=currval-insend;
           if assigned(currsym) then
           if assigned(currsym) then
-           inc(data,currsym^.address);
+           inc(data,currsym.address);
           if (data>127) or (data<-128) then
           if (data>127) or (data<-128) then
            Message1(asmw_e_short_jmp_out_of_range,tostr(data));
            Message1(asmw_e_short_jmp_out_of_range,tostr(data));
           objectdata.writebytes(data,1);
           objectdata.writebytes(data,1);
@@ -1773,7 +1773,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-05 21:33:45  peter
+  Revision 1.14  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/05 21:33:45  peter
     * movd and opsize fix merged
     * movd and opsize fix merged
 
 
   Revision 1.12  2001/03/25 12:29:45  peter
   Revision 1.12  2001/03/25 12:29:45  peter

+ 11 - 7
compiler/i386/cpubase.pas

@@ -31,7 +31,7 @@ unit cpubase;
 interface
 interface
 
 
 uses
 uses
-  globals,cutils,cobjects,aasm;
+  globals,cutils,cclasses,aasm;
 
 
 const
 const
 { Size of the instruction table converted by nasmconv.pas }
 { Size of the instruction table converted by nasmconv.pas }
@@ -194,8 +194,7 @@ type
 
 
   op2strtable=array[tasmop] of string[11];
   op2strtable=array[tasmop] of string[11];
 
 
-  pstr2opentry = ^tstr2opentry;
-  tstr2opentry = object(Tnamedindexobject)
+  tstr2opentry = class(Tnamedindexitem)
     op: TAsmOp;
     op: TAsmOp;
   end;
   end;
 
 
@@ -444,7 +443,7 @@ type
      index       : tregister;
      index       : tregister;
      scalefactor : byte;
      scalefactor : byte;
      offset      : longint;
      offset      : longint;
-     symbol      : pasmsymbol;
+     symbol      : tasmsymbol;
      offsetfixup : longint;
      offsetfixup : longint;
      options     : trefoptions;
      options     : trefoptions;
 {$ifdef newcg}
 {$ifdef newcg}
@@ -466,7 +465,7 @@ type
            top_reg    : (reg:tregister);
            top_reg    : (reg:tregister);
            top_ref    : (ref:preference);
            top_ref    : (ref:preference);
            top_const  : (val:longint);
            top_const  : (val:longint);
-           top_symbol : (sym:pasmsymbol;symofs:longint);
+           top_symbol : (sym:tasmsymbol;symofs:longint);
         end;
         end;
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -924,7 +923,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2001-02-20 21:34:04  peter
+  Revision 1.4  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.3  2001/02/20 21:34:04  peter
     * iret, lret fixes
     * iret, lret fixes
 
 
   Revision 1.2  2000/12/07 17:19:45  jonas
   Revision 1.2  2000/12/07 17:19:45  jonas
@@ -962,4 +966,4 @@ end.
   Revision 1.2  2000/07/13 11:32:39  michael
   Revision 1.2  2000/07/13 11:32:39  michael
   + removed logs
   + removed logs
 
 
-}
+}

+ 32 - 27
compiler/i386/daopt386.pas

@@ -197,7 +197,7 @@ Function DFAPass2(
                                       BlockStart, BlockEnd: Tai): Boolean;
                                       BlockStart, BlockEnd: Tai): Boolean;
 Procedure ShutDownDFA;
 Procedure ShutDownDFA;
 
 
-Function FindLabel(L: PasmLabel; Var hp: Tai): Boolean;
+Function FindLabel(L: tasmlabel; Var hp: Tai): Boolean;
 
 
 Procedure IncState(Var S: Byte; amount: longint);
 Procedure IncState(Var S: Byte; amount: longint);
 
 
@@ -256,19 +256,19 @@ Var
   var temp: PSearchLinkedListItem;
   var temp: PSearchLinkedListItem;
   begin
   begin
     temp := first;
     temp := first;
-    while (temp <> last^.next) and
+    while (temp <> last.next) and
           not(temp.equals(p)) do
           not(temp.equals(p)) do
       temp := temp.next;
       temp := temp.next;
-    searchByValue := temp <> last^.next;
+    searchByValue := temp <> last.next;
   end;
   end;
 
 
   procedure TSearchLinkedList.removeByValue(p: PSearchLinkedListItem);
   procedure TSearchLinkedList.removeByValue(p: PSearchLinkedListItem);
   begin
   begin
     temp := first;
     temp := first;
-    while (temp <> last^.next) and
+    while (temp <> last.next) and
           not(temp.equals(p)) do
           not(temp.equals(p)) do
       temp := temp.next;
       temp := temp.next;
-    if temp <> last^.next then
+    if temp <> last.next then
       begin
       begin
         remove(temp);
         remove(temp);
         dispose(temp,done);
         dispose(temp,done);
@@ -320,10 +320,10 @@ Begin
           Then
           Then
             Begin
             Begin
               LabelFound := True;
               LabelFound := True;
-              If (Tai_Label(p).l^.labelnr < LowLabel) Then
-                LowLabel := Tai_Label(p).l^.labelnr;
-              If (Tai_Label(p).l^.labelnr > HighLabel) Then
-                HighLabel := Tai_Label(p).l^.labelnr;
+              If (Tai_Label(p).l.labelnr < LowLabel) Then
+                LowLabel := Tai_Label(p).l.labelnr;
+              If (Tai_Label(p).l.labelnr > HighLabel) Then
+                HighLabel := Tai_Label(p).l.labelnr;
             End;
             End;
       lastP := p;
       lastP := p;
       GetNextInstruction(p, p);
       GetNextInstruction(p, p);
@@ -388,18 +388,18 @@ Procedure RemoveLastDeallocForFuncRes(asmL: TAAsmOutput; p: Tai);
 
 
 begin
 begin
   if assigned(procinfo^.returntype.def) then
   if assigned(procinfo^.returntype.def) then
-    case procinfo^.returntype.def^.deftype of
+    case procinfo^.returntype.def.deftype of
       arraydef,recorddef,pointerdef,
       arraydef,recorddef,pointerdef,
          stringdef,enumdef,procdef,objectdef,errordef,
          stringdef,enumdef,procdef,objectdef,errordef,
          filedef,setdef,procvardef,
          filedef,setdef,procvardef,
          classrefdef,forwarddef:
          classrefdef,forwarddef:
         DoRemoveLastDeallocForFuncRes(asmL,R_EAX);
         DoRemoveLastDeallocForFuncRes(asmL,R_EAX);
       orddef:
       orddef:
-        if procinfo^.returntype.def^.size <> 0 then
+        if procinfo^.returntype.def.size <> 0 then
           begin
           begin
             DoRemoveLastDeallocForFuncRes(asmL,R_EAX);
             DoRemoveLastDeallocForFuncRes(asmL,R_EAX);
             { for int64/qword }
             { for int64/qword }
-            if procinfo^.returntype.def^.size = 8 then
+            if procinfo^.returntype.def.size = 8 then
               DoRemoveLastDeallocForFuncRes(asmL,R_EDX);
               DoRemoveLastDeallocForFuncRes(asmL,R_EDX);
           end;
           end;
     end;
     end;
@@ -410,18 +410,18 @@ var regCounter: TRegister;
 begin
 begin
   regs := [];
   regs := [];
   if assigned(procinfo^.returntype.def) then
   if assigned(procinfo^.returntype.def) then
-    case procinfo^.returntype.def^.deftype of
+    case procinfo^.returntype.def.deftype of
       arraydef,recorddef,pointerdef,
       arraydef,recorddef,pointerdef,
          stringdef,enumdef,procdef,objectdef,errordef,
          stringdef,enumdef,procdef,objectdef,errordef,
          filedef,setdef,procvardef,
          filedef,setdef,procvardef,
          classrefdef,forwarddef:
          classrefdef,forwarddef:
        regs := [R_EAX];
        regs := [R_EAX];
       orddef:
       orddef:
-        if procinfo^.returntype.def^.size <> 0 then
+        if procinfo^.returntype.def.size <> 0 then
           begin
           begin
             regs := [R_EAX];
             regs := [R_EAX];
             { for int64/qword }
             { for int64/qword }
-            if procinfo^.returntype.def^.size = 8 then
+            if procinfo^.returntype.def.size = 8 then
               regs := regs + [R_EDX];
               regs := regs + [R_EDX];
           end;
           end;
     end;
     end;
@@ -444,7 +444,7 @@ begin
   while not(funcResReg and
   while not(funcResReg and
             (p.typ = ait_instruction) and
             (p.typ = ait_instruction) and
             (Taicpu(p).opcode = A_JMP) and
             (Taicpu(p).opcode = A_JMP) and
-            (pasmlabel(Taicpu(p).oper[0].sym) = aktexit2label)) and
+            (tasmlabel(Taicpu(p).oper[0].sym) = aktexit2label)) and
         getLastInstruction(p, p) And
         getLastInstruction(p, p) And
         not(regInInstruction(reg, p)) Do
         not(regInInstruction(reg, p)) Do
     hp1 := p;
     hp1 := p;
@@ -453,7 +453,7 @@ begin
   if not(funcResReg) or
   if not(funcResReg) or
      not((hp1.typ = ait_instruction) and
      not((hp1.typ = ait_instruction) and
          (Taicpu(hp1).opcode = A_JMP) and
          (Taicpu(hp1).opcode = A_JMP) and
-         (pasmlabel(Taicpu(hp1).oper[0].sym) = aktexit2label)) then
+         (tasmlabel(Taicpu(hp1).oper[0].sym) = aktexit2label)) then
     begin
     begin
       p := TaiRegAlloc.deAlloc(reg);
       p := TaiRegAlloc.deAlloc(reg);
       insertLLItem(AsmL, hp1.previous, hp1, p);
       insertLLItem(AsmL, hp1.previous, hp1, p);
@@ -481,7 +481,7 @@ Begin
       Case p.typ Of
       Case p.typ Of
         ait_Label:
         ait_Label:
           If not labelCanBeSkipped(Tai_label(p)) Then
           If not labelCanBeSkipped(Tai_label(p)) Then
-            LabelTable^[Tai_Label(p).l^.labelnr-LowLabel].TaiObj := p;
+            LabelTable^[Tai_Label(p).l.labelnr-LowLabel].TaiObj := p;
         ait_regAlloc:
         ait_regAlloc:
           { ESI and EDI are (de)allocated manually, don't mess with them }
           { ESI and EDI are (de)allocated manually, don't mess with them }
           if not(TaiRegAlloc(p).Reg in [R_EDI,R_ESI]) then
           if not(TaiRegAlloc(p).Reg in [R_EDI,R_ESI]) then
@@ -528,7 +528,7 @@ End;
 
 
 {************************ Search the Label table ************************}
 {************************ Search the Label table ************************}
 
 
-Function FindLabel(L: PasmLabel; Var hp: Tai): Boolean;
+Function FindLabel(L: tasmlabel; Var hp: Tai): Boolean;
 
 
 {searches for the specified label starting from hp as long as the
 {searches for the specified label starting from hp as long as the
  encountered instructions are labels, to be able to optimize constructs like
  encountered instructions are labels, to be able to optimize constructs like
@@ -1063,7 +1063,7 @@ End;
 
 
 function labelCanBeSkipped(p: Tai_label): boolean;
 function labelCanBeSkipped(p: Tai_label): boolean;
 begin
 begin
-  labelCanBeSkipped := not(p.l^.is_used) or p.l^.is_addr;
+  labelCanBeSkipped := not(p.l.is_used) or p.l.is_addr;
 end;
 end;
 
 
 {******************* The Data Flow Analyzer functions ********************}
 {******************* The Data Flow Analyzer functions ********************}
@@ -1989,7 +1989,7 @@ Begin
                             While GetNextInstruction(hp, hp) And
                             While GetNextInstruction(hp, hp) And
                                   Not((hp.typ = ait_instruction) And
                                   Not((hp.typ = ait_instruction) And
                                       (Taicpu(hp).is_jmp) and
                                       (Taicpu(hp).is_jmp) and
-                                      (pasmlabel(Taicpu(hp).oper[0].sym)^.labelnr = Tai_Label(p).l^.labelnr)) And
+                                      (tasmlabel(Taicpu(hp).oper[0].sym).labelnr = Tai_Label(p).l^.labelnr)) And
                                   Not((hp.typ = ait_label) And
                                   Not((hp.typ = ait_label) And
                                       (LTable^[Tai_Label(hp).l^.labelnr-LoLab].RefsFound
                                       (LTable^[Tai_Label(hp).l^.labelnr-LoLab].RefsFound
                                        = Tai_Label(hp).l^.RefCount) And
                                        = Tai_Label(hp).l^.RefCount) And
@@ -2041,8 +2041,8 @@ Begin
                       con_invalid: typ := con_unknown;
                       con_invalid: typ := con_unknown;
                     end;
                     end;
 {$Else JumpAnal}
 {$Else JumpAnal}
-          With LTable^[pasmlabel(Taicpu(p).oper[0].sym)^.labelnr-LoLab] Do
-            If (RefsFound = pasmlabel(Taicpu(p).oper[0].sym)^.RefCount) Then
+          With LTable^[tasmlabel(Taicpu(p).oper[0].sym).labelnr-LoLab] Do
+            If (RefsFound = tasmlabel(Taicpu(p).oper[0].sym).RefCount) Then
               Begin
               Begin
                 If (InstrCnt < InstrNr)
                 If (InstrCnt < InstrNr)
                   Then
                   Then
@@ -2390,9 +2390,9 @@ Begin
           begin
           begin
             if Taicpu(p).is_jmp then
             if Taicpu(p).is_jmp then
              begin
              begin
-               If (pasmlabel(Taicpu(p).oper[0].sym)^.labelnr >= LoLab) And
-                  (pasmlabel(Taicpu(p).oper[0].sym)^.labelnr <= HiLab) Then
-                 Inc(LTable^[pasmlabel(Taicpu(p).oper[0].sym)^.labelnr-LoLab].RefsFound);
+               If (tasmlabel(Taicpu(p).oper[0].sym).labelnr >= LoLab) And
+                  (tasmlabel(Taicpu(p).oper[0].sym).labelnr <= HiLab) Then
+                 Inc(LTable^[tasmlabel(Taicpu(p).oper[0].sym).labelnr-LoLab].RefsFound);
              end;
              end;
           end;
           end;
 {        ait_instruction:
 {        ait_instruction:
@@ -2454,7 +2454,12 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-04-02 21:20:36  peter
+  Revision 1.17  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.16  2001/04/02 21:20:36  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.15  2000/12/31 11:00:31  jonas
   Revision 1.15  2000/12/31 11:00:31  jonas

+ 57 - 52
compiler/i386/n386add.pas

@@ -42,7 +42,7 @@ interface
 
 
     uses
     uses
       globtype,systems,
       globtype,systems,
-      cutils,cobjects,verbose,globals,
+      cutils,verbose,globals,
       symconst,symdef,aasm,types,
       symconst,symdef,aasm,types,
       hcodegen,temp_gen,pass_2,
       hcodegen,temp_gen,pass_2,
       cpuasm,
       cpuasm,
@@ -102,12 +102,12 @@ interface
       begin
       begin
          { remove temporary location if not a set or string }
          { remove temporary location if not a set or string }
          { that's a bad hack (FK) who did this ?            }
          { that's a bad hack (FK) who did this ?            }
-         if (left.resulttype.def^.deftype<>stringdef) and
-            ((left.resulttype.def^.deftype<>setdef) or (psetdef(left.resulttype.def)^.settype=smallset)) and
+         if (left.resulttype.def.deftype<>stringdef) and
+            ((left.resulttype.def.deftype<>setdef) or (tsetdef(left.resulttype.def).settype=smallset)) and
             (left.location.loc in [LOC_MEM,LOC_REFERENCE]) then
             (left.location.loc in [LOC_MEM,LOC_REFERENCE]) then
            ungetiftemp(left.location.reference);
            ungetiftemp(left.location.reference);
-         if (right.resulttype.def^.deftype<>stringdef) and
-            ((right.resulttype.def^.deftype<>setdef) or (psetdef(right.resulttype.def)^.settype=smallset)) and
+         if (right.resulttype.def.deftype<>stringdef) and
+            ((right.resulttype.def.deftype<>setdef) or (tsetdef(right.resulttype.def).settype=smallset)) and
             (right.location.loc in [LOC_MEM,LOC_REFERENCE]) then
             (right.location.loc in [LOC_MEM,LOC_REFERENCE]) then
            ungetiftemp(right.location.reference);
            ungetiftemp(right.location.reference);
          { in case of comparison operation the put result in the flags }
          { in case of comparison operation the put result in the flags }
@@ -128,7 +128,7 @@ interface
 
 
       var
       var
 {$ifdef newoptimizations2}
 {$ifdef newoptimizations2}
-        l: pasmlabel;
+        l: tasmlabel;
         hreg: tregister;
         hreg: tregister;
         href2: preference;
         href2: preference;
         oldregisterdef: boolean;
         oldregisterdef: boolean;
@@ -142,7 +142,7 @@ interface
         { string operations are not commutative }
         { string operations are not commutative }
         if nf_swaped in flags then
         if nf_swaped in flags then
           swapleftright;
           swapleftright;
-        case pstringdef(left.resulttype.def)^.string_typ of
+        case tstringdef(left.resulttype.def).string_typ of
            st_ansistring:
            st_ansistring:
              begin
              begin
                 case nodetype of
                 case nodetype of
@@ -296,7 +296,7 @@ interface
                              { length of temp string = 255 (JM) }
                              { length of temp string = 255 (JM) }
                              { *** redefining a type is not allowed!! (thanks, Pierre) }
                              { *** redefining a type is not allowed!! (thanks, Pierre) }
                              { also problem with constant string!                      }
                              { also problem with constant string!                      }
-                             pstringdef(left.resulttype.def)^.len := 255;
+                             tstringdef(left.resulttype.def).len := 255;
 
 
 {$endif newoptimizations2}
 {$endif newoptimizations2}
                           end;
                           end;
@@ -317,7 +317,7 @@ interface
                               newreference(left.location.reference),R_EDI);
                               newreference(left.location.reference),R_EDI);
                             { is it already maximal? }
                             { is it already maximal? }
                             emit_const_reg(A_CMP,S_L,
                             emit_const_reg(A_CMP,S_L,
-                              pstringdef(left.resulttype.def)^.len,R_EDI);
+                              tstringdef(left.resulttype.def).len,R_EDI);
                             emitjmp(C_E,l);
                             emitjmp(C_E,l);
                             { no, so add the new character }
                             { no, so add the new character }
                             { is it a constant char? }
                             { is it a constant char? }
@@ -392,7 +392,7 @@ interface
 {$ifdef newoptimizations2}
 {$ifdef newoptimizations2}
                            { string (could be < 255 chars now) (JM)         }
                            { string (could be < 255 chars now) (JM)         }
                             emit_const(A_PUSH,S_L,
                             emit_const(A_PUSH,S_L,
-                              pstringdef(left.resulttype.def)^.len);
+                              tstringdef(left.resulttype.def).len);
 {$endif newoptimizations2}
 {$endif newoptimizations2}
                             emitpushreferenceaddr(left.location.reference);
                             emitpushreferenceaddr(left.location.reference);
                            { the optimizer can more easily put the          }
                            { the optimizer can more easily put the          }
@@ -673,10 +673,10 @@ interface
          pushed,mboverflow,cmpop : boolean;
          pushed,mboverflow,cmpop : boolean;
          op,op2 : tasmop;
          op,op2 : tasmop;
          resflags : tresflags;
          resflags : tresflags;
-         otl,ofl : pasmlabel;
+         otl,ofl : tasmlabel;
          power : longint;
          power : longint;
          opsize : topsize;
          opsize : topsize;
-         hl4: pasmlabel;
+         hl4: tasmlabel;
          hr : preference;
          hr : preference;
 
 
          { true, if unsigned types are compared }
          { true, if unsigned types are compared }
@@ -763,14 +763,14 @@ interface
       begin
       begin
       { to make it more readable, string and set (not smallset!) have their
       { to make it more readable, string and set (not smallset!) have their
         own procedures }
         own procedures }
-         case left.resulttype.def^.deftype of
+         case left.resulttype.def.deftype of
          stringdef : begin
          stringdef : begin
                        addstring;
                        addstring;
                        exit;
                        exit;
                      end;
                      end;
             setdef : begin
             setdef : begin
                      { normalsets are handled separate }
                      { normalsets are handled separate }
-                       if not(psetdef(left.resulttype.def)^.settype=smallset) then
+                       if not(tsetdef(left.resulttype.def).settype=smallset) then
                         begin
                         begin
                           addset;
                           addset;
                           exit;
                           exit;
@@ -787,7 +787,7 @@ interface
 
 
          { are we a (small)set, must be set here because the side can be
          { are we a (small)set, must be set here because the side can be
            swapped ! (PFV) }
            swapped ! (PFV) }
-         is_set:=(left.resulttype.def^.deftype=setdef);
+         is_set:=(left.resulttype.def.deftype=setdef);
 
 
          { calculate the operator which is more difficult }
          { calculate the operator which is more difficult }
          firstcomplex(self);
          firstcomplex(self);
@@ -796,12 +796,12 @@ interface
          if is_boolean(left.resulttype.def) and
          if is_boolean(left.resulttype.def) and
             is_boolean(right.resulttype.def) then
             is_boolean(right.resulttype.def) then
            begin
            begin
-             if (porddef(left.resulttype.def)^.typ=bool8bit) or
-                (porddef(right.resulttype.def)^.typ=bool8bit) then
+             if (torddef(left.resulttype.def).typ=bool8bit) or
+                (torddef(right.resulttype.def).typ=bool8bit) then
                opsize:=S_B
                opsize:=S_B
              else
              else
-               if (porddef(left.resulttype.def)^.typ=bool16bit) or
-                  (porddef(right.resulttype.def)^.typ=bool16bit) then
+               if (torddef(left.resulttype.def).typ=bool16bit) or
+                  (torddef(right.resulttype.def).typ=bool16bit) then
                  opsize:=S_W
                  opsize:=S_W
              else
              else
                opsize:=S_L;
                opsize:=S_L;
@@ -916,28 +916,28 @@ interface
                   set_location(left.location,location);
                   set_location(left.location,location);
                 end;
                 end;
 
 
-              if (left.resulttype.def^.deftype=pointerdef) or
+              if (left.resulttype.def.deftype=pointerdef) or
 
 
-                 (right.resulttype.def^.deftype=pointerdef) or
+                 (right.resulttype.def.deftype=pointerdef) or
 
 
                  (is_class_or_interface(right.resulttype.def) and is_class_or_interface(left.resulttype.def)) or
                  (is_class_or_interface(right.resulttype.def) and is_class_or_interface(left.resulttype.def)) or
 
 
-                 (left.resulttype.def^.deftype=classrefdef) or
+                 (left.resulttype.def.deftype=classrefdef) or
 
 
-                 (left.resulttype.def^.deftype=procvardef) or
+                 (left.resulttype.def.deftype=procvardef) or
 
 
-                 ((left.resulttype.def^.deftype=enumdef) and
-                  (left.resulttype.def^.size=4)) or
+                 ((left.resulttype.def.deftype=enumdef) and
+                  (left.resulttype.def.size=4)) or
 
 
-                 ((left.resulttype.def^.deftype=orddef) and
-                 (porddef(left.resulttype.def)^.typ=s32bit)) or
-                 ((right.resulttype.def^.deftype=orddef) and
-                 (porddef(right.resulttype.def)^.typ=s32bit)) or
+                 ((left.resulttype.def.deftype=orddef) and
+                 (torddef(left.resulttype.def).typ=s32bit)) or
+                 ((right.resulttype.def.deftype=orddef) and
+                 (torddef(right.resulttype.def).typ=s32bit)) or
 
 
-                ((left.resulttype.def^.deftype=orddef) and
-                 (porddef(left.resulttype.def)^.typ=u32bit)) or
-                 ((right.resulttype.def^.deftype=orddef) and
-                 (porddef(right.resulttype.def)^.typ=u32bit)) or
+                ((left.resulttype.def.deftype=orddef) and
+                 (torddef(left.resulttype.def).typ=u32bit)) or
+                 ((right.resulttype.def.deftype=orddef) and
+                 (torddef(right.resulttype.def).typ=u32bit)) or
 
 
                 { as well as small sets }
                 { as well as small sets }
                  is_set then
                  is_set then
@@ -1134,7 +1134,7 @@ interface
                            { constant (JM)                             }
                            { constant (JM)                             }
                            release_loc(right.location);
                            release_loc(right.location);
                            location.register := getregister32;
                            location.register := getregister32;
-                           emitloadord2reg(right.location,porddef(u32bittype.def),location.register,false);
+                           emitloadord2reg(right.location,torddef(u32bittype.def),location.register,false);
                            emit_const_reg(A_SHL,S_L,power,location.register)
                            emit_const_reg(A_SHL,S_L,power,location.register)
                          End
                          End
                        Else
                        Else
@@ -1160,13 +1160,13 @@ interface
                          { left.location can be R_EAX !!! }
                          { left.location can be R_EAX !!! }
                          getexplicitregister32(R_EDI);
                          getexplicitregister32(R_EDI);
                          { load the left value }
                          { load the left value }
-                         emitloadord2reg(left.location,porddef(u32bittype.def),R_EDI,true);
+                         emitloadord2reg(left.location,torddef(u32bittype.def),R_EDI,true);
                          release_loc(left.location);
                          release_loc(left.location);
                          { allocate EAX }
                          { allocate EAX }
                          if R_EAX in unused then
                          if R_EAX in unused then
                            exprasmList.concat(Tairegalloc.Alloc(R_EAX));
                            exprasmList.concat(Tairegalloc.Alloc(R_EAX));
                          { load he right value }
                          { load he right value }
-                         emitloadord2reg(right.location,porddef(u32bittype.def),R_EAX,true);
+                         emitloadord2reg(right.location,torddef(u32bittype.def),R_EAX,true);
                          release_loc(right.location);
                          release_loc(right.location);
                          { allocate EAX if it isn't yet allocated (JM) }
                          { allocate EAX if it isn't yet allocated (JM) }
                          if (R_EAX in unused) then
                          if (R_EAX in unused) then
@@ -1429,11 +1429,11 @@ interface
               else
               else
 
 
               { Char type }
               { Char type }
-                if ((left.resulttype.def^.deftype=orddef) and
-                    (porddef(left.resulttype.def)^.typ=uchar)) or
+                if ((left.resulttype.def.deftype=orddef) and
+                    (torddef(left.resulttype.def).typ=uchar)) or
               { enumeration type 16 bit }
               { enumeration type 16 bit }
-                   ((left.resulttype.def^.deftype=enumdef) and
-                    (left.resulttype.def^.size=1)) then
+                   ((left.resulttype.def.deftype=enumdef) and
+                    (left.resulttype.def.size=1)) then
                  begin
                  begin
                    case nodetype of
                    case nodetype of
                       ltn,lten,gtn,gten,
                       ltn,lten,gtn,gten,
@@ -1507,8 +1507,8 @@ interface
                 end
                 end
               else
               else
               { 16 bit enumeration type }
               { 16 bit enumeration type }
-                if ((left.resulttype.def^.deftype=enumdef) and
-                    (left.resulttype.def^.size=2)) then
+                if ((left.resulttype.def.deftype=enumdef) and
+                    (left.resulttype.def.size=2)) then
                  begin
                  begin
                    case nodetype of
                    case nodetype of
                       ltn,lten,gtn,gten,
                       ltn,lten,gtn,gten,
@@ -1586,10 +1586,10 @@ interface
                 begin
                 begin
                    mboverflow:=false;
                    mboverflow:=false;
                    cmpop:=false;
                    cmpop:=false;
-                   unsigned:=((left.resulttype.def^.deftype=orddef) and
-                       (porddef(left.resulttype.def)^.typ=u64bit)) or
-                      ((right.resulttype.def^.deftype=orddef) and
-                       (porddef(right.resulttype.def)^.typ=u64bit));
+                   unsigned:=((left.resulttype.def.deftype=orddef) and
+                       (torddef(left.resulttype.def).typ=u64bit)) or
+                      ((right.resulttype.def.deftype=orddef) and
+                       (torddef(right.resulttype.def).typ=u64bit));
                    case nodetype of
                    case nodetype of
                       addn : begin
                       addn : begin
                                 begin
                                 begin
@@ -1658,7 +1658,7 @@ interface
                         clear_location(hloc);
                         clear_location(hloc);
                         emit_pushq_loc(right.location);
                         emit_pushq_loc(right.location);
                         saveregvars($ff);
                         saveregvars($ff);
-                        if porddef(resulttype.def)^.typ=u64bit then
+                        if torddef(resulttype.def).typ=u64bit then
                           emitcall('FPC_MUL_QWORD')
                           emitcall('FPC_MUL_QWORD')
                         else
                         else
                           emitcall('FPC_MUL_INT64');
                           emitcall('FPC_MUL_INT64');
@@ -1924,7 +1924,7 @@ interface
                 end
                 end
               else
               else
               { Floating point }
               { Floating point }
-               if (left.resulttype.def^.deftype=floatdef) then
+               if (left.resulttype.def.deftype=floatdef) then
                  begin
                  begin
                     { real constants to the right, but only if it
                     { real constants to the right, but only if it
                       isn't on the FPU stack, i.e. 1.0 or 0.0! }
                       isn't on the FPU stack, i.e. 1.0 or 0.0! }
@@ -1954,7 +1954,7 @@ interface
                               inc(fpuvaroffset);
                               inc(fpuvaroffset);
                             end
                             end
                          else
                          else
-                           floatload(pfloatdef(right.resulttype.def)^.typ,right.location.reference);
+                           floatload(tfloatdef(right.resulttype.def).typ,right.location.reference);
                          if (left.location.loc<>LOC_FPU) then
                          if (left.location.loc<>LOC_FPU) then
                            begin
                            begin
                               if left.location.loc=LOC_CFPUREGISTER then
                               if left.location.loc=LOC_CFPUREGISTER then
@@ -1964,7 +1964,7 @@ interface
                                    inc(fpuvaroffset);
                                    inc(fpuvaroffset);
                                 end
                                 end
                               else
                               else
-                                floatload(pfloatdef(left.resulttype.def)^.typ,left.location.reference)
+                                floatload(tfloatdef(left.resulttype.def).typ,left.location.reference)
                            end
                            end
                          { left was on the stack => swap }
                          { left was on the stack => swap }
                          else
                          else
@@ -1983,7 +1983,7 @@ interface
                               inc(fpuvaroffset);
                               inc(fpuvaroffset);
                            end
                            end
                          else
                          else
-                           floatload(pfloatdef(left.resulttype.def)^.typ,left.location.reference)
+                           floatload(tfloatdef(left.resulttype.def).typ,left.location.reference)
                       end
                       end
                     { fpu operands are always in the wrong order on the stack }
                     { fpu operands are always in the wrong order on the stack }
                     else
                     else
@@ -2273,7 +2273,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2001-04-02 21:20:36  peter
+  Revision 1.11  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.10  2001/04/02 21:20:36  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.9  2000/12/31 11:14:11  jonas
   Revision 1.9  2000/12/31 11:14:11  jonas

+ 15 - 10
compiler/i386/n386bas.pas

@@ -53,16 +53,16 @@ unit n386bas;
 
 
     procedure ti386asmnode.pass_2;
     procedure ti386asmnode.pass_2;
 
 
-      procedure ReLabel(var p:pasmsymbol);
+      procedure ReLabel(var p:tasmsymbol);
         begin
         begin
-          if p^.proclocal then
+          if p.proclocal then
            begin
            begin
-             if not assigned(p^.altsymbol) then
+             if not assigned(p.altsymbol) then
               begin
               begin
-                p^.GenerateAltSymbol;
+                p.GenerateAltSymbol;
                 UsedAsmSymbolListInsert(p);
                 UsedAsmSymbolListInsert(p);
               end;
               end;
-             p:=p^.altsymbol;
+             p:=p.altsymbol;
            end;
            end;
         end;
         end;
 
 
@@ -75,8 +75,8 @@ unit n386bas;
          if inlining_procedure then
          if inlining_procedure then
            begin
            begin
              CreateUsedAsmSymbolList;
              CreateUsedAsmSymbolList;
-             localfixup:=aktprocsym^.definition^.localst^.address_fixup;
-             parafixup:=aktprocsym^.definition^.parast^.address_fixup;
+             localfixup:=aktprocsym.definition.localst.address_fixup;
+             parafixup:=aktprocsym.definition.parast.address_fixup;
              hp:=tai(p_asm.first);
              hp:=tai(p_asm.first);
              while assigned(hp) do
              while assigned(hp) do
               begin
               begin
@@ -86,7 +86,7 @@ unit n386bas;
                   ait_label :
                   ait_label :
                      begin
                      begin
                        { regenerate the labels by setting altsymbol }
                        { regenerate the labels by setting altsymbol }
-                       ReLabel(pasmsymbol(tai_label(hp2).l));
+                       ReLabel(tasmsymbol(tai_label(hp2).l));
                      end;
                      end;
                   ait_const_rva,
                   ait_const_rva,
                   ait_const_symbol :
                   ait_const_symbol :
@@ -144,7 +144,7 @@ unit n386bas;
            begin
            begin
              { if the routine is an inline routine, then we must hold a copy
              { if the routine is an inline routine, then we must hold a copy
                because it can be necessary for inlining later }
                because it can be necessary for inlining later }
-             if (pocall_inline in aktprocsym^.definition^.proccalloptions) then
+             if (pocall_inline in aktprocsym.definition.proccalloptions) then
                exprasmList.concatlistcopy(p_asm)
                exprasmList.concatlistcopy(p_asm)
              else
              else
                exprasmList.concatlist(p_asm);
                exprasmList.concatlist(p_asm);
@@ -204,7 +204,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-04-02 21:20:36  peter
+  Revision 1.7  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2001/04/02 21:20:36  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.5  2000/12/25 00:07:32  peter
   Revision 1.5  2000/12/25 00:07:32  peter

+ 161 - 179
compiler/i386/n386cal.pas

@@ -55,8 +55,8 @@ implementation
       strings,
       strings,
 {$endif}
 {$endif}
       globtype,systems,
       globtype,systems,
-      cutils,cobjects,verbose,globals,
-      symconst,symbase,symtype,symsym,symtable,aasm,types,
+      cutils,verbose,globals,
+      symconst,symbase,symsym,symtable,aasm,types,
 {$ifdef GDB}
 {$ifdef GDB}
       gdb,
       gdb,
 {$endif GDB}
 {$endif GDB}
@@ -86,7 +86,7 @@ implementation
         end;
         end;
 
 
       var
       var
-         otlabel,oflabel : pasmlabel;
+         otlabel,oflabel : tasmlabel;
          { temporary variables: }
          { temporary variables: }
          tempdeftype : tdeftype;
          tempdeftype : tdeftype;
          r : preference;
          r : preference;
@@ -112,7 +112,7 @@ implementation
            end
            end
          { in codegen.handleread.. defcoll.data is set to nil }
          { in codegen.handleread.. defcoll.data is set to nil }
          else if assigned(defcoll.paratype.def) and
          else if assigned(defcoll.paratype.def) and
-           (defcoll.paratype.def^.deftype=formaldef) then
+           (defcoll.paratype.def.deftype=formaldef) then
            begin
            begin
               { allow @var }
               { allow @var }
               inc(pushedparasize,4);
               inc(pushedparasize,4);
@@ -160,7 +160,7 @@ implementation
               if (defcoll.paratyp=vs_out) and
               if (defcoll.paratyp=vs_out) and
                  assigned(defcoll.paratype.def) and
                  assigned(defcoll.paratype.def) and
                  not is_class(defcoll.paratype.def) and
                  not is_class(defcoll.paratype.def) and
-                 defcoll.paratype.def^.needs_inittable then
+                 defcoll.paratype.def.needs_inittable then
                 finalize(defcoll.paratype.def,left.location.reference,false);
                 finalize(defcoll.paratype.def,left.location.reference,false);
               inc(pushedparasize,4);
               inc(pushedparasize,4);
               if inlined then
               if inlined then
@@ -178,7 +178,7 @@ implementation
            end
            end
          else
          else
            begin
            begin
-              tempdeftype:=resulttype.def^.deftype;
+              tempdeftype:=resulttype.def.deftype;
               if tempdeftype=filedef then
               if tempdeftype=filedef then
                CGMessage(cg_e_file_must_call_by_reference);
                CGMessage(cg_e_file_must_call_by_reference);
               { open array must always push the address, this is needed to
               { open array must always push the address, this is needed to
@@ -244,7 +244,7 @@ implementation
          { true if a constructor is called again }
          { true if a constructor is called again }
          extended_new : boolean;
          extended_new : boolean;
          { adress returned from an I/O-error }
          { adress returned from an I/O-error }
-         iolabel : pasmlabel;
+         iolabel : tasmlabel;
          { lexlevel count }
          { lexlevel count }
          i : longint;
          i : longint;
          { help reference pointer }
          { help reference pointer }
@@ -267,7 +267,7 @@ implementation
          pop_esp : boolean;
          pop_esp : boolean;
          pop_allowed : boolean;
          pop_allowed : boolean;
          regs_to_push : byte;
          regs_to_push : byte;
-         constructorfailed : pasmlabel;
+         constructorfailed : tasmlabel;
 
 
       label
       label
          dont_call;
          dont_call;
@@ -283,7 +283,7 @@ implementation
          unusedregisters:=unused;
          unusedregisters:=unused;
          usablecount:=usablereg32;
          usablecount:=usablereg32;
 
 
-         if ([pocall_cdecl,pocall_cppdecl,pocall_stdcall]*procdefinition^.proccalloptions)<>[] then
+         if ([pocall_cdecl,pocall_cppdecl,pocall_stdcall]*procdefinition.proccalloptions)<>[] then
           para_alignment:=4
           para_alignment:=4
          else
          else
           para_alignment:=target_os.stackalignment;
           para_alignment:=target_os.stackalignment;
@@ -296,41 +296,41 @@ implementation
            params:=left.getcopy
            params:=left.getcopy
          else params := nil;
          else params := nil;
 
 
-         if (pocall_inline in procdefinition^.proccalloptions) then
+         if (pocall_inline in procdefinition.proccalloptions) then
            begin
            begin
               inlined:=true;
               inlined:=true;
               inlinecode:=tprocinlinenode(right);
               inlinecode:=tprocinlinenode(right);
               { set it to the same lexical level as the local symtable, becuase
               { set it to the same lexical level as the local symtable, becuase
                 the para's are stored there }
                 the para's are stored there }
-              pprocdef(procdefinition)^.parast^.symtablelevel:=aktprocsym^.definition^.localst^.symtablelevel;
+              tprocdef(procdefinition).parast.symtablelevel:=aktprocsym.definition.localst.symtablelevel;
               if assigned(params) then
               if assigned(params) then
                 inlinecode.para_offset:=gettempofsizepersistant(inlinecode.para_size);
                 inlinecode.para_offset:=gettempofsizepersistant(inlinecode.para_size);
-              pprocdef(procdefinition)^.parast^.address_fixup:=inlinecode.para_offset;
+              tprocdef(procdefinition).parast.address_fixup:=inlinecode.para_offset;
 {$ifdef extdebug}
 {$ifdef extdebug}
              Comment(V_debug,
              Comment(V_debug,
                'inlined parasymtable is at offset '
                'inlined parasymtable is at offset '
-               +tostr(pprocdef(procdefinition)^.parast^.address_fixup));
+               +tostr(tprocdef(procdefinition).parast.address_fixup));
              exprasmList.concat(Tai_asm_comment.Create(
              exprasmList.concat(Tai_asm_comment.Create(
                strpnew('inlined parasymtable is at offset '
                strpnew('inlined parasymtable is at offset '
-               +tostr(pprocdef(procdefinition)^.parast^.address_fixup))));
+               +tostr(tprocdef(procdefinition).parast.address_fixup))));
 {$endif extdebug}
 {$endif extdebug}
               { disable further inlining of the same proc
               { disable further inlining of the same proc
                 in the args }
                 in the args }
-              exclude(procdefinition^.proccalloptions,pocall_inline);
+              exclude(procdefinition.proccalloptions,pocall_inline);
            end;
            end;
          { only if no proc var }
          { only if no proc var }
          if inlined or
          if inlined or
             not(assigned(right)) then
             not(assigned(right)) then
-           is_con_or_destructor:=(procdefinition^.proctypeoption in [potype_constructor,potype_destructor]);
+           is_con_or_destructor:=(procdefinition.proctypeoption in [potype_constructor,potype_destructor]);
          { proc variables destroy all registers }
          { proc variables destroy all registers }
          if (inlined or
          if (inlined or
             (right=nil)) and
             (right=nil)) and
             { virtual methods too }
             { virtual methods too }
-            not(po_virtualmethod in procdefinition^.procoptions) then
+            not(po_virtualmethod in procdefinition.procoptions) then
            begin
            begin
               if (cs_check_io in aktlocalswitches) and
               if (cs_check_io in aktlocalswitches) and
-                 (po_iocheck in procdefinition^.procoptions) and
-                 not(po_iocheck in aktprocsym^.definition^.procoptions) then
+                 (po_iocheck in procdefinition.procoptions) and
+                 not(po_iocheck in aktprocsym.definition.procoptions) then
                 begin
                 begin
                    getaddrlabel(iolabel);
                    getaddrlabel(iolabel);
                    emitlab(iolabel);
                    emitlab(iolabel);
@@ -339,11 +339,11 @@ implementation
                 iolabel:=nil;
                 iolabel:=nil;
 
 
               { save all used registers }
               { save all used registers }
-              regs_to_push := pprocdef(procdefinition)^.usedregisters;
+              regs_to_push := tprocdef(procdefinition).usedregisters;
               pushusedregisters(pushed,regs_to_push);
               pushusedregisters(pushed,regs_to_push);
 
 
               { give used registers through }
               { give used registers through }
-              usedinproc:=usedinproc or pprocdef(procdefinition)^.usedregisters;
+              usedinproc:=usedinproc or tprocdef(procdefinition).usedregisters;
            end
            end
          else
          else
            begin
            begin
@@ -362,9 +362,9 @@ implementation
            and for objects constructors PM }
            and for objects constructors PM }
          if (inlined or
          if (inlined or
             (right=nil)) and
             (right=nil)) and
-            (procdefinition^.proctypeoption=potype_constructor) and
+            (procdefinition.proctypeoption=potype_constructor) and
             { quick'n'dirty check if it is a class or an object }
             { quick'n'dirty check if it is a class or an object }
-            (resulttype.def^.deftype=orddef) then
+            (resulttype.def.deftype=orddef) then
            pop_allowed:=false
            pop_allowed:=false
          else
          else
            pop_allowed:=true;
            pop_allowed:=true;
@@ -375,7 +375,7 @@ implementation
             if i>0 then
             if i>0 then
              inc(pop_size,4-i);
              inc(pop_size,4-i);
           { This parasize aligned on 4 ? }
           { This parasize aligned on 4 ? }
-            i:=procdefinition^.para_size(para_alignment) and 3;
+            i:=procdefinition.para_size(para_alignment) and 3;
             if i>0 then
             if i>0 then
              inc(pop_size,4-i);
              inc(pop_size,4-i);
           { insert the opcode and update pushedparasize }
           { insert the opcode and update pushedparasize }
@@ -396,7 +396,7 @@ implementation
          if pop_allowed and (cs_align in aktglobalswitches) then
          if pop_allowed and (cs_align in aktglobalswitches) then
            begin
            begin
               pop_esp:=true;
               pop_esp:=true;
-              push_size:=procdefinition^.para_size(para_alignment);
+              push_size:=procdefinition.para_size(para_alignment);
               { !!!! here we have to take care of return type, self
               { !!!! here we have to take care of return type, self
                 and nested procedures
                 and nested procedures
               }
               }
@@ -433,30 +433,30 @@ implementation
                 if inlined then
                 if inlined then
                   begin
                   begin
                      reset_reference(funcretref);
                      reset_reference(funcretref);
-                     funcretref.offset:=gettempofsizepersistant(procdefinition^.rettype.def^.size);
+                     funcretref.offset:=gettempofsizepersistant(procdefinition.rettype.def.size);
                      funcretref.base:=procinfo^.framepointer;
                      funcretref.base:=procinfo^.framepointer;
                   end
                   end
                 else
                 else
-                  gettempofsizereference(procdefinition^.rettype.def^.size,funcretref);
+                  gettempofsizereference(procdefinition.rettype.def.size,funcretref);
            end;
            end;
          if assigned(params) then
          if assigned(params) then
            begin
            begin
               { be found elsewhere }
               { be found elsewhere }
               if inlined then
               if inlined then
-                para_offset:=pprocdef(procdefinition)^.parast^.address_fixup+
-                  pprocdef(procdefinition)^.parast^.datasize
+                para_offset:=tprocdef(procdefinition).parast.address_fixup+
+                  tprocdef(procdefinition).parast.datasize
               else
               else
                 para_offset:=0;
                 para_offset:=0;
               if not(inlined) and
               if not(inlined) and
                  assigned(right) then
                  assigned(right) then
-                tcallparanode(params).secondcallparan(TParaItem(pabstractprocdef(right.resulttype.def)^.Para.first),
-                  (pocall_leftright in procdefinition^.proccalloptions),inlined,
-                  (([pocall_cdecl,pocall_cppdecl]*procdefinition^.proccalloptions)<>[]),
+                tcallparanode(params).secondcallparan(TParaItem(tabstractprocdef(right.resulttype.def).Para.first),
+                  (pocall_leftright in procdefinition.proccalloptions),inlined,
+                  (([pocall_cdecl,pocall_cppdecl]*procdefinition.proccalloptions)<>[]),
                   para_alignment,para_offset)
                   para_alignment,para_offset)
               else
               else
-                tcallparanode(params).secondcallparan(TParaItem(procdefinition^.Para.first),
-                  (pocall_leftright in procdefinition^.proccalloptions),inlined,
-                  (([pocall_cdecl,pocall_cppdecl]*procdefinition^.proccalloptions)<>[]),
+                tcallparanode(params).secondcallparan(TParaItem(procdefinition.Para.first),
+                  (pocall_leftright in procdefinition.proccalloptions),inlined,
+                  (([pocall_cdecl,pocall_cppdecl]*procdefinition.proccalloptions)<>[]),
                   para_alignment,para_offset);
                   para_alignment,para_offset);
            end;
            end;
          if inlined then
          if inlined then
@@ -471,16 +471,12 @@ implementation
 {$endif not OLD_C_STACK}
 {$endif not OLD_C_STACK}
               if inlined then
               if inlined then
                 begin
                 begin
-{$ifndef noAllocEdi}
                    getexplicitregister32(R_EDI);
                    getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                    emit_ref_reg(A_LEA,S_L,
                    emit_ref_reg(A_LEA,S_L,
                      newreference(funcretref),R_EDI);
                      newreference(funcretref),R_EDI);
                    r:=new_reference(procinfo^.framepointer,inlinecode.retoffset);
                    r:=new_reference(procinfo^.framepointer,inlinecode.retoffset);
                    emit_reg_ref(A_MOV,S_L,R_EDI,r);
                    emit_reg_ref(A_MOV,S_L,R_EDI,r);
-{$ifndef noAllocEdi}
                    ungetregister32(R_EDI);
                    ungetregister32(R_EDI);
-{$endif noAllocEdi}
                 end
                 end
               else
               else
                 emitpushreferenceaddr(funcretref);
                 emitpushreferenceaddr(funcretref);
@@ -492,36 +488,34 @@ implementation
               { overloaded operator have no symtable }
               { overloaded operator have no symtable }
               { push self }
               { push self }
               if assigned(symtableproc) and
               if assigned(symtableproc) and
-                (symtableproc^.symtabletype=withsymtable) then
+                (symtableproc.symtabletype=withsymtable) then
                 begin
                 begin
                    { dirty trick to avoid the secondcall below }
                    { dirty trick to avoid the secondcall below }
                    methodpointer:=ccallparanode.create(nil,nil);
                    methodpointer:=ccallparanode.create(nil,nil);
                    methodpointer.location.loc:=LOC_REGISTER;
                    methodpointer.location.loc:=LOC_REGISTER;
-{$ifndef noAllocEDI}
                    getexplicitregister32(R_ESI);
                    getexplicitregister32(R_ESI);
-{$endif noAllocEDI}
                    methodpointer.location.register:=R_ESI;
                    methodpointer.location.register:=R_ESI;
                    { ARGHHH this is wrong !!!
                    { ARGHHH this is wrong !!!
                      if we can init from base class for a child
                      if we can init from base class for a child
                      class that the wrong VMT will be
                      class that the wrong VMT will be
                      transfered to constructor !! }
                      transfered to constructor !! }
                    methodpointer.resulttype:=
                    methodpointer.resulttype:=
-                     twithnode(pwithsymtable(symtableproc)^.withnode).left.resulttype;
+                     twithnode(twithsymtable(symtableproc).withnode).left.resulttype;
                    { make a reference }
                    { make a reference }
                    new(r);
                    new(r);
                    reset_reference(r^);
                    reset_reference(r^);
-                   { if assigned(ptree(pwithsymtable(symtable)^.withnode)^.pref) then
+                   { if assigned(ptree(twithsymtable(symtable).withnode)^.pref) then
                      begin
                      begin
-                        r^:=ptree(pwithsymtable(symtable)^.withnode)^.pref^;
+                        r^:=ptree(twithsymtable(symtable).withnode)^.pref^;
                      end
                      end
                    else
                    else
                      begin
                      begin
-                        r^.offset:=symtable^.datasize;
+                        r^.offset:=symtable.datasize;
                         r^.base:=procinfo^.framepointer;
                         r^.base:=procinfo^.framepointer;
                      end; }
                      end; }
-                   r^:=twithnode(pwithsymtable(symtableproc)^.withnode).withreference^;
-                   if ((not(nf_islocal in twithnode(pwithsymtable(symtableproc)^.withnode).flags)) and
-                       (not pwithsymtable(symtableproc)^.direct_with)) or
+                   r^:=twithnode(twithsymtable(symtableproc).withnode).withreference^;
+                   if ((not(nf_islocal in twithnode(twithsymtable(symtableproc).withnode).flags)) and
+                       (not twithsymtable(symtableproc).direct_with)) or
                       is_class_or_interface(methodpointer.resulttype.def) then
                       is_class_or_interface(methodpointer.resulttype.def) then
                      emit_ref_reg(A_MOV,S_L,r,R_ESI)
                      emit_ref_reg(A_MOV,S_L,r,R_ESI)
                    else
                    else
@@ -530,8 +524,8 @@ implementation
 
 
               { push self }
               { push self }
               if assigned(symtableproc) and
               if assigned(symtableproc) and
-                ((symtableproc^.symtabletype=objectsymtable) or
-                (symtableproc^.symtabletype=withsymtable)) then
+                ((symtableproc.symtabletype=objectsymtable) or
+                (symtableproc.symtabletype=withsymtable)) then
                 begin
                 begin
                    if assigned(methodpointer) then
                    if assigned(methodpointer) then
                      begin
                      begin
@@ -549,7 +543,7 @@ implementation
                                typen:
                                typen:
                                  begin
                                  begin
                                     { direct call to inherited method }
                                     { direct call to inherited method }
-                                    if (po_abstractmethod in procdefinition^.procoptions) then
+                                    if (po_abstractmethod in procdefinition.procoptions) then
                                       begin
                                       begin
                                          CGMessage(cg_e_cant_call_abstract_method);
                                          CGMessage(cg_e_cant_call_abstract_method);
                                          goto dont_call;
                                          goto dont_call;
@@ -557,22 +551,20 @@ implementation
                                     { generate no virtual call }
                                     { generate no virtual call }
                                     no_virtual_call:=true;
                                     no_virtual_call:=true;
 
 
-                                    if (sp_static in symtableprocentry^.symoptions) then
+                                    if (sp_static in symtableprocentry.symoptions) then
                                       begin
                                       begin
                                          { well lets put the VMT address directly into ESI }
                                          { well lets put the VMT address directly into ESI }
                                          { it is kind of dirty but that is the simplest    }
                                          { it is kind of dirty but that is the simplest    }
                                          { way to accept virtual static functions (PM)     }
                                          { way to accept virtual static functions (PM)     }
                                          loadesi:=true;
                                          loadesi:=true;
                                          { if no VMT just use $0 bug0214 PM }
                                          { if no VMT just use $0 bug0214 PM }
-{$ifndef noAllocEDI}
                                          getexplicitregister32(R_ESI);
                                          getexplicitregister32(R_ESI);
-{$endif noAllocEDI}
-                                         if not(oo_has_vmt in pobjectdef(methodpointer.resulttype.def)^.objectoptions) then
+                                         if not(oo_has_vmt in tobjectdef(methodpointer.resulttype.def).objectoptions) then
                                            emit_const_reg(A_MOV,S_L,0,R_ESI)
                                            emit_const_reg(A_MOV,S_L,0,R_ESI)
                                          else
                                          else
                                            begin
                                            begin
                                              emit_sym_ofs_reg(A_MOV,S_L,
                                              emit_sym_ofs_reg(A_MOV,S_L,
-                                               newasmsymbol(pobjectdef(methodpointer.resulttype.def)^.vmt_mangledname),
+                                               newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),
                                                0,R_ESI);
                                                0,R_ESI);
                                            end;
                                            end;
                                          { emit_reg(A_PUSH,S_L,R_ESI);
                                          { emit_reg(A_PUSH,S_L,R_ESI);
@@ -583,10 +575,10 @@ implementation
                                       loadesi:=false;
                                       loadesi:=false;
 
 
                                     { a class destructor needs a flag }
                                     { a class destructor needs a flag }
-                                    if is_class(pobjectdef(methodpointer.resulttype.def)) and
+                                    if is_class(tobjectdef(methodpointer.resulttype.def)) and
                                        {assigned(aktprocsym) and
                                        {assigned(aktprocsym) and
-                                       (aktprocsym^.definition^.proctypeoption=potype_destructor)}
-                                       (procdefinition^.proctypeoption=potype_destructor) then
+                                       (aktprocsym.definition.proctypeoption=potype_destructor)}
+                                       (procdefinition.proctypeoption=potype_destructor) then
                                       begin
                                       begin
                                         push_int(0);
                                         push_int(0);
                                         emit_reg(A_PUSH,S_L,R_ESI);
                                         emit_reg(A_PUSH,S_L,R_ESI);
@@ -595,8 +587,8 @@ implementation
                                     if not(is_con_or_destructor and
                                     if not(is_con_or_destructor and
                                            is_class(methodpointer.resulttype.def) and
                                            is_class(methodpointer.resulttype.def) and
                                            {assigned(aktprocsym) and
                                            {assigned(aktprocsym) and
-                                          (aktprocsym^.definition^.proctypeoption in [potype_constructor,potype_destructor])}
-                                           (procdefinition^.proctypeoption in [potype_constructor,potype_destructor])
+                                          (aktprocsym.definition.proctypeoption in [potype_constructor,potype_destructor])}
+                                           (procdefinition.proctypeoption in [potype_constructor,potype_destructor])
                                           ) then
                                           ) then
                                       emit_reg(A_PUSH,S_L,R_ESI);
                                       emit_reg(A_PUSH,S_L,R_ESI);
                                     { if an inherited con- or destructor should be  }
                                     { if an inherited con- or destructor should be  }
@@ -607,7 +599,7 @@ implementation
                                       is_object(methodpointer.resulttype.def) and
                                       is_object(methodpointer.resulttype.def) and
                                       assigned(aktprocsym) then
                                       assigned(aktprocsym) then
                                       begin
                                       begin
-                                         if not(aktprocsym^.definition^.proctypeoption in
+                                         if not(aktprocsym.definition.proctypeoption in
                                                 [potype_constructor,potype_destructor]) then
                                                 [potype_constructor,potype_destructor]) then
                                           CGMessage(cg_w_member_cd_call_from_method);
                                           CGMessage(cg_w_member_cd_call_from_method);
                                       end;
                                       end;
@@ -617,7 +609,7 @@ implementation
                                       not(
                                       not(
                                         is_class(methodpointer.resulttype.def) and
                                         is_class(methodpointer.resulttype.def) and
                                         assigned(aktprocsym) and
                                         assigned(aktprocsym) and
-                                        (aktprocsym^.definition^.proctypeoption=potype_destructor)) then
+                                        (aktprocsym.definition.proctypeoption=potype_destructor)) then
                                       begin
                                       begin
                                          { a constructor needs also a flag }
                                          { a constructor needs also a flag }
                                          if is_class(methodpointer.resulttype.def) then
                                          if is_class(methodpointer.resulttype.def) then
@@ -629,14 +621,12 @@ implementation
                                  begin
                                  begin
                                     { extended syntax of new }
                                     { extended syntax of new }
                                     { ESI must be zero }
                                     { ESI must be zero }
-{$ifndef noAllocEDI}
                                     getexplicitregister32(R_ESI);
                                     getexplicitregister32(R_ESI);
-{$endif noAllocEDI}
                                     emit_reg_reg(A_XOR,S_L,R_ESI,R_ESI);
                                     emit_reg_reg(A_XOR,S_L,R_ESI,R_ESI);
                                     emit_reg(A_PUSH,S_L,R_ESI);
                                     emit_reg(A_PUSH,S_L,R_ESI);
                                     { insert the vmt }
                                     { insert the vmt }
                                     emit_sym(A_PUSH,S_L,
                                     emit_sym(A_PUSH,S_L,
-                                      newasmsymbol(pobjectdef(methodpointer.resulttype.def)^.vmt_mangledname));
+                                      newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname));
                                     extended_new:=true;
                                     extended_new:=true;
                                  end;
                                  end;
                                hdisposen:
                                hdisposen:
@@ -645,25 +635,21 @@ implementation
 
 
                                     { destructor with extended syntax called from dispose }
                                     { destructor with extended syntax called from dispose }
                                     { hdisposen always deliver LOC_REFERENCE          }
                                     { hdisposen always deliver LOC_REFERENCE          }
-{$ifndef noAllocEDI}
                                     getexplicitregister32(R_ESI);
                                     getexplicitregister32(R_ESI);
-{$endif noAllocEDI}
                                     emit_ref_reg(A_LEA,S_L,
                                     emit_ref_reg(A_LEA,S_L,
                                       newreference(methodpointer.location.reference),R_ESI);
                                       newreference(methodpointer.location.reference),R_ESI);
                                     del_reference(methodpointer.location.reference);
                                     del_reference(methodpointer.location.reference);
                                     emit_reg(A_PUSH,S_L,R_ESI);
                                     emit_reg(A_PUSH,S_L,R_ESI);
                                     emit_sym(A_PUSH,S_L,
                                     emit_sym(A_PUSH,S_L,
-                                      newasmsymbol(pobjectdef(methodpointer.resulttype.def)^.vmt_mangledname));
+                                      newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname));
                                  end;
                                  end;
                                else
                                else
                                  begin
                                  begin
                                     { call to an instance member }
                                     { call to an instance member }
-                                    if (symtableproc^.symtabletype<>withsymtable) then
+                                    if (symtableproc.symtabletype<>withsymtable) then
                                       begin
                                       begin
                                          secondpass(methodpointer);
                                          secondpass(methodpointer);
-{$ifndef noAllocEDI}
                                          getexplicitregister32(R_ESI);
                                          getexplicitregister32(R_ESI);
-{$endif noAllocEDI}
                                          case methodpointer.location.loc of
                                          case methodpointer.location.loc of
                                             LOC_CREGISTER,
                                             LOC_CREGISTER,
                                             LOC_REGISTER:
                                             LOC_REGISTER:
@@ -673,7 +659,7 @@ implementation
                                               end;
                                               end;
                                             else
                                             else
                                               begin
                                               begin
-                                                 if (methodpointer.resulttype.def^.deftype=classrefdef) or
+                                                 if (methodpointer.resulttype.def.deftype=classrefdef) or
                                                     is_class_or_interface(methodpointer.resulttype.def) then
                                                     is_class_or_interface(methodpointer.resulttype.def) then
                                                    emit_ref_reg(A_MOV,S_L,
                                                    emit_ref_reg(A_MOV,S_L,
                                                      newreference(methodpointer.location.reference),R_ESI)
                                                      newreference(methodpointer.location.reference),R_ESI)
@@ -686,27 +672,27 @@ implementation
                                       end;
                                       end;
                                     { when calling a class method, we have to load ESI with the VMT !
                                     { when calling a class method, we have to load ESI with the VMT !
                                       But, not for a class method via self }
                                       But, not for a class method via self }
-                                    if not(po_containsself in procdefinition^.procoptions) then
+                                    if not(po_containsself in procdefinition.procoptions) then
                                       begin
                                       begin
-                                        if (po_classmethod in procdefinition^.procoptions) and
-                                           not(methodpointer.resulttype.def^.deftype=classrefdef) then
+                                        if (po_classmethod in procdefinition.procoptions) and
+                                           not(methodpointer.resulttype.def.deftype=classrefdef) then
                                           begin
                                           begin
                                              { class method needs current VMT }
                                              { class method needs current VMT }
                                              getexplicitregister32(R_ESI);
                                              getexplicitregister32(R_ESI);
                                              new(r);
                                              new(r);
                                              reset_reference(r^);
                                              reset_reference(r^);
                                              r^.base:=R_ESI;
                                              r^.base:=R_ESI;
-                                             r^.offset:= pprocdef(procdefinition)^._class^.vmt_offset;
+                                             r^.offset:= tprocdef(procdefinition)._class.vmt_offset;
                                              emit_ref_reg(A_MOV,S_L,r,R_ESI);
                                              emit_ref_reg(A_MOV,S_L,r,R_ESI);
                                           end;
                                           end;
 
 
                                         { direct call to destructor: remove data }
                                         { direct call to destructor: remove data }
-                                        if (procdefinition^.proctypeoption=potype_destructor) and
+                                        if (procdefinition.proctypeoption=potype_destructor) and
                                            is_class(methodpointer.resulttype.def) then
                                            is_class(methodpointer.resulttype.def) then
                                           emit_const(A_PUSH,S_L,1);
                                           emit_const(A_PUSH,S_L,1);
 
 
                                         { direct call to class constructor, don't allocate memory }
                                         { direct call to class constructor, don't allocate memory }
-                                        if (procdefinition^.proctypeoption=potype_constructor) and
+                                        if (procdefinition.proctypeoption=potype_constructor) and
                                            is_class(methodpointer.resulttype.def) then
                                            is_class(methodpointer.resulttype.def) then
                                           begin
                                           begin
                                              emit_const(A_PUSH,S_L,0);
                                              emit_const(A_PUSH,S_L,0);
@@ -715,9 +701,9 @@ implementation
                                         else
                                         else
                                           begin
                                           begin
                                              { constructor call via classreference => allocate memory }
                                              { constructor call via classreference => allocate memory }
-                                             if (procdefinition^.proctypeoption=potype_constructor) and
-                                                (methodpointer.resulttype.def^.deftype=classrefdef) and
-                                                is_class(pclassrefdef(methodpointer.resulttype.def)^.pointertype.def) then
+                                             if (procdefinition.proctypeoption=potype_constructor) and
+                                                (methodpointer.resulttype.def.deftype=classrefdef) and
+                                                is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
                                                 emit_const(A_PUSH,S_L,1);
                                                 emit_const(A_PUSH,S_L,1);
                                              emit_reg(A_PUSH,S_L,R_ESI);
                                              emit_reg(A_PUSH,S_L,R_ESI);
                                           end;
                                           end;
@@ -728,11 +714,11 @@ implementation
                                          { classes don't get a VMT pointer pushed }
                                          { classes don't get a VMT pointer pushed }
                                          if is_object(methodpointer.resulttype.def) then
                                          if is_object(methodpointer.resulttype.def) then
                                            begin
                                            begin
-                                              if (procdefinition^.proctypeoption=potype_constructor) then
+                                              if (procdefinition.proctypeoption=potype_constructor) then
                                                 begin
                                                 begin
                                                    { it's no bad idea, to insert the VMT }
                                                    { it's no bad idea, to insert the VMT }
                                                    emit_sym(A_PUSH,S_L,newasmsymbol(
                                                    emit_sym(A_PUSH,S_L,newasmsymbol(
-                                                     pobjectdef(methodpointer.resulttype.def)^.vmt_mangledname));
+                                                     tobjectdef(methodpointer.resulttype.def).vmt_mangledname));
                                                 end
                                                 end
                                               { destructors haven't to dispose the instance, if this is }
                                               { destructors haven't to dispose the instance, if this is }
                                               { a direct call                                           }
                                               { a direct call                                           }
@@ -746,10 +732,10 @@ implementation
                      end
                      end
                    else
                    else
                      begin
                      begin
-                        if (po_classmethod in procdefinition^.procoptions) and
+                        if (po_classmethod in procdefinition.procoptions) and
                           not(
                           not(
                             assigned(aktprocsym) and
                             assigned(aktprocsym) and
-                            (po_classmethod in aktprocsym^.definition^.procoptions)
+                            (po_classmethod in aktprocsym.definition.procoptions)
                           ) then
                           ) then
                           begin
                           begin
                              { class method needs current VMT }
                              { class method needs current VMT }
@@ -757,7 +743,7 @@ implementation
                              new(r);
                              new(r);
                              reset_reference(r^);
                              reset_reference(r^);
                              r^.base:=R_ESI;
                              r^.base:=R_ESI;
-                             r^.offset:= pprocdef(procdefinition)^._class^.vmt_offset;
+                             r^.offset:= tprocdef(procdefinition)._class.vmt_offset;
                              emit_ref_reg(A_MOV,S_L,r,R_ESI);
                              emit_ref_reg(A_MOV,S_L,r,R_ESI);
                           end
                           end
                         else
                         else
@@ -768,12 +754,12 @@ implementation
                         { direct call to destructor: don't remove data! }
                         { direct call to destructor: don't remove data! }
                         if is_class(procinfo^._class) then
                         if is_class(procinfo^._class) then
                           begin
                           begin
-                             if (procdefinition^.proctypeoption=potype_destructor) then
+                             if (procdefinition.proctypeoption=potype_destructor) then
                                begin
                                begin
                                   emit_const(A_PUSH,S_L,0);
                                   emit_const(A_PUSH,S_L,0);
                                   emit_reg(A_PUSH,S_L,R_ESI);
                                   emit_reg(A_PUSH,S_L,R_ESI);
                                end
                                end
-                             else if (procdefinition^.proctypeoption=potype_constructor) then
+                             else if (procdefinition.proctypeoption=potype_constructor) then
                                begin
                                begin
                                   emit_const(A_PUSH,S_L,0);
                                   emit_const(A_PUSH,S_L,0);
                                   emit_const(A_PUSH,S_L,0);
                                   emit_const(A_PUSH,S_L,0);
@@ -786,11 +772,11 @@ implementation
                              emit_reg(A_PUSH,S_L,R_ESI);
                              emit_reg(A_PUSH,S_L,R_ESI);
                              if is_con_or_destructor then
                              if is_con_or_destructor then
                                begin
                                begin
-                                  if (procdefinition^.proctypeoption=potype_constructor) then
+                                  if (procdefinition.proctypeoption=potype_constructor) then
                                     begin
                                     begin
                                        { it's no bad idea, to insert the VMT }
                                        { it's no bad idea, to insert the VMT }
                                        emit_sym(A_PUSH,S_L,newasmsymbol(
                                        emit_sym(A_PUSH,S_L,newasmsymbol(
-                                         procinfo^._class^.vmt_mangledname));
+                                         procinfo^._class.vmt_mangledname));
                                     end
                                     end
                                   { destructors haven't to dispose the instance, if this is }
                                   { destructors haven't to dispose the instance, if this is }
                                   { a direct call                                           }
                                   { a direct call                                           }
@@ -804,10 +790,10 @@ implementation
                 end;
                 end;
 
 
                 { call to BeforeDestruction? }
                 { call to BeforeDestruction? }
-                if (procdefinition^.proctypeoption=potype_destructor) and
+                if (procdefinition.proctypeoption=potype_destructor) and
                    assigned(methodpointer) and
                    assigned(methodpointer) and
                    (methodpointer.nodetype<>typen) and
                    (methodpointer.nodetype<>typen) and
-                   is_class(pobjectdef(methodpointer.resulttype.def)) and
+                   is_class(tobjectdef(methodpointer.resulttype.def)) and
                    (inlined or
                    (inlined or
                    (right=nil)) then
                    (right=nil)) then
                   begin
                   begin
@@ -826,8 +812,8 @@ implementation
                   end;
                   end;
 
 
               { push base pointer ?}
               { push base pointer ?}
-              if (lexlevel>=normal_function_level) and assigned(pprocdef(procdefinition)^.parast) and
-                ((pprocdef(procdefinition)^.parast^.symtablelevel)>normal_function_level) then
+              if (lexlevel>=normal_function_level) and assigned(tprocdef(procdefinition).parast) and
+                ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
                 begin
                 begin
                    { if we call a nested function in a method, we must      }
                    { if we call a nested function in a method, we must      }
                    { push also SELF!                                    }
                    { push also SELF!                                    }
@@ -839,7 +825,7 @@ implementation
                         emit_reg(A_PUSH,S_L,R_ESI);
                         emit_reg(A_PUSH,S_L,R_ESI);
                      end;
                      end;
                    }
                    }
-                   if lexlevel=(pprocdef(procdefinition)^.parast^.symtablelevel) then
+                   if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
                      begin
                      begin
                         new(r);
                         new(r);
                         reset_reference(r^);
                         reset_reference(r^);
@@ -849,11 +835,11 @@ implementation
                      end
                      end
                      { this is only true if the difference is one !!
                      { this is only true if the difference is one !!
                        but it cannot be more !! }
                        but it cannot be more !! }
-                   else if (lexlevel=pprocdef(procdefinition)^.parast^.symtablelevel-1) then
+                   else if (lexlevel=tprocdef(procdefinition).parast.symtablelevel-1) then
                      begin
                      begin
                         emit_reg(A_PUSH,S_L,procinfo^.framepointer)
                         emit_reg(A_PUSH,S_L,procinfo^.framepointer)
                      end
                      end
-                   else if (lexlevel>pprocdef(procdefinition)^.parast^.symtablelevel) then
+                   else if (lexlevel>tprocdef(procdefinition).parast.symtablelevel) then
                      begin
                      begin
                         hregister:=getregister32;
                         hregister:=getregister32;
                         new(r);
                         new(r);
@@ -861,7 +847,7 @@ implementation
                         r^.offset:=procinfo^.framepointer_offset;
                         r^.offset:=procinfo^.framepointer_offset;
                         r^.base:=procinfo^.framepointer;
                         r^.base:=procinfo^.framepointer;
                         emit_ref_reg(A_MOV,S_L,r,hregister);
                         emit_ref_reg(A_MOV,S_L,r,hregister);
-                        for i:=(pprocdef(procdefinition)^.parast^.symtablelevel) to lexlevel-1 do
+                        for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
                           begin
                           begin
                              new(r);
                              new(r);
                              reset_reference(r^);
                              reset_reference(r^);
@@ -880,7 +866,7 @@ implementation
 
 
               saveregvars(regs_to_push);
               saveregvars(regs_to_push);
 
 
-              if (po_virtualmethod in procdefinition^.procoptions) and
+              if (po_virtualmethod in procdefinition.procoptions) and
                  not(no_virtual_call) then
                  not(no_virtual_call) then
                 begin
                 begin
                    { static functions contain the vmt_address in ESI }
                    { static functions contain the vmt_address in ESI }
@@ -890,19 +876,19 @@ implementation
                    getexplicitregister32(R_ESI);
                    getexplicitregister32(R_ESI);
                    if assigned(aktprocsym) then
                    if assigned(aktprocsym) then
                      begin
                      begin
-                       if (((sp_static in aktprocsym^.symoptions) or
-                        (po_classmethod in aktprocsym^.definition^.procoptions)) and
+                       if (((sp_static in aktprocsym.symoptions) or
+                        (po_classmethod in aktprocsym.definition.procoptions)) and
                         ((methodpointer=nil) or (methodpointer.nodetype=typen)))
                         ((methodpointer=nil) or (methodpointer.nodetype=typen)))
                         or
                         or
-                        (po_staticmethod in procdefinition^.procoptions) or
-                        ((procdefinition^.proctypeoption=potype_constructor) and
+                        (po_staticmethod in procdefinition.procoptions) or
+                        ((procdefinition.proctypeoption=potype_constructor) and
                         { esi contains the vmt if we call a constructor via a class ref }
                         { esi contains the vmt if we call a constructor via a class ref }
                          assigned(methodpointer) and
                          assigned(methodpointer) and
-                         (methodpointer.resulttype.def^.deftype=classrefdef)
+                         (methodpointer.resulttype.def.deftype=classrefdef)
                         ) or
                         ) or
-                        { is_interface(pprocdef(procdefinition)^._class) or }
+                        { is_interface(tprocdef(procdefinition)._class) or }
                         { ESI is loaded earlier }
                         { ESI is loaded earlier }
-                        (po_classmethod in procdefinition^.procoptions) then
+                        (po_classmethod in procdefinition.procoptions) then
                          begin
                          begin
                             new(r);
                             new(r);
                             reset_reference(r^);
                             reset_reference(r^);
@@ -914,7 +900,7 @@ implementation
                             reset_reference(r^);
                             reset_reference(r^);
                             r^.base:=R_ESI;
                             r^.base:=R_ESI;
                             { this is one point where we need vmt_offset (PM) }
                             { this is one point where we need vmt_offset (PM) }
-                            r^.offset:= pprocdef(procdefinition)^._class^.vmt_offset;
+                            r^.offset:= tprocdef(procdefinition)._class.vmt_offset;
                             getexplicitregister32(R_EDI);
                             getexplicitregister32(R_EDI);
                             emit_ref_reg(A_MOV,S_L,r,R_EDI);
                             emit_ref_reg(A_MOV,S_L,r,R_EDI);
                             new(r);
                             new(r);
@@ -936,16 +922,16 @@ implementation
                        r^.base:=R_EDI;
                        r^.base:=R_EDI;
                      end;
                      end;
                    }
                    }
-                   if pprocdef(procdefinition)^.extnumber=-1 then
+                   if tprocdef(procdefinition).extnumber=-1 then
                      internalerror(44584);
                      internalerror(44584);
-                   r^.offset:=pprocdef(procdefinition)^._class^.vmtmethodoffset(pprocdef(procdefinition)^.extnumber);
-                   if not(is_interface(pprocdef(procdefinition)^._class)) and
-                     not(is_cppclass(pprocdef(procdefinition)^._class)) then
+                   r^.offset:=tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber);
+                   if not(is_interface(tprocdef(procdefinition)._class)) and
+                     not(is_cppclass(tprocdef(procdefinition)._class)) then
                      begin
                      begin
                         if (cs_check_object_ext in aktlocalswitches) then
                         if (cs_check_object_ext in aktlocalswitches) then
                           begin
                           begin
                              emit_sym(A_PUSH,S_L,
                              emit_sym(A_PUSH,S_L,
-                               newasmsymbol(pprocdef(procdefinition)^._class^.vmt_mangledname));
+                               newasmsymbol(tprocdef(procdefinition)._class.vmt_mangledname));
                              emit_reg(A_PUSH,S_L,r^.base);
                              emit_reg(A_PUSH,S_L,r^.base);
                              emitcall('FPC_CHECK_OBJECT_EXT');
                              emitcall('FPC_CHECK_OBJECT_EXT');
                           end
                           end
@@ -956,44 +942,42 @@ implementation
                           end;
                           end;
                      end;
                      end;
                    emit_ref(A_CALL,S_NO,r);
                    emit_ref(A_CALL,S_NO,r);
-{$ifndef noAllocEdi}
                    ungetregister32(R_EDI);
                    ungetregister32(R_EDI);
-{$endif noAllocEdi}
                 end
                 end
               else if not inlined then
               else if not inlined then
                 begin
                 begin
                   { We can call interrupts from within the smae code
                   { We can call interrupts from within the smae code
                     by just pushing the flags and CS PM }
                     by just pushing the flags and CS PM }
-                  if (po_interrupt in procdefinition^.procoptions) then
+                  if (po_interrupt in procdefinition.procoptions) then
                     begin
                     begin
                         emit_none(A_PUSHF,S_L);
                         emit_none(A_PUSHF,S_L);
                         emit_reg(A_PUSH,S_L,R_CS);
                         emit_reg(A_PUSH,S_L,R_CS);
                     end;
                     end;
-                  emitcall(pprocdef(procdefinition)^.mangledname);
+                  emitcall(tprocdef(procdefinition).mangledname);
                 end
                 end
               else { inlined proc }
               else { inlined proc }
                 { inlined code is in inlinecode }
                 { inlined code is in inlinecode }
                 begin
                 begin
                    { set poinline again }
                    { set poinline again }
-                   include(procdefinition^.proccalloptions,pocall_inline);
+                   include(procdefinition.proccalloptions,pocall_inline);
                    { process the inlinecode }
                    { process the inlinecode }
                    secondpass(inlinecode);
                    secondpass(inlinecode);
                    { free the args }
                    { free the args }
-                   if pprocdef(procdefinition)^.parast^.datasize>0 then
-                     ungetpersistanttemp(pprocdef(procdefinition)^.parast^.address_fixup);
+                   if tprocdef(procdefinition).parast.datasize>0 then
+                     ungetpersistanttemp(tprocdef(procdefinition).parast.address_fixup);
                 end;
                 end;
            end
            end
          else
          else
            { now procedure variable case }
            { now procedure variable case }
            begin
            begin
               secondpass(right);
               secondpass(right);
-              if (po_interrupt in procdefinition^.procoptions) then
+              if (po_interrupt in procdefinition.procoptions) then
                 begin
                 begin
                     emit_none(A_PUSHF,S_L);
                     emit_none(A_PUSHF,S_L);
                     emit_reg(A_PUSH,S_L,R_CS);
                     emit_reg(A_PUSH,S_L,R_CS);
                 end;
                 end;
               { procedure of object? }
               { procedure of object? }
-              if (po_methodpointer in procdefinition^.procoptions) then
+              if (po_methodpointer in procdefinition.procoptions) then
                 begin
                 begin
                    { method pointer can't be in a register }
                    { method pointer can't be in a register }
                    hregister:=R_NO;
                    hregister:=R_NO;
@@ -1012,7 +996,7 @@ implementation
                      end;
                      end;
 
 
                    { load self, but not if it's already explicitly pushed }
                    { load self, but not if it's already explicitly pushed }
-                   if not(po_containsself in procdefinition^.procoptions) then
+                   if not(po_containsself in procdefinition.procoptions) then
                      begin
                      begin
                        { load ESI }
                        { load ESI }
                        inc(right.location.reference.offset,4);
                        inc(right.location.reference.offset,4);
@@ -1029,14 +1013,7 @@ implementation
                      emit_ref(A_CALL,S_NO,newreference(right.location.reference))
                      emit_ref(A_CALL,S_NO,newreference(right.location.reference))
                    else
                    else
                      begin
                      begin
-{$ifndef noAllocEdi}
                        ungetregister32(hregister);
                        ungetregister32(hregister);
-{$else noAllocEdi}
-                       { the same code, the previous line is just to       }
-                       { indicate EDI actually is deallocated if allocated }
-                       { above (JM)                                        }
-                       ungetregister32(hregister);
-{$endif noAllocEdi}
                        emit_reg(A_CALL,S_NO,hregister);
                        emit_reg(A_CALL,S_NO,hregister);
                      end;
                      end;
 
 
@@ -1061,7 +1038,7 @@ implementation
            { this was only for normal functions
            { this was only for normal functions
              displaced here so we also get
              displaced here so we also get
              it to work for procvars PM }
              it to work for procvars PM }
-           if (not inlined) and (pocall_clearstack in procdefinition^.proccalloptions) then
+           if (not inlined) and (pocall_clearstack in procdefinition.proccalloptions) then
              begin
              begin
                 { we also add the pop_size which is included in pushedparasize }
                 { we also add the pop_size which is included in pushedparasize }
                 pop_size:=0;
                 pop_size:=0;
@@ -1105,10 +1082,10 @@ implementation
            but only if it is a call of an inherited constructor }
            but only if it is a call of an inherited constructor }
          if (inlined or
          if (inlined or
              (right=nil)) and
              (right=nil)) and
-            (procdefinition^.proctypeoption=potype_constructor) and
+            (procdefinition.proctypeoption=potype_constructor) and
             assigned(methodpointer) and
             assigned(methodpointer) and
             (methodpointer.nodetype=typen) and
             (methodpointer.nodetype=typen) and
-            (aktprocsym^.definition^.proctypeoption=potype_constructor) then
+            (aktprocsym.definition.proctypeoption=potype_constructor) then
            begin
            begin
              emitjmp(C_Z,faillabel);
              emitjmp(C_Z,faillabel);
            end;
            end;
@@ -1117,7 +1094,7 @@ implementation
          if is_class(resulttype.def) and
          if is_class(resulttype.def) and
            (inlined or
            (inlined or
            (right=nil)) and
            (right=nil)) and
-           (procdefinition^.proctypeoption=potype_constructor) and
+           (procdefinition.proctypeoption=potype_constructor) and
            assigned(methodpointer) and
            assigned(methodpointer) and
            (methodpointer.nodetype<>typen) then
            (methodpointer.nodetype<>typen) then
            begin
            begin
@@ -1157,9 +1134,9 @@ implementation
               { a contructor could be a function with boolean result }
               { a contructor could be a function with boolean result }
               if (inlined or
               if (inlined or
                   (right=nil)) and
                   (right=nil)) and
-                 (procdefinition^.proctypeoption=potype_constructor) and
+                 (procdefinition.proctypeoption=potype_constructor) and
                  { quick'n'dirty check if it is a class or an object }
                  { quick'n'dirty check if it is a class or an object }
-                 (resulttype.def^.deftype=orddef) then
+                 (resulttype.def.deftype=orddef) then
                 begin
                 begin
                    { this fails if popsize > 0 PM }
                    { this fails if popsize > 0 PM }
                    location.loc:=LOC_FLAGS;
                    location.loc:=LOC_FLAGS;
@@ -1190,10 +1167,10 @@ implementation
                 end
                 end
               else
               else
                 begin
                 begin
-                   if (resulttype.def^.deftype in [orddef,enumdef]) then
+                   if (resulttype.def.deftype in [orddef,enumdef]) then
                      begin
                      begin
                         location.loc:=LOC_REGISTER;
                         location.loc:=LOC_REGISTER;
-                        case resulttype.def^.size of
+                        case resulttype.def.size of
                           4 :
                           4 :
                             begin
                             begin
 {$ifdef test_dest_loc}
 {$ifdef test_dest_loc}
@@ -1257,7 +1234,7 @@ implementation
                      end
                      end
 
 
                 end
                 end
-              else if (resulttype.def^.deftype=floatdef) then
+              else if (resulttype.def.deftype=floatdef) then
                 begin
                 begin
                   location.loc:=LOC_FPU;
                   location.loc:=LOC_FPU;
                   inc(fpuvaroffset);
                   inc(fpuvaroffset);
@@ -1347,7 +1324,7 @@ implementation
               if location.loc in [LOC_MEM,LOC_REFERENCE] then
               if location.loc in [LOC_MEM,LOC_REFERENCE] then
                 begin
                 begin
                    { data which must be finalized ? }
                    { data which must be finalized ? }
-                   if (resulttype.def^.needs_inittable) then
+                   if (resulttype.def.needs_inittable) then
                       finalize(resulttype.def,location.reference,false);
                       finalize(resulttype.def,location.reference,false);
                    { release unused temp }
                    { release unused temp }
                    ungetiftemp(location.reference)
                    ungetiftemp(location.reference)
@@ -1372,15 +1349,15 @@ implementation
 
 
 
 
     procedure ti386procinlinenode.pass_2;
     procedure ti386procinlinenode.pass_2;
-       var st : psymtable;
-           oldprocsym : pprocsym;
+       var st : tsymtable;
+           oldprocsym : tprocsym;
            ps, i : longint;
            ps, i : longint;
            tmpreg: tregister;
            tmpreg: tregister;
            oldprocinfo : pprocinfo;
            oldprocinfo : pprocinfo;
            oldinlining_procedure,
            oldinlining_procedure,
            nostackframe,make_global : boolean;
            nostackframe,make_global : boolean;
            inlineentrycode,inlineexitcode : TAAsmoutput;
            inlineentrycode,inlineexitcode : TAAsmoutput;
-           oldexitlabel,oldexit2label,oldquickexitlabel:Pasmlabel;
+           oldexitlabel,oldexit2label,oldquickexitlabel:tasmlabel;
            oldunused,oldusableregs : tregisterset;
            oldunused,oldusableregs : tregisterset;
            oldc_usableregs : longint;
            oldc_usableregs : longint;
            oldreg_pushes : regvar_longintarray;
            oldreg_pushes : regvar_longintarray;
@@ -1391,18 +1368,18 @@ implementation
            oldreg_releaser : regvar_ptreearray;
            oldreg_releaser : regvar_ptreearray;
 {$endif TEMPREGDEBUG}
 {$endif TEMPREGDEBUG}
 {$ifdef GDB}
 {$ifdef GDB}
-           startlabel,endlabel : pasmlabel;
+           startlabel,endlabel : tasmlabel;
            pp : pchar;
            pp : pchar;
            mangled_length  : longint;
            mangled_length  : longint;
 {$endif GDB}
 {$endif GDB}
        begin
        begin
           { deallocate the registers used for the current procedure's regvars }
           { deallocate the registers used for the current procedure's regvars }
-          if assigned(aktprocsym^.definition^.regvarinfo) then
+          if assigned(aktprocsym.definition.regvarinfo) then
             begin
             begin
-              with pregvarinfo(aktprocsym^.definition^.regvarinfo)^ do
+              with pregvarinfo(aktprocsym.definition.regvarinfo)^ do
                 for i := 1 to maxvarregs do
                 for i := 1 to maxvarregs do
                   if assigned(regvars[i]) then
                   if assigned(regvars[i]) then
-                    store_regvar(exprasmlist,regvars[i]^.reg);
+                    store_regvar(exprasmlist,regvars[i].reg);
               oldunused := unused;
               oldunused := unused;
               oldusableregs := usableregs;
               oldusableregs := usableregs;
               oldc_usableregs := c_usableregs;
               oldc_usableregs := c_usableregs;
@@ -1418,15 +1395,15 @@ implementation
               resetusableregisters;
               resetusableregisters;
               clearregistercount;
               clearregistercount;
               cleartempgen;
               cleartempgen;
-              if assigned(inlineprocsym^.definition^.regvarinfo) then
-                with pregvarinfo(inlineprocsym^.definition^.regvarinfo)^ do
+              if assigned(inlineprocsym.definition.regvarinfo) then
+                with pregvarinfo(inlineprocsym.definition.regvarinfo)^ do
                  for i := 1 to maxvarregs do
                  for i := 1 to maxvarregs do
                   if assigned(regvars[i]) then
                   if assigned(regvars[i]) then
                     begin
                     begin
-                      case regsize(regvars[i]^.reg) of
-                        S_B: tmpreg := reg8toreg32(regvars[i]^.reg);
-                        S_W: tmpreg := reg16toreg32(regvars[i]^.reg);
-                        S_L: tmpreg := regvars[i]^.reg;
+                      case regsize(regvars[i].reg) of
+                        S_B: tmpreg := reg8toreg32(regvars[i].reg);
+                        S_W: tmpreg := reg16toreg32(regvars[i].reg);
+                        S_L: tmpreg := regvars[i].reg;
                       end;
                       end;
                       usableregs:=usableregs-[tmpreg];
                       usableregs:=usableregs-[tmpreg];
                       is_reg_var[tmpreg]:=true;
                       is_reg_var[tmpreg]:=true;
@@ -1447,20 +1424,20 @@ implementation
           move(procinfo^,oldprocinfo^,sizeof(tprocinfo));
           move(procinfo^,oldprocinfo^,sizeof(tprocinfo));
           { set the return value }
           { set the return value }
           aktprocsym:=inlineprocsym;
           aktprocsym:=inlineprocsym;
-          procinfo^.returntype:=aktprocsym^.definition^.rettype;
+          procinfo^.returntype:=aktprocsym.definition.rettype;
           procinfo^.return_offset:=retoffset;
           procinfo^.return_offset:=retoffset;
           procinfo^.para_offset:=para_offset;
           procinfo^.para_offset:=para_offset;
           { arg space has been filled by the parent secondcall }
           { arg space has been filled by the parent secondcall }
-          st:=aktprocsym^.definition^.localst;
+          st:=aktprocsym.definition.localst;
           { set it to the same lexical level }
           { set it to the same lexical level }
-          st^.symtablelevel:=oldprocsym^.definition^.localst^.symtablelevel;
-          if st^.datasize>0 then
+          st.symtablelevel:=oldprocsym.definition.localst.symtablelevel;
+          if st.datasize>0 then
             begin
             begin
-              st^.address_fixup:=gettempofsizepersistant(st^.datasize)+st^.datasize;
+              st.address_fixup:=gettempofsizepersistant(st.datasize)+st.datasize;
 {$ifdef extdebug}
 {$ifdef extdebug}
-              Comment(V_debug,'local symtable is at offset '+tostr(st^.address_fixup));
+              Comment(V_debug,'local symtable is at offset '+tostr(st.address_fixup));
               exprasmList.concat(Tai_asm_comment.Create(strpnew(
               exprasmList.concat(Tai_asm_comment.Create(strpnew(
-                'local symtable is at offset '+tostr(st^.address_fixup))));
+                'local symtable is at offset '+tostr(st.address_fixup))));
 {$endif extdebug}
 {$endif extdebug}
             end;
             end;
           exprasmList.concat(Tai_Marker.Create(InlineStart));
           exprasmList.concat(Tai_Marker.Create(InlineStart));
@@ -1473,23 +1450,23 @@ implementation
               getaddrlabel(startlabel);
               getaddrlabel(startlabel);
               getaddrlabel(endlabel);
               getaddrlabel(endlabel);
               emitlab(startlabel);
               emitlab(startlabel);
-              inlineprocsym^.definition^.localst^.symtabletype:=inlinelocalsymtable;
-              inlineprocsym^.definition^.parast^.symtabletype:=inlineparasymtable;
+              inlineprocsym.definition.localst.symtabletype:=inlinelocalsymtable;
+              inlineprocsym.definition.parast.symtabletype:=inlineparasymtable;
 
 
               { Here we must include the para and local symtable info }
               { Here we must include the para and local symtable info }
-              inlineprocsym^.concatstabto(withdebuglist);
+              inlineprocsym.concatstabto(withdebuglist);
 
 
-              { set it back for savety }
-              inlineprocsym^.definition^.localst^.symtabletype:=localsymtable;
-              inlineprocsym^.definition^.parast^.symtabletype:=parasymtable;
+              { set it back for safety }
+              inlineprocsym.definition.localst.symtabletype:=localsymtable;
+              inlineprocsym.definition.parast.symtabletype:=parasymtable;
 
 
-              mangled_length:=length(oldprocsym^.definition^.mangledname);
+              mangled_length:=length(oldprocsym.definition.mangledname);
               getmem(pp,mangled_length+50);
               getmem(pp,mangled_length+50);
-              strpcopy(pp,'192,0,0,'+startlabel^.name);
+              strpcopy(pp,'192,0,0,'+startlabel.name);
               if (target_os.use_function_relative_addresses) then
               if (target_os.use_function_relative_addresses) then
                 begin
                 begin
                   strpcopy(strend(pp),'-');
                   strpcopy(strend(pp),'-');
-                  strpcopy(strend(pp),oldprocsym^.definition^.mangledname);
+                  strpcopy(strend(pp),oldprocsym.definition.mangledname);
                 end;
                 end;
               withdebugList.concat(Tai_stabn.Create(strnew(pp)));
               withdebugList.concat(Tai_stabn.Create(strnew(pp)));
             end;
             end;
@@ -1500,12 +1477,12 @@ implementation
           ps:=para_size;
           ps:=para_size;
           make_global:=false; { to avoid warning }
           make_global:=false; { to avoid warning }
           genentrycode(inlineentrycode,make_global,0,ps,nostackframe,true);
           genentrycode(inlineentrycode,make_global,0,ps,nostackframe,true);
-          if po_assembler in aktprocsym^.definition^.procoptions then
+          if po_assembler in aktprocsym.definition.procoptions then
             inlineentrycode.insert(Tai_marker.Create(asmblockstart));
             inlineentrycode.insert(Tai_marker.Create(asmblockstart));
           exprasmList.concatlist(inlineentrycode);
           exprasmList.concatlist(inlineentrycode);
           secondpass(inlinetree);
           secondpass(inlinetree);
           genexitcode(inlineexitcode,0,false,true);
           genexitcode(inlineexitcode,0,false,true);
-          if po_assembler in aktprocsym^.definition^.procoptions then
+          if po_assembler in aktprocsym.definition.procoptions then
             inlineexitcode.concat(Tai_marker.Create(asmblockend));
             inlineexitcode.concat(Tai_marker.Create(asmblockend));
           exprasmList.concatlist(inlineexitcode);
           exprasmList.concatlist(inlineexitcode);
 
 
@@ -1517,10 +1494,10 @@ implementation
           exprasmList.concat(Tai_Marker.Create(InlineEnd));
           exprasmList.concat(Tai_Marker.Create(InlineEnd));
 
 
           {we can free the local data now, reset also the fixup address }
           {we can free the local data now, reset also the fixup address }
-          if st^.datasize>0 then
+          if st.datasize>0 then
             begin
             begin
-              ungetpersistanttemp(st^.address_fixup-st^.datasize);
-              st^.address_fixup:=0;
+              ungetpersistanttemp(st.address_fixup-st.datasize);
+              st.address_fixup:=0;
             end;
             end;
           { restore procinfo }
           { restore procinfo }
           move(oldprocinfo^,procinfo^,sizeof(tprocinfo));
           move(oldprocinfo^,procinfo^,sizeof(tprocinfo));
@@ -1529,11 +1506,11 @@ implementation
           if (cs_debuginfo in aktmoduleswitches) then
           if (cs_debuginfo in aktmoduleswitches) then
             begin
             begin
               emitlab(endlabel);
               emitlab(endlabel);
-              strpcopy(pp,'224,0,0,'+endlabel^.name);
+              strpcopy(pp,'224,0,0,'+endlabel.name);
              if (target_os.use_function_relative_addresses) then
              if (target_os.use_function_relative_addresses) then
                begin
                begin
                  strpcopy(strend(pp),'-');
                  strpcopy(strend(pp),'-');
-                 strpcopy(strend(pp),oldprocsym^.definition^.mangledname);
+                 strpcopy(strend(pp),oldprocsym.definition.mangledname);
                end;
                end;
               withdebugList.concat(Tai_stabn.Create(strnew(pp)));
               withdebugList.concat(Tai_stabn.Create(strnew(pp)));
               freemem(pp,mangled_length+50);
               freemem(pp,mangled_length+50);
@@ -1549,7 +1526,7 @@ implementation
           { reallocate the registers used for the current procedure's regvars, }
           { reallocate the registers used for the current procedure's regvars, }
           { since they may have been used and then deallocated in the inlined  }
           { since they may have been used and then deallocated in the inlined  }
           { procedure (JM)                                                     }
           { procedure (JM)                                                     }
-          if assigned(aktprocsym^.definition^.regvarinfo) then
+          if assigned(aktprocsym.definition.regvarinfo) then
             begin
             begin
               unused := oldunused;
               unused := oldunused;
               usableregs := oldusableregs;
               usableregs := oldusableregs;
@@ -1572,7 +1549,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  2001-04-02 21:20:36  peter
+  Revision 1.21  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.20  2001/04/02 21:20:36  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.19  2001/03/11 22:58:51  peter
   Revision 1.19  2001/03/11 22:58:51  peter

+ 59 - 76
compiler/i386/n386cnv.pas

@@ -83,7 +83,7 @@ implementation
         opsize    : topsize;
         opsize    : topsize;
         hregister,
         hregister,
         hregister2 : tregister;
         hregister2 : tregister;
-        l : pasmlabel;
+        l : tasmlabel;
 
 
       begin
       begin
         { insert range check if not explicit conversion }
         { insert range check if not explicit conversion }
@@ -91,12 +91,12 @@ implementation
           emitrangecheck(left,resulttype.def);
           emitrangecheck(left,resulttype.def);
 
 
         { is the result size smaller ? }
         { is the result size smaller ? }
-        if resulttype.def^.size<left.resulttype.def^.size then
+        if resulttype.def.size<left.resulttype.def.size then
           begin
           begin
             { only need to set the new size of a register }
             { only need to set the new size of a register }
             if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
             if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
              begin
              begin
-               case resulttype.def^.size of
+               case resulttype.def.size of
                 1 : location.register:=makereg8(left.location.register);
                 1 : location.register:=makereg8(left.location.register);
                 2 : location.register:=makereg16(left.location.register);
                 2 : location.register:=makereg16(left.location.register);
                 4 : location.register:=makereg32(left.location.register);
                 4 : location.register:=makereg32(left.location.register);
@@ -108,7 +108,7 @@ implementation
           end
           end
 
 
         { is the result size bigger ? }
         { is the result size bigger ? }
-        else if resulttype.def^.size>left.resulttype.def^.size then
+        else if resulttype.def.size>left.resulttype.def.size then
           begin
           begin
             { remove reference }
             { remove reference }
             if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
             if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
@@ -155,7 +155,7 @@ implementation
                  hregister2:=getregister32;
                  hregister2:=getregister32;
                  location.registerhigh:=hregister2;
                  location.registerhigh:=hregister2;
               end;
               end;
-            case resulttype.def^.size of
+            case resulttype.def.size of
              1:
              1:
                location.register:=makereg8(hregister);
                location.register:=makereg8(hregister);
              2:
              2:
@@ -185,7 +185,7 @@ implementation
                 begin
                 begin
                   emit_reg_reg(A_XOR,S_L,
                   emit_reg_reg(A_XOR,S_L,
                     hregister2,hregister2);
                     hregister2,hregister2);
-                  if (porddef(resulttype.def)^.typ=s64bit) and
+                  if (torddef(resulttype.def).typ=s64bit) and
                     is_signed(left.resulttype.def) then
                     is_signed(left.resulttype.def) then
                     begin
                     begin
                        getlabel(l);
                        getlabel(l);
@@ -208,15 +208,15 @@ implementation
       begin
       begin
          { does anybody know a better solution than this big case statement ? }
          { does anybody know a better solution than this big case statement ? }
          { ok, a proc table would do the job                              }
          { ok, a proc table would do the job                              }
-         case pstringdef(resulttype.def)^.string_typ of
+         case tstringdef(resulttype.def).string_typ of
 
 
             st_shortstring:
             st_shortstring:
-              case pstringdef(left.resulttype.def)^.string_typ of
+              case tstringdef(left.resulttype.def).string_typ of
                  st_shortstring:
                  st_shortstring:
                    begin
                    begin
-                      gettempofsizereference(resulttype.def^.size,location.reference);
+                      gettempofsizereference(resulttype.def.size,location.reference);
                       copyshortstring(location.reference,left.location.reference,
                       copyshortstring(location.reference,left.location.reference,
-                        pstringdef(resulttype.def)^.len,false,true);
+                        tstringdef(resulttype.def).len,false,true);
 {                      done by copyshortstring now (JM)          }
 {                      done by copyshortstring now (JM)          }
 {                      del_reference(left.location.reference); }
 {                      del_reference(left.location.reference); }
                       ungetiftemp(left.location.reference);
                       ungetiftemp(left.location.reference);
@@ -228,7 +228,7 @@ implementation
                    end;
                    end;
                  st_ansistring:
                  st_ansistring:
                    begin
                    begin
-                      gettempofsizereference(resulttype.def^.size,location.reference);
+                      gettempofsizereference(resulttype.def.size,location.reference);
                       loadansi2short(left,self);
                       loadansi2short(left,self);
                       { this is done in secondtypeconv (FK)
                       { this is done in secondtypeconv (FK)
                       removetemps(exprasmlist,temptoremove);
                       removetemps(exprasmlist,temptoremove);
@@ -243,7 +243,7 @@ implementation
               end;
               end;
 
 
             st_longstring:
             st_longstring:
-              case pstringdef(left.resulttype.def)^.string_typ of
+              case tstringdef(left.resulttype.def).string_typ of
                  st_shortstring:
                  st_shortstring:
                    begin
                    begin
                       {!!!!!!!}
                       {!!!!!!!}
@@ -262,7 +262,7 @@ implementation
               end;
               end;
 
 
             st_ansistring:
             st_ansistring:
-              case pstringdef(left.resulttype.def)^.string_typ of
+              case tstringdef(left.resulttype.def).string_typ of
                  st_shortstring:
                  st_shortstring:
                    begin
                    begin
                       clear_location(location);
                       clear_location(location);
@@ -294,7 +294,7 @@ implementation
               end;
               end;
 
 
             st_widestring:
             st_widestring:
-              case pstringdef(left.resulttype.def)^.string_typ of
+              case tstringdef(left.resulttype.def).string_typ of
                  st_shortstring:
                  st_shortstring:
                    begin
                    begin
                       {!!!!!!!}
                       {!!!!!!!}
@@ -327,7 +327,7 @@ implementation
          clear_location(location);
          clear_location(location);
          location.loc:=LOC_REGISTER;
          location.loc:=LOC_REGISTER;
          location.register:=getregister32;
          location.register:=getregister32;
-         case pstringdef(left.resulttype.def)^.string_typ of
+         case tstringdef(left.resulttype.def).string_typ of
            st_shortstring :
            st_shortstring :
              begin
              begin
                inc(left.location.reference.offset);
                inc(left.location.reference.offset);
@@ -365,12 +365,12 @@ implementation
     procedure ti386typeconvnode.second_string_to_chararray;
     procedure ti386typeconvnode.second_string_to_chararray;
       var
       var
          pushedregs: tpushed;
          pushedregs: tpushed;
-         //l1 : pasmlabel;
+         //l1 : tasmlabel;
          //hr : preference;
          //hr : preference;
          arrsize, strtype: longint;
          arrsize, strtype: longint;
          regstopush: byte;
          regstopush: byte;
       begin
       begin
-         with parraydef(resulttype.def)^ do
+         with tarraydef(resulttype.def) do
           begin
           begin
             if highrange<lowrange then
             if highrange<lowrange then
              internalerror(75432653);
              internalerror(75432653);
@@ -380,7 +380,7 @@ implementation
          if (left.nodetype = stringconstn) and
          if (left.nodetype = stringconstn) and
             { left.length+1 since there's always a terminating #0 character (JM) }
             { left.length+1 since there's always a terminating #0 character (JM) }
             (tstringconstnode(left).len+1 >= arrsize) and
             (tstringconstnode(left).len+1 >= arrsize) and
-            (pstringdef(left.resulttype.def)^.string_typ=st_shortstring) then
+            (tstringdef(left.resulttype.def).string_typ=st_shortstring) then
            begin
            begin
              inc(location.reference.offset);
              inc(location.reference.offset);
              exit;
              exit;
@@ -395,7 +395,7 @@ implementation
 
 
          emit_push_lea_loc(location,false);
          emit_push_lea_loc(location,false);
 
 
-         case pstringdef(left.resulttype.def)^.string_typ of
+         case tstringdef(left.resulttype.def).string_typ of
            st_shortstring :
            st_shortstring :
              begin
              begin
                { 0 means shortstring }
                { 0 means shortstring }
@@ -492,12 +492,12 @@ implementation
          l : longint;
          l : longint;
       begin
       begin
          { calc the length of the array }
          { calc the length of the array }
-         l:=parraydef(left.resulttype.def)^.highrange-parraydef(left.resulttype.def)^.lowrange+1;
+         l:=tarraydef(left.resulttype.def).highrange-tarraydef(left.resulttype.def).lowrange+1;
          { this is a type conversion which copies the data, so we can't }
          { this is a type conversion which copies the data, so we can't }
          { return a reference                                        }
          { return a reference                                        }
          clear_location(location);
          clear_location(location);
          location.loc:=LOC_MEM;
          location.loc:=LOC_MEM;
-         case pstringdef(resulttype.def)^.string_typ of
+         case tstringdef(resulttype.def).string_typ of
            st_shortstring :
            st_shortstring :
              begin
              begin
                if l>255 then
                if l>255 then
@@ -505,15 +505,15 @@ implementation
                   CGMessage(type_e_mismatch);
                   CGMessage(type_e_mismatch);
                   l:=255;
                   l:=255;
                 end;
                 end;
-               gettempofsizereference(resulttype.def^.size,location.reference);
+               gettempofsizereference(resulttype.def.size,location.reference);
                { we've also to release the registers ... }
                { we've also to release the registers ... }
                { Yes, but before pushusedregisters since that one resets unused! }
                { Yes, but before pushusedregisters since that one resets unused! }
                { This caused web bug 1073 (JM)                                   }
                { This caused web bug 1073 (JM)                                   }
                regstopush := $ff;
                regstopush := $ff;
                remove_non_regvars_from_loc(left.location,regstopush);
                remove_non_regvars_from_loc(left.location,regstopush);
                pushusedregisters(pushed,regstopush);
                pushusedregisters(pushed,regstopush);
-               if l>=resulttype.def^.size then
-                 push_int(resulttype.def^.size-1)
+               if l>=resulttype.def.size then
+                 push_int(resulttype.def.size-1)
                else
                else
                  push_int(l);
                  push_int(l);
                { ... here only the temp. location is released }
                { ... here only the temp. location is released }
@@ -562,7 +562,7 @@ implementation
       begin
       begin
          clear_location(location);
          clear_location(location);
          location.loc:=LOC_MEM;
          location.loc:=LOC_MEM;
-         case pstringdef(resulttype.def)^.string_typ of
+         case tstringdef(resulttype.def).string_typ of
            st_shortstring :
            st_shortstring :
              begin
              begin
                gettempofsizereference(256,location.reference);
                gettempofsizereference(256,location.reference);
@@ -592,22 +592,20 @@ implementation
       var
       var
          r : preference;
          r : preference;
          hregister : tregister;
          hregister : tregister;
-         l1,l2 : pasmlabel;
+         l1,l2 : tasmlabel;
 
 
       begin
       begin
          { for u32bit a solution is to push $0 and to load a comp }
          { for u32bit a solution is to push $0 and to load a comp }
          { does this first, it destroys maybe EDI }
          { does this first, it destroys maybe EDI }
          hregister:=R_EDI;
          hregister:=R_EDI;
-         if porddef(left.resulttype.def)^.typ=u32bit then
+         if torddef(left.resulttype.def).typ=u32bit then
             push_int(0);
             push_int(0);
          if (left.location.loc=LOC_REGISTER) or
          if (left.location.loc=LOC_REGISTER) or
             (left.location.loc=LOC_CREGISTER) then
             (left.location.loc=LOC_CREGISTER) then
            begin
            begin
-{$ifndef noAllocEdi}
-              if not (porddef(left.resulttype.def)^.typ in [u32bit,s32bit,u64bit,s64bit]) then
+              if not (torddef(left.resulttype.def).typ in [u32bit,s32bit,u64bit,s64bit]) then
                 getexplicitregister32(R_EDI);
                 getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
-              case porddef(left.resulttype.def)^.typ of
+              case torddef(left.resulttype.def).typ of
                  s8bit : emit_reg_reg(A_MOVSX,S_BL,left.location.register,R_EDI);
                  s8bit : emit_reg_reg(A_MOVSX,S_BL,left.location.register,R_EDI);
                  u8bit : emit_reg_reg(A_MOVZX,S_BL,left.location.register,R_EDI);
                  u8bit : emit_reg_reg(A_MOVZX,S_BL,left.location.register,R_EDI);
                  s16bit : emit_reg_reg(A_MOVSX,S_WL,left.location.register,R_EDI);
                  s16bit : emit_reg_reg(A_MOVSX,S_WL,left.location.register,R_EDI);
@@ -625,10 +623,8 @@ implementation
          else
          else
            begin
            begin
               r:=newreference(left.location.reference);
               r:=newreference(left.location.reference);
-{$ifndef noAllocEdi}
               getexplicitregister32(R_EDI);
               getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
-              case porddef(left.resulttype.def)^.typ of
+              case torddef(left.resulttype.def).typ of
                  s8bit:
                  s8bit:
                    emit_ref_reg(A_MOVSX,S_BL,r,R_EDI);
                    emit_ref_reg(A_MOVSX,S_BL,r,R_EDI);
                  u8bit:
                  u8bit:
@@ -653,12 +649,10 @@ implementation
            end;
            end;
          { for 64 bit integers, the high dword is already pushed }
          { for 64 bit integers, the high dword is already pushed }
          emit_reg(A_PUSH,S_L,hregister);
          emit_reg(A_PUSH,S_L,hregister);
-{$ifndef noAllocEdi}
          if hregister = R_EDI then
          if hregister = R_EDI then
            ungetregister32(R_EDI);
            ungetregister32(R_EDI);
-{$endif noAllocEdi}
          r:=new_reference(R_ESP,0);
          r:=new_reference(R_ESP,0);
-         case porddef(left.resulttype.def)^.typ of
+         case torddef(left.resulttype.def).typ of
            u32bit:
            u32bit:
              begin
              begin
                 emit_ref(A_FILD,S_IQ,r);
                 emit_ref(A_FILD,S_IQ,r);
@@ -676,16 +670,12 @@ implementation
                 { if it is 1 then we add $80000000 000000000 }
                 { if it is 1 then we add $80000000 000000000 }
                 { as double                                  }
                 { as double                                  }
                 inc(r^.offset,4);
                 inc(r^.offset,4);
-{$ifndef noAllocEdi}
                 getexplicitregister32(R_EDI);
                 getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                 emit_ref_reg(A_MOV,S_L,r,R_EDI);
                 emit_ref_reg(A_MOV,S_L,r,R_EDI);
                 r:=new_reference(R_ESP,4);
                 r:=new_reference(R_ESP,4);
                 emit_const_ref(A_AND,S_L,$7fffffff,r);
                 emit_const_ref(A_AND,S_L,$7fffffff,r);
                 emit_const_reg(A_TEST,S_L,longint($80000000),R_EDI);
                 emit_const_reg(A_TEST,S_L,longint($80000000),R_EDI);
-{$ifndef noAllocEdi}
                 ungetregister32(R_EDI);
                 ungetregister32(R_EDI);
-{$endif noAllocEdi}
                 r:=new_reference(R_ESP,0);
                 r:=new_reference(R_ESP,0);
                 emit_ref(A_FILD,S_IQ,r);
                 emit_ref(A_FILD,S_IQ,r);
                 getdatalabel(l1);
                 getdatalabel(l1);
@@ -704,13 +694,9 @@ implementation
            else
            else
              begin
              begin
                 emit_ref(A_FILD,S_IL,r);
                 emit_ref(A_FILD,S_IL,r);
-{$ifndef noAllocEdi}
                 getexplicitregister32(R_EDI);
                 getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                 emit_reg(A_POP,S_L,R_EDI);
                 emit_reg(A_POP,S_L,R_EDI);
-{$ifndef noAllocEdi}
                 ungetregister32(R_EDI);
                 ungetregister32(R_EDI);
-{$endif noAllocEdi}
              end;
              end;
          end;
          end;
          inc(fpuvaroffset);
          inc(fpuvaroffset);
@@ -731,7 +717,7 @@ implementation
             LOC_MEM,
             LOC_MEM,
             LOC_REFERENCE:
             LOC_REFERENCE:
               begin
               begin
-                 floatload(pfloatdef(left.resulttype.def)^.typ,
+                 floatload(tfloatdef(left.resulttype.def).typ,
                    left.location.reference);
                    left.location.reference);
                  { we have to free the reference }
                  { we have to free the reference }
                  del_reference(left.location.reference);
                  del_reference(left.location.reference);
@@ -771,7 +757,7 @@ implementation
 
 
     procedure ti386typeconvnode.second_bool_to_int;
     procedure ti386typeconvnode.second_bool_to_int;
       var
       var
-         oldtruelabel,oldfalselabel,hlabel : pasmlabel;
+         oldtruelabel,oldfalselabel,hlabel : tasmlabel;
          hregister : tregister;
          hregister : tregister;
          newsize,
          newsize,
          opsize : topsize;
          opsize : topsize;
@@ -785,7 +771,7 @@ implementation
          { byte(boolean) or word(wordbool) or longint(longbool) must
          { byte(boolean) or word(wordbool) or longint(longbool) must
          be accepted for var parameters }
          be accepted for var parameters }
          if (nf_explizit in flags) and
          if (nf_explizit in flags) and
-            (left.resulttype.def^.size=resulttype.def^.size) and
+            (left.resulttype.def.size=resulttype.def.size) and
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
            begin
            begin
               set_location(location,left.location);
               set_location(location,left.location);
@@ -796,16 +782,16 @@ implementation
          clear_location(location);
          clear_location(location);
          location.loc:=LOC_REGISTER;
          location.loc:=LOC_REGISTER;
          del_reference(left.location.reference);
          del_reference(left.location.reference);
-         case left.resulttype.def^.size of
+         case left.resulttype.def.size of
           1 : begin
           1 : begin
-                case resulttype.def^.size of
+                case resulttype.def.size of
                  1 : opsize:=S_B;
                  1 : opsize:=S_B;
                  2 : opsize:=S_BW;
                  2 : opsize:=S_BW;
                  4 : opsize:=S_BL;
                  4 : opsize:=S_BL;
                 end;
                 end;
               end;
               end;
           2 : begin
           2 : begin
-                case resulttype.def^.size of
+                case resulttype.def.size of
                  1 : begin
                  1 : begin
                        if left.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
                        if left.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
                         left.location.register:=reg16toreg8(left.location.register);
                         left.location.register:=reg16toreg8(left.location.register);
@@ -816,7 +802,7 @@ implementation
                 end;
                 end;
               end;
               end;
           4 : begin
           4 : begin
-                case resulttype.def^.size of
+                case resulttype.def.size of
                  1 : begin
                  1 : begin
                        if left.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
                        if left.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
                         left.location.register:=reg32toreg8(left.location.register);
                         left.location.register:=reg32toreg8(left.location.register);
@@ -839,7 +825,7 @@ implementation
           else
           else
            op:=A_MOVZX;
            op:=A_MOVZX;
          hregister:=getregister32;
          hregister:=getregister32;
-         case resulttype.def^.size of
+         case resulttype.def.size of
           1 : begin
           1 : begin
                 location.register:=reg32toreg8(hregister);
                 location.register:=reg32toreg8(hregister);
                 newsize:=S_B;
                 newsize:=S_B;
@@ -898,7 +884,7 @@ implementation
          { byte(boolean) or word(wordbool) or longint(longbool) must
          { byte(boolean) or word(wordbool) or longint(longbool) must
          be accepted for var parameters }
          be accepted for var parameters }
          if (nf_explizit in flags) and
          if (nf_explizit in flags) and
-            (left.resulttype.def^.size=resulttype.def^.size) and
+            (left.resulttype.def.size=resulttype.def.size) and
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
            begin
            begin
               set_location(location,left.location);
               set_location(location,left.location);
@@ -930,7 +916,7 @@ implementation
             else
             else
               internalerror(10062);
               internalerror(10062);
          end;
          end;
-         case resulttype.def^.size of
+         case resulttype.def.size of
           1 : location.register:=makereg8(hregister);
           1 : location.register:=makereg8(hregister);
           2 : location.register:=makereg16(hregister);
           2 : location.register:=makereg16(hregister);
           4 : location.register:=makereg32(hregister);
           4 : location.register:=makereg32(hregister);
@@ -963,7 +949,7 @@ implementation
 
 
     procedure ti386typeconvnode.second_ansistring_to_pchar;
     procedure ti386typeconvnode.second_ansistring_to_pchar;
       var
       var
-         l1 : pasmlabel;
+         l1 : tasmlabel;
          hr : preference;
          hr : preference;
       begin
       begin
          clear_location(location);
          clear_location(location);
@@ -995,11 +981,11 @@ implementation
         pushed : tpushed;
         pushed : tpushed;
         regs_to_push: byte;
         regs_to_push: byte;
       begin
       begin
-         case pstringdef(resulttype.def)^.string_typ of
+         case tstringdef(resulttype.def).string_typ of
            st_shortstring:
            st_shortstring:
              begin
              begin
                 location.loc:=LOC_REFERENCE;
                 location.loc:=LOC_REFERENCE;
-                gettempofsizereference(resulttype.def^.size,location.reference);
+                gettempofsizereference(resulttype.def.size,location.reference);
                 pushusedregisters(pushed,$ff);
                 pushusedregisters(pushed,$ff);
                 case left.location.loc of
                 case left.location.loc of
                    LOC_REGISTER,LOC_CREGISTER:
                    LOC_REGISTER,LOC_CREGISTER:
@@ -1063,7 +1049,7 @@ implementation
     procedure ti386typeconvnode.second_class_to_intf;
     procedure ti386typeconvnode.second_class_to_intf;
       var
       var
          hreg : tregister;
          hreg : tregister;
-         l1 : pasmlabel;
+         l1 : tasmlabel;
       begin
       begin
          case left.location.loc of
          case left.location.loc of
             LOC_MEM,
             LOC_MEM,
@@ -1087,8 +1073,8 @@ implementation
          emit_reg_reg(A_TEST,S_L,hreg,hreg);
          emit_reg_reg(A_TEST,S_L,hreg,hreg);
          getlabel(l1);
          getlabel(l1);
          emitjmp(C_Z,l1);
          emitjmp(C_Z,l1);
-         emit_const_reg(A_ADD,S_L,pobjectdef(left.resulttype.def)^.implementedinterfaces^.ioffsets(
-           pobjectdef(left.resulttype.def)^.implementedinterfaces^.searchintf(resulttype.def))^,hreg);
+         emit_const_reg(A_ADD,S_L,tobjectdef(left.resulttype.def).implementedinterfaces.ioffsets(
+           tobjectdef(left.resulttype.def).implementedinterfaces.searchintf(resulttype.def))^,hreg);
          emitlab(l1);
          emitlab(l1);
          location.loc:=LOC_REGISTER;
          location.loc:=LOC_REGISTER;
          location.register:=hreg;
          location.register:=hreg;
@@ -1174,10 +1160,10 @@ implementation
 {$ifdef TESTOBJEXT2}
 {$ifdef TESTOBJEXT2}
                   { Check explicit conversions to objects pointers !! }
                   { Check explicit conversions to objects pointers !! }
                      if p^.explizit and
                      if p^.explizit and
-                        (p^.resulttype.def^.deftype=pointerdef) and
-                        (ppointerdef(p^.resulttype.def)^.definition^.deftype=objectdef) and not
-                        (pobjectdef(ppointerdef(p^.resulttype.def)^.definition)^.isclass) and
-                        ((pobjectdef(ppointerdef(p^.resulttype.def)^.definition)^.options and oo_hasvmt)<>0) and
+                        (p^.resulttype.def.deftype=pointerdef) and
+                        (tpointerdef(p^.resulttype.def).definition.deftype=objectdef) and not
+                        (tobjectdef(tpointerdef(p^.resulttype.def).definition).isclass) and
+                        ((tobjectdef(tpointerdef(p^.resulttype.def).definition).options and oo_hasvmt)<>0) and
                         (cs_check_range in aktlocalswitches) then
                         (cs_check_range in aktlocalswitches) then
                        begin
                        begin
                           new(r);
                           new(r);
@@ -1186,31 +1172,23 @@ implementation
                            r^.base:=p^.location.register
                            r^.base:=p^.location.register
                           else
                           else
                             begin
                             begin
-{$ifndef noAllocEdi}
                                getexplicitregister32(R_EDI);
                                getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                                emit_mov_loc_reg(p^.location,R_EDI);
                                emit_mov_loc_reg(p^.location,R_EDI);
                                r^.base:=R_EDI;
                                r^.base:=R_EDI;
                             end;
                             end;
                           { NIL must be accepted !! }
                           { NIL must be accepted !! }
                           emit_reg_reg(A_OR,S_L,r^.base,r^.base);
                           emit_reg_reg(A_OR,S_L,r^.base,r^.base);
-{$ifndef noAllocEdi}
                           ungetregister32(R_EDI);
                           ungetregister32(R_EDI);
-{$endif noAllocEdi}
                           getlabel(nillabel);
                           getlabel(nillabel);
                           emitjmp(C_E,nillabel);
                           emitjmp(C_E,nillabel);
                           { this is one point where we need vmt_offset (PM) }
                           { this is one point where we need vmt_offset (PM) }
-                          r^.offset:= pobjectdef(ppointerdef(p^.resulttype.def)^.definition)^.vmt_offset;
-{$ifndef noAllocEdi}
+                          r^.offset:= tobjectdef(tpointerdef(p^.resulttype.def).definition).vmt_offset;
                           getexplicitregister32(R_EDI);
                           getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                           emit_ref_reg(A_MOV,S_L,r,R_EDI);
                           emit_ref_reg(A_MOV,S_L,r,R_EDI);
                           emit_sym(A_PUSH,S_L,
                           emit_sym(A_PUSH,S_L,
-                            newasmsymbol(pobjectdef(ppointerdef(p^.resulttype.def)^.definition)^.vmt_mangledname));
+                            newasmsymbol(tobjectdef(tpointerdef(p^.resulttype.def).definition).vmt_mangledname));
                           emit_reg(A_PUSH,S_L,R_EDI);
                           emit_reg(A_PUSH,S_L,R_EDI);
-{$ifndef noAllocEdi}
                           ungetregister32(R_EDI);
                           ungetregister32(R_EDI);
-{$endif noAllocEdi}
                           emitcall('FPC_CHECK_OBJECT_EXT');
                           emitcall('FPC_CHECK_OBJECT_EXT');
                           emitlab(nillabel);
                           emitlab(nillabel);
                        end;
                        end;
@@ -1334,7 +1312,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-02 21:20:36  peter
+  Revision 1.14  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/02 21:20:36  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.12  2001/01/08 21:45:11  peter
   Revision 1.12  2001/01/08 21:45:11  peter

+ 15 - 10
compiler/i386/n386con.pas

@@ -76,7 +76,7 @@ implementation
 
 
       var
       var
          hp1 : tai;
          hp1 : tai;
-         lastlabel : pasmlabel;
+         lastlabel : tasmlabel;
          realait : tait;
          realait : tait;
 
 
       begin
       begin
@@ -95,7 +95,7 @@ implementation
          else
          else
            begin
            begin
               lastlabel:=nil;
               lastlabel:=nil;
-              realait:=floattype2ait[pfloatdef(resulttype.def)^.typ];
+              realait:=floattype2ait[tfloatdef(resulttype.def).typ];
               { const already used ? }
               { const already used ? }
               if not assigned(lab_real) then
               if not assigned(lab_real) then
                 begin
                 begin
@@ -160,7 +160,7 @@ implementation
 
 
     procedure ti386ordconstnode.pass_2;
     procedure ti386ordconstnode.pass_2;
       var
       var
-         l : pasmlabel;
+         l : tasmlabel;
 
 
       begin
       begin
          location.loc:=LOC_MEM;
          location.loc:=LOC_MEM;
@@ -193,7 +193,7 @@ implementation
          { an integer const. behaves as a memory reference }
          { an integer const. behaves as a memory reference }
          location.loc:=LOC_MEM;
          location.loc:=LOC_MEM;
          location.reference.is_immediate:=true;
          location.reference.is_immediate:=true;
-         location.reference.offset:=value;
+         location.reference.offset:=longint(value);
       end;
       end;
 
 
 
 
@@ -205,7 +205,7 @@ implementation
       var
       var
          hp1 : tai;
          hp1 : tai;
          l1,l2,
          l1,l2,
-         lastlabel   : pasmlabel;
+         lastlabel   : tasmlabel;
          pc       : pchar;
          pc       : pchar;
          same_string : boolean;
          same_string : boolean;
          l,j,
          l,j,
@@ -386,19 +386,19 @@ implementation
     procedure ti386setconstnode.pass_2;
     procedure ti386setconstnode.pass_2;
       var
       var
          hp1     : tai;
          hp1     : tai;
-         lastlabel   : pasmlabel;
+         lastlabel   : tasmlabel;
          i         : longint;
          i         : longint;
          neededtyp   : tait;
          neededtyp   : tait;
       begin
       begin
         { small sets are loaded as constants }
         { small sets are loaded as constants }
-        if psetdef(resulttype.def)^.settype=smallset then
+        if tsetdef(resulttype.def).settype=smallset then
          begin
          begin
            location.loc:=LOC_MEM;
            location.loc:=LOC_MEM;
            location.reference.is_immediate:=true;
            location.reference.is_immediate:=true;
            location.reference.offset:=plongint(value_set)^;
            location.reference.offset:=plongint(value_set)^;
            exit;
            exit;
          end;
          end;
-        if psetdef(resulttype.def)^.settype=smallset then
+        if tsetdef(resulttype.def).settype=smallset then
          neededtyp:=ait_const_32bit
          neededtyp:=ait_const_32bit
         else
         else
          neededtyp:=ait_const_8bit;
          neededtyp:=ait_const_8bit;
@@ -461,7 +461,7 @@ implementation
                  if (cs_create_smart in aktmoduleswitches) then
                  if (cs_create_smart in aktmoduleswitches) then
                   Consts.concat(Tai_cut.Create);
                   Consts.concat(Tai_cut.Create);
                  Consts.concat(Tai_label.Create(lastlabel));
                  Consts.concat(Tai_label.Create(lastlabel));
-                 if psetdef(resulttype.def)^.settype=smallset then
+                 if tsetdef(resulttype.def).settype=smallset then
                   begin
                   begin
                     move(value_set^,i,sizeof(longint));
                     move(value_set^,i,sizeof(longint));
                     Consts.concat(Tai_const.Create_32bit(i));
                     Consts.concat(Tai_const.Create_32bit(i));
@@ -500,7 +500,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2001-04-02 21:20:37  peter
+  Revision 1.8  2001-04-13 01:22:18  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.7  2001/04/02 21:20:37  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.6  2000/12/25 00:07:32  peter
   Revision 1.6  2000/12/25 00:07:32  peter

+ 25 - 20
compiler/i386/n386flw.pas

@@ -99,8 +99,8 @@ implementation
     procedure ti386whilerepeatnode.pass_2;
     procedure ti386whilerepeatnode.pass_2;
       var
       var
          lcont,lbreak,lloop,
          lcont,lbreak,lloop,
-         oldclabel,oldblabel : pasmlabel;
-         otlabel,oflabel : pasmlabel;
+         oldclabel,oldblabel : tasmlabel;
+         otlabel,oflabel : tasmlabel;
 
 
          //start_regvars_loaded,
          //start_regvars_loaded,
          //then_regvars_loaded: regvar_booleanarray;
          //then_regvars_loaded: regvar_booleanarray;
@@ -178,7 +178,7 @@ implementation
     procedure ti386ifnode.pass_2;
     procedure ti386ifnode.pass_2;
 
 
       var
       var
-         hl,otlabel,oflabel : pasmlabel;
+         hl,otlabel,oflabel : tasmlabel;
 
 
       begin
       begin
          otlabel:=truelabel;
          otlabel:=truelabel;
@@ -232,7 +232,7 @@ implementation
 
 
     procedure ti386fornode.pass_2;
     procedure ti386fornode.pass_2;
       var
       var
-         l3,oldclabel,oldblabel : pasmlabel;
+         l3,oldclabel,oldblabel : tasmlabel;
          omitfirstcomp,temptovalue : boolean;
          omitfirstcomp,temptovalue : boolean;
          hs : byte;
          hs : byte;
          temp1 : treference;
          temp1 : treference;
@@ -261,7 +261,7 @@ implementation
          { only calculate reference }
          { only calculate reference }
          cleartempgen;
          cleartempgen;
          secondpass(t2);
          secondpass(t2);
-         hs:=t2.resulttype.def^.size;
+         hs:=t2.resulttype.def.size;
          if t2.location.loc <> LOC_CREGISTER then
          if t2.location.loc <> LOC_CREGISTER then
            cmp32:=getregister32;
            cmp32:=getregister32;
          case hs of
          case hs of
@@ -308,7 +308,7 @@ implementation
          { produce start assignment }
          { produce start assignment }
          cleartempgen;
          cleartempgen;
          secondpass(left);
          secondpass(left);
-         count_var_is_signed:=is_signed(porddef(t2.resulttype.def));
+         count_var_is_signed:=is_signed(torddef(t2.resulttype.def));
          if temptovalue then
          if temptovalue then
              begin
              begin
               if t2.location.loc=LOC_CREGISTER then
               if t2.location.loc=LOC_CREGISTER then
@@ -464,7 +464,7 @@ implementation
       var
       var
          {op : tasmop;
          {op : tasmop;
          s : topsize;}
          s : topsize;}
-         otlabel,oflabel : pasmlabel;
+         otlabel,oflabel : tasmlabel;
          r : preference;
          r : preference;
          is_mem,
          is_mem,
          allocated_eax,
          allocated_eax,
@@ -531,7 +531,7 @@ implementation
               else
               else
                 internalerror(2001);
                 internalerror(2001);
               end;
               end;
-              case procinfo^.returntype.def^.deftype of
+              case procinfo^.returntype.def.deftype of
            pointerdef,
            pointerdef,
            procvardef : begin
            procvardef : begin
                           cleanleft;
                           cleanleft;
@@ -547,7 +547,7 @@ implementation
              floatdef : begin
              floatdef : begin
                           cleanleft;
                           cleanleft;
                           if is_mem then
                           if is_mem then
-                           floatload(pfloatdef(procinfo^.returntype.def)^.typ,left.location.reference);
+                           floatload(tfloatdef(procinfo^.returntype.def).typ,left.location.reference);
                         end;
                         end;
               { orddef,
               { orddef,
               enumdef : }
               enumdef : }
@@ -558,7 +558,7 @@ implementation
                           cleanleft;
                           cleanleft;
                           exprasmlist.concat(tairegalloc.alloc(R_EAX));
                           exprasmlist.concat(tairegalloc.alloc(R_EAX));
                           allocated_eax := true;
                           allocated_eax := true;
-                          case procinfo^.returntype.def^.size of
+                          case procinfo^.returntype.def.size of
                            { it can be a qword/int64 too ... }
                            { it can be a qword/int64 too ... }
                            8 : if is_mem then
                            8 : if is_mem then
                                  begin
                                  begin
@@ -657,8 +657,8 @@ do_jmp:
          emitjmp(C_None,labelnr);
          emitjmp(C_None,labelnr);
          { the assigned avoids only crashes if the label isn't defined }
          { the assigned avoids only crashes if the label isn't defined }
          if assigned(labsym) and
          if assigned(labsym) and
-           assigned(labsym^.code) and
-            (aktexceptblock<>tlabelnode(labsym^.code).exceptionblock) then
+           assigned(labsym.code) and
+            (aktexceptblock<>tlabelnode(labsym.code).exceptionblock) then
            CGMessage(cg_e_goto_inout_of_exception_block);
            CGMessage(cg_e_goto_inout_of_exception_block);
        end;
        end;
 
 
@@ -683,7 +683,7 @@ do_jmp:
     procedure ti386raisenode.pass_2;
     procedure ti386raisenode.pass_2;
 
 
       var
       var
-         a : pasmlabel;
+         a : tasmlabel;
       begin
       begin
          if assigned(left) then
          if assigned(left) then
            begin
            begin
@@ -733,7 +733,7 @@ do_jmp:
 *****************************************************************************}
 *****************************************************************************}
 
 
     var
     var
-       endexceptlabel : pasmlabel;
+       endexceptlabel : tasmlabel;
 
 
     { does the necessary things to clean up the object stack }
     { does the necessary things to clean up the object stack }
     { in the except block                                    }
     { in the except block                                    }
@@ -777,7 +777,7 @@ do_jmp:
          oldaktexitlabel,
          oldaktexitlabel,
          oldaktexit2label,
          oldaktexit2label,
          oldaktcontinuelabel,
          oldaktcontinuelabel,
-         oldaktbreaklabel : pasmlabel;
+         oldaktbreaklabel : tasmlabel;
          oldexceptblock : tnode;
          oldexceptblock : tnode;
 
 
 
 
@@ -1044,7 +1044,7 @@ do_jmp:
          oldaktcontinuelabel,
          oldaktcontinuelabel,
          doobjectdestroyandreraise,
          doobjectdestroyandreraise,
          doobjectdestroy,
          doobjectdestroy,
-         oldaktbreaklabel : pasmlabel;
+         oldaktbreaklabel : tasmlabel;
          ref : treference;
          ref : treference;
          oldexceptblock : tnode;
          oldexceptblock : tnode;
          oldflowcontrol : tflowcontrol;
          oldflowcontrol : tflowcontrol;
@@ -1057,7 +1057,7 @@ do_jmp:
 
 
          { push the vmt }
          { push the vmt }
          emit_sym(A_PUSH,S_L,
          emit_sym(A_PUSH,S_L,
-           newasmsymbol(excepttype^.vmt_mangledname));
+           newasmsymbol(excepttype.vmt_mangledname));
          emitcall('FPC_CATCHES');
          emitcall('FPC_CATCHES');
          { allocate eax }
          { allocate eax }
          exprasmList.concat(Tairegalloc.Alloc(R_EAX));
          exprasmList.concat(Tairegalloc.Alloc(R_EAX));
@@ -1068,7 +1068,7 @@ do_jmp:
 
 
          { what a hack ! }
          { what a hack ! }
          if assigned(exceptsymtable) then
          if assigned(exceptsymtable) then
-           pvarsym(exceptsymtable^.symindex^.first)^.address:=ref.offset;
+           tvarsym(exceptsymtable.symindex.first).address:=ref.offset;
 
 
          emit_reg_ref(A_MOV,S_L,
          emit_reg_ref(A_MOV,S_L,
            R_EAX,newreference(ref));
            R_EAX,newreference(ref));
@@ -1204,7 +1204,7 @@ do_jmp:
          oldaktexitlabel,
          oldaktexitlabel,
          oldaktexit2label,
          oldaktexit2label,
          oldaktcontinuelabel,
          oldaktcontinuelabel,
-         oldaktbreaklabel : pasmlabel;
+         oldaktbreaklabel : tasmlabel;
          oldexceptblock : tnode;
          oldexceptblock : tnode;
          oldflowcontrol,tryflowcontrol : tflowcontrol;
          oldflowcontrol,tryflowcontrol : tflowcontrol;
          decconst : longint;
          decconst : longint;
@@ -1385,7 +1385,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2001-04-02 21:20:37  peter
+  Revision 1.10  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.9  2001/04/02 21:20:37  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.8  2001/01/27 21:29:35  florian
   Revision 1.8  2001/01/27 21:29:35  florian

+ 25 - 20
compiler/i386/n386ic.pas

@@ -28,7 +28,7 @@ uses
   aasm,
   aasm,
   symbase,symtype,symtable,symdef,symsym;
   symbase,symtype,symtable,symdef,symsym;
 
 
-procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: pprocdef; const labelname: string; ioffset: longint);
+procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);
 
 
 implementation
 implementation
 
 
@@ -82,22 +82,22 @@ virtual(2):      OK     OK    OK(3)  OK     OK(3)      OK          OK(4)
 
 
 }
 }
 
 
-function getselfoffsetfromsp(procdef: pprocdef): longint;
+function getselfoffsetfromsp(procdef: tprocdef): longint;
 begin
 begin
-  if not assigned(procdef^.parast^.symindex^.first) then
+  if not assigned(procdef.parast.symindex.first) then
     getselfoffsetfromsp:=4
     getselfoffsetfromsp:=4
   else
   else
-    if psym(procdef^.parast^.symindex^.first)^.typ=varsym then
-      getselfoffsetfromsp:=pvarsym(procdef^.parast^.symindex^.first)^.address+4
+    if tsym(procdef.parast.symindex.first).typ=varsym then
+      getselfoffsetfromsp:=tvarsym(procdef.parast.symindex.first).address+4
     else
     else
       Internalerror(2000061310);
       Internalerror(2000061310);
 end;
 end;
 
 
 
 
-procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: pprocdef; const labelname: string; ioffset: longint);
+procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);
   procedure checkvirtual;
   procedure checkvirtual;
   begin
   begin
-    if (procdef^.extnumber=-1) then
+    if (procdef.extnumber=-1) then
       Internalerror(200006139);
       Internalerror(200006139);
   end;
   end;
 
 
@@ -123,24 +123,24 @@ procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: pprocdef; const labelname
   procedure op_oneaxmethodaddr(op: TAsmOp);
   procedure op_oneaxmethodaddr(op: TAsmOp);
   begin
   begin
     { call/jmp  vmtoffs(%eax) ; method offs }
     { call/jmp  vmtoffs(%eax) ; method offs }
-    emit_ref(op,S_L,new_reference(R_EAX,procdef^._class^.vmtmethodoffset(procdef^.extnumber)));
+    emit_ref(op,S_L,new_reference(R_EAX,procdef._class.vmtmethodoffset(procdef.extnumber)));
   end;
   end;
 
 
   procedure loadmethodoffstoeax;
   procedure loadmethodoffstoeax;
   begin
   begin
     { mov  vmtoffs(%eax),%eax ; method offs }
     { mov  vmtoffs(%eax),%eax ; method offs }
-    emit_ref_reg(A_MOV,S_L,new_reference(R_EAX,procdef^._class^.vmtmethodoffset(procdef^.extnumber)),R_EAX);
+    emit_ref_reg(A_MOV,S_L,new_reference(R_EAX,procdef._class.vmtmethodoffset(procdef.extnumber)),R_EAX);
   end;
   end;
 
 
 var
 var
   oldexprasmlist: TAAsmoutput;
   oldexprasmlist: TAAsmoutput;
-  lab : pasmsymbol;
+  lab : tasmsymbol;
 
 
 begin
 begin
-  if procdef^.proctypeoption<>potype_none then
+  if procdef.proctypeoption<>potype_none then
     Internalerror(200006137);
     Internalerror(200006137);
-  if not assigned(procdef^._class) or
-     (procdef^.procoptions*[po_containsself, po_classmethod, po_staticmethod,
+  if not assigned(procdef._class) or
+     (procdef.procoptions*[po_containsself, po_classmethod, po_staticmethod,
        po_methodpointer, po_interrupt, po_iocheck]<>[]) then
        po_methodpointer, po_interrupt, po_iocheck]<>[]) then
     Internalerror(200006138);
     Internalerror(200006138);
 
 
@@ -153,9 +153,9 @@ begin
   adjustselfvalue(ioffset);
   adjustselfvalue(ioffset);
 
 
   { case 1  or 2 }
   { case 1  or 2 }
-  if (pocall_clearstack in procdef^.proccalloptions) then
+  if (pocall_clearstack in procdef.proccalloptions) then
     begin
     begin
-      if po_virtualmethod in procdef^.procoptions then
+      if po_virtualmethod in procdef.procoptions then
         begin { case 2 }
         begin { case 2 }
           getselftoeax(0);
           getselftoeax(0);
           loadvmttoeax;
           loadvmttoeax;
@@ -163,13 +163,13 @@ begin
         end
         end
       else { case 1 }
       else { case 1 }
         begin
         begin
-          emitcall(procdef^.mangledname);
+          emitcall(procdef.mangledname);
         end;
         end;
       { restore param1 value self to interface }
       { restore param1 value self to interface }
       adjustselfvalue(-ioffset);
       adjustselfvalue(-ioffset);
     end
     end
   { case 3 }
   { case 3 }
-  else if [po_virtualmethod,po_saveregisters]*procdef^.procoptions=[po_virtualmethod,po_saveregisters] then
+  else if [po_virtualmethod,po_saveregisters]*procdef.procoptions=[po_virtualmethod,po_saveregisters] then
     begin
     begin
       emit_reg(A_PUSH,S_L,R_EBX); { allocate space for address}
       emit_reg(A_PUSH,S_L,R_EBX); { allocate space for address}
       emit_reg(A_PUSH,S_L,R_EAX);
       emit_reg(A_PUSH,S_L,R_EAX);
@@ -184,7 +184,7 @@ begin
       emit_none(A_RET,S_L);
       emit_none(A_RET,S_L);
     end
     end
   { case 4 }
   { case 4 }
-  else if po_virtualmethod in procdef^.procoptions then
+  else if po_virtualmethod in procdef.procoptions then
     begin
     begin
       getselftoeax(0);
       getselftoeax(0);
       loadvmttoeax;
       loadvmttoeax;
@@ -193,7 +193,7 @@ begin
   { case 0 }
   { case 0 }
   else
   else
     begin
     begin
-      lab:=newasmsymbol(procdef^.mangledname);
+      lab:=newasmsymbol(procdef.mangledname);
       emit_sym(A_JMP,S_NO,lab);
       emit_sym(A_JMP,S_NO,lab);
     end;
     end;
   exprasmlist:=oldexprasmlist;
   exprasmlist:=oldexprasmlist;
@@ -202,7 +202,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2000-12-25 00:07:33  peter
+  Revision 1.5  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.4  2000/12/25 00:07:33  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 114 - 135
compiler/i386/n386inl.pas

@@ -91,7 +91,7 @@ implementation
 
 
       begin
       begin
         { Get the accumulator first so it can't be used in the dest }
         { Get the accumulator first so it can't be used in the dest }
-        if (dest.resulttype.def^.deftype=orddef) and
+        if (dest.resulttype.def.deftype=orddef) and
           not(is_64bitint(dest.resulttype.def)) then
           not(is_64bitint(dest.resulttype.def)) then
           hregister:=getexplicitregister32(accumulator);
           hregister:=getexplicitregister32(accumulator);
         { process dest }
         { process dest }
@@ -99,17 +99,17 @@ implementation
         if Codegenerror then
         if Codegenerror then
          exit;
          exit;
         { store the value }
         { store the value }
-        Case dest.resulttype.def^.deftype of
+        Case dest.resulttype.def.deftype of
           floatdef:
           floatdef:
             if dest.location.loc=LOC_CFPUREGISTER then
             if dest.location.loc=LOC_CFPUREGISTER then
               begin
               begin
-                 floatstoreops(pfloatdef(dest.resulttype.def)^.typ,op,opsize);
+                 floatstoreops(tfloatdef(dest.resulttype.def).typ,op,opsize);
                  emit_reg(op,opsize,correct_fpuregister(dest.location.register,fpuvaroffset+1));
                  emit_reg(op,opsize,correct_fpuregister(dest.location.register,fpuvaroffset+1));
               end
               end
             else
             else
               begin
               begin
                  inc(fpuvaroffset);
                  inc(fpuvaroffset);
-                 floatstore(PFloatDef(dest.resulttype.def)^.typ,dest.location.reference);
+                 floatstore(tfloatdef(dest.resulttype.def).typ,dest.location.reference);
                  { floatstore decrements the fpu var offset }
                  { floatstore decrements the fpu var offset }
                  { but in fact we didn't increment it       }
                  { but in fact we didn't increment it       }
               end;
               end;
@@ -121,7 +121,7 @@ implementation
                 end
                 end
               else
               else
                begin
                begin
-                 Case dest.resulttype.def^.size of
+                 Case dest.resulttype.def.size of
                   1 : hreg:=regtoreg8(hregister);
                   1 : hreg:=regtoreg8(hregister);
                   2 : hreg:=regtoreg16(hregister);
                   2 : hreg:=regtoreg16(hregister);
                   4 : hreg:=hregister;
                   4 : hreg:=hregister;
@@ -129,26 +129,26 @@ implementation
                  emit_mov_reg_loc(hreg,dest.location);
                  emit_mov_reg_loc(hreg,dest.location);
                  If (cs_check_range in aktlocalswitches) and
                  If (cs_check_range in aktlocalswitches) and
                     {no need to rangecheck longints or cardinals on 32bit processors}
                     {no need to rangecheck longints or cardinals on 32bit processors}
-                    not((porddef(dest.resulttype.def)^.typ = s32bit) and
-                        (porddef(dest.resulttype.def)^.low = longint($80000000)) and
-                        (porddef(dest.resulttype.def)^.high = $7fffffff)) and
-                    not((porddef(dest.resulttype.def)^.typ = u32bit) and
-                        (porddef(dest.resulttype.def)^.low = 0) and
-                        (porddef(dest.resulttype.def)^.high = longint($ffffffff))) then
+                    not((torddef(dest.resulttype.def).typ = s32bit) and
+                        (torddef(dest.resulttype.def).low = longint($80000000)) and
+                        (torddef(dest.resulttype.def).high = $7fffffff)) and
+                    not((torddef(dest.resulttype.def).typ = u32bit) and
+                        (torddef(dest.resulttype.def).low = 0) and
+                        (torddef(dest.resulttype.def).high = longint($ffffffff))) then
                   Begin
                   Begin
                     {do not register this temporary def}
                     {do not register this temporary def}
                     OldRegisterDef := RegisterDef;
                     OldRegisterDef := RegisterDef;
                     RegisterDef := False;
                     RegisterDef := False;
                     htype.reset;
                     htype.reset;
-                    Case PordDef(dest.resulttype.def)^.typ of
+                    Case torddef(dest.resulttype.def).typ of
                       u8bit,u16bit,u32bit:
                       u8bit,u16bit,u32bit:
                         begin
                         begin
-                          htype.setdef(new(porddef,init(u32bit,0,longint($ffffffff))));
+                          htype.setdef(torddef.create(u32bit,0,longint($ffffffff)));
                           hreg:=hregister;
                           hreg:=hregister;
                         end;
                         end;
                       s8bit,s16bit,s32bit:
                       s8bit,s16bit,s32bit:
                         begin
                         begin
-                          htype.setdef(new(porddef,init(s32bit,longint($80000000),$7fffffff)));
+                          htype.setdef(torddef.create(s32bit,longint($80000000),$7fffffff));
                           hreg:=hregister;
                           hreg:=hregister;
                         end;
                         end;
                     end;
                     end;
@@ -163,7 +163,7 @@ implementation
                     { emit the range check }
                     { emit the range check }
                     emitrangecheck(hp,dest.resulttype.def);
                     emitrangecheck(hp,dest.resulttype.def);
                     if assigned(htype.def) then
                     if assigned(htype.def) then
-                      Dispose(htype.def, Done);
+                      htype.def.free;
                     RegisterDef := OldRegisterDef;
                     RegisterDef := OldRegisterDef;
                     hp.free;
                     hp.free;
                   End;
                   End;
@@ -220,20 +220,21 @@ implementation
            node       : tcallparanode;
            node       : tcallparanode;
            hp         : tnode;
            hp         : tnode;
            typedtyp,
            typedtyp,
-           pararesult : pdef;
+           pararesult : tdef;
            orgfloattype : tfloattype;
            orgfloattype : tfloattype;
            dummycoll  : tparaitem;
            dummycoll  : tparaitem;
-           iolabel    : pasmlabel;
+           iolabel    : tasmlabel;
            npara      : longint;
            npara      : longint;
            esireloaded : boolean;
            esireloaded : boolean;
-
+        label
+          myexit;
         begin
         begin
            { here we don't use register calling conventions }
            { here we don't use register calling conventions }
            dummycoll:=TParaItem.Create;
            dummycoll:=TParaItem.Create;
            dummycoll.register:=R_NO;
            dummycoll.register:=R_NO;
            { I/O check }
            { I/O check }
            if (cs_check_io in aktlocalswitches) and
            if (cs_check_io in aktlocalswitches) and
-              not(po_iocheck in aktprocsym^.definition^.procoptions) then
+              not(po_iocheck in aktprocsym.definition.procoptions) then
              begin
              begin
                 getaddrlabel(iolabel);
                 getaddrlabel(iolabel);
                 emitlab(iolabel);
                 emitlab(iolabel);
@@ -254,9 +255,7 @@ implementation
                 loadstream;
                 loadstream;
                 { save @aktfile in temporary variable }
                 { save @aktfile in temporary variable }
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
-{$ifndef noAllocEdi}
                 ungetregister32(R_EDI);
                 ungetregister32(R_EDI);
-{$endif noAllocEdi}
              end
              end
            else
            else
              begin
              begin
@@ -267,25 +266,22 @@ implementation
                 npara := nb_para;
                 npara := nb_para;
                 { calculate data variable }
                 { calculate data variable }
                 { is first parameter a file type ? }
                 { is first parameter a file type ? }
-                if node.left.resulttype.def^.deftype=filedef then
+                if node.left.resulttype.def.deftype=filedef then
                   begin
                   begin
-                     ft:=pfiledef(node.left.resulttype.def)^.filetyp;
+                     ft:=tfiledef(node.left.resulttype.def).filetyp;
                      if ft=ft_typed then
                      if ft=ft_typed then
-                       typedtyp:=pfiledef(node.left.resulttype.def)^.typedfiletype.def;
+                       typedtyp:=tfiledef(node.left.resulttype.def).typedfiletype.def;
                      secondpass(node.left);
                      secondpass(node.left);
                      if codegenerror then
                      if codegenerror then
-                       exit;
+                       goto myexit;
 
 
                      { save reference in temporary variables }
                      { save reference in temporary variables }
                      if node.left.location.loc<>LOC_REFERENCE then
                      if node.left.location.loc<>LOC_REFERENCE then
                        begin
                        begin
                           CGMessage(cg_e_illegal_expression);
                           CGMessage(cg_e_illegal_expression);
-                          exit;
+                          goto myexit;
                        end;
                        end;
-{$ifndef noAllocEdi}
                      getexplicitregister32(R_EDI);
                      getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
-
                      emit_ref_reg(A_LEA,S_L,newreference(node.left.location.reference),R_EDI);
                      emit_ref_reg(A_LEA,S_L,newreference(node.left.location.reference),R_EDI);
                      del_reference(node.left.location.reference);
                      del_reference(node.left.location.reference);
                      { skip to the next parameter }
                      { skip to the next parameter }
@@ -299,9 +295,7 @@ implementation
 
 
                 { save @aktfile in temporary variable }
                 { save @aktfile in temporary variable }
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
-{$ifndef noAllocEdi}
                 ungetregister32(R_EDI);
                 ungetregister32(R_EDI);
-{$endif noAllocEdi}
                 if doread then
                 if doread then
                 { parameter by READ gives call by reference }
                 { parameter by READ gives call by reference }
                   dummycoll.paratyp:=vs_var
                   dummycoll.paratyp:=vs_var
@@ -312,7 +306,7 @@ implementation
                 { because of secondcallparan, which otherwise attaches }
                 { because of secondcallparan, which otherwise attaches }
                 if ft=ft_typed then
                 if ft=ft_typed then
                   { this is to avoid copy of simple const parameters }
                   { this is to avoid copy of simple const parameters }
-                  {dummycoll.data:=new(pformaldef,init)}
+                  {dummycoll.data:=new(pformaldef.create)}
                   dummycoll.paratype:=cformaltype
                   dummycoll.paratype:=cformaltype
                 else
                 else
                   { I think, this isn't a good solution (FK) }
                   { I think, this isn't a good solution (FK) }
@@ -331,9 +325,9 @@ implementation
                        convert here else we loose the old float type }
                        convert here else we loose the old float type }
                      if (not doread) and
                      if (not doread) and
                         (ft<>ft_typed) and
                         (ft<>ft_typed) and
-                        (tcallparanode(hp).left.resulttype.def^.deftype=floatdef) then
+                        (tcallparanode(hp).left.resulttype.def.deftype=floatdef) then
                       begin
                       begin
-                        orgfloattype:=pfloatdef(tcallparanode(hp).left.resulttype.def)^.typ;
+                        orgfloattype:=tfloatdef(tcallparanode(hp).left.resulttype.def).typ;
                         tcallparanode(hp).left:=ctypeconvnode.create(tcallparanode(hp).left,pbestrealtype^);
                         tcallparanode(hp).left:=ctypeconvnode.create(tcallparanode(hp).left,pbestrealtype^);
                         firstpass(tcallparanode(hp).left);
                         firstpass(tcallparanode(hp).left);
                       end;
                       end;
@@ -341,7 +335,7 @@ implementation
                        parameter as their destination instead of being pushed }
                        parameter as their destination instead of being pushed }
                      if doread and
                      if doread and
                         (ft<>ft_typed) and
                         (ft<>ft_typed) and
-                        (tcallparanode(hp).resulttype.def^.deftype in [orddef,floatdef]) then
+                        (tcallparanode(hp).resulttype.def.deftype in [orddef,floatdef]) then
                       begin
                       begin
                       end
                       end
                      else
                      else
@@ -362,7 +356,7 @@ implementation
                       end;
                       end;
                      tcallparanode(hp).right:=node;
                      tcallparanode(hp).right:=node;
                      if codegenerror then
                      if codegenerror then
-                       exit;
+                       goto myexit;
 
 
                      emit_push_mem(aktfile);
                      emit_push_mem(aktfile);
                      if (ft=ft_typed) then
                      if (ft=ft_typed) then
@@ -378,7 +372,7 @@ implementation
                           { I think that is only possible by adding }
                           { I think that is only possible by adding }
                           { reset and rewrite to the inline list a call }
                           { reset and rewrite to the inline list a call }
                           { allways read only one record by element }
                           { allways read only one record by element }
-                            push_int(typedtyp^.size);
+                            push_int(typedtyp.size);
                             saveregvars($ff);
                             saveregvars($ff);
                             if doread then
                             if doread then
                               emitcall('FPC_TYPED_READ')
                               emitcall('FPC_TYPED_READ')
@@ -404,10 +398,10 @@ implementation
                                    tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                                    tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                                    tcallparanode(hp).right:=node;
                                    tcallparanode(hp).right:=node;
                                    if codegenerror then
                                    if codegenerror then
-                                     exit;
+                                     goto myexit;
                                 end
                                 end
                               else
                               else
-                                if pararesult^.deftype<>floatdef then
+                                if pararesult.deftype<>floatdef then
                                   push_int(0)
                                   push_int(0)
                                 else
                                 else
                                   push_int(-32767);
                                   push_int(-32767);
@@ -421,25 +415,25 @@ implementation
                                    dummycoll.paratyp:=vs_value;
                                    dummycoll.paratyp:=vs_value;
                                    tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                                    tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                                    tcallparanode(hp).right:=node;
                                    tcallparanode(hp).right:=node;
-                                   if pararesult^.deftype<>floatdef then
+                                   if pararesult.deftype<>floatdef then
                                      CGMessage(parser_e_illegal_colon_qualifier);
                                      CGMessage(parser_e_illegal_colon_qualifier);
                                    if codegenerror then
                                    if codegenerror then
-                                     exit;
+                                     goto myexit;
                                 end
                                 end
                               else
                               else
                                 begin
                                 begin
-                                  if pararesult^.deftype=floatdef then
+                                  if pararesult.deftype=floatdef then
                                     push_int(-1);
                                     push_int(-1);
                                 end;
                                 end;
                              { push also the real type for floats }
                              { push also the real type for floats }
-                              if pararesult^.deftype=floatdef then
+                              if pararesult.deftype=floatdef then
                                 push_int(ord(orgfloattype));
                                 push_int(ord(orgfloattype));
                             end;
                             end;
                           saveregvars($ff);
                           saveregvars($ff);
-                          case pararesult^.deftype of
+                          case pararesult.deftype of
                             stringdef :
                             stringdef :
                               begin
                               begin
-                                emitcall(rdwrprefix[doread]+pstringdef(pararesult)^.stringtypname);
+                                emitcall(rdwrprefix[doread]+tstringdef(pararesult).stringtypname);
                               end;
                               end;
                             pointerdef :
                             pointerdef :
                               begin
                               begin
@@ -455,7 +449,7 @@ implementation
                               begin
                               begin
                                 emitcall(rdwrprefix[doread]+'FLOAT');
                                 emitcall(rdwrprefix[doread]+'FLOAT');
                                 {
                                 {
-                                if pfloatdef(resulttype.def)^.typ<>f32bit then
+                                if tfloatdef(resulttype.def).typ<>f32bit then
                                   dec(fpuvaroffset);
                                   dec(fpuvaroffset);
                                 }
                                 }
                                 if doread then
                                 if doread then
@@ -467,7 +461,7 @@ implementation
                               end;
                               end;
                             orddef :
                             orddef :
                               begin
                               begin
-                                case porddef(pararesult)^.typ of
+                                case torddef(pararesult).typ of
                                   s8bit,s16bit,s32bit :
                                   s8bit,s16bit,s32bit :
                                     emitcall(rdwrprefix[doread]+'SINT');
                                     emitcall(rdwrprefix[doread]+'SINT');
                                   u8bit,u16bit,u32bit :
                                   u8bit,u16bit,u32bit :
@@ -544,6 +538,9 @@ implementation
                      hp:=tcallparanode(hp).right;
                      hp:=tcallparanode(hp).right;
                   end;
                   end;
              end;
              end;
+
+        myexit:
+           dummycoll.free;
         end;
         end;
 
 
       procedure handle_str;
       procedure handle_str;
@@ -556,7 +553,8 @@ implementation
            is_real : boolean;
            is_real : boolean;
            realtype : tfloattype;
            realtype : tfloattype;
            procedureprefix : string;
            procedureprefix : string;
-
+        label
+           myexit;
           begin
           begin
            dummycoll:=TParaItem.Create;
            dummycoll:=TParaItem.Create;
            dummycoll.register:=R_NO;
            dummycoll.register:=R_NO;
@@ -565,10 +563,10 @@ implementation
            is_real:=false;
            is_real:=false;
            while assigned(node.right) do node:=tcallparanode(node.right);
            while assigned(node.right) do node:=tcallparanode(node.right);
            { if a real parameter somewhere then call REALSTR }
            { if a real parameter somewhere then call REALSTR }
-           if (node.left.resulttype.def^.deftype=floatdef) then
+           if (node.left.resulttype.def.deftype=floatdef) then
             begin
             begin
               is_real:=true;
               is_real:=true;
-              realtype:=pfloatdef(node.left.resulttype.def)^.typ;
+              realtype:=tfloatdef(node.left.resulttype.def).typ;
             end;
             end;
 
 
            node:=tcallparanode(left);
            node:=tcallparanode(left);
@@ -584,13 +582,10 @@ implementation
              dummycoll.paratype:=openshortstringtype
              dummycoll.paratype:=openshortstringtype
            else
            else
              dummycoll.paratype:=hp.resulttype;
              dummycoll.paratype:=hp.resulttype;
-           procedureprefix:='FPC_'+pstringdef(hp.resulttype.def)^.stringtypname+'_';
+           procedureprefix:='FPC_'+tstringdef(hp.resulttype.def).stringtypname+'_';
            tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
            tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
            if codegenerror then
            if codegenerror then
-             begin
-               dummycoll.free;
-               exit;
-             end;
+            goto myexit;
 
 
            dummycoll.paratyp:=vs_const;
            dummycoll.paratyp:=vs_const;
            left.free;
            left.free;
@@ -612,10 +607,7 @@ implementation
                 dummycoll.paratyp:=vs_value;
                 dummycoll.paratyp:=vs_value;
                 tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                 tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                 if codegenerror then
                 if codegenerror then
-                  begin
-                    dummycoll.free;
-                    exit;
-                  end;
+                  goto myexit;
                 hp.free;
                 hp.free;
                 hp:=node;
                 hp:=node;
                 node:=tcallparanode(node.right);
                 node:=tcallparanode(node.right);
@@ -632,10 +624,7 @@ implementation
                 dummycoll.paratyp:=vs_value;
                 dummycoll.paratyp:=vs_value;
                 tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                 tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                 if codegenerror then
                 if codegenerror then
-                  begin
-                    dummycoll.free;
-                    exit;
-                  end;
+                  goto myexit;
                 hp.free;
                 hp.free;
                 hp:=node;
                 hp:=node;
                 node:=tcallparanode(node.right);
                 node:=tcallparanode(node.right);
@@ -659,16 +648,13 @@ implementation
            dummycoll.paratyp:=vs_value;
            dummycoll.paratyp:=vs_value;
            tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
            tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
            if codegenerror then
            if codegenerror then
-             begin
-               dummycoll.free;
-               exit;
-             end;
+            goto myexit;
 
 
            saveregvars($ff);
            saveregvars($ff);
            if is_real then
            if is_real then
              emitcall(procedureprefix+'FLOAT')
              emitcall(procedureprefix+'FLOAT')
            else
            else
-             case porddef(hp.resulttype.def)^.typ of
+             case torddef(hp.resulttype.def).typ of
                 u32bit:
                 u32bit:
                   emitcall(procedureprefix+'CARDINAL');
                   emitcall(procedureprefix+'CARDINAL');
 
 
@@ -681,9 +667,11 @@ implementation
                 else
                 else
                   emitcall(procedureprefix+'LONGINT');
                   emitcall(procedureprefix+'LONGINT');
              end;
              end;
+           popusedregisters(pushed);
            hp.free;
            hp.free;
+
+        myexit:
            dummycoll.free;
            dummycoll.free;
-           popusedregisters(pushed);
         end;
         end;
 
 
 
 
@@ -692,13 +680,14 @@ implementation
            hp,node,
            hp,node,
            code_para, dest_para : tcallparanode;
            code_para, dest_para : tcallparanode;
            hreg,hreg2: TRegister;
            hreg,hreg2: TRegister;
-           hdef: POrdDef;
+           hdef: torddef;
            procedureprefix : string;
            procedureprefix : string;
            hr, hr2: TReference;
            hr, hr2: TReference;
            dummycoll : tparaitem;
            dummycoll : tparaitem;
            has_code, has_32bit_code, oldregisterdef: boolean;
            has_code, has_32bit_code, oldregisterdef: boolean;
            r : preference;
            r : preference;
-
+          label
+            myexit;
           begin
           begin
            dummycoll:=TParaItem.Create;
            dummycoll:=TParaItem.Create;
            dummycoll.register:=R_NO;
            dummycoll.register:=R_NO;
@@ -719,7 +708,7 @@ implementation
                hp := node;
                hp := node;
                node := tcallparanode(node.right);
                node := tcallparanode(node.right);
                hp.right := nil;
                hp.right := nil;
-               has_32bit_code := (porddef(tcallparanode(code_para).left.resulttype.def)^.typ in [u32bit,s32bit]);
+               has_32bit_code := (torddef(tcallparanode(code_para).left.resulttype.def).typ in [u32bit,s32bit]);
              End;
              End;
 
 
           {hp = destination now, save for later use}
           {hp = destination now, save for later use}
@@ -734,10 +723,7 @@ implementation
            dummycoll.paratype.setdef(dest_para.resulttype.def);
            dummycoll.paratype.setdef(dest_para.resulttype.def);
            dest_para.secondcallparan(dummycoll,false,false,false,0,0);
            dest_para.secondcallparan(dummycoll,false,false,false,0,0);
            if codegenerror then
            if codegenerror then
-           begin
-             dummycoll.free;
-             exit;
-           end;
+            goto myexit;
 
 
           {save the regvars}
           {save the regvars}
            pushusedregisters(pushed,$ff);
            pushusedregisters(pushed,$ff);
@@ -751,10 +737,7 @@ implementation
                dummycoll.paratype.setdef(code_para.resulttype.def);
                dummycoll.paratype.setdef(code_para.resulttype.def);
                code_para.secondcallparan(dummycoll,false,false,false,0,0);
                code_para.secondcallparan(dummycoll,false,false,false,0,0);
                if codegenerror then
                if codegenerror then
-                 begin
-                   dummycoll.free;
-                   exit;
-                 end;
+                goto myexit;
                code_para.free;
                code_para.free;
              End
              End
            Else
            Else
@@ -769,12 +752,9 @@ implementation
            dummycoll.paratype.setdef(node.resulttype.def);
            dummycoll.paratype.setdef(node.resulttype.def);
            node.secondcallparan(dummycoll,false,false,false,0,0);
            node.secondcallparan(dummycoll,false,false,false,0,0);
            if codegenerror then
            if codegenerror then
-             begin
-               dummycoll.free;
-               exit;
-             end;
+             goto myexit;
 
 
-           Case dest_para.resulttype.def^.deftype of
+           Case dest_para.resulttype.def.deftype of
              floatdef:
              floatdef:
                begin
                begin
                   procedureprefix := 'FPC_VAL_REAL_';
                   procedureprefix := 'FPC_VAL_REAL_';
@@ -795,7 +775,7 @@ implementation
                         {if we are converting to a signed number, we have to include the
                         {if we are converting to a signed number, we have to include the
                          size of the destination, so the Val function can extend the sign
                          size of the destination, so the Val function can extend the sign
                          of the result to allow proper range checking}
                          of the result to allow proper range checking}
-                        emit_const(A_PUSH,S_L,dest_para.resulttype.def^.size);
+                        emit_const(A_PUSH,S_L,dest_para.resulttype.def.size);
                         procedureprefix := 'FPC_VAL_SINT_'
                         procedureprefix := 'FPC_VAL_SINT_'
                       end
                       end
                     else
                     else
@@ -804,7 +784,7 @@ implementation
            End;
            End;
 
 
            saveregvars($ff);
            saveregvars($ff);
-           emitcall(procedureprefix+pstringdef(node.resulttype.def)^.stringtypname);
+           emitcall(procedureprefix+tstringdef(node.resulttype.def).stringtypname);
            { before disposing node we need to ungettemp !! PM }
            { before disposing node we need to ungettemp !! PM }
            if node.left.location.loc in [LOC_REFERENCE,LOC_MEM] then
            if node.left.location.loc in [LOC_REFERENCE,LOC_MEM] then
              ungetiftemp(node.left.location.reference);
              ungetiftemp(node.left.location.reference);
@@ -814,7 +794,7 @@ implementation
           {reload esi in case the dest_para/code_para is a class variable or so}
           {reload esi in case the dest_para/code_para is a class variable or so}
            maybe_loadself;
            maybe_loadself;
 
 
-           If (dest_para.resulttype.def^.deftype = orddef) Then
+           If (dest_para.resulttype.def.deftype = orddef) Then
              Begin
              Begin
               {store the result in a safe place, because EAX may be used by a
               {store the result in a safe place, because EAX may be used by a
                register variable}
                register variable}
@@ -839,21 +819,15 @@ implementation
               {load the address of the code parameter}
               {load the address of the code parameter}
                secondpass(code_para.left);
                secondpass(code_para.left);
               {move the code to its destination}
               {move the code to its destination}
-{$ifndef noAllocEdi}
                getexplicitregister32(R_EDI);
                getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                emit_ref_reg(A_MOV,S_L,NewReference(hr),R_EDI);
                emit_ref_reg(A_MOV,S_L,NewReference(hr),R_EDI);
                emit_mov_reg_loc(R_DI,code_para.left.location);
                emit_mov_reg_loc(R_DI,code_para.left.location);
-{$ifndef noAllocEdi}
                ungetregister32(R_EDI);
                ungetregister32(R_EDI);
-{$endif noAllocEdi}
                code_para.free;
                code_para.free;
              End;
              End;
 
 
           {restore the address of the result}
           {restore the address of the result}
-{$ifndef noAllocEdi}
            getexplicitregister32(R_EDI);
            getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
            emit_reg(A_POP,S_L,R_EDI);
            emit_reg(A_POP,S_L,R_EDI);
 
 
           {set up hr2 to a refernce with EDI as base register}
           {set up hr2 to a refernce with EDI as base register}
@@ -861,11 +835,11 @@ implementation
            hr2.base := R_EDI;
            hr2.base := R_EDI;
 
 
           {save the function result in the destination variable}
           {save the function result in the destination variable}
-           Case dest_para.left.resulttype.def^.deftype of
+           Case dest_para.left.resulttype.def.deftype of
              floatdef:
              floatdef:
-               floatstore(PFloatDef(dest_para.left.resulttype.def)^.typ, hr2);
+               floatstore(tfloatdef(dest_para.left.resulttype.def).typ, hr2);
              orddef:
              orddef:
-               Case PordDef(dest_para.left.resulttype.def)^.typ of
+               Case torddef(dest_para.left.resulttype.def).typ of
                  u8bit,s8bit:
                  u8bit,s8bit:
                    emit_reg_ref(A_MOV, S_B,
                    emit_reg_ref(A_MOV, S_B,
                      RegToReg8(hreg),newreference(hr2));
                      RegToReg8(hreg),newreference(hr2));
@@ -886,22 +860,20 @@ implementation
                    end;
                    end;
                End;
                End;
            End;
            End;
-{$ifndef noAllocEdi}
            ungetregister32(R_EDI);
            ungetregister32(R_EDI);
-{$endif noAllocEdi}
            If (cs_check_range in aktlocalswitches) and
            If (cs_check_range in aktlocalswitches) and
-              (dest_para.left.resulttype.def^.deftype = orddef) and
+              (dest_para.left.resulttype.def.deftype = orddef) and
               (not(is_64bitint(dest_para.left.resulttype.def))) and
               (not(is_64bitint(dest_para.left.resulttype.def))) and
             {the following has to be changed to 64bit checking, once Val
             {the following has to be changed to 64bit checking, once Val
              returns 64 bit values (unless a special Val function is created
              returns 64 bit values (unless a special Val function is created
              for that)}
              for that)}
             {no need to rangecheck longints or cardinals on 32bit processors}
             {no need to rangecheck longints or cardinals on 32bit processors}
-               not((porddef(dest_para.left.resulttype.def)^.typ = s32bit) and
-                   (porddef(dest_para.left.resulttype.def)^.low = longint($80000000)) and
-                   (porddef(dest_para.left.resulttype.def)^.high = $7fffffff)) and
-               not((porddef(dest_para.left.resulttype.def)^.typ = u32bit) and
-                   (porddef(dest_para.left.resulttype.def)^.low = 0) and
-                   (porddef(dest_para.left.resulttype.def)^.high = longint($ffffffff))) then
+               not((torddef(dest_para.left.resulttype.def).typ = s32bit) and
+                   (torddef(dest_para.left.resulttype.def).low = longint($80000000)) and
+                   (torddef(dest_para.left.resulttype.def).high = $7fffffff)) and
+               not((torddef(dest_para.left.resulttype.def).typ = u32bit) and
+                   (torddef(dest_para.left.resulttype.def).low = 0) and
+                   (torddef(dest_para.left.resulttype.def).high = longint($ffffffff))) then
              Begin
              Begin
                hp:=tcallparanode(dest_para.left.getcopy);
                hp:=tcallparanode(dest_para.left.getcopy);
                hp.location.loc := LOC_REGISTER;
                hp.location.loc := LOC_REGISTER;
@@ -909,21 +881,22 @@ implementation
               {do not register this temporary def}
               {do not register this temporary def}
                OldRegisterDef := RegisterDef;
                OldRegisterDef := RegisterDef;
                RegisterDef := False;
                RegisterDef := False;
-               Case PordDef(dest_para.left.resulttype.def)^.typ of
-                 u8bit,u16bit,u32bit: new(hdef,init(u32bit,0,longint($ffffffff)));
-                 s8bit,s16bit,s32bit: new(hdef,init(s32bit,longint($80000000),$7fffffff));
+               Case torddef(dest_para.left.resulttype.def).typ of
+                 u8bit,u16bit,u32bit: hdef:=torddef.create(u32bit,0,longint($ffffffff));
+                 s8bit,s16bit,s32bit: hdef:=torddef.create(s32bit,longint($80000000),$7fffffff);
                end;
                end;
                hp.resulttype.def := hdef;
                hp.resulttype.def := hdef;
                emitrangecheck(hp,dest_para.left.resulttype.def);
                emitrangecheck(hp,dest_para.left.resulttype.def);
                hp.right := nil;
                hp.right := nil;
-               Dispose(hp.resulttype.def, Done);
+               hp.resulttype.def.free;
                RegisterDef := OldRegisterDef;
                RegisterDef := OldRegisterDef;
                hp.free;
                hp.free;
              End;
              End;
           {dest_para.right is already nil}
           {dest_para.right is already nil}
            dest_para.free;
            dest_para.free;
-           dummycoll.free;
            UnGetIfTemp(hr);
            UnGetIfTemp(hr);
+        myexit:
+           dummycoll.free;
         end;
         end;
 
 
       var
       var
@@ -934,9 +907,9 @@ implementation
          l : longint;
          l : longint;
          ispushed : boolean;
          ispushed : boolean;
          hregister : tregister;
          hregister : tregister;
-         otlabel,oflabel{,l1}   : pasmlabel;
+         otlabel,oflabel{,l1}   : tasmlabel;
          oldpushedparasize : longint;
          oldpushedparasize : longint;
-         def : pdef;
+         def : tdef;
          hr,hr2 : treference;
          hr,hr2 : treference;
 
 
       begin
       begin
@@ -1011,7 +984,7 @@ implementation
                    begin
                    begin
                       location.register:=getregister32;
                       location.register:=getregister32;
                       emit_sym_ofs_reg(A_MOV,
                       emit_sym_ofs_reg(A_MOV,
-                        S_L,newasmsymbol(pobjectdef(left.resulttype.def)^.vmt_mangledname),0,
+                        S_L,newasmsymbol(tobjectdef(left.resulttype.def).vmt_mangledname),0,
                         location.register);
                         location.register);
                    end
                    end
                  else
                  else
@@ -1022,7 +995,7 @@ implementation
                       location.register:=getregister32;
                       location.register:=getregister32;
                       { load VMT pointer }
                       { load VMT pointer }
                       inc(left.location.reference.offset,
                       inc(left.location.reference.offset,
-                        pobjectdef(left.resulttype.def)^.vmt_offset);
+                        tobjectdef(left.resulttype.def).vmt_offset);
                       emit_ref_reg(A_MOV,S_L,
                       emit_ref_reg(A_MOV,S_L,
                       newreference(left.location.reference),
                       newreference(left.location.reference),
                         location.register);
                         location.register);
@@ -1134,7 +1107,7 @@ implementation
                      asmop:=A_SUB
                      asmop:=A_SUB
                    else
                    else
                      asmop:=A_ADD;
                      asmop:=A_ADD;
-                 case resulttype.def^.size of
+                 case resulttype.def.size of
                    8 : opsize:=S_L;
                    8 : opsize:=S_L;
                    4 : opsize:=S_L;
                    4 : opsize:=S_L;
                    2 : opsize:=S_W;
                    2 : opsize:=S_W;
@@ -1143,7 +1116,7 @@ implementation
                    internalerror(10080);
                    internalerror(10080);
                  end;
                  end;
                  location.loc:=LOC_REGISTER;
                  location.loc:=LOC_REGISTER;
-                 if resulttype.def^.size=8 then
+                 if resulttype.def.size=8 then
                    begin
                    begin
                       if left.location.loc<>LOC_REGISTER then
                       if left.location.loc<>LOC_REGISTER then
                         begin
                         begin
@@ -1198,9 +1171,9 @@ implementation
                              del_reference(left.location.reference);
                              del_reference(left.location.reference);
 
 
                            location.register:=getregister32;
                            location.register:=getregister32;
-                           if (resulttype.def^.size=2) then
+                           if (resulttype.def.size=2) then
                              location.register:=reg32toreg16(location.register);
                              location.register:=reg32toreg16(location.register);
-                           if (resulttype.def^.size=1) then
+                           if (resulttype.def.size=1) then
                              location.register:=reg32toreg8(location.register);
                              location.register:=reg32toreg8(location.register);
                            if left.location.loc=LOC_CREGISTER then
                            if left.location.loc=LOC_CREGISTER then
                              emit_reg_reg(A_MOV,opsize,left.location.register,
                              emit_reg_reg(A_MOV,opsize,left.location.register,
@@ -1231,10 +1204,10 @@ implementation
                 addconstant:=true;
                 addconstant:=true;
               { load first parameter, must be a reference }
               { load first parameter, must be a reference }
                 secondpass(tcallparanode(left).left);
                 secondpass(tcallparanode(left).left);
-                case tcallparanode(left).left.resulttype.def^.deftype of
+                case tcallparanode(left).left.resulttype.def.deftype of
                   orddef,
                   orddef,
                  enumdef : begin
                  enumdef : begin
-                             case tcallparanode(left).left.resulttype.def^.size of
+                             case tcallparanode(left).left.resulttype.def.size of
                               1 : opsize:=S_B;
                               1 : opsize:=S_B;
                               2 : opsize:=S_W;
                               2 : opsize:=S_W;
                               4 : opsize:=S_L;
                               4 : opsize:=S_L;
@@ -1243,10 +1216,10 @@ implementation
                            end;
                            end;
               pointerdef : begin
               pointerdef : begin
                              opsize:=S_L;
                              opsize:=S_L;
-                             if is_void(ppointerdef(tcallparanode(left).left.resulttype.def)^.pointertype.def) then
+                             if is_void(tpointerdef(tcallparanode(left).left.resulttype.def).pointertype.def) then
                               addvalue:=1
                               addvalue:=1
                              else
                              else
-                              addvalue:=ppointerdef(tcallparanode(left).left.resulttype.def)^.pointertype.def^.size;
+                              addvalue:=tpointerdef(tcallparanode(left).left.resulttype.def).pointertype.def.size;
                            end;
                            end;
                 else
                 else
                  internalerror(10081);
                  internalerror(10081);
@@ -1336,11 +1309,11 @@ implementation
 
 
             in_typeinfo_x:
             in_typeinfo_x:
                begin
                begin
-                  pstoreddef(ttypenode(tcallparanode(left).left).resulttype.def)^.generate_rtti;
+                  tstoreddef(ttypenode(tcallparanode(left).left).resulttype.def).generate_rtti;
                   location.register:=getregister32;
                   location.register:=getregister32;
                   new(r);
                   new(r);
                   reset_reference(r^);
                   reset_reference(r^);
-                  r^.symbol:=pstoreddef(ttypenode(tcallparanode(left).left).resulttype.def)^.rtti_label;
+                  r^.symbol:=tstoreddef(ttypenode(tcallparanode(left).left).resulttype.def).rtti_label;
                   emit_ref_reg(A_LEA,S_L,r,location.register);
                   emit_ref_reg(A_LEA,S_L,r,location.register);
                end;
                end;
 
 
@@ -1348,12 +1321,12 @@ implementation
                begin
                begin
                   pushusedregisters(pushed,$ff);
                   pushusedregisters(pushed,$ff);
                   { force rtti generation }
                   { force rtti generation }
-                  pstoreddef(ttypenode(tcallparanode(left).left).resulttype.def)^.generate_rtti;
+                  tstoreddef(ttypenode(tcallparanode(left).left).resulttype.def).generate_rtti;
                   { if a count is passed, push size, typeinfo and count }
                   { if a count is passed, push size, typeinfo and count }
                   if assigned(tcallparanode(left).right) then
                   if assigned(tcallparanode(left).right) then
                     begin
                     begin
                        secondpass(tcallparanode(tcallparanode(left).right).left);
                        secondpass(tcallparanode(tcallparanode(left).right).left);
-                       push_int(tcallparanode(left).left.resulttype.def^.size);
+                       push_int(tcallparanode(left).left.resulttype.def.size);
                        if codegenerror then
                        if codegenerror then
                         exit;
                         exit;
                        emit_push_loc(tcallparanode(tcallparanode(left).right).left.location);
                        emit_push_loc(tcallparanode(tcallparanode(left).right).left.location);
@@ -1361,7 +1334,7 @@ implementation
 
 
                   { generate a reference }
                   { generate a reference }
                   reset_reference(hr);
                   reset_reference(hr);
-                  hr.symbol:=pstoreddef(ttypenode(tcallparanode(left).left).resulttype.def)^.rtti_label;
+                  hr.symbol:=tstoreddef(ttypenode(tcallparanode(left).left).resulttype.def).rtti_label;
                   emitpushreferenceaddr(hr);
                   emitpushreferenceaddr(hr);
 
 
                   { data to finalize }
                   { data to finalize }
@@ -1399,7 +1372,7 @@ implementation
              in_reset_typedfile,in_rewrite_typedfile :
              in_reset_typedfile,in_rewrite_typedfile :
                begin
                begin
                   pushusedregisters(pushed,$ff);
                   pushusedregisters(pushed,$ff);
-                  emit_const(A_PUSH,S_L,pfiledef(left.resulttype.def)^.typedfiletype.def^.size);
+                  emit_const(A_PUSH,S_L,tfiledef(left.resulttype.def).typedfiletype.def.size);
                   secondpass(left);
                   secondpass(left);
                   emitpushreferenceaddr(left.location.reference);
                   emitpushreferenceaddr(left.location.reference);
                   saveregvars($ff);
                   saveregvars($ff);
@@ -1448,12 +1421,13 @@ implementation
                   { handle shortstrings separately since the hightree must be }
                   { handle shortstrings separately since the hightree must be }
                   { pushed too (JM)                                           }
                   { pushed too (JM)                                           }
                   if not(is_dynamic_array(def)) and
                   if not(is_dynamic_array(def)) and
-                     (pstringdef(def)^.string_typ = st_shortstring) then
+                     (tstringdef(def).string_typ = st_shortstring) then
                     begin
                     begin
                       dummycoll:=TParaItem.Create;
                       dummycoll:=TParaItem.Create;
                       dummycoll.paratyp:=vs_var;
                       dummycoll.paratyp:=vs_var;
                       dummycoll.paratype:=openshortstringtype;
                       dummycoll.paratype:=openshortstringtype;
                       tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
                       tcallparanode(hp).secondcallparan(dummycoll,false,false,false,0,0);
+                      dummycoll.free;
                       if codegenerror then
                       if codegenerror then
                         exit;
                         exit;
                     end
                     end
@@ -1463,7 +1437,7 @@ implementation
                        emitpushreferenceaddr(hr2);
                        emitpushreferenceaddr(hr2);
                        push_int(l);
                        push_int(l);
                        reset_reference(hr2);
                        reset_reference(hr2);
-                       hr2.symbol:=pstoreddef(def)^.get_inittable_label;
+                       hr2.symbol:=tstoreddef(def).get_inittable_label;
                        emitpushreferenceaddr(hr2);
                        emitpushreferenceaddr(hr2);
                        emitpushreferenceaddr(tcallparanode(hp).left.location.reference);
                        emitpushreferenceaddr(tcallparanode(hp).left.location.reference);
                        saveregvars($ff);
                        saveregvars($ff);
@@ -1473,7 +1447,7 @@ implementation
                   else
                   else
                     { must be string }
                     { must be string }
                     begin
                     begin
-                       case pstringdef(def)^.string_typ of
+                       case tstringdef(def).string_typ of
                           st_widestring:
                           st_widestring:
                             begin
                             begin
                               emitpushreferenceaddr(tcallparanode(hp).left.location.reference);
                               emitpushreferenceaddr(tcallparanode(hp).left.location.reference);
@@ -1558,7 +1532,7 @@ implementation
                         asmop:=A_BTS
                         asmop:=A_BTS
                       else
                       else
                         asmop:=A_BTR;
                         asmop:=A_BTR;
-                      if psetdef(left.resulttype.def)^.settype=smallset then
+                      if tsetdef(left.resulttype.def).settype=smallset then
                         begin
                         begin
                            if tcallparanode(tcallparanode(left).right).left.location.loc in [LOC_CREGISTER,LOC_REGISTER] then
                            if tcallparanode(tcallparanode(left).right).left.location.loc in [LOC_CREGISTER,LOC_REGISTER] then
                              { we don't need a mod 32 because this is done automatically  }
                              { we don't need a mod 32 because this is done automatically  }
@@ -1627,7 +1601,7 @@ implementation
                       end;
                       end;
                     LOC_REFERENCE,LOC_MEM:
                     LOC_REFERENCE,LOC_MEM:
                       begin
                       begin
-                         floatload(pfloatdef(left.resulttype.def)^.typ,left.location.reference);
+                         floatload(tfloatdef(left.resulttype.def).typ,left.location.reference);
                          del_reference(left.location.reference);
                          del_reference(left.location.reference);
                       end
                       end
                     else
                     else
@@ -1704,7 +1678,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-02 21:20:37  peter
+  Revision 1.14  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/02 21:20:37  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.12  2001/03/13 11:52:48  jonas
   Revision 1.12  2001/03/13 11:52:48  jonas

+ 95 - 94
compiler/i386/n386ld.pas

@@ -67,7 +67,7 @@ implementation
          symtabletype : tsymtabletype;
          symtabletype : tsymtabletype;
          i : longint;
          i : longint;
          hp : preference;
          hp : preference;
-         s : pasmsymbol;
+         s : tasmsymbol;
          popeax : boolean;
          popeax : boolean;
          //pushed : tpushed;
          //pushed : tpushed;
          //hr : treference;
          //hr : treference;
@@ -75,27 +75,27 @@ implementation
       begin
       begin
          simple_loadn:=true;
          simple_loadn:=true;
          reset_reference(location.reference);
          reset_reference(location.reference);
-         case symtableentry^.typ of
+         case symtableentry.typ of
               { this is only for toasm and toaddr }
               { this is only for toasm and toaddr }
               absolutesym :
               absolutesym :
                  begin
                  begin
                     location.reference.symbol:=nil;
                     location.reference.symbol:=nil;
-                    if (pabsolutesym(symtableentry)^.abstyp=toaddr) then
+                    if (tabsolutesym(symtableentry).abstyp=toaddr) then
                      begin
                      begin
-                       if pabsolutesym(symtableentry)^.absseg then
+                       if tabsolutesym(symtableentry).absseg then
                         location.reference.segment:=R_FS;
                         location.reference.segment:=R_FS;
-                       location.reference.offset:=pabsolutesym(symtableentry)^.address;
+                       location.reference.offset:=tabsolutesym(symtableentry).address;
                      end
                      end
                     else
                     else
-                     location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                     location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                  end;
                  end;
               constsym:
               constsym:
                 begin
                 begin
-                   if pconstsym(symtableentry)^.consttyp=constresourcestring then
+                   if tconstsym(symtableentry).consttyp=constresourcestring then
                      begin
                      begin
                         location.loc:=LOC_MEM;
                         location.loc:=LOC_MEM;
-                        location.reference.symbol:=newasmsymbol(pconstsym(symtableentry)^.owner^.name^+'_RESOURCESTRINGLIST');
-                        location.reference.offset:=pconstsym(symtableentry)^.resstrindex*16+8;
+                        location.reference.symbol:=newasmsymbol(tconstsym(symtableentry).owner.name^+'_RESOURCESTRINGLIST');
+                        location.reference.offset:=tconstsym(symtableentry).resstrindex*16+8;
                      end
                      end
                    else
                    else
                      internalerror(22798);
                      internalerror(22798);
@@ -104,31 +104,31 @@ implementation
                  begin
                  begin
                     hregister:=R_NO;
                     hregister:=R_NO;
                     { C variable }
                     { C variable }
-                    if (vo_is_C_var in pvarsym(symtableentry)^.varoptions) then
+                    if (vo_is_C_var in tvarsym(symtableentry).varoptions) then
                       begin
                       begin
-                         location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                         location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                       end
                       end
                     { DLL variable }
                     { DLL variable }
-                    else if (vo_is_dll_var in pvarsym(symtableentry)^.varoptions) then
+                    else if (vo_is_dll_var in tvarsym(symtableentry).varoptions) then
                       begin
                       begin
                          hregister:=getregister32;
                          hregister:=getregister32;
-                         location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                         location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                          emit_ref_reg(A_MOV,S_L,newreference(location.reference),hregister);
                          emit_ref_reg(A_MOV,S_L,newreference(location.reference),hregister);
                          location.reference.symbol:=nil;
                          location.reference.symbol:=nil;
                          location.reference.base:=hregister;
                          location.reference.base:=hregister;
                       end
                       end
                     { external variable }
                     { external variable }
-                    else if (vo_is_external in pvarsym(symtableentry)^.varoptions) then
+                    else if (vo_is_external in tvarsym(symtableentry).varoptions) then
                       begin
                       begin
-                         location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                         location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                       end
                       end
                     { thread variable }
                     { thread variable }
-                    else if (vo_is_thread_var in pvarsym(symtableentry)^.varoptions) then
+                    else if (vo_is_thread_var in tvarsym(symtableentry).varoptions) then
                       begin
                       begin
                          popeax:=not(R_EAX in unused);
                          popeax:=not(R_EAX in unused);
                          if popeax then
                          if popeax then
                            emit_reg(A_PUSH,S_L,R_EAX);
                            emit_reg(A_PUSH,S_L,R_EAX);
-                         location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                         location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                          emit_ref(A_PUSH,S_L,newreference(location.reference));
                          emit_ref(A_PUSH,S_L,newreference(location.reference));
                          { the called procedure isn't allowed to change }
                          { the called procedure isn't allowed to change }
                          { any register except EAX                    }
                          { any register except EAX                    }
@@ -144,29 +144,29 @@ implementation
                     { normal variable }
                     { normal variable }
                     else
                     else
                       begin
                       begin
-                         symtabletype:=symtable^.symtabletype;
+                         symtabletype:=symtable.symtabletype;
                          { in case it is a register variable: }
                          { in case it is a register variable: }
-                         if pvarsym(symtableentry)^.reg<>R_NO then
+                         if tvarsym(symtableentry).reg<>R_NO then
                            begin
                            begin
-                              if pvarsym(symtableentry)^.reg in [R_ST0..R_ST7] then
+                              if tvarsym(symtableentry).reg in [R_ST0..R_ST7] then
                                 begin
                                 begin
                                    location.loc:=LOC_CFPUREGISTER;
                                    location.loc:=LOC_CFPUREGISTER;
-                                   location.register:=pvarsym(symtableentry)^.reg;
+                                   location.register:=tvarsym(symtableentry).reg;
                                 end
                                 end
                               else
                               else
-                                if not(makereg32(pvarsym(symtableentry)^.reg) in [R_EAX..R_EBX]) or
-                                   regvar_loaded[pvarsym(symtableentry)^.reg] then
+                                if not(makereg32(tvarsym(symtableentry).reg) in [R_EAX..R_EBX]) or
+                                   regvar_loaded[tvarsym(symtableentry).reg] then
                                 begin
                                 begin
                                    location.loc:=LOC_CREGISTER;
                                    location.loc:=LOC_CREGISTER;
-                                   location.register:=pvarsym(symtableentry)^.reg;
-                                   unused:=unused-[pvarsym(symtableentry)^.reg];
+                                   location.register:=tvarsym(symtableentry).reg;
+                                   unused:=unused-[tvarsym(symtableentry).reg];
                                 end
                                 end
                               else
                               else
                                 begin
                                 begin
-                                  load_regvar(exprasmlist,pvarsym(symtableentry));
+                                  load_regvar(exprasmlist,tvarsym(symtableentry));
                                   location.loc:=LOC_CREGISTER;
                                   location.loc:=LOC_CREGISTER;
-                                  location.register:=pvarsym(symtableentry)^.reg;
-                                  unused:=unused-[pvarsym(symtableentry)^.reg];
+                                  location.register:=tvarsym(symtableentry).reg;
+                                  unused:=unused-[tvarsym(symtableentry).reg];
                                 end
                                 end
                            end
                            end
                          else
                          else
@@ -179,20 +179,20 @@ implementation
                                    if (symtabletype in [inlinelocalsymtable,
                                    if (symtabletype in [inlinelocalsymtable,
                                                         localsymtable]) then
                                                         localsymtable]) then
                                      location.reference.offset:=
                                      location.reference.offset:=
-                                       pvarsym(symtableentry)^.address-symtable^.address_fixup
+                                       tvarsym(symtableentry).address-symtable.address_fixup
                                    else
                                    else
                                      location.reference.offset:=
                                      location.reference.offset:=
-                                       pvarsym(symtableentry)^.address+symtable^.address_fixup;
+                                       tvarsym(symtableentry).address+symtable.address_fixup;
 
 
                                    if (symtabletype in [localsymtable,inlinelocalsymtable]) then
                                    if (symtabletype in [localsymtable,inlinelocalsymtable]) then
                                      begin
                                      begin
                                         if use_esp_stackframe then
                                         if use_esp_stackframe then
                                           dec(location.reference.offset,
                                           dec(location.reference.offset,
-                                            pvarsym(symtableentry)^.getvaluesize)
+                                            tvarsym(symtableentry).getvaluesize)
                                         else
                                         else
                                           location.reference.offset:=-location.reference.offset;
                                           location.reference.offset:=-location.reference.offset;
                                      end;
                                      end;
-                                   if (lexlevel>(symtable^.symtablelevel)) then
+                                   if (lexlevel>(symtable.symtablelevel)) then
                                      begin
                                      begin
                                         hregister:=getregister32;
                                         hregister:=getregister32;
 
 
@@ -204,7 +204,7 @@ implementation
 
 
                                         simple_loadn:=false;
                                         simple_loadn:=false;
                                         i:=lexlevel-1;
                                         i:=lexlevel-1;
-                                        while i>(symtable^.symtablelevel) do
+                                        while i>(symtable.symtablelevel) do
                                           begin
                                           begin
                                              { make a reference }
                                              { make a reference }
                                              hp:=new_reference(hregister,8);
                                              hp:=new_reference(hregister,8);
@@ -216,27 +216,27 @@ implementation
                                 end
                                 end
                               else
                               else
                                 case symtabletype of
                                 case symtabletype of
-                                   unitsymtable,globalsymtable,
+                                   globalsymtable,
                                    staticsymtable :
                                    staticsymtable :
                                      begin
                                      begin
-                                       location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                                       location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                                      end;
                                      end;
                                    stt_exceptsymtable:
                                    stt_exceptsymtable:
                                      begin
                                      begin
                                         location.reference.base:=procinfo^.framepointer;
                                         location.reference.base:=procinfo^.framepointer;
-                                        location.reference.offset:=pvarsym(symtableentry)^.address;
+                                        location.reference.offset:=tvarsym(symtableentry).address;
                                      end;
                                      end;
                                    objectsymtable:
                                    objectsymtable:
                                      begin
                                      begin
                                         getexplicitregister32(R_ESI);
                                         getexplicitregister32(R_ESI);
-                                        if (sp_static in pvarsym(symtableentry)^.symoptions) then
+                                        if (sp_static in tvarsym(symtableentry).symoptions) then
                                           begin
                                           begin
-                                             location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                                             location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                                           end
                                           end
                                         else
                                         else
                                           begin
                                           begin
                                              location.reference.base:=R_ESI;
                                              location.reference.base:=R_ESI;
-                                             location.reference.offset:=pvarsym(symtableentry)^.address;
+                                             location.reference.offset:=tvarsym(symtableentry).address;
                                           end;
                                           end;
                                      end;
                                      end;
                                    withsymtable:
                                    withsymtable:
@@ -246,33 +246,33 @@ implementation
                                           contains the offset of the temp
                                           contains the offset of the temp
                                           stored }
                                           stored }
 {                                       hp:=new_reference(procinfo^.framepointer,
 {                                       hp:=new_reference(procinfo^.framepointer,
-                                          symtable^.datasize);
+                                          symtable.datasize);
 
 
                                         emit_ref_reg(A_MOV,S_L,hp,hregister);}
                                         emit_ref_reg(A_MOV,S_L,hp,hregister);}
 
 
-                                        if nf_islocal in tnode(pwithsymtable(symtable)^.withnode).flags then
+                                        if nf_islocal in tnode(twithsymtable(symtable).withnode).flags then
                                          begin
                                          begin
-                                           location.reference:=twithnode(pwithsymtable(symtable)^.withnode).withreference^;
+                                           location.reference:=twithnode(twithsymtable(symtable).withnode).withreference^;
                                          end
                                          end
                                         else
                                         else
                                          begin
                                          begin
                                            hregister:=getregister32;
                                            hregister:=getregister32;
                                            location.reference.base:=hregister;
                                            location.reference.base:=hregister;
                                            emit_ref_reg(A_MOV,S_L,
                                            emit_ref_reg(A_MOV,S_L,
-                                             newreference(twithnode(pwithsymtable(symtable)^.withnode).withreference^),
+                                             newreference(twithnode(twithsymtable(symtable).withnode).withreference^),
                                              hregister);
                                              hregister);
                                          end;
                                          end;
-                                        inc(location.reference.offset,pvarsym(symtableentry)^.address);
+                                        inc(location.reference.offset,tvarsym(symtableentry).address);
                                      end;
                                      end;
                                 end;
                                 end;
                            end;
                            end;
                          { in case call by reference, then calculate. Open array
                          { in case call by reference, then calculate. Open array
                            is always an reference! }
                            is always an reference! }
-                         if (pvarsym(symtableentry)^.varspez in [vs_var,vs_out]) or
-                            is_open_array(pvarsym(symtableentry)^.vartype.def) or
-                            is_array_of_const(pvarsym(symtableentry)^.vartype.def) or
-                            ((pvarsym(symtableentry)^.varspez=vs_const) and
-                             push_addr_param(pvarsym(symtableentry)^.vartype.def)) then
+                         if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
+                            is_open_array(tvarsym(symtableentry).vartype.def) or
+                            is_array_of_const(tvarsym(symtableentry).vartype.def) or
+                            ((tvarsym(symtableentry).varspez=vs_const) and
+                             push_addr_param(tvarsym(symtableentry).vartype.def)) then
                            begin
                            begin
                               simple_loadn:=false;
                               simple_loadn:=false;
                               if hregister=R_NO then
                               if hregister=R_NO then
@@ -302,13 +302,13 @@ implementation
                          gettempofsizereference(8,location.reference);
                          gettempofsizereference(8,location.reference);
                          if left.nodetype=typen then
                          if left.nodetype=typen then
                           begin
                           begin
-                            if left.resulttype.def^.deftype<>objectdef then
+                            if left.resulttype.def.deftype<>objectdef then
                              internalerror(200103261);
                              internalerror(200103261);
                             getexplicitregister32(R_EDI);
                             getexplicitregister32(R_EDI);
                             hregister:=R_EDI;
                             hregister:=R_EDI;
                             new(hp);
                             new(hp);
                             emit_sym_ofs_reg(A_MOV,S_L,
                             emit_sym_ofs_reg(A_MOV,S_L,
-                              newasmsymbol(pobjectdef(left.resulttype.def)^.vmt_mangledname),0,R_EDI);
+                              newasmsymbol(tobjectdef(left.resulttype.def).vmt_mangledname),0,R_EDI);
                           end
                           end
                          else
                          else
                           begin
                           begin
@@ -352,7 +352,7 @@ implementation
                            hregister,hp);
                            hregister,hp);
 
 
                          { virtual method ? }
                          { virtual method ? }
-                         if (po_virtualmethod in pprocsym(symtableentry)^.definition^.procoptions) then
+                         if (po_virtualmethod in tprocsym(symtableentry).definition.procoptions) then
                            begin
                            begin
                               new(hp);
                               new(hp);
                               reset_reference(hp^);
                               reset_reference(hp^);
@@ -367,23 +367,19 @@ implementation
                               new(hp);
                               new(hp);
                               reset_reference(hp^);
                               reset_reference(hp^);
                               hp^.base:=R_EDI;
                               hp^.base:=R_EDI;
-                              hp^.offset:=pprocsym(symtableentry)^.definition^._class^.vmtmethodoffset(
-                                pprocsym(symtableentry)^.definition^.extnumber);
+                              hp^.offset:=tprocsym(symtableentry).definition._class.vmtmethodoffset(
+                                tprocsym(symtableentry).definition.extnumber);
                               emit_ref_reg(A_MOV,S_L,
                               emit_ref_reg(A_MOV,S_L,
                                 hp,R_EDI);
                                 hp,R_EDI);
                               { ... and store it }
                               { ... and store it }
                               emit_reg_ref(A_MOV,S_L,
                               emit_reg_ref(A_MOV,S_L,
                                 R_EDI,newreference(location.reference));
                                 R_EDI,newreference(location.reference));
-{$ifndef noAllocEdi}
                               ungetregister32(R_EDI);
                               ungetregister32(R_EDI);
-{$endif noAllocEdi}
                            end
                            end
                          else
                          else
                            begin
                            begin
-{$ifndef noAllocEdi}
                               ungetregister32(R_EDI);
                               ungetregister32(R_EDI);
-{$endif noAllocEdi}
-                              s:=newasmsymbol(pprocsym(symtableentry)^.definition^.mangledname);
+                              s:=newasmsymbol(tprocsym(symtableentry).definition.mangledname);
                               emit_sym_ofs_ref(A_MOV,S_L,s,0,
                               emit_sym_ofs_ref(A_MOV,S_L,s,0,
                                 newreference(location.reference));
                                 newreference(location.reference));
                            end;
                            end;
@@ -391,12 +387,12 @@ implementation
                     else
                     else
                       begin
                       begin
                          {!!!!! Be aware, work on virtual methods too }
                          {!!!!! Be aware, work on virtual methods too }
-                         location.reference.symbol:=newasmsymbol(pprocsym(symtableentry)^.definition^.mangledname);
+                         location.reference.symbol:=newasmsymbol(tprocsym(symtableentry).definition.mangledname);
                       end;
                       end;
                  end;
                  end;
               typedconstsym :
               typedconstsym :
                  begin
                  begin
-                    location.reference.symbol:=newasmsymbol(symtableentry^.mangledname);
+                    location.reference.symbol:=newasmsymbol(symtableentry.mangledname);
                  end;
                  end;
               else internalerror(4);
               else internalerror(4);
          end;
          end;
@@ -410,7 +406,7 @@ implementation
     procedure ti386assignmentnode.pass_2;
     procedure ti386assignmentnode.pass_2;
       var
       var
          opsize : topsize;
          opsize : topsize;
-         otlabel,hlabel,oflabel : pasmlabel;
+         otlabel,hlabel,oflabel : tasmlabel;
          fputyp : tfloattype;
          fputyp : tfloattype;
          loc : tloc;
          loc : tloc;
          r : preference;
          r : preference;
@@ -481,7 +477,7 @@ implementation
               exit;
               exit;
            end;
            end;
 {$endif test_dest_loc}
 {$endif test_dest_loc}
-         if left.resulttype.def^.deftype=stringdef then
+         if left.resulttype.def.deftype=stringdef then
            begin
            begin
               if is_ansistring(left.resulttype.def) then
               if is_ansistring(left.resulttype.def) then
                 begin
                 begin
@@ -572,7 +568,7 @@ implementation
                          if (right.nodetype=ordconstn) or
                          if (right.nodetype=ordconstn) or
                             (loc=LOC_CREGISTER) then
                             (loc=LOC_CREGISTER) then
                            begin
                            begin
-                              case left.resulttype.def^.size of
+                              case left.resulttype.def.size of
                                  1 : opsize:=S_B;
                                  1 : opsize:=S_B;
                                  2 : opsize:=S_W;
                                  2 : opsize:=S_W;
                                  4 : opsize:=S_L;
                                  4 : opsize:=S_L;
@@ -625,7 +621,7 @@ implementation
                            end
                            end
                          else if loc=LOC_CFPUREGISTER then
                          else if loc=LOC_CFPUREGISTER then
                            begin
                            begin
-                              floatloadops(pfloatdef(right.resulttype.def)^.typ,op,opsize);
+                              floatloadops(tfloatdef(right.resulttype.def).typ,op,opsize);
                               emit_ref(op,opsize,
                               emit_ref(op,opsize,
                                 newreference(right.location.reference));
                                 newreference(right.location.reference));
                               emit_reg(A_FSTP,S_NO,
                               emit_reg(A_FSTP,S_NO,
@@ -633,16 +629,16 @@ implementation
                            end
                            end
                          else
                          else
                            begin
                            begin
-                              if (right.resulttype.def^.needs_inittable) then
+                              if (right.resulttype.def.needs_inittable) then
                                 begin
                                 begin
                                    { this would be a problem }
                                    { this would be a problem }
-                                   if not(left.resulttype.def^.needs_inittable) then
+                                   if not(left.resulttype.def.needs_inittable) then
                                      internalerror(3457);
                                      internalerror(3457);
 
 
                                    { increment source reference counter }
                                    { increment source reference counter }
                                    new(r);
                                    new(r);
                                    reset_reference(r^);
                                    reset_reference(r^);
-                                   r^.symbol:=pstoreddef(right.resulttype.def)^.get_inittable_label;
+                                   r^.symbol:=tstoreddef(right.resulttype.def).get_inittable_label;
                                    emitpushreferenceaddr(r^);
                                    emitpushreferenceaddr(r^);
 
 
                                    emitpushreferenceaddr(right.location.reference);
                                    emitpushreferenceaddr(right.location.reference);
@@ -650,7 +646,7 @@ implementation
                                    { decrement destination reference counter }
                                    { decrement destination reference counter }
                                    new(r);
                                    new(r);
                                    reset_reference(r^);
                                    reset_reference(r^);
-                                   r^.symbol:=pstoreddef(left.resulttype.def)^.get_inittable_label;
+                                   r^.symbol:=tstoreddef(left.resulttype.def).get_inittable_label;
                                    emitpushreferenceaddr(r^);
                                    emitpushreferenceaddr(r^);
                                    emitpushreferenceaddr(left.location.reference);
                                    emitpushreferenceaddr(left.location.reference);
                                    emitcall('FPC_DECREF');
                                    emitcall('FPC_DECREF');
@@ -658,11 +654,11 @@ implementation
 
 
 {$ifdef regallocfix}
 {$ifdef regallocfix}
                               concatcopy(right.location.reference,
                               concatcopy(right.location.reference,
-                                left.location.reference,left.resulttype.def^.size,true,false);
+                                left.location.reference,left.resulttype.def.size,true,false);
                               ungetiftemp(right.location.reference);
                               ungetiftemp(right.location.reference);
 {$Else regallocfix}
 {$Else regallocfix}
                               concatcopy(right.location.reference,
                               concatcopy(right.location.reference,
-                                left.location.reference,left.resulttype.def^.size,false,false);
+                                left.location.reference,left.resulttype.def.size,false,false);
                               ungetiftemp(right.location.reference);
                               ungetiftemp(right.location.reference);
 {$endif regallocfix}
 {$endif regallocfix}
                            end;
                            end;
@@ -681,7 +677,7 @@ implementation
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
             LOC_REGISTER,
             LOC_REGISTER,
             LOC_CREGISTER : begin
             LOC_CREGISTER : begin
-                              case right.resulttype.def^.size of
+                              case right.resulttype.def.size of
                                  1 : opsize:=S_B;
                                  1 : opsize:=S_B;
                                  2 : opsize:=S_W;
                                  2 : opsize:=S_W;
                                  4 : opsize:=S_L;
                                  4 : opsize:=S_L;
@@ -726,15 +722,15 @@ implementation
 
 
                            end;
                            end;
             LOC_FPU : begin
             LOC_FPU : begin
-                              if (left.resulttype.def^.deftype=floatdef) then
-                               fputyp:=pfloatdef(left.resulttype.def)^.typ
+                              if (left.resulttype.def.deftype=floatdef) then
+                               fputyp:=tfloatdef(left.resulttype.def).typ
                               else
                               else
-                               if (right.resulttype.def^.deftype=floatdef) then
-                                fputyp:=pfloatdef(right.resulttype.def)^.typ
+                               if (right.resulttype.def.deftype=floatdef) then
+                                fputyp:=tfloatdef(right.resulttype.def).typ
                               else
                               else
                                if (right.nodetype=typeconvn) and
                                if (right.nodetype=typeconvn) and
-                                  (ttypeconvnode(right).left.resulttype.def^.deftype=floatdef) then
-                                fputyp:=pfloatdef(ttypeconvnode(right).left.resulttype.def)^.typ
+                                  (ttypeconvnode(right).left.resulttype.def.deftype=floatdef) then
+                                fputyp:=tfloatdef(ttypeconvnode(right).left.resulttype.def).typ
                               else
                               else
                                 fputyp:=s32real;
                                 fputyp:=s32real;
                               case loc of
                               case loc of
@@ -751,15 +747,15 @@ implementation
                               end;
                               end;
                            end;
                            end;
             LOC_CFPUREGISTER: begin
             LOC_CFPUREGISTER: begin
-                              if (left.resulttype.def^.deftype=floatdef) then
-                               fputyp:=pfloatdef(left.resulttype.def)^.typ
+                              if (left.resulttype.def.deftype=floatdef) then
+                               fputyp:=tfloatdef(left.resulttype.def).typ
                               else
                               else
-                               if (right.resulttype.def^.deftype=floatdef) then
-                                fputyp:=pfloatdef(right.resulttype.def)^.typ
+                               if (right.resulttype.def.deftype=floatdef) then
+                                fputyp:=tfloatdef(right.resulttype.def).typ
                               else
                               else
                                if (right.nodetype=typeconvn) and
                                if (right.nodetype=typeconvn) and
-                                  (ttypeconvnode(right).left.resulttype.def^.deftype=floatdef) then
-                                fputyp:=pfloatdef(ttypeconvnode(right).left.resulttype.def)^.typ
+                                  (ttypeconvnode(right).left.resulttype.def.deftype=floatdef) then
+                                fputyp:=tfloatdef(ttypeconvnode(right).left.resulttype.def).typ
                               else
                               else
                                 fputyp:=s32real;
                                 fputyp:=s32real;
                               emit_reg(A_FLD,S_NO,
                               emit_reg(A_FLD,S_NO,
@@ -905,19 +901,19 @@ implementation
       var
       var
         hp    : tarrayconstructornode;
         hp    : tarrayconstructornode;
         href  : treference;
         href  : treference;
-        lt    : pdef;
+        lt    : tdef;
         vaddr : boolean;
         vaddr : boolean;
         vtype : longint;
         vtype : longint;
         freetemp,
         freetemp,
         dovariant : boolean;
         dovariant : boolean;
         elesize : longint;
         elesize : longint;
       begin
       begin
-        dovariant:=(nf_forcevaria in flags) or parraydef(resulttype.def)^.isvariant;
+        dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
         if dovariant then
         if dovariant then
          elesize:=8
          elesize:=8
         else
         else
          begin
          begin
-           elesize:=parraydef(resulttype.def)^.elesize;
+           elesize:=tarraydef(resulttype.def).elesize;
            if elesize>4 then
            if elesize>4 then
             internalerror(8765678);
             internalerror(8765678);
          end;
          end;
@@ -926,10 +922,10 @@ implementation
            reset_reference(location.reference);
            reset_reference(location.reference);
            { Allocate always a temp, also if no elements are required, to
            { Allocate always a temp, also if no elements are required, to
              be sure that location is valid (PFV) }
              be sure that location is valid (PFV) }
-            if parraydef(resulttype.def)^.highrange=-1 then
+            if tarraydef(resulttype.def).highrange=-1 then
               gettempofsizereference(elesize,location.reference)
               gettempofsizereference(elesize,location.reference)
             else
             else
-              gettempofsizereference((parraydef(resulttype.def)^.highrange+1)*elesize,location.reference);
+              gettempofsizereference((tarraydef(resulttype.def).highrange+1)*elesize,location.reference);
            href:=location.reference;
            href:=location.reference;
          end;
          end;
         hp:=self;
         hp:=self;
@@ -947,13 +943,13 @@ implementation
                  vtype:=$ff;
                  vtype:=$ff;
                  vaddr:=false;
                  vaddr:=false;
                  lt:=hp.left.resulttype.def;
                  lt:=hp.left.resulttype.def;
-                 case lt^.deftype of
+                 case lt.deftype of
                    enumdef,
                    enumdef,
                    orddef :
                    orddef :
                      begin
                      begin
                        if is_64bitint(lt) then
                        if is_64bitint(lt) then
                          begin
                          begin
-                            case porddef(lt)^.typ of
+                            case torddef(lt).typ of
                                s64bit:
                                s64bit:
                                  vtype:=vtInt64;
                                  vtype:=vtInt64;
                                u64bit:
                                u64bit:
@@ -962,14 +958,14 @@ implementation
                             freetemp:=false;
                             freetemp:=false;
                             vaddr:=true;
                             vaddr:=true;
                          end
                          end
-                       else if (lt^.deftype=enumdef) or
+                       else if (lt.deftype=enumdef) or
                          is_integer(lt) then
                          is_integer(lt) then
                          vtype:=vtInteger
                          vtype:=vtInteger
                        else
                        else
                          if is_boolean(lt) then
                          if is_boolean(lt) then
                            vtype:=vtBoolean
                            vtype:=vtBoolean
                          else
                          else
-                           if (lt^.deftype=orddef) and (porddef(lt)^.typ=uchar) then
+                           if (lt.deftype=orddef) and (torddef(lt).typ=uchar) then
                              vtype:=vtChar;
                              vtype:=vtChar;
                      end;
                      end;
                    floatdef :
                    floatdef :
@@ -1072,7 +1068,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-04-02 21:20:37  peter
+  Revision 1.13  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.12  2001/04/02 21:20:37  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.11  2000/12/25 00:07:33  peter
   Revision 1.11  2000/12/25 00:07:33  peter

+ 14 - 9
compiler/i386/n386mat.pas

@@ -68,7 +68,7 @@ implementation
          shrdiv, andmod, pushed,popeax,popedx : boolean;
          shrdiv, andmod, pushed,popeax,popedx : boolean;
 
 
          power : longint;
          power : longint;
-         hl : pasmlabel;
+         hl : tasmlabel;
          hloc : tlocation;
          hloc : tlocation;
          pushedreg : tpushed;
          pushedreg : tpushed;
          typename,opname : string[6];
          typename,opname : string[6];
@@ -102,7 +102,7 @@ implementation
               clear_location(hloc);
               clear_location(hloc);
               emit_pushq_loc(right.location);
               emit_pushq_loc(right.location);
 
 
-              if porddef(resulttype.def)^.typ=u64bit then
+              if torddef(resulttype.def).typ=u64bit then
                 typename:='QWORD'
                 typename:='QWORD'
               else
               else
                 typename:='INT64';
                 typename:='INT64';
@@ -260,13 +260,13 @@ implementation
                           end;
                           end;
                      end;
                      end;
                    { sign extension depends on the left type }
                    { sign extension depends on the left type }
-                   if porddef(left.resulttype.def)^.typ=u32bit then
+                   if torddef(left.resulttype.def).typ=u32bit then
                       emit_reg_reg(A_XOR,S_L,R_EDX,R_EDX)
                       emit_reg_reg(A_XOR,S_L,R_EDX,R_EDX)
                    else
                    else
                       emit_none(A_CDQ,S_NO);
                       emit_none(A_CDQ,S_NO);
 
 
                    { division depends on the right type }
                    { division depends on the right type }
-                   if porddef(right.resulttype.def)^.typ=u32bit then
+                   if torddef(right.resulttype.def).typ=u32bit then
                      emit_reg(A_DIV,S_L,R_EDI)
                      emit_reg(A_DIV,S_L,R_EDI)
                    else
                    else
                      emit_reg(A_IDIV,S_L,R_EDI);
                      emit_reg(A_IDIV,S_L,R_EDI);
@@ -340,7 +340,7 @@ implementation
          hregisterhigh,hregisterlow : tregister;
          hregisterhigh,hregisterlow : tregister;
          pushed,popecx : boolean;
          pushed,popecx : boolean;
          op : tasmop;
          op : tasmop;
-         l1,l2,l3 : pasmlabel;
+         l1,l2,l3 : tasmlabel;
 
 
       begin
       begin
          popecx:=false;
          popecx:=false;
@@ -761,10 +761,10 @@ implementation
                  LOC_REFERENCE,LOC_MEM:
                  LOC_REFERENCE,LOC_MEM:
                                 begin
                                 begin
                                    del_reference(left.location.reference);
                                    del_reference(left.location.reference);
-                                   if (left.resulttype.def^.deftype=floatdef) then
+                                   if (left.resulttype.def.deftype=floatdef) then
                                      begin
                                      begin
                                         location.loc:=LOC_FPU;
                                         location.loc:=LOC_FPU;
-                                        floatload(pfloatdef(left.resulttype.def)^.typ,
+                                        floatload(tfloatdef(left.resulttype.def).typ,
                                           left.location.reference);
                                           left.location.reference);
                                         emit_none(A_FCHS,S_NO);
                                         emit_none(A_FCHS,S_NO);
                                      end
                                      end
@@ -823,7 +823,7 @@ implementation
             (F_NE,F_E,F_LE,F_GE,F_L,F_G,F_NC,F_C,
             (F_NE,F_E,F_LE,F_GE,F_L,F_G,F_NC,F_C,
              F_BE,F_B,F_AE,F_A);
              F_BE,F_B,F_AE,F_A);
       var
       var
-         hl : pasmlabel;
+         hl : tasmlabel;
          opsize : topsize;
          opsize : topsize;
       begin
       begin
          if is_boolean(resulttype.def) then
          if is_boolean(resulttype.def) then
@@ -998,7 +998,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-04-04 22:37:06  peter
+  Revision 1.13  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.12  2001/04/04 22:37:06  peter
     * fix for not with no 32bit values
     * fix for not with no 32bit values
 
 
   Revision 1.11  2001/04/02 21:20:38  peter
   Revision 1.11  2001/04/02 21:20:38  peter

+ 56 - 57
compiler/i386/n386mem.pas

@@ -105,7 +105,7 @@ implementation
       begin
       begin
          location.register:=getregister32;
          location.register:=getregister32;
          emit_sym_ofs_reg(A_MOV,
          emit_sym_ofs_reg(A_MOV,
-            S_L,newasmsymbol(pobjectdef(pclassrefdef(resulttype.def)^.pointertype.def)^.vmt_mangledname),0,
+            S_L,newasmsymbol(tobjectdef(tclassrefdef(resulttype.def).pointertype.def).vmt_mangledname),0,
             location.register);
             location.register);
       end;
       end;
 
 
@@ -140,16 +140,16 @@ implementation
               gettempofsizereference(target_os.size_of_pointer,location.reference);
               gettempofsizereference(target_os.size_of_pointer,location.reference);
 
 
               { determines the size of the mem block }
               { determines the size of the mem block }
-              push_int(ppointerdef(resulttype.def)^.pointertype.def^.size);
+              push_int(tpointerdef(resulttype.def).pointertype.def.size);
               emit_push_lea_loc(location,false);
               emit_push_lea_loc(location,false);
               saveregvars($ff);
               saveregvars($ff);
               emitcall('FPC_GETMEM');
               emitcall('FPC_GETMEM');
 
 
-              if ppointerdef(resulttype.def)^.pointertype.def^.needs_inittable then
+              if tpointerdef(resulttype.def).pointertype.def.needs_inittable then
                 begin
                 begin
                    new(r);
                    new(r);
                    reset_reference(r^);
                    reset_reference(r^);
-                   r^.symbol:=pstoreddef(ppointerdef(resulttype.def)^.pointertype.def)^.get_inittable_label;
+                   r^.symbol:=tstoreddef(tpointerdef(resulttype.def).pointertype.def).get_inittable_label;
                    emitpushreferenceaddr(r^);
                    emitpushreferenceaddr(r^);
                    dispose(r);
                    dispose(r);
                    { push pointer we just allocated, we need to initialize the
                    { push pointer we just allocated, we need to initialize the
@@ -219,11 +219,11 @@ implementation
          case nodetype of
          case nodetype of
            simpledisposen:
            simpledisposen:
              begin
              begin
-                if ppointerdef(left.resulttype.def)^.pointertype.def^.needs_inittable then
+                if tpointerdef(left.resulttype.def).pointertype.def.needs_inittable then
                   begin
                   begin
                      new(r);
                      new(r);
                      reset_reference(r^);
                      reset_reference(r^);
-                     r^.symbol:=pstoreddef(ppointerdef(left.resulttype.def)^.pointertype.def)^.get_inittable_label;
+                     r^.symbol:=tstoreddef(tpointerdef(left.resulttype.def).pointertype.def).get_inittable_label;
                      emitpushreferenceaddr(r^);
                      emitpushreferenceaddr(r^);
                      dispose(r);
                      dispose(r);
                      { push pointer adress }
                      { push pointer adress }
@@ -236,14 +236,14 @@ implementation
            simplenewn:
            simplenewn:
              begin
              begin
                 { determines the size of the mem block }
                 { determines the size of the mem block }
-                push_int(ppointerdef(left.resulttype.def)^.pointertype.def^.size);
+                push_int(tpointerdef(left.resulttype.def).pointertype.def.size);
                 emit_push_lea_loc(left.location,true);
                 emit_push_lea_loc(left.location,true);
                 emitcall('FPC_GETMEM');
                 emitcall('FPC_GETMEM');
-                if ppointerdef(left.resulttype.def)^.pointertype.def^.needs_inittable then
+                if tpointerdef(left.resulttype.def).pointertype.def.needs_inittable then
                   begin
                   begin
                      new(r);
                      new(r);
                      reset_reference(r^);
                      reset_reference(r^);
-                     r^.symbol:=pstoreddef(ppointerdef(left.resulttype.def)^.pointertype.def)^.get_inittable_label;
+                     r^.symbol:=tstoreddef(tpointerdef(left.resulttype.def).pointertype.def).get_inittable_label;
                      emitpushreferenceaddr(r^);
                      emitpushreferenceaddr(r^);
                      dispose(r);
                      dispose(r);
                      emit_push_loc(left.location);
                      emit_push_loc(left.location);
@@ -279,13 +279,13 @@ implementation
          {@ on a procvar means returning an address to the procedure that
          {@ on a procvar means returning an address to the procedure that
            is stored in it.}
            is stored in it.}
          { yes but left.symtableentry can be nil
          { yes but left.symtableentry can be nil
-           for example on @self !! }
+           for example on self !! }
          { symtableentry can be also invalid, if left is no tree node }
          { symtableentry can be also invalid, if left is no tree node }
          if (m_tp_procvar in aktmodeswitches) and
          if (m_tp_procvar in aktmodeswitches) and
            (left.nodetype=loadn) and
            (left.nodetype=loadn) and
            assigned(tloadnode(left).symtableentry) and
            assigned(tloadnode(left).symtableentry) and
-           (tloadnode(left).symtableentry^.typ=varsym) and
-           (pvarsym(tloadnode(left).symtableentry)^.vartype.def^.deftype=procvardef) then
+           (tloadnode(left).symtableentry.typ=varsym) and
+           (tvarsym(tloadnode(left).symtableentry).vartype.def.deftype=procvardef) then
            emit_ref_reg(A_MOV,S_L,
            emit_ref_reg(A_MOV,S_L,
              newreference(left.location.reference),
              newreference(left.location.reference),
              location.register)
              location.register)
@@ -348,9 +348,9 @@ implementation
                  location.reference.base:=hr;
                  location.reference.base:=hr;
               end;
               end;
          end;
          end;
-         if ppointerdef(left.resulttype.def)^.is_far then
+         if tpointerdef(left.resulttype.def).is_far then
           location.reference.segment:=R_FS;
           location.reference.segment:=R_FS;
-         if not ppointerdef(left.resulttype.def)^.is_far and
+         if not tpointerdef(left.resulttype.def).is_far and
             (cs_gdb_heaptrc in aktglobalswitches) and
             (cs_gdb_heaptrc in aktglobalswitches) and
             (cs_checkpointer in aktglobalswitches) then
             (cs_checkpointer in aktglobalswitches) then
               begin
               begin
@@ -408,7 +408,7 @@ implementation
          else
          else
            set_location(location,left.location);
            set_location(location,left.location);
 
 
-         inc(location.reference.offset,vs^.address);
+         inc(location.reference.offset,vs.address);
       end;
       end;
 
 
 
 
@@ -428,10 +428,10 @@ implementation
              get_mul_size:=1
              get_mul_size:=1
             else
             else
              begin
              begin
-               if (left.resulttype.def^.deftype=arraydef) then
-                get_mul_size:=parraydef(left.resulttype.def)^.elesize
+               if (left.resulttype.def.deftype=arraydef) then
+                get_mul_size:=tarraydef(left.resulttype.def).elesize
                else
                else
-                get_mul_size:=resulttype.def^.size;
+                get_mul_size:=resulttype.def.size;
              end
              end
           end;
           end;
 
 
@@ -462,10 +462,10 @@ implementation
          hp  : preference;
          hp  : preference;
          href : treference;
          href : treference;
          tai : Taicpu;
          tai : Taicpu;
-         srsym : psym;
+         srsym : tsym;
          pushed : tpushed;
          pushed : tpushed;
          hightree : tnode;
          hightree : tnode;
-         hl,otl,ofl : pasmlabel;
+         hl,otl,ofl : tasmlabel;
       begin
       begin
          secondpass(left);
          secondpass(left);
          { we load the array reference to location }
          { we load the array reference to location }
@@ -571,21 +571,21 @@ implementation
            set_location(location,left.location);
            set_location(location,left.location);
 
 
          { offset can only differ from 0 if arraydef }
          { offset can only differ from 0 if arraydef }
-         if (left.resulttype.def^.deftype=arraydef) and
+         if (left.resulttype.def.deftype=arraydef) and
            not(is_dynamic_array(left.resulttype.def)) then
            not(is_dynamic_array(left.resulttype.def)) then
            dec(location.reference.offset,
            dec(location.reference.offset,
-               get_mul_size*parraydef(left.resulttype.def)^.lowrange);
+               get_mul_size*tarraydef(left.resulttype.def).lowrange);
          if right.nodetype=ordconstn then
          if right.nodetype=ordconstn then
            begin
            begin
               { offset can only differ from 0 if arraydef }
               { offset can only differ from 0 if arraydef }
-              if (left.resulttype.def^.deftype=arraydef) then
+              if (left.resulttype.def.deftype=arraydef) then
                 begin
                 begin
                    if not(is_open_array(left.resulttype.def)) and
                    if not(is_open_array(left.resulttype.def)) and
                       not(is_array_of_const(left.resulttype.def)) and
                       not(is_array_of_const(left.resulttype.def)) and
                       not(is_dynamic_array(left.resulttype.def)) then
                       not(is_dynamic_array(left.resulttype.def)) then
                      begin
                      begin
-                        if (tordconstnode(right).value>parraydef(left.resulttype.def)^.highrange) or
-                           (tordconstnode(right).value<parraydef(left.resulttype.def)^.lowrange) then
+                        if (tordconstnode(right).value>tarraydef(left.resulttype.def).highrange) or
+                           (tordconstnode(right).value<tarraydef(left.resulttype.def).lowrange) then
                            begin
                            begin
                               if (cs_check_range in aktlocalswitches) then
                               if (cs_check_range in aktlocalswitches) then
                                 CGMessage(parser_e_range_check_error)
                                 CGMessage(parser_e_range_check_error)
@@ -593,7 +593,7 @@ implementation
                                 CGMessage(parser_w_range_check_error);
                                 CGMessage(parser_w_range_check_error);
                            end;
                            end;
                         dec(left.location.reference.offset,
                         dec(left.location.reference.offset,
-                            get_mul_size*parraydef(left.resulttype.def)^.lowrange);
+                            get_mul_size*tarraydef(left.resulttype.def).lowrange);
                      end
                      end
                    else
                    else
                      begin
                      begin
@@ -602,13 +602,13 @@ implementation
                         {!!!!!!!!!!!!!!!!!}
                         {!!!!!!!!!!!!!!!!!}
                      end;
                      end;
                 end
                 end
-              else if (left.resulttype.def^.deftype=stringdef) then
+              else if (left.resulttype.def.deftype=stringdef) then
                 begin
                 begin
                    if (tordconstnode(right).value=0) and not(is_shortstring(left.resulttype.def)) then
                    if (tordconstnode(right).value=0) and not(is_shortstring(left.resulttype.def)) then
                      CGMessage(cg_e_can_access_element_zero);
                      CGMessage(cg_e_can_access_element_zero);
 
 
                    if (cs_check_range in aktlocalswitches) then
                    if (cs_check_range in aktlocalswitches) then
-                     case pstringdef(left.resulttype.def)^.string_typ of
+                     case tstringdef(left.resulttype.def).string_typ of
                         { it's the same for ansi- and wide strings }
                         { it's the same for ansi- and wide strings }
                         st_widestring,
                         st_widestring,
                         st_ansistring:
                         st_ansistring:
@@ -656,7 +656,7 @@ implementation
               { need that fancy code (it would be }
               { need that fancy code (it would be }
               { buggy)                            }
               { buggy)                            }
                 not(cs_check_range in aktlocalswitches) and
                 not(cs_check_range in aktlocalswitches) and
-                (left.resulttype.def^.deftype=arraydef) then
+                (left.resulttype.def.deftype=arraydef) then
                 begin
                 begin
                    extraoffset:=0;
                    extraoffset:=0;
                    if (right.nodetype=addn) then
                    if (right.nodetype=addn) then
@@ -733,18 +733,18 @@ implementation
 
 
               if cs_check_range in aktlocalswitches then
               if cs_check_range in aktlocalswitches then
                begin
                begin
-                 if left.resulttype.def^.deftype=arraydef then
+                 if left.resulttype.def.deftype=arraydef then
                    begin
                    begin
                      if is_open_array(left.resulttype.def) or
                      if is_open_array(left.resulttype.def) or
                         is_array_of_const(left.resulttype.def) then
                         is_array_of_const(left.resulttype.def) then
                       begin
                       begin
                         reset_reference(href);
                         reset_reference(href);
-                        parraydef(left.resulttype.def)^.genrangecheck;
-                        href.symbol:=newasmsymbol(parraydef(left.resulttype.def)^.getrangecheckstring);
+                        tarraydef(left.resulttype.def).genrangecheck;
+                        href.symbol:=newasmsymbol(tarraydef(left.resulttype.def).getrangecheckstring);
                         href.offset:=4;
                         href.offset:=4;
                         srsym:=searchsymonlyin(tloadnode(left).symtable,
                         srsym:=searchsymonlyin(tloadnode(left).symtable,
-                          'high'+pvarsym(tloadnode(left).symtableentry)^.name);
-                        hightree:=cloadnode.create(pvarsym(srsym),tloadnode(left).symtable);
+                          'high'+tvarsym(tloadnode(left).symtableentry).name);
+                        hightree:=cloadnode.create(tvarsym(srsym),tloadnode(left).symtable);
                         firstpass(hightree);
                         firstpass(hightree);
                         secondpass(hightree);
                         secondpass(hightree);
                         emit_mov_loc_ref(hightree.location,href,S_L,true);
                         emit_mov_loc_ref(hightree.location,href,S_L,true);
@@ -759,7 +759,7 @@ implementation
                  LOC_REGISTER:
                  LOC_REGISTER:
                    begin
                    begin
                       ind:=right.location.register;
                       ind:=right.location.register;
-                      case right.resulttype.def^.size of
+                      case right.resulttype.def.size of
                          1:
                          1:
                            begin
                            begin
                               hr:=reg8toreg32(ind);
                               hr:=reg8toreg32(ind);
@@ -777,7 +777,7 @@ implementation
                  LOC_CREGISTER:
                  LOC_CREGISTER:
                    begin
                    begin
                       ind:=getregister32;
                       ind:=getregister32;
-                      case right.resulttype.def^.size of
+                      case right.resulttype.def.size of
                          1:
                          1:
                            emit_reg_reg(A_MOVZX,S_BL,right.location.register,ind);
                            emit_reg_reg(A_MOVZX,S_BL,right.location.register,ind);
                          2:
                          2:
@@ -811,7 +811,7 @@ implementation
                       ind:=getregister32;
                       ind:=getregister32;
                       { Booleans are stored in an 8 bit memory location, so
                       { Booleans are stored in an 8 bit memory location, so
                         the use of MOVL is not correct }
                         the use of MOVL is not correct }
-                      case right.resulttype.def^.size of
+                      case right.resulttype.def.size of
                        1 : tai:=Taicpu.Op_ref_reg(A_MOVZX,S_BL,newreference(right.location.reference),ind);
                        1 : tai:=Taicpu.Op_ref_reg(A_MOVZX,S_BL,newreference(right.location.reference),ind);
                        2 : tai:=Taicpu.Op_ref_reg(A_MOVZX,S_WL,newreference(right.location.reference),ind);
                        2 : tai:=Taicpu.Op_ref_reg(A_MOVZX,S_WL,newreference(right.location.reference),ind);
                        4 : tai:=Taicpu.Op_ref_reg(A_MOV,S_L,newreference(right.location.reference),ind);
                        4 : tai:=Taicpu.Op_ref_reg(A_MOV,S_L,newreference(right.location.reference),ind);
@@ -825,13 +825,13 @@ implementation
             { produce possible range check code: }
             { produce possible range check code: }
               if cs_check_range in aktlocalswitches then
               if cs_check_range in aktlocalswitches then
                begin
                begin
-                 if left.resulttype.def^.deftype=arraydef then
+                 if left.resulttype.def.deftype=arraydef then
                    begin
                    begin
                      { done defore (PM) }
                      { done defore (PM) }
                    end
                    end
-                 else if (left.resulttype.def^.deftype=stringdef) then
+                 else if (left.resulttype.def.deftype=stringdef) then
                    begin
                    begin
-                      case pstringdef(left.resulttype.def)^.string_typ of
+                      case tstringdef(left.resulttype.def).string_typ of
                          { it's the same for ansi- and wide strings }
                          { it's the same for ansi- and wide strings }
                          st_widestring,
                          st_widestring,
                          st_ansistring:
                          st_ansistring:
@@ -906,7 +906,7 @@ implementation
       begin
       begin
          reset_reference(location.reference);
          reset_reference(location.reference);
          getexplicitregister32(R_ESI);
          getexplicitregister32(R_ESI);
-         if (resulttype.def^.deftype=classrefdef) or
+         if (resulttype.def.deftype=classrefdef) or
            is_class(resulttype.def) then
            is_class(resulttype.def) then
            location.register:=R_ESI
            location.register:=R_ESI
          else
          else
@@ -922,7 +922,7 @@ implementation
       var
       var
         usetemp,with_expr_in_temp : boolean;
         usetemp,with_expr_in_temp : boolean;
 {$ifdef GDB}
 {$ifdef GDB}
-        withstartlabel,withendlabel : pasmlabel;
+        withstartlabel,withendlabel : tasmlabel;
         pp : pchar;
         pp : pchar;
         mangled_length  : longint;
         mangled_length  : longint;
 
 
@@ -940,7 +940,7 @@ implementation
 
 
                usetemp:=false;
                usetemp:=false;
                if (left.nodetype=loadn) and
                if (left.nodetype=loadn) and
-                  (tloadnode(left).symtable=aktprocsym^.definition^.localst) then
+                  (tloadnode(left).symtable=aktprocsym.definition.localst) then
                  begin
                  begin
                     { for locals use the local storage }
                     { for locals use the local storage }
                     withreference^:=left.location.reference;
                     withreference^:=left.location.reference;
@@ -950,17 +950,13 @@ implementation
                 { call can have happend with a property }
                 { call can have happend with a property }
                 if is_class_or_interface(left.resulttype.def) then
                 if is_class_or_interface(left.resulttype.def) then
                  begin
                  begin
-{$ifndef noAllocEdi}
                     getexplicitregister32(R_EDI);
                     getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                     emit_mov_loc_reg(left.location,R_EDI);
                     emit_mov_loc_reg(left.location,R_EDI);
                     usetemp:=true;
                     usetemp:=true;
                  end
                  end
                else
                else
                  begin
                  begin
-{$ifndef noAllocEdi}
                    getexplicitregister32(R_EDI);
                    getexplicitregister32(R_EDI);
-{$endif noAllocEdi}
                    emit_lea_loc_reg(left.location,R_EDI,false);
                    emit_lea_loc_reg(left.location,R_EDI,false);
                    usetemp:=true;
                    usetemp:=true;
                  end;
                  end;
@@ -986,9 +982,7 @@ implementation
                   normaltemptopersistant(withreference^.offset);
                   normaltemptopersistant(withreference^.offset);
                   { move to temp reference }
                   { move to temp reference }
                   emit_reg_ref(A_MOV,S_L,R_EDI,newreference(withreference^));
                   emit_reg_ref(A_MOV,S_L,R_EDI,newreference(withreference^));
-{$ifndef noAllocEdi}
                   ungetregister32(R_EDI);
                   ungetregister32(R_EDI);
-{$endif noAllocEdi}
 {$ifdef GDB}
 {$ifdef GDB}
                   if (cs_debuginfo in aktmoduleswitches) then
                   if (cs_debuginfo in aktmoduleswitches) then
                     begin
                     begin
@@ -997,16 +991,16 @@ implementation
                       getaddrlabel(withendlabel);
                       getaddrlabel(withendlabel);
                       emitlab(withstartlabel);
                       emitlab(withstartlabel);
                       withdebugList.concat(Tai_stabs.Create(strpnew(
                       withdebugList.concat(Tai_stabs.Create(strpnew(
-                         '"with'+tostr(withlevel)+':'+tostr(symtablestack^.getnewtypecount)+
-                         '=*'+pstoreddef(left.resulttype.def)^.numberstring+'",'+
+                         '"with'+tostr(withlevel)+':'+tostr(symtablestack.getnewtypecount)+
+                         '=*'+tstoreddef(left.resulttype.def).numberstring+'",'+
                          tostr(N_LSYM)+',0,0,'+tostr(withreference^.offset))));
                          tostr(N_LSYM)+',0,0,'+tostr(withreference^.offset))));
-                      mangled_length:=length(aktprocsym^.definition^.mangledname);
+                      mangled_length:=length(aktprocsym.definition.mangledname);
                       getmem(pp,mangled_length+50);
                       getmem(pp,mangled_length+50);
-                      strpcopy(pp,'192,0,0,'+withstartlabel^.name);
+                      strpcopy(pp,'192,0,0,'+withstartlabel.name);
                       if (target_os.use_function_relative_addresses) then
                       if (target_os.use_function_relative_addresses) then
                         begin
                         begin
                           strpcopy(strend(pp),'-');
                           strpcopy(strend(pp),'-');
-                          strpcopy(strend(pp),aktprocsym^.definition^.mangledname);
+                          strpcopy(strend(pp),aktprocsym.definition.mangledname);
                         end;
                         end;
                       withdebugList.concat(Tai_stabn.Create(strnew(pp)));
                       withdebugList.concat(Tai_stabn.Create(strnew(pp)));
                     end;
                     end;
@@ -1024,11 +1018,11 @@ implementation
                    if (cs_debuginfo in aktmoduleswitches) then
                    if (cs_debuginfo in aktmoduleswitches) then
                      begin
                      begin
                        emitlab(withendlabel);
                        emitlab(withendlabel);
-                       strpcopy(pp,'224,0,0,'+withendlabel^.name);
+                       strpcopy(pp,'224,0,0,'+withendlabel.name);
                       if (target_os.use_function_relative_addresses) then
                       if (target_os.use_function_relative_addresses) then
                         begin
                         begin
                           strpcopy(strend(pp),'-');
                           strpcopy(strend(pp),'-');
-                          strpcopy(strend(pp),aktprocsym^.definition^.mangledname);
+                          strpcopy(strend(pp),aktprocsym.definition.mangledname);
                         end;
                         end;
                        withdebugList.concat(Tai_stabn.Create(strnew(pp)));
                        withdebugList.concat(Tai_stabn.Create(strnew(pp)));
                        freemem(pp,mangled_length+50);
                        freemem(pp,mangled_length+50);
@@ -1061,7 +1055,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2001-04-02 21:20:38  peter
+  Revision 1.12  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.11  2001/04/02 21:20:38  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.10  2001/03/11 22:58:52  peter
   Revision 1.10  2001/03/11 22:58:52  peter

+ 9 - 4
compiler/i386/n386opt.pas

@@ -82,7 +82,7 @@ end;
 
 
 procedure ti386addsstringcharoptnode.pass_2;
 procedure ti386addsstringcharoptnode.pass_2;
 var
 var
-  l: pasmlabel;
+  l: tasmlabel;
   href2: preference;
   href2: preference;
   href:  treference;
   href:  treference;
   hreg, lengthreg: tregister;
   hreg, lengthreg: tregister;
@@ -135,7 +135,7 @@ begin
   if istemp(left.location.reference) then
   if istemp(left.location.reference) then
     checklength := curmaxlen = 255
     checklength := curmaxlen = 255
   else
   else
-    checklength := curmaxlen >= pstringdef(left.resulttype.def)^.len;
+    checklength := curmaxlen >= tstringdef(left.resulttype.def).len;
   if checklength then
   if checklength then
     begin
     begin
       { is it already maximal? }
       { is it already maximal? }
@@ -143,7 +143,7 @@ begin
       if istemp(left.location.reference) then
       if istemp(left.location.reference) then
         emit_const_reg(A_CMP,S_L,255,lengthreg)
         emit_const_reg(A_CMP,S_L,255,lengthreg)
       else
       else
-        emit_const_reg(A_CMP,S_L,pstringdef(left.resulttype.def)^.len,lengthreg);
+        emit_const_reg(A_CMP,S_L,tstringdef(left.resulttype.def).len,lengthreg);
       emitjmp(C_E,l);
       emitjmp(C_E,l);
     end;
     end;
 
 
@@ -248,7 +248,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2001-04-02 21:20:38  peter
+  Revision 1.4  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.3  2001/04/02 21:20:38  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.2  2001/01/06 19:12:31  jonas
   Revision 1.2  2001/01/06 19:12:31  jonas

+ 16 - 11
compiler/i386/n386set.pas

@@ -101,7 +101,7 @@ implementation
          i,numparts : byte;
          i,numparts : byte;
          adjustment : longint;
          adjustment : longint;
          {href,href2 : Treference;}
          {href,href2 : Treference;}
-         l,l2       : pasmlabel;
+         l,l2       : tasmlabel;
 {$ifdef CORRECT_SET_IN_FPC}
 {$ifdef CORRECT_SET_IN_FPC}
          AM         : tasmop;
          AM         : tasmop;
 {$endif CORRECT_SET_IN_FPC}
 {$endif CORRECT_SET_IN_FPC}
@@ -172,9 +172,9 @@ implementation
 
 
          { check if we can use smallset operation using btl which is limited
          { check if we can use smallset operation using btl which is limited
            to 32 bits, the left side may also not contain higher values !! }
            to 32 bits, the left side may also not contain higher values !! }
-         use_small:=(psetdef(right.resulttype.def)^.settype=smallset) and
-                    ((left.resulttype.def^.deftype=orddef) and (porddef(left.resulttype.def)^.high<=32) or
-                     (left.resulttype.def^.deftype=enumdef) and (penumdef(left.resulttype.def)^.max<=32));
+         use_small:=(tsetdef(right.resulttype.def).settype=smallset) and
+                    ((left.resulttype.def.deftype=orddef) and (torddef(left.resulttype.def).high<=32) or
+                     (left.resulttype.def.deftype=enumdef) and (tenumdef(left.resulttype.def).max<=32));
 
 
          { Can we generate jumps? Possible for all types of sets }
          { Can we generate jumps? Possible for all types of sets }
          genjumps:=(right.nodetype=setconstn) and
          genjumps:=(right.nodetype=setconstn) and
@@ -531,7 +531,7 @@ implementation
          hp : tnode;
          hp : tnode;
          { register with case expression }
          { register with case expression }
          hregister,hregister2 : tregister;
          hregister,hregister2 : tregister;
-         endlabel,elselabel : pasmlabel;
+         endlabel,elselabel : tasmlabel;
 
 
          { true, if we can omit the range check of the jump table }
          { true, if we can omit the range check of the jump table }
          jumptable_no_range : boolean;
          jumptable_no_range : boolean;
@@ -542,7 +542,7 @@ implementation
       procedure gentreejmp(p : pcaserecord);
       procedure gentreejmp(p : pcaserecord);
 
 
         var
         var
-           lesslabel,greaterlabel : pasmlabel;
+           lesslabel,greaterlabel : tasmlabel;
 
 
        begin
        begin
          emitlab(p^._at);
          emitlab(p^._at);
@@ -592,7 +592,7 @@ implementation
         procedure genitem(t : pcaserecord);
         procedure genitem(t : pcaserecord);
 
 
           var
           var
-             l1 : pasmlabel;
+             l1 : tasmlabel;
 
 
           begin
           begin
              if assigned(t^.less) then
              if assigned(t^.less) then
@@ -753,7 +753,7 @@ implementation
       procedure genjumptable(hp : pcaserecord;min_,max_ : longint);
       procedure genjumptable(hp : pcaserecord;min_,max_ : longint);
 
 
         var
         var
-           table : pasmlabel;
+           table : tasmlabel;
            last : TConstExprInt;
            last : TConstExprInt;
            hr : preference;
            hr : preference;
 
 
@@ -830,7 +830,7 @@ implementation
          max_label: tconstexprint;
          max_label: tconstexprint;
          lv,hv,labels : longint;
          lv,hv,labels : longint;
          max_linear_list : longint;
          max_linear_list : longint;
-         otl, ofl: pasmlabel;
+         otl, ofl: tasmlabel;
 {$ifdef Delphi}
 {$ifdef Delphi}
          dist : cardinal;
          dist : cardinal;
 {$else Delphi}
 {$else Delphi}
@@ -870,7 +870,7 @@ implementation
            end;
            end;
          secondpass(left);
          secondpass(left);
          { determines the size of the operand }
          { determines the size of the operand }
-         opsize:=bytes2Sxx[left.resulttype.def^.size];
+         opsize:=bytes2Sxx[left.resulttype.def.size];
          { copy the case expression to a register }
          { copy the case expression to a register }
          case left.location.loc of
          case left.location.loc of
             LOC_REGISTER:
             LOC_REGISTER:
@@ -1065,7 +1065,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-06 14:09:34  jonas
+  Revision 1.14  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/06 14:09:34  jonas
     * fixed bug in ti386innode.pass_2 code and made it simpler/faster
     * fixed bug in ti386innode.pass_2 code and made it simpler/faster
 
 
   Revision 1.12  2001/04/02 21:20:38  peter
   Revision 1.12  2001/04/02 21:20:38  peter

+ 60 - 55
compiler/i386/n386util.pas

@@ -47,14 +47,14 @@ interface
 
 
     procedure maketojumpbool(p : tnode);
     procedure maketojumpbool(p : tnode);
     procedure emitoverflowcheck(p:tnode);
     procedure emitoverflowcheck(p:tnode);
-    procedure emitrangecheck(p:tnode;todef:pdef);
+    procedure emitrangecheck(p:tnode;todef:tdef);
     procedure firstcomplex(p : tbinarynode);
     procedure firstcomplex(p : tbinarynode);
 
 
 implementation
 implementation
 
 
     uses
     uses
        globtype,globals,systems,verbose,
        globtype,globals,systems,verbose,
-       cutils,cobjects,
+       cutils,
        aasm,cpubase,cpuasm,
        aasm,cpubase,cpuasm,
        symconst,symbase,symdef,symsym,symtable,
        symconst,symbase,symdef,symsym,symtable,
 {$ifdef GDB}
 {$ifdef GDB}
@@ -347,13 +347,13 @@ implementation
         op : tasmop;
         op : tasmop;
         hreg : tregister;
         hreg : tregister;
         size : longint;
         size : longint;
-        hlabel : pasmlabel;
+        hlabel : tasmlabel;
       begin
       begin
         case p.location.loc of
         case p.location.loc of
            LOC_REGISTER,
            LOC_REGISTER,
            LOC_CREGISTER:
            LOC_CREGISTER:
              begin
              begin
-                  if p.resulttype.def^.size=8 then
+                  if p.resulttype.def.size=8 then
                     begin
                     begin
                        inc(pushedparasize,8);
                        inc(pushedparasize,8);
                        if inlined then
                        if inlined then
@@ -437,7 +437,7 @@ implementation
              end;
              end;
            LOC_FPU:
            LOC_FPU:
              begin
              begin
-                size:=align(pfloatdef(p.resulttype.def)^.size,alignment);
+                size:=align(tfloatdef(p.resulttype.def).size,alignment);
                 inc(pushedparasize,size);
                 inc(pushedparasize,size);
                 if not inlined then
                 if not inlined then
                  emit_const_reg(A_SUB,S_L,size,R_ESP);
                  emit_const_reg(A_SUB,S_L,size,R_ESP);
@@ -447,7 +447,7 @@ implementation
                   exprasmList.concat(Tai_force_line.Create);
                   exprasmList.concat(Tai_force_line.Create);
 {$endif GDB}
 {$endif GDB}
                 r:=new_reference(R_ESP,0);
                 r:=new_reference(R_ESP,0);
-                floatstoreops(pfloatdef(p.resulttype.def)^.typ,op,opsize);
+                floatstoreops(tfloatdef(p.resulttype.def).typ,op,opsize);
                 { this is the easiest case for inlined !! }
                 { this is the easiest case for inlined !! }
                 if inlined then
                 if inlined then
                   begin
                   begin
@@ -461,7 +461,7 @@ implementation
              begin
              begin
                 exprasmList.concat(Taicpu.Op_reg(A_FLD,S_NO,
                 exprasmList.concat(Taicpu.Op_reg(A_FLD,S_NO,
                   correct_fpuregister(p.location.register,fpuvaroffset)));
                   correct_fpuregister(p.location.register,fpuvaroffset)));
-                size:=align(pfloatdef(p.resulttype.def)^.size,alignment);
+                size:=align(tfloatdef(p.resulttype.def).size,alignment);
                 inc(pushedparasize,size);
                 inc(pushedparasize,size);
                 if not inlined then
                 if not inlined then
                  emit_const_reg(A_SUB,S_L,size,R_ESP);
                  emit_const_reg(A_SUB,S_L,size,R_ESP);
@@ -471,7 +471,7 @@ implementation
                   exprasmList.concat(Tai_force_line.Create);
                   exprasmList.concat(Tai_force_line.Create);
 {$endif GDB}
 {$endif GDB}
                 r:=new_reference(R_ESP,0);
                 r:=new_reference(R_ESP,0);
-                floatstoreops(pfloatdef(p.resulttype.def)^.typ,op,opsize);
+                floatstoreops(tfloatdef(p.resulttype.def).typ,op,opsize);
                 { this is the easiest case for inlined !! }
                 { this is the easiest case for inlined !! }
                 if inlined then
                 if inlined then
                   begin
                   begin
@@ -484,11 +484,11 @@ implementation
              begin
              begin
                 tempreference:=p.location.reference;
                 tempreference:=p.location.reference;
                 del_reference(p.location.reference);
                 del_reference(p.location.reference);
-                case p.resulttype.def^.deftype of
+                case p.resulttype.def.deftype of
                   enumdef,
                   enumdef,
                   orddef :
                   orddef :
                     begin
                     begin
-                      case p.resulttype.def^.size of
+                      case p.resulttype.def.size of
                        8 : begin
                        8 : begin
                              inc(pushedparasize,8);
                              inc(pushedparasize,8);
                              if inlined then
                              if inlined then
@@ -552,7 +552,7 @@ implementation
                                 ungetregister32(R_EDI);
                                 ungetregister32(R_EDI);
                               end
                               end
                              else
                              else
-                              emit_push_mem_size(tempreference,p.resulttype.def^.size);
+                              emit_push_mem_size(tempreference,p.resulttype.def.size);
                            end;
                            end;
                          else
                          else
                            internalerror(234231);
                            internalerror(234231);
@@ -560,7 +560,7 @@ implementation
                     end;
                     end;
                   floatdef :
                   floatdef :
                     begin
                     begin
-                      case pfloatdef(p.resulttype.def)^.typ of
+                      case tfloatdef(p.resulttype.def).typ of
                         s32real :
                         s32real :
                           begin
                           begin
                              inc(pushedparasize,4);
                              inc(pushedparasize,4);
@@ -693,20 +693,20 @@ implementation
                        if is_widestring(p.resulttype.def) or
                        if is_widestring(p.resulttype.def) or
                           is_ansistring(p.resulttype.def) or
                           is_ansistring(p.resulttype.def) or
                           is_smallset(p.resulttype.def) or
                           is_smallset(p.resulttype.def) or
-                          ((p.resulttype.def^.deftype in [recorddef,arraydef]) and
+                          ((p.resulttype.def.deftype in [recorddef,arraydef]) and
                            (
                            (
-                            (p.resulttype.def^.deftype<>arraydef) or not
-                            (parraydef(p.resulttype.def)^.IsConstructor or
-                             parraydef(p.resulttype.def)^.isArrayOfConst or
+                            (p.resulttype.def.deftype<>arraydef) or not
+                            (tarraydef(p.resulttype.def).IsConstructor or
+                             tarraydef(p.resulttype.def).isArrayOfConst or
                              is_open_array(p.resulttype.def))
                              is_open_array(p.resulttype.def))
                            ) and
                            ) and
-                           (p.resulttype.def^.size<=4)
+                           (p.resulttype.def.size<=4)
                           ) or
                           ) or
                           is_class(p.resulttype.def) or
                           is_class(p.resulttype.def) or
                           is_interface(p.resulttype.def) then
                           is_interface(p.resulttype.def) then
                          begin
                          begin
-                            if (p.resulttype.def^.size>2) or
-                               ((alignment=4) and (p.resulttype.def^.size>0)) then
+                            if (p.resulttype.def.size>2) or
+                               ((alignment=4) and (p.resulttype.def.size>0)) then
                               begin
                               begin
                                 inc(pushedparasize,4);
                                 inc(pushedparasize,4);
                                 if inlined then
                                 if inlined then
@@ -719,7 +719,7 @@ implementation
                               end
                               end
                             else
                             else
                               begin
                               begin
-                                if p.resulttype.def^.size>0 then
+                                if p.resulttype.def.size>0 then
                                   begin
                                   begin
                                     inc(pushedparasize,2);
                                     inc(pushedparasize,2);
                                     if inlined then
                                     if inlined then
@@ -736,7 +736,7 @@ implementation
                        else if is_cdecl then
                        else if is_cdecl then
                          begin
                          begin
                            { push on stack }
                            { push on stack }
-                           size:=align(p.resulttype.def^.size,alignment);
+                           size:=align(p.resulttype.def.size,alignment);
                            inc(pushedparasize,size);
                            inc(pushedparasize,size);
                            emit_const_reg(A_SUB,S_L,size,R_ESP);
                            emit_const_reg(A_SUB,S_L,size,R_ESP);
                            r:=new_reference(R_ESP,0);
                            r:=new_reference(R_ESP,0);
@@ -904,14 +904,14 @@ implementation
     { produces if necessary overflowcode }
     { produces if necessary overflowcode }
     procedure emitoverflowcheck(p:tnode);
     procedure emitoverflowcheck(p:tnode);
       var
       var
-         hl : pasmlabel;
+         hl : tasmlabel;
       begin
       begin
          if not(cs_check_overflow in aktlocalswitches) then
          if not(cs_check_overflow in aktlocalswitches) then
           exit;
           exit;
          getlabel(hl);
          getlabel(hl);
-         if not ((p.resulttype.def^.deftype=pointerdef) or
-                ((p.resulttype.def^.deftype=orddef) and
-                 (porddef(p.resulttype.def)^.typ in [u64bit,u16bit,u32bit,u8bit,uchar,
+         if not ((p.resulttype.def.deftype=pointerdef) or
+                ((p.resulttype.def.deftype=orddef) and
+                 (torddef(p.resulttype.def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,
                                                   bool8bit,bool16bit,bool32bit]))) then
                                                   bool8bit,bool16bit,bool32bit]))) then
            emitjmp(C_NO,hl)
            emitjmp(C_NO,hl)
          else
          else
@@ -922,16 +922,16 @@ implementation
 
 
     { produces range check code, while one of the operands is a 64 bit
     { produces range check code, while one of the operands is a 64 bit
       integer }
       integer }
-    procedure emitrangecheck64(p : tnode;todef : pdef);
+    procedure emitrangecheck64(p : tnode;todef : tdef);
 
 
       var
       var
         neglabel,
         neglabel,
         poslabel,
         poslabel,
-        endlabel: pasmlabel;
+        endlabel: tasmlabel;
         href   : preference;
         href   : preference;
         hreg   : tregister;
         hreg   : tregister;
-        hdef   :  porddef;
-        fromdef : pdef;
+        hdef   :  torddef;
+        fromdef : tdef;
         opcode : tasmop;
         opcode : tasmop;
         opsize   : topsize;
         opsize   : topsize;
         oldregisterdef: boolean;
         oldregisterdef: boolean;
@@ -978,11 +978,11 @@ implementation
              { if the high dword = 0, the low dword can be considered a }
              { if the high dword = 0, the low dword can be considered a }
              { simple cardinal                                          }
              { simple cardinal                                          }
              emitlab(poslabel);
              emitlab(poslabel);
-             new(hdef,init(u32bit,0,longint($ffffffff)));
+             hdef:=torddef.create(u32bit,0,longint($ffffffff));
              { the real p.resulttype.def is already saved in fromdef }
              { the real p.resulttype.def is already saved in fromdef }
              p.resulttype.def := hdef;
              p.resulttype.def := hdef;
              emitrangecheck(p,todef);
              emitrangecheck(p,todef);
-             dispose(hdef,done);
+             hdef.free;
              { restore original resulttype.def }
              { restore original resulttype.def }
              p.resulttype.def := todef;
              p.resulttype.def := todef;
 
 
@@ -1013,10 +1013,10 @@ implementation
                  { if we get here, the 64bit value lies between }
                  { if we get here, the 64bit value lies between }
                  { longint($80000000) and -1 (JM)               }
                  { longint($80000000) and -1 (JM)               }
                  emitlab(neglabel);
                  emitlab(neglabel);
-                 new(hdef,init(s32bit,longint($80000000),-1));
+                 hdef:=torddef.create(s32bit,longint($80000000),-1);
                  p.resulttype.def := hdef;
                  p.resulttype.def := hdef;
                  emitrangecheck(p,todef);
                  emitrangecheck(p,todef);
-                 dispose(hdef,done);
+                 hdef.free;
                  emitlab(endlabel);
                  emitlab(endlabel);
                end;
                end;
              registerdef := oldregisterdef;
              registerdef := oldregisterdef;
@@ -1032,7 +1032,7 @@ implementation
               { also not if the fromdef is unsigned and < 64bit, since that will }
               { also not if the fromdef is unsigned and < 64bit, since that will }
               { always fit in a 64bit int (todef is 64bit)                       }
               { always fit in a 64bit int (todef is 64bit)                       }
               (from_signed or
               (from_signed or
-               (porddef(fromdef)^.typ = u64bit)) then
+               (torddef(fromdef).typ = u64bit)) then
              begin
              begin
                { in all cases, there is only a problem if the higest bit is set }
                { in all cases, there is only a problem if the higest bit is set }
                if p.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
                if p.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
@@ -1043,7 +1043,7 @@ implementation
                else
                else
                  begin
                  begin
                    hreg := getexplicitregister32(R_EDI);
                    hreg := getexplicitregister32(R_EDI);
-                   case p.resulttype.def^.size of
+                   case p.resulttype.def.size of
                      1: opsize := S_BL;
                      1: opsize := S_BL;
                      2: opsize := S_WL;
                      2: opsize := S_WL;
                      4,8: opsize := S_L;
                      4,8: opsize := S_L;
@@ -1055,7 +1055,7 @@ implementation
                    else
                    else
                      opcode := A_MOV;
                      opcode := A_MOV;
                    href := newreference(p.location.reference);
                    href := newreference(p.location.reference);
-                   if p.resulttype.def^.size = 8 then
+                   if p.resulttype.def.size = 8 then
                      inc(href^.offset,4);
                      inc(href^.offset,4);
                    emit_ref_reg(opcode,opsize,href,hreg);
                    emit_ref_reg(opcode,opsize,href,hreg);
                  end;
                  end;
@@ -1070,7 +1070,7 @@ implementation
       end;
       end;
 
 
      { produces if necessary rangecheckcode }
      { produces if necessary rangecheckcode }
-     procedure emitrangecheck(p:tnode;todef:pdef);
+     procedure emitrangecheck(p:tnode;todef:tdef);
      {
      {
        generate range checking code for the value at location t. The
        generate range checking code for the value at location t. The
        type used is the checked against todefs ranges. fromdef (p.resulttype.def)
        type used is the checked against todefs ranges. fromdef (p.resulttype.def)
@@ -1078,17 +1078,17 @@ implementation
        equal the check is also insert (needed for succ,pref,inc,dec)
        equal the check is also insert (needed for succ,pref,inc,dec)
      }
      }
       var
       var
-        neglabel : pasmlabel;
+        neglabel : tasmlabel;
         opsize : topsize;
         opsize : topsize;
         op     : tasmop;
         op     : tasmop;
-        fromdef : pdef;
+        fromdef : tdef;
         lto,hto,
         lto,hto,
         lfrom,hfrom : longint;
         lfrom,hfrom : longint;
         is_reg : boolean;
         is_reg : boolean;
       begin
       begin
         { range checking on and range checkable value? }
         { range checking on and range checkable value? }
         if not(cs_check_range in aktlocalswitches) or
         if not(cs_check_range in aktlocalswitches) or
-           not(todef^.deftype in [orddef,enumdef,arraydef]) then
+           not(todef.deftype in [orddef,enumdef,arraydef]) then
           exit;
           exit;
         { only check when assigning to scalar, subranges are different,
         { only check when assigning to scalar, subranges are different,
           when todef=fromdef then the check is always generated }
           when todef=fromdef then the check is always generated }
@@ -1097,12 +1097,12 @@ implementation
         { int64/qword, since such operations can at most cause overflows (JM)   }
         { int64/qword, since such operations can at most cause overflows (JM)   }
         if (fromdef = todef) and
         if (fromdef = todef) and
           { then fromdef and todef can only be orddefs }
           { then fromdef and todef can only be orddefs }
-           (((porddef(fromdef)^.typ = s32bit) and
-             (porddef(fromdef)^.low = longint($80000000)) and
-             (porddef(fromdef)^.high = $7fffffff)) or
-            ((porddef(fromdef)^.typ = u32bit) and
-             (porddef(fromdef)^.low = 0) and
-             (porddef(fromdef)^.high = longint($ffffffff))) or
+           (((torddef(fromdef).typ = s32bit) and
+             (torddef(fromdef).low = longint($80000000)) and
+             (torddef(fromdef).high = $7fffffff)) or
+            ((torddef(fromdef).typ = u32bit) and
+             (torddef(fromdef).low = 0) and
+             (torddef(fromdef).high = longint($ffffffff))) or
             is_64bitint(fromdef)) then
             is_64bitint(fromdef)) then
           exit;
           exit;
         if is_64bitint(fromdef) or is_64bitint(todef) then
         if is_64bitint(fromdef) or is_64bitint(todef) then
@@ -1208,8 +1208,8 @@ implementation
       begin
       begin
          { always calculate boolean AND and OR from left to right }
          { always calculate boolean AND and OR from left to right }
          if (p.nodetype in [orn,andn]) and
          if (p.nodetype in [orn,andn]) and
-            (p.left.resulttype.def^.deftype=orddef) and
-            (porddef(p.left.resulttype.def)^.typ in [bool8bit,bool16bit,bool32bit]) then
+            (p.left.resulttype.def.deftype=orddef) and
+            (torddef(p.left.resulttype.def).typ in [bool8bit,bool16bit,bool32bit]) then
            begin
            begin
              { p.swaped:=false}
              { p.swaped:=false}
              if nf_swaped in p.flags then
              if nf_swaped in p.flags then
@@ -1242,12 +1242,12 @@ implementation
     procedure push_shortstring_length(p:tnode);
     procedure push_shortstring_length(p:tnode);
       var
       var
         hightree : tnode;
         hightree : tnode;
-        srsym    : psym;
+        srsym    : tsym;
       begin
       begin
         if is_open_string(p.resulttype.def) then
         if is_open_string(p.resulttype.def) then
          begin
          begin
-           srsym:=searchsymonlyin(tloadnode(p).symtable,'high'+pvarsym(tloadnode(p).symtableentry)^.name);
-           hightree:=cloadnode.create(pvarsym(srsym),tloadnode(p).symtable);
+           srsym:=searchsymonlyin(tloadnode(p).symtable,'high'+tvarsym(tloadnode(p).symtableentry).name);
+           hightree:=cloadnode.create(tvarsym(srsym),tloadnode(p).symtable);
            firstpass(hightree);
            firstpass(hightree);
            secondpass(hightree);
            secondpass(hightree);
            push_value_para(hightree,false,false,0,4);
            push_value_para(hightree,false,false,0,4);
@@ -1256,7 +1256,7 @@ implementation
          end
          end
         else
         else
          begin
          begin
-           push_int(pstringdef(p.resulttype.def)^.len);
+           push_int(tstringdef(p.resulttype.def).len);
          end;
          end;
       end;
       end;
 
 
@@ -1271,7 +1271,7 @@ implementation
       var
       var
         href: treference;
         href: treference;
       begin
       begin
-         case source.resulttype.def^.deftype of
+         case source.resulttype.def.deftype of
             stringdef:
             stringdef:
               begin
               begin
                  if (source.nodetype=stringconstn) and
                  if (source.nodetype=stringconstn) and
@@ -1332,7 +1332,7 @@ implementation
          r : preference;
          r : preference;
 
 
       begin
       begin
-         case p.right.resulttype.def^.deftype of
+         case p.right.resulttype.def.deftype of
             stringdef:
             stringdef:
               begin
               begin
                  if (p.right.nodetype=stringconstn) and
                  if (p.right.nodetype=stringconstn) and
@@ -1472,7 +1472,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2001-04-02 21:20:39  peter
+  Revision 1.15  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.14  2001/04/02 21:20:39  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.13  2001/03/11 22:58:52  peter
   Revision 1.13  2001/03/11 22:58:52  peter

+ 25 - 20
compiler/i386/popt386.pas

@@ -445,9 +445,9 @@ Var
    jmp l3               jmp l3}
    jmp l3               jmp l3}
 
 
   Var p1, p2: Tai;
   Var p1, p2: Tai;
-      l: pasmlabel;
+      l: tasmlabel;
 
 
-    Function FindAnyLabel(hp: Tai; var l: pasmlabel): Boolean;
+    Function FindAnyLabel(hp: Tai; var l: tasmlabel): Boolean;
     Begin
     Begin
       FindAnyLabel := false;
       FindAnyLabel := false;
       While assigned(hp.next) and
       While assigned(hp.next) and
@@ -462,11 +462,11 @@ Var
     End;
     End;
 
 
   Begin
   Begin
-    If (pasmlabel(hp.oper[0].sym)^.labelnr >= LoLab) and
-       (pasmlabel(hp.oper[0].sym)^.labelnr <= HiLab) and   {range check, a jump can go past an assembler block!}
-       Assigned(LTable^[pasmlabel(hp.oper[0].sym)^.labelnr-LoLab].TaiObj) Then
+    If (tasmlabel(hp.oper[0].sym).labelnr >= LoLab) and
+       (tasmlabel(hp.oper[0].sym).labelnr <= HiLab) and   {range check, a jump can go past an assembler block!}
+       Assigned(LTable^[tasmlabel(hp.oper[0].sym).labelnr-LoLab].TaiObj) Then
       Begin
       Begin
-        p1 := LTable^[pasmlabel(hp.oper[0].sym)^.labelnr-LoLab].TaiObj; {the jump's destination}
+        p1 := LTable^[tasmlabel(hp.oper[0].sym).labelnr-LoLab].TaiObj; {the jump's destination}
         SkipLabels(p1,p1);
         SkipLabels(p1,p1);
         If (Tai(p1).typ = ait_instruction) and
         If (Tai(p1).typ = ait_instruction) and
            (Taicpu(p1).is_jmp) Then
            (Taicpu(p1).is_jmp) Then
@@ -486,9 +486,9 @@ Var
               SkipLabels(p1,p1)) Then
               SkipLabels(p1,p1)) Then
             Begin
             Begin
               GetFinalDestination(asml, Taicpu(p1));
               GetFinalDestination(asml, Taicpu(p1));
-              Dec(pasmlabel(hp.oper[0].sym)^.refs);
+              Dec(tasmlabel(hp.oper[0].sym).refs);
               hp.oper[0].sym:=Taicpu(p1).oper[0].sym;
               hp.oper[0].sym:=Taicpu(p1).oper[0].sym;
-              inc(pasmlabel(hp.oper[0].sym)^.refs);
+              inc(tasmlabel(hp.oper[0].sym).refs);
             End
             End
           Else
           Else
             If (Taicpu(p1).condition = inverse_cond[hp.condition]) then
             If (Taicpu(p1).condition = inverse_cond[hp.condition]) then
@@ -500,9 +500,9 @@ Var
   {$endif finaldestdebug}
   {$endif finaldestdebug}
                   getlabel(l);
                   getlabel(l);
                   insertllitem(asml,p1,p1.next,Tai_label.Create(l));
                   insertllitem(asml,p1,p1.next,Tai_label.Create(l));
-                  dec(pasmlabel(Taicpu(hp).oper[0].sym)^.refs);
+                  dec(tasmlabel(Taicpu(hp).oper[0].sym).refs);
                   hp.oper[0].sym := l;
                   hp.oper[0].sym := l;
-                  inc(l^.refs);
+                  inc(l.refs);
   {               this won't work, since the new label isn't in the labeltable }
   {               this won't work, since the new label isn't in the labeltable }
   {               so it will fail the rangecheck. Labeltable should become a   }
   {               so it will fail the rangecheck. Labeltable should become a   }
   {               hashtable to support this:                                   }
   {               hashtable to support this:                                   }
@@ -514,7 +514,7 @@ Var
                   insertllitem(asml,p1,p1.next,Tai_asm_comment.Create(
                   insertllitem(asml,p1,p1.next,Tai_asm_comment.Create(
                     strpnew('next label reused'))));
                     strpnew('next label reused'))));
   {$endif finaldestdebug}
   {$endif finaldestdebug}
-                  inc(l^.refs);
+                  inc(l.refs);
                   hp.oper[0].sym := l;
                   hp.oper[0].sym := l;
                   GetFinalDestination(asml, hp);
                   GetFinalDestination(asml, hp);
                 end;
                 end;
@@ -594,7 +594,7 @@ Begin
                { remove jumps to a label coming right after them }
                { remove jumps to a label coming right after them }
                If GetNextInstruction(p, hp1) then
                If GetNextInstruction(p, hp1) then
                  Begin
                  Begin
-                   if FindLabel(pasmlabel(Taicpu(p).oper[0].sym), hp1) then
+                   if FindLabel(tasmlabel(Taicpu(p).oper[0].sym), hp1) then
                      Begin
                      Begin
                        hp2:=Tai(hp1.next);
                        hp2:=Tai(hp1.next);
                        asml.remove(p);
                        asml.remove(p);
@@ -609,7 +609,7 @@ Begin
                        If (Tai(hp1).typ=ait_instruction) and
                        If (Tai(hp1).typ=ait_instruction) and
                           (Taicpu(hp1).opcode=A_JMP) and
                           (Taicpu(hp1).opcode=A_JMP) and
                           GetNextInstruction(hp1, hp2) And
                           GetNextInstruction(hp1, hp2) And
-                          FindLabel(PAsmLabel(Taicpu(p).oper[0].sym), hp2)
+                          FindLabel(tasmlabel(Taicpu(p).oper[0].sym), hp2)
                          Then
                          Then
                            Begin
                            Begin
                              if Taicpu(p).opcode=A_Jcc then
                              if Taicpu(p).opcode=A_Jcc then
@@ -621,9 +621,9 @@ Begin
                                 p:=Tai(p.next);
                                 p:=Tai(p.next);
                                 continue;
                                 continue;
                               end;
                               end;
-                             Dec(Tai_label(hp2).l^.refs);
+                             Dec(Tai_label(hp2).l.refs);
                              Taicpu(p).oper[0].sym:=Taicpu(hp1).oper[0].sym;
                              Taicpu(p).oper[0].sym:=Taicpu(hp1).oper[0].sym;
-                             Inc(Taicpu(p).oper[0].sym^.refs);
+                             Inc(Taicpu(p).oper[0].sym.refs);
                              asml.remove(hp1);
                              asml.remove(hp1);
                              hp1.free;
                              hp1.free;
                              If (LabDif <> 0) Then
                              If (LabDif <> 0) Then
@@ -699,7 +699,7 @@ Begin
                        (Taicpu(hp3).is_jmp) and
                        (Taicpu(hp3).is_jmp) and
                        (Taicpu(hp3).opcode = A_JMP) And
                        (Taicpu(hp3).opcode = A_JMP) And
                        GetNextInstruction(hp3, hp4) And
                        GetNextInstruction(hp3, hp4) And
-                       FindLabel(PAsmLabel(Taicpu(hp1).oper[0].sym),hp4)
+                       FindLabel(tasmlabel(Taicpu(hp1).oper[0].sym),hp4)
                       Then
                       Then
                         Begin
                         Begin
                           Taicpu(hp2).Opcode := A_SUB;
                           Taicpu(hp2).Opcode := A_SUB;
@@ -1688,7 +1688,7 @@ Begin
                        end;
                        end;
                      if assigned(hp1) then
                      if assigned(hp1) then
                        begin
                        begin
-                          if FindLabel(PAsmLabel(Taicpu(p).oper[0].sym),hp1) then
+                          if FindLabel(tasmlabel(Taicpu(p).oper[0].sym),hp1) then
                             begin
                             begin
                                if (l<=4) and (l>0) then
                                if (l<=4) and (l>0) then
                                  begin
                                  begin
@@ -1728,7 +1728,7 @@ Begin
                                 (hp2.typ=ait_instruction) and
                                 (hp2.typ=ait_instruction) and
                                 (Taicpu(hp2).is_jmp) and
                                 (Taicpu(hp2).is_jmp) and
                                 (Taicpu(hp2).condition=C_None) and
                                 (Taicpu(hp2).condition=C_None) and
-                                FindLabel(PAsmLabel(Taicpu(p).oper[0].sym),hp1) then
+                                FindLabel(tasmlabel(Taicpu(p).oper[0].sym),hp1) then
                                  begin
                                  begin
                                     l:=0;
                                     l:=0;
                                     while assigned(hp1) And
                                     while assigned(hp1) And
@@ -1740,7 +1740,7 @@ Begin
                                  end;
                                  end;
                               {
                               {
                               if assigned(hp1) and
                               if assigned(hp1) and
-                                FindLabel(PAsmLabel(Taicpu(hp2).oper[0].sym),hp1) then
+                                FindLabel(tasmlabel(Taicpu(hp2).oper[0].sym),hp1) then
                                 begin
                                 begin
                                    condition:=inverse_cond[Taicpu(p).condition];
                                    condition:=inverse_cond[Taicpu(p).condition];
                                    GetNextInstruction(p,hp1);
                                    GetNextInstruction(p,hp1);
@@ -2008,7 +2008,12 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-04-06 14:06:03  jonas
+  Revision 1.13  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.12  2001/04/06 14:06:03  jonas
     * fixed incompatibility between new regvar handling and -Op2
     * fixed incompatibility between new regvar handling and -Op2
 
 
   Revision 1.11  2001/04/02 21:20:39  peter
   Revision 1.11  2001/04/02 21:20:39  peter

+ 81 - 78
compiler/i386/ra386.pas

@@ -37,21 +37,19 @@ Function CheckOverride(overrideop,op:tasmop): Boolean;
 Procedure FWaitWarning;
 Procedure FWaitWarning;
 
 
 type
 type
-  P386Operand=^T386Operand;
-  T386Operand=object(TOperand)
-    Procedure SetCorrectSize(opcode:tasmop);virtual;
-    Function SetupResult : boolean;virtual;
+  T386Operand=class(TOperand)
+    Procedure SetCorrectSize(opcode:tasmop);override;
+    Function SetupResult : boolean;override;
   end;
   end;
 
 
-  P386Instruction=^T386Instruction;
-  T386Instruction=object(TInstruction)
+  T386Instruction=class(TInstruction)
     { Operand sizes }
     { Operand sizes }
     procedure AddReferenceSizes;
     procedure AddReferenceSizes;
     procedure SetInstructionOpsize;
     procedure SetInstructionOpsize;
     procedure CheckOperandSizes;
     procedure CheckOperandSizes;
     procedure CheckNonCommutativeOpcodes;
     procedure CheckNonCommutativeOpcodes;
     { opcode adding }
     { opcode adding }
-    procedure ConcatInstruction(p : taasmoutput);virtual;
+    procedure ConcatInstruction(p : taasmoutput);override;
   end;
   end;
 
 
 
 
@@ -193,7 +191,7 @@ Function T386Operand.SetupResult:boolean;
 var
 var
   Res : boolean;
   Res : boolean;
 Begin
 Begin
-  Res:=TOperand.setupResult;
+  Res:=inherited setupResult;
   { replace by ref by register if not place was
   { replace by ref by register if not place was
     reserved on stack }
     reserved on stack }
   if res and (procinfo^.return_offset=0) then
   if res and (procinfo^.return_offset=0) then
@@ -202,7 +200,7 @@ Begin
      if is_fpu(procinfo^.returntype.def) then
      if is_fpu(procinfo^.returntype.def) then
        begin
        begin
          opr.reg:=R_ST0;
          opr.reg:=R_ST0;
-         case pfloatdef(procinfo^.returntype.def)^.typ of
+         case tfloatdef(procinfo^.returntype.def).typ of
            s32real : size:=S_FS;
            s32real : size:=S_FS;
            s64real : size:=S_FL;
            s64real : size:=S_FL;
            s80real : size:=S_FX;
            s80real : size:=S_FX;
@@ -215,7 +213,7 @@ Begin
          end;
          end;
        end
        end
      else if ret_in_acc(procinfo^.returntype.def) then
      else if ret_in_acc(procinfo^.returntype.def) then
-       case procinfo^.returntype.def^.size of
+       case procinfo^.returntype.def.size of
        1 : begin
        1 : begin
              opr.reg:=R_AL;
              opr.reg:=R_AL;
              size:=S_B;
              size:=S_B;
@@ -251,15 +249,15 @@ procedure T386Instruction.AddReferenceSizes;
   operand is a register }
   operand is a register }
 var
 var
   operand2,i : longint;
   operand2,i : longint;
-  s : pasmsymbol;
+  s : tasmsymbol;
   so : longint;
   so : longint;
 begin
 begin
   for i:=1to ops do
   for i:=1to ops do
    begin
    begin
-   operands[i]^.SetCorrectSize(opcode);
-   if (operands[i]^.size=S_NO) then
+   operands[i].SetCorrectSize(opcode);
+   if (operands[i].size=S_NO) then
     begin
     begin
-      case operands[i]^.Opr.Typ of
+      case operands[i].Opr.Typ of
         OPR_REFERENCE :
         OPR_REFERENCE :
           begin
           begin
             if i=2 then
             if i=2 then
@@ -269,30 +267,30 @@ begin
             if operand2<ops then
             if operand2<ops then
              begin
              begin
                { Only allow register as operand to take the size from }
                { Only allow register as operand to take the size from }
-               if operands[operand2]^.opr.typ=OPR_REGISTER then
+               if operands[operand2].opr.typ=OPR_REGISTER then
                  begin
                  begin
                    if ((opcode<>A_MOVD) and
                    if ((opcode<>A_MOVD) and
                        (opcode<>A_CVTSI2SS)) then
                        (opcode<>A_CVTSI2SS)) then
-                     operands[i]^.size:=operands[operand2]^.size;
+                     operands[i].size:=operands[operand2].size;
                  end
                  end
                else
                else
                 begin
                 begin
                   { if no register then take the opsize (which is available with ATT),
                   { if no register then take the opsize (which is available with ATT),
                     if not availble then give an error }
                     if not availble then give an error }
                   if opsize<>S_NO then
                   if opsize<>S_NO then
-                    operands[i]^.size:=opsize
+                    operands[i].size:=opsize
                   else
                   else
                    begin
                    begin
                      Message(asmr_e_unable_to_determine_reference_size);
                      Message(asmr_e_unable_to_determine_reference_size);
                      { recovery }
                      { recovery }
-                     operands[i]^.size:=S_L;
+                     operands[i].size:=S_L;
                    end;
                    end;
                 end;
                 end;
              end
              end
             else
             else
              begin
              begin
                if opsize<>S_NO then
                if opsize<>S_NO then
-                 operands[i]^.size:=opsize
+                 operands[i].size:=opsize
              end;
              end;
           end;
           end;
         OPR_SYMBOL :
         OPR_SYMBOL :
@@ -300,14 +298,14 @@ begin
             { Fix lea which need a reference }
             { Fix lea which need a reference }
             if opcode=A_LEA then
             if opcode=A_LEA then
              begin
              begin
-               s:=operands[i]^.opr.symbol;
-               so:=operands[i]^.opr.symofs;
-               operands[i]^.opr.typ:=OPR_REFERENCE;
-               reset_reference(operands[i]^.opr.ref);
-               operands[i]^.opr.ref.symbol:=s;
-               operands[i]^.opr.ref.offset:=so;
+               s:=operands[i].opr.symbol;
+               so:=operands[i].opr.symofs;
+               operands[i].opr.typ:=OPR_REFERENCE;
+               reset_reference(operands[i].opr.ref);
+               operands[i].opr.ref.symbol:=s;
+               operands[i].opr.ref.offset:=so;
              end;
              end;
-            operands[i]^.size:=S_L;
+            operands[i].size:=S_L;
           end;
           end;
       end;
       end;
     end;
     end;
@@ -325,25 +323,25 @@ begin
       { "push es" must be stored as a long PM }
       { "push es" must be stored as a long PM }
       if ((opcode=A_PUSH) or
       if ((opcode=A_PUSH) or
           (opcode=A_POP)) and
           (opcode=A_POP)) and
-         (operands[1]^.opr.typ=OPR_REGISTER) and
-         ((operands[1]^.opr.reg>=firstsreg) and
-          (operands[1]^.opr.reg<=lastsreg)) then
+         (operands[1].opr.typ=OPR_REGISTER) and
+         ((operands[1].opr.reg>=firstsreg) and
+          (operands[1].opr.reg<=lastsreg)) then
         opsize:=S_L
         opsize:=S_L
       else
       else
-        opsize:=operands[1]^.size;
+        opsize:=operands[1].size;
     2 :
     2 :
       begin
       begin
         case opcode of
         case opcode of
           A_MOVZX,A_MOVSX :
           A_MOVZX,A_MOVSX :
             begin
             begin
-              case operands[1]^.size of
+              case operands[1].size of
                 S_W :
                 S_W :
-                  case operands[2]^.size of
+                  case operands[2].size of
                     S_L :
                     S_L :
                       opsize:=S_WL;
                       opsize:=S_WL;
                   end;
                   end;
                 S_B :
                 S_B :
-                  case operands[2]^.size of
+                  case operands[2].size of
                     S_W :
                     S_W :
                       opsize:=S_BW;
                       opsize:=S_BW;
                     S_L :
                     S_L :
@@ -355,13 +353,13 @@ begin
                      32 bit register or memory, so no opsize is correct here PM }
                      32 bit register or memory, so no opsize is correct here PM }
             exit;
             exit;
           A_OUT :
           A_OUT :
-            opsize:=operands[1]^.size;
+            opsize:=operands[1].size;
           else
           else
-            opsize:=operands[2]^.size;
+            opsize:=operands[2].size;
         end;
         end;
       end;
       end;
     3 :
     3 :
-      opsize:=operands[3]^.size;
+      opsize:=operands[3].size;
   end;
   end;
 end;
 end;
 
 
@@ -387,9 +385,9 @@ begin
   { special push/pop selector case }
   { special push/pop selector case }
   if ((opcode=A_PUSH) or
   if ((opcode=A_PUSH) or
       (opcode=A_POP)) and
       (opcode=A_POP)) and
-     (operands[1]^.opr.typ=OPR_REGISTER) and
-     ((operands[1]^.opr.reg>=firstsreg) and
-      (operands[1]^.opr.reg<=lastsreg)) then
+     (operands[1].opr.typ=OPR_REGISTER) and
+     ((operands[1].opr.reg>=firstsreg) and
+      (operands[1].opr.reg<=lastsreg)) then
      exit;
      exit;
   if opsize in [S_BW,S_BL,S_WL] then
   if opsize in [S_BW,S_BL,S_WL] then
    begin
    begin
@@ -399,11 +397,11 @@ begin
       begin
       begin
         case opsize of
         case opsize of
           S_BW :
           S_BW :
-            sizeerr:=(operands[1]^.size<>S_B) or (operands[2]^.size<>S_W);
+            sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_W);
           S_BL :
           S_BL :
-            sizeerr:=(operands[1]^.size<>S_B) or (operands[2]^.size<>S_L);
+            sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_L);
           S_WL :
           S_WL :
-            sizeerr:=(operands[1]^.size<>S_W) or (operands[2]^.size<>S_L);
+            sizeerr:=(operands[1].size<>S_W) or (operands[2].size<>S_L);
         end;
         end;
       end;
       end;
    end
    end
@@ -411,9 +409,9 @@ begin
    begin
    begin
      for i:=1 to ops do
      for i:=1 to ops do
       begin
       begin
-        if (operands[i]^.opr.typ<>OPR_CONSTANT) and
-           (operands[i]^.size in [S_B,S_W,S_L]) and
-           (operands[i]^.size<>opsize) then
+        if (operands[i].opr.typ<>OPR_CONSTANT) and
+           (operands[i].size in [S_B,S_W,S_L]) and
+           (operands[i].size<>opsize) then
          sizeerr:=true;
          sizeerr:=true;
       end;
       end;
    end;
    end;
@@ -435,11 +433,11 @@ end;
 procedure T386Instruction.CheckNonCommutativeOpcodes;
 procedure T386Instruction.CheckNonCommutativeOpcodes;
 begin
 begin
   if ((ops=2) and
   if ((ops=2) and
-     (operands[1]^.opr.typ=OPR_REGISTER) and
-     (operands[2]^.opr.typ=OPR_REGISTER) and
+     (operands[1].opr.typ=OPR_REGISTER) and
+     (operands[2].opr.typ=OPR_REGISTER) and
      { if the first is ST and the second is also a register
      { if the first is ST and the second is also a register
        it is necessarily ST1 .. ST7 }
        it is necessarily ST1 .. ST7 }
-     (operands[1]^.opr.reg=R_ST)) or
+     (operands[1].opr.reg=R_ST)) or
       (ops=0)  then
       (ops=0)  then
       if opcode=A_FSUBR then
       if opcode=A_FSUBR then
         opcode:=A_FSUB
         opcode:=A_FSUB
@@ -458,8 +456,8 @@ begin
       else if opcode=A_FDIVP then
       else if opcode=A_FDIVP then
         opcode:=A_FDIVRP;
         opcode:=A_FDIVRP;
   if  ((ops=1) and
   if  ((ops=1) and
-      (operands[1]^.opr.typ=OPR_REGISTER) and
-      (operands[1]^.opr.reg in [R_ST1..R_ST7])) then
+      (operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg in [R_ST1..R_ST7])) then
       if opcode=A_FSUBRP then
       if opcode=A_FSUBRP then
         opcode:=A_FSUBP
         opcode:=A_FSUBP
       else if opcode=A_FSUBP then
       else if opcode=A_FSUBP then
@@ -485,20 +483,20 @@ begin
    siz:=opsize
    siz:=opsize
   else
   else
    begin
    begin
-     if (Ops=2) and (operands[1]^.opr.typ=OPR_REGISTER) then
-      siz:=operands[1]^.size
+     if (Ops=2) and (operands[1].opr.typ=OPR_REGISTER) then
+      siz:=operands[1].size
      else
      else
-      siz:=operands[Ops]^.size;
+      siz:=operands[Ops].size;
      { MOVD should be of size S_LQ or S_QL, but these do not exist PM }
      { MOVD should be of size S_LQ or S_QL, but these do not exist PM }
-     if (ops=2) and (operands[1]^.size<>S_NO) and
-        (operands[2]^.size<>S_NO) and (operands[1]^.size<>operands[2]^.size) then
+     if (ops=2) and (operands[1].size<>S_NO) and
+        (operands[2].size<>S_NO) and (operands[1].size<>operands[2].size) then
        siz:=S_NO;
        siz:=S_NO;
    end;
    end;
 
 
    if ((opcode=A_MOVD)or
    if ((opcode=A_MOVD)or
        (opcode=A_CVTSI2SS)) and
        (opcode=A_CVTSI2SS)) and
-      ((operands[1]^.size=S_NO) or
-       (operands[2]^.size=S_NO)) then
+      ((operands[1].size=S_NO) or
+       (operands[2].size=S_NO)) then
      siz:=S_NO;
      siz:=S_NO;
    { NASM does not support FADD without args
    { NASM does not support FADD without args
      as alias of FADDP
      as alias of FADDP
@@ -558,14 +556,14 @@ begin
   {$endif INTELOP}
   {$endif INTELOP}
 {$endif ATTOP}
 {$endif ATTOP}
        ops:=2;
        ops:=2;
-       operands[1]^.opr.typ:=OPR_REGISTER;
-       operands[2]^.opr.typ:=OPR_REGISTER;
-       operands[1]^.opr.reg:=R_ST;
-       operands[2]^.opr.reg:=R_ST1;
+       operands[1].opr.typ:=OPR_REGISTER;
+       operands[2].opr.typ:=OPR_REGISTER;
+       operands[1].opr.reg:=R_ST;
+       operands[2].opr.reg:=R_ST1;
      end;
      end;
   if (ops=1) and
   if (ops=1) and
-      ((operands[1]^.opr.typ=OPR_REGISTER) and
-      (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
+      ((operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg in [R_ST1..R_ST7])) and
       ((opcode=A_FSUBP) or
       ((opcode=A_FSUBP) or
       (opcode=A_FSUBRP) or
       (opcode=A_FSUBRP) or
       (opcode=A_FDIVP) or
       (opcode=A_FDIVP) or
@@ -583,14 +581,14 @@ begin
   {$endif INTELOP}
   {$endif INTELOP}
 {$endif ATTOP}
 {$endif ATTOP}
        ops:=2;
        ops:=2;
-       operands[2]^.opr.typ:=OPR_REGISTER;
-       operands[2]^.opr.reg:=operands[1]^.opr.reg;
-       operands[1]^.opr.reg:=R_ST;
+       operands[2].opr.typ:=OPR_REGISTER;
+       operands[2].opr.reg:=operands[1].opr.reg;
+       operands[1].opr.reg:=R_ST;
      end;
      end;
 
 
   if (ops=1) and
   if (ops=1) and
-      ((operands[1]^.opr.typ=OPR_REGISTER) and
-      (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
+      ((operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg in [R_ST1..R_ST7])) and
       ((opcode=A_FSUB) or
       ((opcode=A_FSUB) or
       (opcode=A_FSUBR) or
       (opcode=A_FSUBR) or
       (opcode=A_FDIV) or
       (opcode=A_FDIV) or
@@ -608,8 +606,8 @@ begin
   {$endif INTELOP}
   {$endif INTELOP}
 {$endif ATTOP}
 {$endif ATTOP}
        ops:=2;
        ops:=2;
-       operands[2]^.opr.typ:=OPR_REGISTER;
-       operands[2]^.opr.reg:=R_ST;
+       operands[2].opr.typ:=OPR_REGISTER;
+       operands[2].opr.reg:=R_ST;
      end;
      end;
 
 
    { I tried to convince Linus Torwald to add
    { I tried to convince Linus Torwald to add
@@ -630,20 +628,20 @@ begin
   ai.Ops:=Ops;
   ai.Ops:=Ops;
   for i:=1to Ops do
   for i:=1to Ops do
    begin
    begin
-     case operands[i]^.opr.typ of
+     case operands[i].opr.typ of
        OPR_CONSTANT :
        OPR_CONSTANT :
-         ai.loadconst(i-1,operands[i]^.opr.val);
+         ai.loadconst(i-1,operands[i].opr.val);
        OPR_REGISTER:
        OPR_REGISTER:
-         ai.loadreg(i-1,operands[i]^.opr.reg);
+         ai.loadreg(i-1,operands[i].opr.reg);
        OPR_SYMBOL:
        OPR_SYMBOL:
-         ai.loadsymbol(i-1,operands[i]^.opr.symbol,operands[i]^.opr.symofs);
+         ai.loadsymbol(i-1,operands[i].opr.symbol,operands[i].opr.symofs);
        OPR_REFERENCE:
        OPR_REFERENCE:
          begin
          begin
-           ai.loadref(i-1,newreference(operands[i]^.opr.ref));
-           if operands[i]^.size<>S_NO then
+           ai.loadref(i-1,newreference(operands[i].opr.ref));
+           if operands[i].size<>S_NO then
              begin
              begin
                asize:=0;
                asize:=0;
-               case operands[i]^.size of
+               case operands[i].size of
                    S_B :
                    S_B :
                      asize:=OT_BITS8;
                      asize:=OT_BITS8;
                    S_W, S_IS :
                    S_W, S_IS :
@@ -688,7 +686,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2001-04-05 21:33:45  peter
+  Revision 1.9  2001-04-13 01:22:19  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.8  2001/04/05 21:33:45  peter
     * movd and opsize fix merged
     * movd and opsize fix merged
 
 
   Revision 1.7  2001/03/05 21:49:44  peter
   Revision 1.7  2001/03/05 21:49:44  peter

+ 48 - 45
compiler/i386/ra386att.pas

@@ -36,7 +36,7 @@ Implementation
 
 
     uses
     uses
        { common }
        { common }
-       cutils,cobjects,
+       cutils,cclasses,
        { global }
        { global }
        globtype,globals,verbose,
        globtype,globals,verbose,
        systems,
        systems,
@@ -108,7 +108,7 @@ var
   actasmregister : tregister;
   actasmregister : tregister;
   actopsize      : topsize;
   actopsize      : topsize;
   actcondition   : tasmcond;
   actcondition   : tasmcond;
-  iasmops        : Pdictionary;
+  iasmops        : tdictionary;
   iasmregs       : ^reg2strtable;
   iasmregs       : ^reg2strtable;
 
 
 
 
@@ -117,16 +117,16 @@ Procedure SetupTables;
 var
 var
   i : tasmop;
   i : tasmop;
   j : tregister;
   j : tregister;
-  str2opentry: pstr2opentry;
+  str2opentry: tstr2opentry;
 Begin
 Begin
   { opcodes }
   { opcodes }
-  new(iasmops,init);
-  iasmops^.delete_doubles:=true;
+  iasmops:=TDictionary.Create;
+  iasmops.delete_doubles:=true;
   for i:=firstop to lastop do
   for i:=firstop to lastop do
     begin
     begin
-      new(str2opentry,initname(upper(att_op2str[i])));
-      str2opentry^.op:=i;
-      iasmops^.insert(str2opentry);
+      str2opentry:=tstr2opentry.createname(upper(att_op2str[i]));
+      str2opentry.op:=i;
+      iasmops.insert(str2opentry);
     end;
     end;
   { registers }
   { registers }
   new(iasmregs);
   new(iasmregs);
@@ -156,7 +156,7 @@ const
     S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
     S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
   );
   );
 var
 var
-  str2opentry: pstr2opentry;
+  str2opentry: tstr2opentry;
   cond : string[4];
   cond : string[4];
   cnd  : tasmcond;
   cnd  : tasmcond;
   len,
   len,
@@ -178,10 +178,10 @@ Begin
         { here we search the entire table... }
         { here we search the entire table... }
         str2opentry:=nil;
         str2opentry:=nil;
         if {(length(s)>0) and} (len>0) then
         if {(length(s)>0) and} (len>0) then
-          str2opentry:=pstr2opentry(iasmops^.search(copy(s,1,len)));
+          str2opentry:=tstr2opentry(iasmops.search(copy(s,1,len)));
         if assigned(str2opentry) then
         if assigned(str2opentry) then
           begin
           begin
-            actopcode:=str2opentry^.op;
+            actopcode:=str2opentry.op;
             if att_needsuffix[actopcode]=attsufFPU then
             if att_needsuffix[actopcode]=attsufFPU then
              actopsize:=att_sizefpusuffix[sufidx]
              actopsize:=att_sizefpusuffix[sufidx]
             else if att_needsuffix[actopcode]=attsufFPUint then
             else if att_needsuffix[actopcode]=attsufFPUint then
@@ -818,9 +818,9 @@ var
   parenlevel,l,k : longint;
   parenlevel,l,k : longint;
   errorflag : boolean;
   errorflag : boolean;
   prevtok : tasmtoken;
   prevtok : tasmtoken;
-  sym : psym;
-  srsymtable : psymtable;
-  hl  : PAsmLabel;
+  sym : tsym;
+  srsymtable : tsymtable;
+  hl  : tasmlabel;
 Begin
 Begin
   asmsym:='';
   asmsym:='';
   value:=0;
   value:=0;
@@ -952,13 +952,13 @@ Begin
                 searchsym(tempstr,sym,srsymtable);
                 searchsym(tempstr,sym,srsymtable);
                 if assigned(sym) then
                 if assigned(sym) then
                  begin
                  begin
-                   case sym^.typ of
+                   case sym.typ of
                      varsym :
                      varsym :
-                       l:=pvarsym(sym)^.getsize;
+                       l:=tvarsym(sym).getsize;
                      typedconstsym :
                      typedconstsym :
-                       l:=ptypedconstsym(sym)^.getsize;
+                       l:=ttypedconstsym(sym).getsize;
                      typesym :
                      typesym :
-                       l:=ptypesym(sym)^.restype.def^.size;
+                       l:=ttypesym(sym).restype.def.size;
                      else
                      else
                        Message(asmr_e_wrong_sym_type);
                        Message(asmr_e_wrong_sym_type);
                    end;
                    end;
@@ -986,30 +986,30 @@ Begin
              if is_locallabel(tempstr) then
              if is_locallabel(tempstr) then
               begin
               begin
                 CreateLocalLabel(tempstr,hl,false);
                 CreateLocalLabel(tempstr,hl,false);
-                hs:=hl^.name
+                hs:=hl.name
               end
               end
              else
              else
               if SearchLabel(tempstr,hl,false) then
               if SearchLabel(tempstr,hl,false) then
-               hs:=hl^.name
+               hs:=hl.name
              else
              else
               begin
               begin
                 searchsym(tempstr,sym,srsymtable);
                 searchsym(tempstr,sym,srsymtable);
                 if assigned(sym) then
                 if assigned(sym) then
                  begin
                  begin
-                   case sym^.typ of
+                   case sym.typ of
                      varsym :
                      varsym :
                        begin
                        begin
-                         if sym^.owner^.symtabletype in [localsymtable,parasymtable] then
+                         if sym.owner.symtabletype in [localsymtable,parasymtable] then
                           Message(asmr_e_no_local_or_para_allowed);
                           Message(asmr_e_no_local_or_para_allowed);
-                         hs:=pvarsym(sym)^.mangledname;
+                         hs:=tvarsym(sym).mangledname;
                        end;
                        end;
                      typedconstsym :
                      typedconstsym :
-                       hs:=ptypedconstsym(sym)^.mangledname;
+                       hs:=ttypedconstsym(sym).mangledname;
                      procsym :
                      procsym :
-                       hs:=pprocsym(sym)^.mangledname;
+                       hs:=tprocsym(sym).mangledname;
                      typesym :
                      typesym :
                        begin
                        begin
-                         if not(ptypesym(sym)^.restype.def^.deftype in [recorddef,objectdef]) then
+                         if not(ttypesym(sym).restype.def.deftype in [recorddef,objectdef]) then
                           Message(asmr_e_wrong_sym_type);
                           Message(asmr_e_wrong_sym_type);
                        end;
                        end;
                      else
                      else
@@ -1095,9 +1095,8 @@ end;
 ****************************************************************************}
 ****************************************************************************}
 
 
 type
 type
-  P386ATTOperand=^T386ATTOperand;
-  T386ATTOperand=object(T386Operand)
-    Procedure BuildOperand;virtual;
+  T386ATTOperand=class(T386Operand)
+    Procedure BuildOperand;override;
   private
   private
     Procedure BuildReference;
     Procedure BuildReference;
     Procedure BuildConstant;
     Procedure BuildConstant;
@@ -1278,7 +1277,7 @@ var
   expr : string;
   expr : string;
   l,k : longint;
   l,k : longint;
 
 
-  procedure AddLabelOperand(hl:pasmlabel);
+  procedure AddLabelOperand(hl:tasmlabel);
   begin
   begin
     if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and
     if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and
        is_calljmp(actopcode) then
        is_calljmp(actopcode) then
@@ -1387,7 +1386,7 @@ var
 
 
 var
 var
   tempreg : tregister;
   tempreg : tregister;
-  hl      : PAsmLabel;
+  hl      : tasmlabel;
 Begin
 Begin
   expr:='';
   expr:='';
   case actasmtoken of
   case actasmtoken of
@@ -1598,10 +1597,9 @@ end;
 *****************************************************************************}
 *****************************************************************************}
 
 
 type
 type
-  P386AttInstruction=^T386AttInstruction;
-  T386AttInstruction=object(T386Instruction)
-    procedure InitOperands;virtual;
-    procedure BuildOpcode;virtual;
+  T386AttInstruction=class(T386Instruction)
+    procedure InitOperands;override;
+    procedure BuildOpcode;override;
   end;
   end;
 
 
 procedure T386AttInstruction.InitOperands;
 procedure T386AttInstruction.InitOperands;
@@ -1609,7 +1607,7 @@ var
   i : longint;
   i : longint;
 begin
 begin
   for i:=1to 3 do
   for i:=1to 3 do
-   Operands[i]:=new(P386AttOperand,Init);
+   Operands[i]:=T386AttOperand.Create;
 end;
 end;
 
 
 
 
@@ -1689,7 +1687,7 @@ Begin
           break;
           break;
         end;
         end;
     else
     else
-      Operands[operandnum]^.BuildOperand;
+      Operands[operandnum].BuildOperand;
     end; { end case }
     end; { end case }
   until false;
   until false;
   Ops:=operandnum;
   Ops:=operandnum;
@@ -1866,7 +1864,7 @@ end;
 
 
 Function Assemble: tnode;
 Function Assemble: tnode;
 Var
 Var
-  hl         : PAsmLabel;
+  hl         : tasmlabel;
   commname   : string;
   commname   : string;
   lastsec    : tsection;
   lastsec    : tsection;
   l1,l2      : longint;
   l1,l2      : longint;
@@ -1887,7 +1885,7 @@ Begin
   curlist:=TAAsmoutput.Create;
   curlist:=TAAsmoutput.Create;
   lastsec:=sec_code;
   lastsec:=sec_code;
   { setup label linked list }
   { setup label linked list }
-  new(LocalLabelList,Init);
+  LocalLabelList:=TLocalLabelList.Create;
   { start tokenizer }
   { start tokenizer }
   c:=current_scanner^.asmgetchar;
   c:=current_scanner^.asmgetchar;
   gettoken;
   gettoken;
@@ -2057,13 +2055,13 @@ Begin
         end;
         end;
       AS_OPCODE:
       AS_OPCODE:
         Begin
         Begin
-          instr.init;
+          instr:=T386ATTInstruction.Create;
           instr.BuildOpcode;
           instr.BuildOpcode;
           instr.AddReferenceSizes;
           instr.AddReferenceSizes;
           instr.SetInstructionOpsize;
           instr.SetInstructionOpsize;
           instr.CheckOperandSizes;
           instr.CheckOperandSizes;
           instr.ConcatInstruction(curlist);
           instr.ConcatInstruction(curlist);
-          instr.done;
+          instr.Free;
         end;
         end;
 
 
       AS_SEPARATOR:
       AS_SEPARATOR:
@@ -2084,8 +2082,8 @@ Begin
     end;
     end;
   until false;
   until false;
   { Check LocalLabelList }
   { Check LocalLabelList }
-  LocalLabelList^.CheckEmitted;
-  dispose(LocalLabelList,Done);
+  LocalLabelList.CheckEmitted;
+  LocalLabelList.Free;
   { are we back in the code section? }
   { are we back in the code section? }
   if lastsec<>sec_code then
   if lastsec<>sec_code then
    begin
    begin
@@ -2109,7 +2107,7 @@ procedure ra386att_exit;
 begin
 begin
   exitproc:=old_exit;
   exitproc:=old_exit;
   if assigned(iasmops) then
   if assigned(iasmops) then
-    dispose(iasmops,done);
+    iasmops.Free;
   if assigned(iasmregs) then
   if assigned(iasmregs) then
     dispose(iasmregs);
     dispose(iasmregs);
 end;
 end;
@@ -2121,7 +2119,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2001-03-25 12:29:45  peter
+  Revision 1.9  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.8  2001/03/25 12:29:45  peter
     * offset_fixup fixes (merged)
     * offset_fixup fixes (merged)
 
 
   Revision 1.7  2001/03/11 22:58:52  peter
   Revision 1.7  2001/03/11 22:58:52  peter

+ 40 - 36
compiler/i386/ra386dir.pas

@@ -42,7 +42,7 @@ interface
        { aasm }
        { aasm }
        cpubase,aasm,
        cpubase,aasm,
        { symtable }
        { symtable }
-       symconst,symbase,symtype,symdef,symsym,symtable,types,
+       symconst,symbase,symtype,symsym,symtable,types,
        { pass 1 }
        { pass 1 }
        nbas,
        nbas,
        { parser }
        { parser }
@@ -62,8 +62,8 @@ interface
          retstr,s,hs : string;
          retstr,s,hs : string;
          c : char;
          c : char;
          ende : boolean;
          ende : boolean;
-         srsym,sym : psym;
-         srsymtable : psymtable;
+         srsym,sym : tsym;
+         srsymtable : tsymtable;
          code : TAAsmoutput;
          code : TAAsmoutput;
          i,l : longint;
          i,l : longint;
 
 
@@ -124,10 +124,10 @@ interface
                               begin
                               begin
                                 searchsym(upper(hs),srsym,srsymtable);
                                 searchsym(upper(hs),srsym,srsymtable);
                                 if srsym<>nil then
                                 if srsym<>nil then
-                                  if (srsym^.typ = labelsym) then
+                                  if (srsym.typ = labelsym) then
                                     Begin
                                     Begin
-                                       hs:=plabelsym(srsym)^.lab^.name;
-                                       plabelsym(srsym)^.lab^.is_set:=true;
+                                       hs:=tlabelsym(srsym).lab.name;
+                                       tlabelsym(srsym).lab.is_set:=true;
                                     end
                                     end
                                   else
                                   else
                                     Message(asmr_w_using_defined_as_local);
                                     Message(asmr_w_using_defined_as_local);
@@ -149,56 +149,56 @@ interface
                                    (s[length(s)]<>'$') and
                                    (s[length(s)]<>'$') and
                                    ((s[length(s)]<>'0') or (hs[1]<>'x')) then
                                    ((s[length(s)]<>'0') or (hs[1]<>'x')) then
                                    begin
                                    begin
-                                      if assigned(aktprocsym^.definition^.localst) and
+                                      if assigned(aktprocsym.definition.localst) and
                                          (lexlevel >= normal_function_level) then
                                          (lexlevel >= normal_function_level) then
-                                        sym:=psym(aktprocsym^.definition^.localst^.search(upper(hs)))
+                                        sym:=tsym(aktprocsym.definition.localst.search(upper(hs)))
                                       else
                                       else
                                         sym:=nil;
                                         sym:=nil;
                                       if assigned(sym) then
                                       if assigned(sym) then
                                         begin
                                         begin
-                                           if (sym^.typ = labelsym) then
+                                           if (sym.typ = labelsym) then
                                              Begin
                                              Begin
-                                                hs:=plabelsym(sym)^.lab^.name;
+                                                hs:=tlabelsym(sym).lab.name;
                                              end
                                              end
-                                           else if sym^.typ=varsym then
+                                           else if sym.typ=varsym then
                                              begin
                                              begin
                                              {variables set are after a comma }
                                              {variables set are after a comma }
                                              {like in movl %eax,I }
                                              {like in movl %eax,I }
                                              if pos(',',s) > 0 then
                                              if pos(',',s) > 0 then
-                                               pvarsym(sym)^.varstate:=vs_used
+                                               tvarsym(sym).varstate:=vs_used
                                              else
                                              else
-                                             if (pos('MOV',upper(s)) > 0) and (pvarsym(sym)^.varstate=vs_declared) then
+                                             if (pos('MOV',upper(s)) > 0) and (tvarsym(sym).varstate=vs_declared) then
                                               Message1(sym_n_uninitialized_local_variable,hs);
                                               Message1(sym_n_uninitialized_local_variable,hs);
-                                             if (vo_is_external in pvarsym(sym)^.varoptions) then
-                                               hs:=pvarsym(sym)^.mangledname
+                                             if (vo_is_external in tvarsym(sym).varoptions) then
+                                               hs:=tvarsym(sym).mangledname
                                              else
                                              else
-                                               hs:='-'+tostr(pvarsym(sym)^.address)+
+                                               hs:='-'+tostr(tvarsym(sym).address)+
                                                    '('+att_reg2str[procinfo^.framepointer]+')';
                                                    '('+att_reg2str[procinfo^.framepointer]+')';
                                              end
                                              end
                                            else
                                            else
                                            { call to local function }
                                            { call to local function }
-                                           if (sym^.typ=procsym) and ((pos('CALL',upper(s))>0) or
+                                           if (sym.typ=procsym) and ((pos('CALL',upper(s))>0) or
                                               (pos('LEA',upper(s))>0)) then
                                               (pos('LEA',upper(s))>0)) then
                                              begin
                                              begin
-                                                hs:=pprocsym(sym)^.definition^.mangledname;
+                                                hs:=tprocsym(sym).definition.mangledname;
                                              end;
                                              end;
                                         end
                                         end
                                       else
                                       else
                                         begin
                                         begin
-                                           if assigned(aktprocsym^.definition^.parast) then
-                                             sym:=psym(aktprocsym^.definition^.parast^.search(upper(hs)))
+                                           if assigned(aktprocsym.definition.parast) then
+                                             sym:=tsym(aktprocsym.definition.parast.search(upper(hs)))
                                            else
                                            else
                                              sym:=nil;
                                              sym:=nil;
                                            if assigned(sym) then
                                            if assigned(sym) then
                                              begin
                                              begin
-                                                if sym^.typ=varsym then
+                                                if sym.typ=varsym then
                                                   begin
                                                   begin
-                                                     l:=pvarsym(sym)^.address;
+                                                     l:=tvarsym(sym).address;
                                                      { set offset }
                                                      { set offset }
-                                                     inc(l,aktprocsym^.definition^.parast^.address_fixup);
+                                                     inc(l,aktprocsym.definition.parast.address_fixup);
                                                      hs:=tostr(l)+'('+att_reg2str[procinfo^.framepointer]+')';
                                                      hs:=tostr(l)+'('+att_reg2str[procinfo^.framepointer]+')';
                                                      if pos(',',s) > 0 then
                                                      if pos(',',s) > 0 then
-                                                       pvarsym(sym)^.varstate:=vs_used;
+                                                       tvarsym(sym).varstate:=vs_used;
                                                   end;
                                                   end;
                                              end
                                              end
                                       { I added that but it creates a problem in line.ppi
                                       { I added that but it creates a problem in line.ppi
@@ -210,24 +210,23 @@ interface
                                         begin
                                         begin
 {$ifndef IGNOREGLOBALVAR}
 {$ifndef IGNOREGLOBALVAR}
                                            searchsym(upper(hs),sym,srsymtable);
                                            searchsym(upper(hs),sym,srsymtable);
-                                           if assigned(sym) and (sym^.owner^.symtabletype in [unitsymtable,
-                                             globalsymtable,staticsymtable]) then
+                                           if assigned(sym) and (sym.owner.symtabletype in [globalsymtable,staticsymtable]) then
                                              begin
                                              begin
-                                                if (sym^.typ = varsym) or (sym^.typ = typedconstsym) then
+                                                if (sym.typ = varsym) or (sym.typ = typedconstsym) then
                                                   begin
                                                   begin
-                                                     Message2(asmr_h_direct_global_to_mangled,hs,sym^.mangledname);
-                                                     hs:=sym^.mangledname;
-                                                     if sym^.typ=varsym then
-                                                       inc(pvarsym(sym)^.refs);
+                                                     Message2(asmr_h_direct_global_to_mangled,hs,sym.mangledname);
+                                                     hs:=sym.mangledname;
+                                                     if sym.typ=varsym then
+                                                       inc(tvarsym(sym).refs);
                                                   end;
                                                   end;
                                                 { procs can be called or the address can be loaded }
                                                 { procs can be called or the address can be loaded }
-                                                if (sym^.typ=procsym) and
+                                                if (sym.typ=procsym) and
                                                    ((pos('CALL',upper(s))>0) or (pos('LEA',upper(s))>0)) then
                                                    ((pos('CALL',upper(s))>0) or (pos('LEA',upper(s))>0)) then
                                                   begin
                                                   begin
-                                                     if assigned(pprocsym(sym)^.definition^.nextoverloaded) then
+                                                     if assigned(tprocsym(sym).definition.nextoverloaded) then
                                                        Message1(asmr_w_direct_global_is_overloaded_func,hs);
                                                        Message1(asmr_w_direct_global_is_overloaded_func,hs);
-                                                     Message2(asmr_h_direct_global_to_mangled,hs,sym^.mangledname);
-                                                     hs:=sym^.mangledname;
+                                                     Message2(asmr_h_direct_global_to_mangled,hs,sym.mangledname);
+                                                     hs:=sym.mangledname;
                                                   end;
                                                   end;
                                              end
                                              end
                                            else
                                            else
@@ -288,7 +287,12 @@ interface
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-04-02 21:20:40  peter
+  Revision 1.7  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2001/04/02 21:20:40  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.5  2001/03/11 22:58:52  peter
   Revision 1.5  2001/03/11 22:58:52  peter

+ 54 - 51
compiler/i386/ra386int.pas

@@ -36,7 +36,7 @@ Implementation
 
 
     uses
     uses
        { common }
        { common }
-       cutils,cobjects,
+       cutils,cclasses,
        { global }
        { global }
        globtype,globals,verbose,
        globtype,globals,verbose,
        systems,
        systems,
@@ -123,7 +123,7 @@ var
   actopcode      : tasmop;
   actopcode      : tasmop;
   actopsize      : topsize;
   actopsize      : topsize;
   actcondition   : tasmcond;
   actcondition   : tasmcond;
-  iasmops        : Pdictionary;
+  iasmops        : tdictionary;
   iasmregs       : ^reg2strtable;
   iasmregs       : ^reg2strtable;
 
 
 
 
@@ -132,16 +132,16 @@ Procedure SetupTables;
 var
 var
   i : tasmop;
   i : tasmop;
   j : tregister;
   j : tregister;
-  str2opentry: pstr2opentry;
+  str2opentry: tstr2opentry;
 Begin
 Begin
   { opcodes }
   { opcodes }
-  new(iasmops,init);
-  iasmops^.delete_doubles:=true;
+  iasmops:=tdictionary.create;
+  iasmops.delete_doubles:=true;
   for i:=firstop to lastop do
   for i:=firstop to lastop do
     begin
     begin
-      new(str2opentry,initname(upper(int_op2str[i])));
-      str2opentry^.op:=i;
-      iasmops^.insert(str2opentry);
+      str2opentry:=tstr2opentry.createname(upper(int_op2str[i]));
+      str2opentry.op:=i;
+      iasmops.insert(str2opentry);
     end;
     end;
   { registers }
   { registers }
   new(iasmregs);
   new(iasmregs);
@@ -157,7 +157,7 @@ end;
 
 
    function is_asmopcode(const s: string):boolean;
    function is_asmopcode(const s: string):boolean;
    var
    var
-     str2opentry: pstr2opentry;
+     str2opentry: tstr2opentry;
      cond : string[4];
      cond : string[4];
      cnd : tasmcond;
      cnd : tasmcond;
      j: longint;
      j: longint;
@@ -168,10 +168,10 @@ end;
      actcondition:=C_None;
      actcondition:=C_None;
      actopsize:=S_NO;
      actopsize:=S_NO;
 
 
-     str2opentry:=pstr2opentry(iasmops^.search(s));
+     str2opentry:=tstr2opentry(iasmops.search(s));
      if assigned(str2opentry) then
      if assigned(str2opentry) then
        begin
        begin
-         actopcode:=str2opentry^.op;
+         actopcode:=str2opentry.op;
          actasmtoken:=AS_OPCODE;
          actasmtoken:=AS_OPCODE;
          is_asmopcode:=TRUE;
          is_asmopcode:=TRUE;
          exit;
          exit;
@@ -704,9 +704,9 @@ var
   parenlevel,l,k : longint;
   parenlevel,l,k : longint;
   errorflag : boolean;
   errorflag : boolean;
   prevtok : tasmtoken;
   prevtok : tasmtoken;
-  hl : PAsmLabel;
-  sym : psym;
-  srsymtable : psymtable;
+  hl : tasmlabel;
+  sym : tsym;
+  srsymtable : tsymtable;
 Begin
 Begin
   { reset }
   { reset }
   value:=0;
   value:=0;
@@ -817,13 +817,13 @@ Begin
                 searchsym(tempstr,sym,srsymtable);
                 searchsym(tempstr,sym,srsymtable);
                 if assigned(sym) then
                 if assigned(sym) then
                  begin
                  begin
-                   case sym^.typ of
+                   case sym.typ of
                      varsym :
                      varsym :
-                       l:=pvarsym(sym)^.getsize;
+                       l:=tvarsym(sym).getsize;
                      typedconstsym :
                      typedconstsym :
-                       l:=ptypedconstsym(sym)^.getsize;
+                       l:=ttypedconstsym(sym).getsize;
                      typesym :
                      typesym :
-                       l:=ptypesym(sym)^.restype.def^.size;
+                       l:=ttypesym(sym).restype.def.size;
                      else
                      else
                        Message(asmr_e_wrong_sym_type);
                        Message(asmr_e_wrong_sym_type);
                    end;
                    end;
@@ -872,30 +872,30 @@ Begin
              if is_locallabel(tempstr) then
              if is_locallabel(tempstr) then
               begin
               begin
                 CreateLocalLabel(tempstr,hl,false);
                 CreateLocalLabel(tempstr,hl,false);
-                hs:=hl^.name
+                hs:=hl.name
               end
               end
              else
              else
               if SearchLabel(tempstr,hl,false) then
               if SearchLabel(tempstr,hl,false) then
-               hs:=hl^.name
+               hs:=hl.name
              else
              else
               begin
               begin
                 searchsym(tempstr,sym,srsymtable);
                 searchsym(tempstr,sym,srsymtable);
                 if assigned(sym) then
                 if assigned(sym) then
                  begin
                  begin
-                   case sym^.typ of
+                   case sym.typ of
                      varsym :
                      varsym :
                        begin
                        begin
-                         if sym^.owner^.symtabletype in [localsymtable,parasymtable] then
+                         if sym.owner.symtabletype in [localsymtable,parasymtable] then
                           Message(asmr_e_no_local_or_para_allowed);
                           Message(asmr_e_no_local_or_para_allowed);
-                         hs:=pvarsym(sym)^.mangledname;
+                         hs:=tvarsym(sym).mangledname;
                        end;
                        end;
                      typedconstsym :
                      typedconstsym :
-                       hs:=ptypedconstsym(sym)^.mangledname;
+                       hs:=ttypedconstsym(sym).mangledname;
                      procsym :
                      procsym :
-                       hs:=pprocsym(sym)^.mangledname;
+                       hs:=tprocsym(sym).mangledname;
                      typesym :
                      typesym :
                        begin
                        begin
-                         if not(ptypesym(sym)^.restype.def^.deftype in [recorddef,objectdef]) then
+                         if not(ttypesym(sym).restype.def.deftype in [recorddef,objectdef]) then
                           Message(asmr_e_wrong_sym_type);
                           Message(asmr_e_wrong_sym_type);
                        end;
                        end;
                      else
                      else
@@ -997,9 +997,8 @@ end;
 ****************************************************************************}
 ****************************************************************************}
 
 
 type
 type
-  P386IntelOperand=^T386IntelOperand;
-  T386IntelOperand=object(T386Operand)
-    Procedure BuildOperand;virtual;
+  T386IntelOperand=class(T386Operand)
+    Procedure BuildOperand;override;
   private
   private
     Procedure BuildReference;
     Procedure BuildReference;
     Procedure BuildConstant;
     Procedure BuildConstant;
@@ -1312,9 +1311,9 @@ var
   expr    : string;
   expr    : string;
   tempreg : tregister;
   tempreg : tregister;
   l       : longint;
   l       : longint;
-  hl      : PAsmLabel;
+  hl      : tasmlabel;
 
 
-  procedure AddLabelOperand(hl:pasmlabel);
+  procedure AddLabelOperand(hl:tasmlabel);
   begin
   begin
     if is_calljmp(actopcode) then
     if is_calljmp(actopcode) then
      begin
      begin
@@ -1587,10 +1586,9 @@ end;
 *****************************************************************************}
 *****************************************************************************}
 
 
 type
 type
-  P386IntelInstruction=^T386IntelInstruction;
-  T386IntelInstruction=object(T386Instruction)
-    procedure InitOperands;virtual;
-    procedure BuildOpcode;virtual;
+  T386IntelInstruction=class(T386Instruction)
+    procedure InitOperands;override;
+    procedure BuildOpcode;override;
   end;
   end;
 
 
 procedure T386IntelInstruction.InitOperands;
 procedure T386IntelInstruction.InitOperands;
@@ -1598,7 +1596,7 @@ var
   i : longint;
   i : longint;
 begin
 begin
   for i:=1 to 3 do
   for i:=1 to 3 do
-   Operands[i]:=new(P386IntelOperand,Init);
+   Operands[i]:=T386IntelOperand.Create;
 end;
 end;
 
 
 
 
@@ -1716,11 +1714,11 @@ Begin
           if actasmtoken=AS_PTR then
           if actasmtoken=AS_PTR then
            begin
            begin
              Consume(AS_PTR);
              Consume(AS_PTR);
-             Operands[operandnum]^.InitRef;
+             Operands[operandnum].InitRef;
            end;
            end;
-          Operands[operandnum]^.BuildOperand;
+          Operands[operandnum].BuildOperand;
           { now set the size which was specified by the override }
           { now set the size which was specified by the override }
-          Operands[operandnum]^.size:=size;
+          Operands[operandnum].size:=size;
         end;
         end;
 
 
       { Type specifier }
       { Type specifier }
@@ -1741,13 +1739,13 @@ Begin
           if actasmtoken=AS_PTR then
           if actasmtoken=AS_PTR then
            begin
            begin
              Consume(AS_PTR);
              Consume(AS_PTR);
-             Operands[operandnum]^.InitRef;
+             Operands[operandnum].InitRef;
            end;
            end;
-          Operands[operandnum]^.BuildOperand;
+          Operands[operandnum].BuildOperand;
         end;
         end;
 
 
       else
       else
-        Operands[operandnum]^.BuildOperand;
+        Operands[operandnum].BuildOperand;
     end; { end case }
     end; { end case }
   until false;
   until false;
   Ops:=operandnum;
   Ops:=operandnum;
@@ -1823,7 +1821,7 @@ end;
 
 
 Function Assemble: tnode;
 Function Assemble: tnode;
 Var
 Var
-  hl : PAsmLabel;
+  hl : tasmlabel;
   instr : T386IntelInstruction;
   instr : T386IntelInstruction;
 Begin
 Begin
   Message1(asmr_d_start_reading,'intel');
   Message1(asmr_d_start_reading,'intel');
@@ -1841,7 +1839,7 @@ Begin
    end;
    end;
   curlist:=TAAsmoutput.Create;
   curlist:=TAAsmoutput.Create;
   { setup label linked list }
   { setup label linked list }
-  new(LocalLabelList,Init);
+  LocalLabelList:=TLocalLabelList.Create;
   { start tokenizer }
   { start tokenizer }
   c:=current_scanner^.asmgetchar;
   c:=current_scanner^.asmgetchar;
   gettoken;
   gettoken;
@@ -1890,17 +1888,17 @@ Begin
 
 
       AS_OPCODE :
       AS_OPCODE :
         Begin
         Begin
-          instr.init;
+          instr:=T386IntelInstruction.Create;
           instr.BuildOpcode;
           instr.BuildOpcode;
           { We need AT&T style operands }
           { We need AT&T style operands }
-          instr.SwapOperands;
+          instr.Swatoperands;
           { Must be done with args in ATT order }
           { Must be done with args in ATT order }
           instr.CheckNonCommutativeOpcodes;
           instr.CheckNonCommutativeOpcodes;
           instr.AddReferenceSizes;
           instr.AddReferenceSizes;
           instr.SetInstructionOpsize;
           instr.SetInstructionOpsize;
           instr.CheckOperandSizes;
           instr.CheckOperandSizes;
           instr.ConcatInstruction(curlist);
           instr.ConcatInstruction(curlist);
-          instr.done;
+          instr.Free;
         end;
         end;
 
 
       AS_SEPARATOR :
       AS_SEPARATOR :
@@ -1919,8 +1917,8 @@ Begin
     end; { end case }
     end; { end case }
   until false;
   until false;
   { Check LocalLabelList }
   { Check LocalLabelList }
-  LocalLabelList^.CheckEmitted;
-  dispose(LocalLabelList,Done);
+  LocalLabelList.CheckEmitted;
+  LocalLabelList.Free;
   { Return the list in an asmnode }
   { Return the list in an asmnode }
   assemble:=casmnode.create(curlist);
   assemble:=casmnode.create(curlist);
   Message1(asmr_d_finish_reading,'intel');
   Message1(asmr_d_finish_reading,'intel');
@@ -1938,7 +1936,7 @@ procedure ra386int_exit;
 begin
 begin
   exitproc:=old_exit;
   exitproc:=old_exit;
   if assigned(iasmops) then
   if assigned(iasmops) then
-    dispose(iasmops,done);
+    iasmops.Free;
   if assigned(iasmregs) then
   if assigned(iasmregs) then
     dispose(iasmregs);
     dispose(iasmregs);
 end;
 end;
@@ -1950,7 +1948,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2001-03-25 12:29:45  peter
+  Revision 1.12  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.11  2001/03/25 12:29:45  peter
     * offset_fixup fixes (merged)
     * offset_fixup fixes (merged)
 
 
   Revision 1.10  2001/03/11 22:58:52  peter
   Revision 1.10  2001/03/11 22:58:52  peter

+ 7 - 2
compiler/i386/tgcpu.pas

@@ -27,7 +27,7 @@ unit tgcpu;
 interface
 interface
 
 
     uses
     uses
-       cobjects,globals,
+       globals,
        hcodegen,verbose,aasm,
        hcodegen,verbose,aasm,
        node,
        node,
        cpubase,cpuasm
        cpubase,cpuasm
@@ -674,7 +674,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-12-25 00:07:34  peter
+  Revision 1.4  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.3  2000/12/25 00:07:34  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 7 - 2
compiler/impdef.pas

@@ -23,7 +23,7 @@
 
 
  ****************************************************************************
  ****************************************************************************
 }
 }
-unit impdef;
+unit imtdef;
 
 
 {$ifndef STANDALONE}
 {$ifndef STANDALONE}
   {$i defines.inc}
   {$i defines.inc}
@@ -479,7 +479,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2001-01-13 00:09:21  peter
+  Revision 1.6  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.5  2001/01/13 00:09:21  peter
     * made Pavel O. happy ;)
     * made Pavel O. happy ;)
 
 
   Revision 1.4  2000/11/20 13:58:19  pierre
   Revision 1.4  2000/11/20 13:58:19  pierre

+ 9 - 3
compiler/import.pas

@@ -26,14 +26,15 @@ unit import;
 interface
 interface
 
 
 uses
 uses
-  cutils,cclasses;
+  cutils,cclasses,
+  aasm;
 
 
 type
 type
    timported_item = class(tlinkedlistitem)
    timported_item = class(tlinkedlistitem)
       ordnr  : word;
       ordnr  : word;
       name,
       name,
       func   : pstring;
       func   : pstring;
-      lab    : pointer; { should be plabel, but this gaves problems with circular units }
+      lab    : tasmlabel; { should be plabel, but this gaves problems with circular units }
       is_var : boolean;
       is_var : boolean;
       constructor Create(const n,s : string;o : word);
       constructor Create(const n,s : string;o : word);
       constructor Create_var(const n,s : string);
       constructor Create_var(const n,s : string);
@@ -290,7 +291,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2001-03-06 18:28:02  peter
+  Revision 1.12  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.11  2001/03/06 18:28:02  peter
     * patch from Pavel with a new and much faster DLL Scanner for
     * patch from Pavel with a new and much faster DLL Scanner for
       automatic importing so $linklib works for DLLs. Thanks Pavel!
       automatic importing so $linklib works for DLLs. Thanks Pavel!
 
 

+ 7 - 2
compiler/link.pas

@@ -32,7 +32,7 @@ unit link;
 
 
 interface
 interface
 uses
 uses
-  cobjects,cclasses,
+  cclasses,
   systems,
   systems,
   fmodule;
   fmodule;
 
 
@@ -557,7 +557,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2001-02-26 19:44:52  peter
+  Revision 1.15  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.14  2001/02/26 19:44:52  peter
     * merged generic m68k updates from fixes branch
     * merged generic m68k updates from fixes branch
 
 
   Revision 1.13  2001/02/20 21:41:17  peter
   Revision 1.13  2001/02/20 21:41:17  peter

+ 1 - 1
compiler/mdppc386.bat

@@ -1,2 +1,2 @@
-dcc32 -Di386 -DGDB -Ddelphi -CC -$O+ ppc.dpr %1 %2 %3 %4 %5 %6 %7 %8 %9
+dcc32 -Di386 -DGDB -Ddelphi -CC -Ui386 -Utargets -E. -N. -$O+ ppc.dpr %1 %2 %3 %4 %5 %6 %7 %8 %9
 
 

+ 92 - 76
compiler/nadd.pas

@@ -78,7 +78,7 @@ implementation
       var
       var
          hp,t    : tnode;
          hp,t    : tnode;
          lt,rt   : tnodetype;
          lt,rt   : tnodetype;
-         rd,ld   : pdef;
+         rd,ld   : tdef;
          htype   : ttype;
          htype   : ttype;
          ot      : tnodetype;
          ot      : tnodetype;
          concatstrings : boolean;
          concatstrings : boolean;
@@ -102,27 +102,34 @@ implementation
          if codegenerror then
          if codegenerror then
            exit;
            exit;
 
 
-         { load easier access variables }
-         rd:=right.resulttype.def;
-         ld:=left.resulttype.def;
-         rt:=right.nodetype;
-         lt:=left.nodetype;
-
          { convert array constructors to sets, because there is no other operator
          { convert array constructors to sets, because there is no other operator
            possible for array constructors }
            possible for array constructors }
-         if is_array_constructor(ld) then
+         if is_array_constructor(left.resulttype.def) then
           begin
           begin
             arrayconstructor_to_set(tarrayconstructornode(left));
             arrayconstructor_to_set(tarrayconstructornode(left));
             resulttypepass(left);
             resulttypepass(left);
-            ld:=left.resulttype.def;
           end;
           end;
-         if is_array_constructor(rd) then
+         if is_array_constructor(right.resulttype.def) then
           begin
           begin
             arrayconstructor_to_set(tarrayconstructornode(right));
             arrayconstructor_to_set(tarrayconstructornode(right));
             resulttypepass(right);
             resulttypepass(right);
-            rd:=right.resulttype.def;
           end;
           end;
 
 
+         { is one a real float, then both need to be floats, this
+           need to be done before the constant folding so constant
+           operation on a float and int are also handled }
+         if (right.resulttype.def.deftype=floatdef) or (left.resulttype.def.deftype=floatdef) then
+          begin
+            inserttypeconv(right,pbestrealtype^);
+            inserttypeconv(left,pbestrealtype^);
+          end;
+
+         { load easier access variables }
+         rd:=right.resulttype.def;
+         ld:=left.resulttype.def;
+         rt:=right.nodetype;
+         lt:=left.nodetype;
+
          { both are int constants }
          { both are int constants }
          if (((is_constintnode(left) and is_constintnode(right)) or
          if (((is_constintnode(left) and is_constintnode(right)) or
               (is_constboolnode(left) and is_constboolnode(right) and
               (is_constboolnode(left) and is_constboolnode(right) and
@@ -154,7 +161,7 @@ implementation
                 begin
                 begin
                   { make left const type the biggest, this type will be used
                   { make left const type the biggest, this type will be used
                     for orn,andn,xorn }
                     for orn,andn,xorn }
-                  if rd^.size>ld^.size then
+                  if rd.size>ld.size then
                     inserttypeconv(left,right.resulttype);
                     inserttypeconv(left,right.resulttype);
                 end;
                 end;
 
 
@@ -169,10 +176,10 @@ implementation
                 rv:=tpointerconstnode(right).value;
                 rv:=tpointerconstnode(right).value;
               if (lt = pointerconstn) and
               if (lt = pointerconstn) and
                  (rt <> pointerconstn) then
                  (rt <> pointerconstn) then
-                rv := rv * ppointerdef(left.resulttype.def)^.pointertype.def^.size;
+                rv := rv * tpointerdef(left.resulttype.def).pointertype.def.size;
               if (rt = pointerconstn) and
               if (rt = pointerconstn) and
                  (lt <> pointerconstn) then
                  (lt <> pointerconstn) then
-                lv := lv * ppointerdef(right.resulttype.def)^.pointertype.def^.size;
+                lv := lv * tpointerdef(right.resulttype.def).pointertype.def.size;
               case nodetype of
               case nodetype of
                 addn :
                 addn :
                   if (lt <> pointerconstn) then
                   if (lt <> pointerconstn) then
@@ -445,18 +452,18 @@ implementation
           end
           end
 
 
          { if both are orddefs then check sub types }
          { if both are orddefs then check sub types }
-         else if (ld^.deftype=orddef) and (rd^.deftype=orddef) then
+         else if (ld.deftype=orddef) and (rd.deftype=orddef) then
            begin
            begin
              { 2 booleans? Make them equal to the largest boolean }
              { 2 booleans? Make them equal to the largest boolean }
              if is_boolean(ld) and is_boolean(rd) then
              if is_boolean(ld) and is_boolean(rd) then
               begin
               begin
-                if porddef(left.resulttype.def)^.size>porddef(right.resulttype.def)^.size then
+                if torddef(left.resulttype.def).size>torddef(right.resulttype.def).size then
                  begin
                  begin
                    inserttypeconv(right,left.resulttype);
                    inserttypeconv(right,left.resulttype);
                    ttypeconvnode(right).convtype:=tc_bool_2_int;
                    ttypeconvnode(right).convtype:=tc_bool_2_int;
                    include(right.flags,nf_explizit);
                    include(right.flags,nf_explizit);
                  end
                  end
-                else if porddef(left.resulttype.def)^.size<porddef(right.resulttype.def)^.size then
+                else if torddef(left.resulttype.def).size<torddef(right.resulttype.def).size then
                  begin
                  begin
                    inserttypeconv(left,right.resulttype);
                    inserttypeconv(left,right.resulttype);
                    ttypeconvnode(left).convtype:=tc_bool_2_int;
                    ttypeconvnode(left).convtype:=tc_bool_2_int;
@@ -535,23 +542,23 @@ implementation
                   end;
                   end;
                end
                end
              { is there a signed 64 bit type ? }
              { is there a signed 64 bit type ? }
-             else if ((porddef(rd)^.typ=s64bit) or (porddef(ld)^.typ=s64bit)) then
+             else if ((torddef(rd).typ=s64bit) or (torddef(ld).typ=s64bit)) then
                begin
                begin
-                  if (porddef(ld)^.typ<>s64bit) then
+                  if (torddef(ld).typ<>s64bit) then
                    inserttypeconv(left,cs64bittype);
                    inserttypeconv(left,cs64bittype);
-                  if (porddef(rd)^.typ<>s64bit) then
+                  if (torddef(rd).typ<>s64bit) then
                    inserttypeconv(right,cs64bittype);
                    inserttypeconv(right,cs64bittype);
                end
                end
              { is there a unsigned 64 bit type ? }
              { is there a unsigned 64 bit type ? }
-             else if ((porddef(rd)^.typ=u64bit) or (porddef(ld)^.typ=u64bit)) then
+             else if ((torddef(rd).typ=u64bit) or (torddef(ld).typ=u64bit)) then
                begin
                begin
-                  if (porddef(ld)^.typ<>u64bit) then
+                  if (torddef(ld).typ<>u64bit) then
                    inserttypeconv(left,cu64bittype);
                    inserttypeconv(left,cu64bittype);
-                  if (porddef(rd)^.typ<>u64bit) then
+                  if (torddef(rd).typ<>u64bit) then
                    inserttypeconv(right,cu64bittype);
                    inserttypeconv(right,cu64bittype);
                end
                end
              { is there a cardinal? }
              { is there a cardinal? }
-             else if ((porddef(rd)^.typ=u32bit) or (porddef(ld)^.typ=u32bit)) then
+             else if ((torddef(rd).typ=u32bit) or (torddef(ld).typ=u32bit)) then
                begin
                begin
                  if is_signed(ld) and
                  if is_signed(ld) and
                     { then rd = u32bit }
                     { then rd = u32bit }
@@ -609,16 +616,28 @@ implementation
                end;
                end;
            end
            end
 
 
+         { if both are floatdefs, conversion is already done before constant folding }
+           else if (ld.deftype=floatdef) then
+            begin
+              { already converted }
+            end
+
+         else if (right.resulttype.def.deftype=floatdef) or (left.resulttype.def.deftype=floatdef) then
+          begin
+            inserttypeconv(right,pbestrealtype^);
+            inserttypeconv(left,pbestrealtype^);
+          end
+
          { left side a setdef, must be before string processing,
          { left side a setdef, must be before string processing,
            else array constructor can be seen as array of char (PFV) }
            else array constructor can be seen as array of char (PFV) }
-         else if (ld^.deftype=setdef) then
+         else if (ld.deftype=setdef) then
           begin
           begin
             { trying to add a set element? }
             { trying to add a set element? }
-            if (nodetype=addn) and (rd^.deftype<>setdef) then
+            if (nodetype=addn) and (rd.deftype<>setdef) then
              begin
              begin
                if (rt=setelementn) then
                if (rt=setelementn) then
                 begin
                 begin
-                  if not(is_equal(psetdef(ld)^.elementtype.def,rd)) then
+                  if not(is_equal(tsetdef(ld).elementtype.def,rd)) then
                    CGMessage(type_e_set_element_are_not_comp);
                    CGMessage(type_e_set_element_are_not_comp);
                 end
                 end
                else
                else
@@ -629,18 +648,18 @@ implementation
                if not(nodetype in [addn,subn,symdifn,muln,equaln,unequaln,lten,gten]) then
                if not(nodetype in [addn,subn,symdifn,muln,equaln,unequaln,lten,gten]) then
                 CGMessage(type_e_set_operation_unknown);
                 CGMessage(type_e_set_operation_unknown);
                { right def must be a also be set }
                { right def must be a also be set }
-               if (rd^.deftype<>setdef) or not(is_equal(rd,ld)) then
+               if (rd.deftype<>setdef) or not(is_equal(rd,ld)) then
                 CGMessage(type_e_set_element_are_not_comp);
                 CGMessage(type_e_set_element_are_not_comp);
              end;
              end;
 
 
             { ranges require normsets }
             { ranges require normsets }
-            if (psetdef(ld)^.settype=smallset) and
+            if (tsetdef(ld).settype=smallset) and
                (rt=setelementn) and
                (rt=setelementn) and
                assigned(tsetelementnode(right).right) then
                assigned(tsetelementnode(right).right) then
              begin
              begin
                { generate a temporary normset def, it'll be destroyed
                { generate a temporary normset def, it'll be destroyed
                  when the symtable is unloaded }
                  when the symtable is unloaded }
-               htype.setdef(new(psetdef,init(psetdef(ld)^.elementtype,255)));
+               htype.setdef(tsetdef.create(tsetdef(ld).elementtype,255));
                inserttypeconv(left,htype);
                inserttypeconv(left,htype);
              end;
              end;
           end
           end
@@ -658,7 +677,7 @@ implementation
          { is one of the operands a string?,
          { is one of the operands a string?,
            chararrays are also handled as strings (after conversion), also take
            chararrays are also handled as strings (after conversion), also take
            care of chararray+chararray and chararray+char }
            care of chararray+chararray and chararray+char }
-         else if (rd^.deftype=stringdef) or (ld^.deftype=stringdef) or
+         else if (rd.deftype=stringdef) or (ld.deftype=stringdef) or
                  ((is_chararray(rd) or is_char(rd)) and
                  ((is_chararray(rd) or is_char(rd)) and
                   (is_chararray(ld) or is_char(ld))) then
                   (is_chararray(ld) or is_char(ld))) then
           begin
           begin
@@ -694,16 +713,8 @@ implementation
               end;
               end;
           end
           end
 
 
-         { is one a real float ? }
-         else if (rd^.deftype=floatdef) or (ld^.deftype=floatdef) then
-          begin
-          { convert both to bestreal }
-            inserttypeconv(right,pbestrealtype^);
-            inserttypeconv(left,pbestrealtype^);
-          end
-
          { pointer comparision and subtraction }
          { pointer comparision and subtraction }
-         else if (rd^.deftype=pointerdef) and (ld^.deftype=pointerdef) then
+         else if (rd.deftype=pointerdef) and (ld.deftype=pointerdef) then
           begin
           begin
             case nodetype of
             case nodetype of
                equaln,unequaln :
                equaln,unequaln :
@@ -771,7 +782,7 @@ implementation
           begin
           begin
             if is_class_or_interface(rd) and is_class_or_interface(ld) then
             if is_class_or_interface(rd) and is_class_or_interface(ld) then
              begin
              begin
-               if pobjectdef(rd)^.is_related(pobjectdef(ld)) then
+               if tobjectdef(rd).is_related(tobjectdef(ld)) then
                 inserttypeconv(right,left.resulttype)
                 inserttypeconv(right,left.resulttype)
                else
                else
                 inserttypeconv(left,right.resulttype);
                 inserttypeconv(left,right.resulttype);
@@ -785,10 +796,10 @@ implementation
              CGMessage(type_e_mismatch);
              CGMessage(type_e_mismatch);
           end
           end
 
 
-         else if (rd^.deftype=classrefdef) and (ld^.deftype=classrefdef) then
+         else if (rd.deftype=classrefdef) and (ld.deftype=classrefdef) then
           begin
           begin
-            if pobjectdef(pclassrefdef(rd)^.pointertype.def)^.is_related(
-                    pobjectdef(pclassrefdef(ld)^.pointertype.def)) then
+            if tobjectdef(tclassrefdef(rd).pointertype.def).is_related(
+                    tobjectdef(tclassrefdef(ld).pointertype.def)) then
               inserttypeconv(right,left.resulttype)
               inserttypeconv(right,left.resulttype)
             else
             else
               inserttypeconv(left,right.resulttype);
               inserttypeconv(left,right.resulttype);
@@ -798,14 +809,14 @@ implementation
           end
           end
 
 
          { allows comperasion with nil pointer }
          { allows comperasion with nil pointer }
-         else if is_class_or_interface(rd) or (rd^.deftype=classrefdef) then
+         else if is_class_or_interface(rd) or (rd.deftype=classrefdef) then
           begin
           begin
             inserttypeconv(left,right.resulttype);
             inserttypeconv(left,right.resulttype);
             if not(nodetype in [equaln,unequaln]) then
             if not(nodetype in [equaln,unequaln]) then
              CGMessage(type_e_mismatch);
              CGMessage(type_e_mismatch);
           end
           end
 
 
-         else if is_class_or_interface(ld) or (ld^.deftype=classrefdef) then
+         else if is_class_or_interface(ld) or (ld.deftype=classrefdef) then
           begin
           begin
             inserttypeconv(right,left.resulttype);
             inserttypeconv(right,left.resulttype);
             if not(nodetype in [equaln,unequaln]) then
             if not(nodetype in [equaln,unequaln]) then
@@ -813,8 +824,8 @@ implementation
           end
           end
 
 
        { support procvar=nil,procvar<>nil }
        { support procvar=nil,procvar<>nil }
-         else if ((ld^.deftype=procvardef) and (rt=niln)) or
-                 ((rd^.deftype=procvardef) and (lt=niln)) then
+         else if ((ld.deftype=procvardef) and (rt=niln)) or
+                 ((rd.deftype=procvardef) and (lt=niln)) then
           begin
           begin
             if not(nodetype in [equaln,unequaln]) then
             if not(nodetype in [equaln,unequaln]) then
              CGMessage(type_e_mismatch);
              CGMessage(type_e_mismatch);
@@ -843,11 +854,11 @@ implementation
 
 
          { this is a little bit dangerous, also the left type }
          { this is a little bit dangerous, also the left type }
          { pointer to should be checked! This broke the mmx support      }
          { pointer to should be checked! This broke the mmx support      }
-         else if (rd^.deftype=pointerdef) or is_zero_based_array(rd) then
+         else if (rd.deftype=pointerdef) or is_zero_based_array(rd) then
           begin
           begin
             if is_zero_based_array(rd) then
             if is_zero_based_array(rd) then
               begin
               begin
-                resulttype.setdef(new(ppointerdef,init(parraydef(rd)^.elementtype)));
+                resulttype.setdef(tpointerdef.create(tarraydef(rd).elementtype));
                 inserttypeconv(right,resulttype);
                 inserttypeconv(right,resulttype);
               end;
               end;
             inserttypeconv(left,s32bittype);
             inserttypeconv(left,s32bittype);
@@ -856,19 +867,19 @@ implementation
                 if not(cs_extsyntax in aktmoduleswitches) or
                 if not(cs_extsyntax in aktmoduleswitches) or
                    (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
                    (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
                   CGMessage(type_e_mismatch);
                   CGMessage(type_e_mismatch);
-                if (rd^.deftype=pointerdef) and
-                   (ppointerdef(rd)^.pointertype.def^.size>1) then
-                  left:=caddnode.create(muln,left,cordconstnode.create(ppointerdef(rd)^.pointertype.def^.size,s32bittype));
+                if (rd.deftype=pointerdef) and
+                   (tpointerdef(rd).pointertype.def.size>1) then
+                  left:=caddnode.create(muln,left,cordconstnode.create(tpointerdef(rd).pointertype.def.size,s32bittype));
               end
               end
             else
             else
               CGMessage(type_e_mismatch);
               CGMessage(type_e_mismatch);
           end
           end
 
 
-         else if (ld^.deftype=pointerdef) or is_zero_based_array(ld) then
+         else if (ld.deftype=pointerdef) or is_zero_based_array(ld) then
           begin
           begin
             if is_zero_based_array(ld) then
             if is_zero_based_array(ld) then
               begin
               begin
-                 resulttype.setdef(new(ppointerdef,init(parraydef(ld)^.elementtype)));
+                 resulttype.setdef(tpointerdef.create(tarraydef(ld).elementtype));
                  inserttypeconv(left,resulttype);
                  inserttypeconv(left,resulttype);
               end;
               end;
             inserttypeconv(right,s32bittype);
             inserttypeconv(right,s32bittype);
@@ -877,22 +888,22 @@ implementation
                 if not(cs_extsyntax in aktmoduleswitches) or
                 if not(cs_extsyntax in aktmoduleswitches) or
                    (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
                    (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
                   CGMessage(type_e_mismatch);
                   CGMessage(type_e_mismatch);
-                if (ld^.deftype=pointerdef) and
-                   (ppointerdef(ld)^.pointertype.def^.size>1) then
-                  right:=caddnode.create(muln,right,cordconstnode.create(ppointerdef(ld)^.pointertype.def^.size,s32bittype));
+                if (ld.deftype=pointerdef) and
+                   (tpointerdef(ld).pointertype.def.size>1) then
+                  right:=caddnode.create(muln,right,cordconstnode.create(tpointerdef(ld).pointertype.def.size,s32bittype));
               end
               end
             else
             else
               CGMessage(type_e_mismatch);
               CGMessage(type_e_mismatch);
          end
          end
 
 
-         else if (rd^.deftype=procvardef) and (ld^.deftype=procvardef) and is_equal(rd,ld) then
+         else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
           begin
           begin
             if not (nodetype in [equaln,unequaln]) then
             if not (nodetype in [equaln,unequaln]) then
              CGMessage(type_e_mismatch);
              CGMessage(type_e_mismatch);
           end
           end
 
 
          { enums }
          { enums }
-         else if (ld^.deftype=enumdef) and (rd^.deftype=enumdef) then
+         else if (ld.deftype=enumdef) and (rd.deftype=enumdef) then
           begin
           begin
             if not(is_equal(ld,rd)) then
             if not(is_equal(ld,rd)) then
              inserttypeconv(right,left.resulttype);
              inserttypeconv(right,left.resulttype);
@@ -937,7 +948,7 @@ implementation
       var
       var
          hp      : tnode;
          hp      : tnode;
          lt,rt   : tnodetype;
          lt,rt   : tnodetype;
-         rd,ld   : pdef;
+         rd,ld   : tdef;
       begin
       begin
          result:=nil;
          result:=nil;
          { first do the two subtrees }
          { first do the two subtrees }
@@ -967,7 +978,7 @@ implementation
            end
            end
 
 
          { if both are orddefs then check sub types }
          { if both are orddefs then check sub types }
-         else if (ld^.deftype=orddef) and (rd^.deftype=orddef) then
+         else if (ld.deftype=orddef) and (rd.deftype=orddef) then
            begin
            begin
            { 2 booleans ? }
            { 2 booleans ? }
              if is_boolean(ld) and is_boolean(rd) then
              if is_boolean(ld) and is_boolean(rd) then
@@ -996,10 +1007,10 @@ implementation
                  calcregisters(self,1,0,0);
                  calcregisters(self,1,0,0);
                end
                end
               { is there a 64 bit type ? }
               { is there a 64 bit type ? }
-             else if (porddef(ld)^.typ in [s64bit,u64bit]) then
+             else if (torddef(ld).typ in [s64bit,u64bit]) then
                calcregisters(self,2,0,0)
                calcregisters(self,2,0,0)
              { is there a cardinal? }
              { is there a cardinal? }
-             else if (porddef(ld)^.typ=u32bit) then
+             else if (torddef(ld).typ=u32bit) then
                begin
                begin
                  calcregisters(self,1,0,0);
                  calcregisters(self,1,0,0);
                  { for unsigned mul we need an extra register }
                  { for unsigned mul we need an extra register }
@@ -1013,9 +1024,9 @@ implementation
 
 
          { left side a setdef, must be before string processing,
          { left side a setdef, must be before string processing,
            else array constructor can be seen as array of char (PFV) }
            else array constructor can be seen as array of char (PFV) }
-         else if (ld^.deftype=setdef) then
+         else if (ld.deftype=setdef) then
            begin
            begin
-             if psetdef(ld)^.settype=smallset then
+             if tsetdef(ld).settype=smallset then
               begin
               begin
                  { are we adding set elements ? }
                  { are we adding set elements ? }
                  if right.nodetype=setelementn then
                  if right.nodetype=setelementn then
@@ -1041,7 +1052,7 @@ implementation
            end
            end
 
 
          { is one of the operands a string }
          { is one of the operands a string }
-         else if (ld^.deftype=stringdef) then
+         else if (ld.deftype=stringdef) then
             begin
             begin
               if is_widestring(ld) then
               if is_widestring(ld) then
                 begin
                 begin
@@ -1099,14 +1110,14 @@ implementation
            end
            end
 
 
          { is one a real float ? }
          { is one a real float ? }
-         else if (rd^.deftype=floatdef) or (ld^.deftype=floatdef) then
+         else if (rd.deftype=floatdef) or (ld.deftype=floatdef) then
             begin
             begin
               calcregisters(self,0,1,0);
               calcregisters(self,0,1,0);
               location.loc:=LOC_FPU;
               location.loc:=LOC_FPU;
             end
             end
 
 
          { pointer comperation and subtraction }
          { pointer comperation and subtraction }
-         else if (ld^.deftype=pointerdef) then
+         else if (ld.deftype=pointerdef) then
             begin
             begin
               location.loc:=LOC_REGISTER;
               location.loc:=LOC_REGISTER;
               calcregisters(self,1,0,0);
               calcregisters(self,1,0,0);
@@ -1118,15 +1129,15 @@ implementation
               calcregisters(self,1,0,0);
               calcregisters(self,1,0,0);
             end
             end
 
 
-         else if (ld^.deftype=classrefdef) then
+         else if (ld.deftype=classrefdef) then
             begin
             begin
               location.loc:=LOC_REGISTER;
               location.loc:=LOC_REGISTER;
               calcregisters(self,1,0,0);
               calcregisters(self,1,0,0);
             end
             end
 
 
          { support procvar=nil,procvar<>nil }
          { support procvar=nil,procvar<>nil }
-         else if ((ld^.deftype=procvardef) and (rt=niln)) or
-                 ((rd^.deftype=procvardef) and (lt=niln)) then
+         else if ((ld.deftype=procvardef) and (rt=niln)) or
+                 ((rd.deftype=procvardef) and (lt=niln)) then
             begin
             begin
               calcregisters(self,1,0,0);
               calcregisters(self,1,0,0);
               location.loc:=LOC_REGISTER;
               location.loc:=LOC_REGISTER;
@@ -1143,19 +1154,19 @@ implementation
             end
             end
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
-         else if (rd^.deftype=pointerdef) or (ld^.deftype=pointerdef) then
+         else if (rd.deftype=pointerdef) or (ld.deftype=pointerdef) then
             begin
             begin
               location.loc:=LOC_REGISTER;
               location.loc:=LOC_REGISTER;
               calcregisters(self,1,0,0);
               calcregisters(self,1,0,0);
             end
             end
 
 
-         else  if (rd^.deftype=procvardef) and (ld^.deftype=procvardef) and is_equal(rd,ld) then
+         else  if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
            begin
            begin
              calcregisters(self,1,0,0);
              calcregisters(self,1,0,0);
              location.loc:=LOC_REGISTER;
              location.loc:=LOC_REGISTER;
            end
            end
 
 
-         else if (ld^.deftype=enumdef) then
+         else if (ld.deftype=enumdef) then
            begin
            begin
               calcregisters(self,1,0,0);
               calcregisters(self,1,0,0);
            end
            end
@@ -1197,7 +1208,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.24  2001-04-04 22:42:39  peter
+  Revision 1.25  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.24  2001/04/04 22:42:39  peter
     * move constant folding into det_resulttype
     * move constant folding into det_resulttype
 
 
   Revision 1.23  2001/04/02 21:20:30  peter
   Revision 1.23  2001/04/02 21:20:30  peter

+ 8 - 3
compiler/nbas.pas

@@ -159,7 +159,7 @@ implementation
          if (not (cs_extsyntax in aktmoduleswitches)) and
          if (not (cs_extsyntax in aktmoduleswitches)) and
             assigned(right.resulttype.def) and
             assigned(right.resulttype.def) and
             not((right.nodetype=calln) and
             not((right.nodetype=calln) and
-                (tcallnode(right).procdefinition^.proctypeoption=potype_constructor)) and
+                (tcallnode(right).procdefinition.proctypeoption=potype_constructor)) and
             not(is_void(right.resulttype.def)) then
             not(is_void(right.resulttype.def)) then
            CGMessage(cg_e_illegal_expression);
            CGMessage(cg_e_illegal_expression);
          if codegenerror then
          if codegenerror then
@@ -248,7 +248,7 @@ implementation
                    if (not (cs_extsyntax in aktmoduleswitches)) and
                    if (not (cs_extsyntax in aktmoduleswitches)) and
                       assigned(hp.right.resulttype.def) and
                       assigned(hp.right.resulttype.def) and
                       not((hp.right.nodetype=calln) and
                       not((hp.right.nodetype=calln) and
-                          (tcallnode(hp.right).procdefinition^.proctypeoption=potype_constructor)) and
+                          (tcallnode(hp.right).procdefinition.proctypeoption=potype_constructor)) and
                       not(is_void(hp.right.resulttype.def)) then
                       not(is_void(hp.right.resulttype.def)) then
                      CGMessage(cg_e_illegal_expression);
                      CGMessage(cg_e_illegal_expression);
                 end;
                 end;
@@ -401,7 +401,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2001-04-02 21:20:30  peter
+  Revision 1.10  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.9  2001/04/02 21:20:30  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.8  2001/02/05 20:45:49  peter
   Revision 1.8  2001/02/05 20:45:49  peter

+ 148 - 141
compiler/ncal.pas

@@ -35,15 +35,15 @@ interface
        tcallnode = class(tbinarynode)
        tcallnode = class(tbinarynode)
           { the symbol containing the definition of the procedure }
           { the symbol containing the definition of the procedure }
           { to call                                               }
           { to call                                               }
-          symtableprocentry : pprocsym;
+          symtableprocentry : tprocsym;
           { the symtable containing symtableprocentry }
           { the symtable containing symtableprocentry }
-          symtableproc   : psymtable;
+          symtableproc   : tsymtable;
           { the definition of the procedure to call }
           { the definition of the procedure to call }
-          procdefinition : pabstractprocdef;
+          procdefinition : tabstractprocdef;
           methodpointer  : tnode;
           methodpointer  : tnode;
           { only the processor specific nodes need to override this }
           { only the processor specific nodes need to override this }
           { constructor                                             }
           { constructor                                             }
-          constructor create(l:tnode; v : pprocsym;st : psymtable; mp : tnode);virtual;
+          constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
           destructor destroy;override;
           destructor destroy;override;
           function  getcopy : tnode;override;
           function  getcopy : tnode;override;
           procedure insertintolist(l : tnodelist);override;
           procedure insertintolist(l : tnodelist);override;
@@ -83,7 +83,7 @@ interface
 
 
        tprocinlinenode = class(tnode)
        tprocinlinenode = class(tnode)
           inlinetree : tnode;
           inlinetree : tnode;
-          inlineprocsym : pprocsym;
+          inlineprocsym : tprocsym;
           retoffset,para_offset,para_size : longint;
           retoffset,para_offset,para_size : longint;
           constructor create(callp,code : tnode);virtual;
           constructor create(callp,code : tnode);virtual;
           destructor destroy;override;
           destructor destroy;override;
@@ -209,7 +209,7 @@ implementation
            it here before the arrayconstructor node breaks the tree
            it here before the arrayconstructor node breaks the tree
            with its conversions of enum->ord }
            with its conversions of enum->ord }
          if (left.nodetype=arrayconstructorn) and
          if (left.nodetype=arrayconstructorn) and
-            (defcoll.paratype.def^.deftype=setdef) then
+            (defcoll.paratype.def.deftype=setdef) then
            inserttypeconv(left,defcoll.paratype);
            inserttypeconv(left,defcoll.paratype);
 
 
          { set some settings needed for arrayconstructor }
          { set some settings needed for arrayconstructor }
@@ -218,8 +218,8 @@ implementation
             if is_array_of_const(defcoll.paratype.def) then
             if is_array_of_const(defcoll.paratype.def) then
              begin
              begin
                if assigned(aktcallprocsym) and
                if assigned(aktcallprocsym) and
-                  (([pocall_cppdecl,pocall_cdecl]*aktcallprocsym^.definition^.proccalloptions)<>[]) and
-                  (po_external in aktcallprocsym^.definition^.procoptions) then
+                  (([pocall_cppdecl,pocall_cdecl]*aktcallprocsym.definition.proccalloptions)<>[]) and
+                  (po_external in aktcallprocsym.definition.procoptions) then
                  include(left.flags,nf_cargs);
                  include(left.flags,nf_cargs);
                { force variant array }
                { force variant array }
                include(left.flags,nf_forcevaria);
                include(left.flags,nf_forcevaria);
@@ -227,7 +227,7 @@ implementation
             else
             else
              begin
              begin
                include(left.flags,nf_novariaallowed);
                include(left.flags,nf_novariaallowed);
-               tarrayconstructornode(left).constructortype:=parraydef(defcoll.paratype.def)^.elementtype;
+               tarrayconstructornode(left).constructortype:=tarraydef(defcoll.paratype.def).elementtype;
              end;
              end;
           end;
           end;
 
 
@@ -258,58 +258,58 @@ implementation
             allow_array_constructor:=old_array_constructor; }
             allow_array_constructor:=old_array_constructor; }
           end;
           end;
          { check if local proc/func is assigned to procvar }
          { check if local proc/func is assigned to procvar }
-         if left.resulttype.def^.deftype=procvardef then
-           test_local_to_procvar(pprocvardef(left.resulttype.def),defcoll.paratype.def);
+         if left.resulttype.def.deftype=procvardef then
+           test_local_to_procvar(tprocvardef(left.resulttype.def),defcoll.paratype.def);
          { property is not allowed as var parameter }
          { property is not allowed as var parameter }
          if (defcoll.paratyp in [vs_out,vs_var]) and
          if (defcoll.paratyp in [vs_out,vs_var]) and
             (nf_isproperty in left.flags) then
             (nf_isproperty in left.flags) then
            CGMessagePos(left.fileinfo,type_e_argument_cant_be_assigned);
            CGMessagePos(left.fileinfo,type_e_argument_cant_be_assigned);
          { generate the high() value tree }
          { generate the high() value tree }
          if not(assigned(aktcallprocsym) and
          if not(assigned(aktcallprocsym) and
-                (([pocall_cppdecl,pocall_cdecl]*aktcallprocsym^.definition^.proccalloptions)<>[]) and
-                (po_external in aktcallprocsym^.definition^.procoptions)) and
+                (([pocall_cppdecl,pocall_cdecl]*aktcallprocsym.definition.proccalloptions)<>[]) and
+                (po_external in aktcallprocsym.definition.procoptions)) and
             push_high_param(defcoll.paratype.def) then
             push_high_param(defcoll.paratype.def) then
            gen_high_tree(is_open_string(defcoll.paratype.def));
            gen_high_tree(is_open_string(defcoll.paratype.def));
          if not(is_shortstring(left.resulttype.def) and
          if not(is_shortstring(left.resulttype.def) and
                 is_shortstring(defcoll.paratype.def)) and
                 is_shortstring(defcoll.paratype.def)) and
-                (defcoll.paratype.def^.deftype<>formaldef) then
+                (defcoll.paratype.def.deftype<>formaldef) then
            begin
            begin
               if (defcoll.paratyp in [vs_var,vs_out]) and
               if (defcoll.paratyp in [vs_var,vs_out]) and
               { allows conversion from word to integer and
               { allows conversion from word to integer and
                 byte to shortint }
                 byte to shortint }
                 (not(
                 (not(
-                   (left.resulttype.def^.deftype=orddef) and
-                   (defcoll.paratype.def^.deftype=orddef) and
-                   (left.resulttype.def^.size=defcoll.paratype.def^.size)
+                   (left.resulttype.def.deftype=orddef) and
+                   (defcoll.paratype.def.deftype=orddef) and
+                   (left.resulttype.def.size=defcoll.paratype.def.size)
                     ) and
                     ) and
               { an implicit pointer conversion is allowed }
               { an implicit pointer conversion is allowed }
                 not(
                 not(
-                   (left.resulttype.def^.deftype=pointerdef) and
-                   (defcoll.paratype.def^.deftype=pointerdef)
+                   (left.resulttype.def.deftype=pointerdef) and
+                   (defcoll.paratype.def.deftype=pointerdef)
                     ) and
                     ) and
               { child classes can be also passed }
               { child classes can be also passed }
                 not(
                 not(
-                   (left.resulttype.def^.deftype=objectdef) and
-                   (defcoll.paratype.def^.deftype=objectdef) and
-                   pobjectdef(left.resulttype.def)^.is_related(pobjectdef(defcoll.paratype.def))
+                   (left.resulttype.def.deftype=objectdef) and
+                   (defcoll.paratype.def.deftype=objectdef) and
+                   tobjectdef(left.resulttype.def).is_related(tobjectdef(defcoll.paratype.def))
                    ) and
                    ) and
               { passing a single element to a openarray of the same type }
               { passing a single element to a openarray of the same type }
                 not(
                 not(
                    (is_open_array(defcoll.paratype.def) and
                    (is_open_array(defcoll.paratype.def) and
-                   is_equal(parraydef(defcoll.paratype.def)^.elementtype.def,left.resulttype.def))
+                   is_equal(tarraydef(defcoll.paratype.def).elementtype.def,left.resulttype.def))
                    ) and
                    ) and
               { an implicit file conversion is also allowed }
               { an implicit file conversion is also allowed }
               { from a typed file to an untyped one           }
               { from a typed file to an untyped one           }
                 not(
                 not(
-                   (left.resulttype.def^.deftype=filedef) and
-                   (defcoll.paratype.def^.deftype=filedef) and
-                   (pfiledef(defcoll.paratype.def)^.filetyp = ft_untyped) and
-                   (pfiledef(left.resulttype.def)^.filetyp = ft_typed)
+                   (left.resulttype.def.deftype=filedef) and
+                   (defcoll.paratype.def.deftype=filedef) and
+                   (tfiledef(defcoll.paratype.def).filetyp = ft_untyped) and
+                   (tfiledef(left.resulttype.def).filetyp = ft_typed)
                     ) and
                     ) and
                 not(is_equal(left.resulttype.def,defcoll.paratype.def))) then
                 not(is_equal(left.resulttype.def,defcoll.paratype.def))) then
                   begin
                   begin
                      CGMessagePos2(left.fileinfo,parser_e_call_by_ref_without_typeconv,
                      CGMessagePos2(left.fileinfo,parser_e_call_by_ref_without_typeconv,
-                       left.resulttype.def^.typename,defcoll.paratype.def^.typename);
+                       left.resulttype.def.typename,defcoll.paratype.def.typename);
                   end;
                   end;
               { Process open parameters }
               { Process open parameters }
               if push_high_param(defcoll.paratype.def) then
               if push_high_param(defcoll.paratype.def) then
@@ -345,7 +345,7 @@ implementation
          { into a register }
          { into a register }
          { is this usefull here ? }
          { is this usefull here ? }
          { this was missing in formal parameter list   }
          { this was missing in formal parameter list   }
-         if (defcoll.paratype.def^.deftype=formaldef) then
+         if (defcoll.paratype.def.deftype=formaldef) then
            begin
            begin
              if defcoll.paratyp in [vs_var,vs_out] then
              if defcoll.paratyp in [vs_var,vs_out] then
                begin
                begin
@@ -441,30 +441,30 @@ implementation
     procedure tcallparanode.gen_high_tree(openstring:boolean);
     procedure tcallparanode.gen_high_tree(openstring:boolean);
       var
       var
         len : longint;
         len : longint;
-        st  : psymtable;
+        st  : tsymtable;
         loadconst : boolean;
         loadconst : boolean;
-        srsym : psym;
+        srsym : tsym;
       begin
       begin
         if assigned(hightree) then
         if assigned(hightree) then
           exit;
           exit;
         len:=-1;
         len:=-1;
         loadconst:=true;
         loadconst:=true;
-        case left.resulttype.def^.deftype of
+        case left.resulttype.def.deftype of
           arraydef :
           arraydef :
             begin
             begin
               if is_open_array(left.resulttype.def) or
               if is_open_array(left.resulttype.def) or
                  is_array_of_const(left.resulttype.def) then
                  is_array_of_const(left.resulttype.def) then
                begin
                begin
                  st:=tloadnode(left).symtable;
                  st:=tloadnode(left).symtable;
-                 srsym:=searchsymonlyin(st,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
-                 hightree:=cloadnode.create(pvarsym(srsym),st);
+                 srsym:=searchsymonlyin(st,'high'+tvarsym(tloadnode(left).symtableentry).name);
+                 hightree:=cloadnode.create(tvarsym(srsym),st);
                  loadconst:=false;
                  loadconst:=false;
                end
                end
               else
               else
                 begin
                 begin
                   { this is an empty constructor }
                   { this is an empty constructor }
-                  len:=parraydef(left.resulttype.def)^.highrange-
-                       parraydef(left.resulttype.def)^.lowrange;
+                  len:=tarraydef(left.resulttype.def).highrange-
+                       tarraydef(left.resulttype.def).lowrange;
                 end;
                 end;
             end;
             end;
           stringdef :
           stringdef :
@@ -474,12 +474,12 @@ implementation
                  if is_open_string(left.resulttype.def) then
                  if is_open_string(left.resulttype.def) then
                   begin
                   begin
                     st:=tloadnode(left).symtable;
                     st:=tloadnode(left).symtable;
-                    srsym:=searchsymonlyin(st,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
-                    hightree:=cloadnode.create(pvarsym(srsym),st);
+                    srsym:=searchsymonlyin(st,'high'+tvarsym(tloadnode(left).symtableentry).name);
+                    hightree:=cloadnode.create(tvarsym(srsym),st);
                     loadconst:=false;
                     loadconst:=false;
                   end
                   end
                  else
                  else
-                  len:=pstringdef(left.resulttype.def)^.len;
+                  len:=tstringdef(left.resulttype.def).len;
                end
                end
               else
               else
              { passing a string to an array of char }
              { passing a string to an array of char }
@@ -521,7 +521,7 @@ implementation
                                  TCALLNODE
                                  TCALLNODE
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tcallnode.create(l:tnode;v : pprocsym;st : psymtable; mp : tnode);
+    constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp : tnode);
 
 
       begin
       begin
          inherited create(calln,l,nil);
          inherited create(calln,l,nil);
@@ -571,25 +571,25 @@ implementation
       type
       type
          pprocdefcoll = ^tprocdefcoll;
          pprocdefcoll = ^tprocdefcoll;
          tprocdefcoll = record
          tprocdefcoll = record
-            data      : pprocdef;
+            data      : tprocdef;
             nextpara  : tparaitem;
             nextpara  : tparaitem;
             firstpara : tparaitem;
             firstpara : tparaitem;
             next      : pprocdefcoll;
             next      : pprocdefcoll;
          end;
          end;
       var
       var
          hp,procs,hp2 : pprocdefcoll;
          hp,procs,hp2 : pprocdefcoll;
-         pd : pprocdef;
-         oldcallprocsym : pprocsym;
-         def_from,def_to,conv_to : pdef;
-         hpt,hpt2 : tnode;
+         pd : tprocdef;
+         oldcallprocsym : tprocsym;
+         def_from,def_to,conv_to : tdef;
+         hpt : tnode;
          pt : tcallparanode;
          pt : tcallparanode;
          exactmatch : boolean;
          exactmatch : boolean;
          paralength,lastpara : longint;
          paralength,lastpara : longint;
-         lastparatype : pdef;
+         lastparatype : tdef;
          pdc : tparaitem;
          pdc : tparaitem;
 {$ifdef TEST_PROCSYMS}
 {$ifdef TEST_PROCSYMS}
-         nextprocsym : pprocsym;
-         symt : psymtable;
+         nextprocsym : tprocsym;
+         symt : tsymtable;
 {$endif TEST_PROCSYMS}
 {$endif TEST_PROCSYMS}
          { only Dummy }
          { only Dummy }
          hcvt : tconverttype;
          hcvt : tconverttype;
@@ -598,7 +598,7 @@ implementation
 
 
       { check if the resulttype.def from tree p is equal with def, needed
       { check if the resulttype.def from tree p is equal with def, needed
         for stringconstn and formaldef }
         for stringconstn and formaldef }
-      function is_equal(p:tcallparanode;def:pdef) : boolean;
+      function is_equal(p:tcallparanode;def:tdef) : boolean;
 
 
         begin
         begin
            { safety check }
            { safety check }
@@ -608,7 +608,7 @@ implementation
               exit;
               exit;
             end;
             end;
            { all types can be passed to a formaldef }
            { all types can be passed to a formaldef }
-           is_equal:=(def^.deftype=formaldef) or
+           is_equal:=(def.deftype=formaldef) or
              (types.is_equal(p.resulttype.def,def))
              (types.is_equal(p.resulttype.def,def))
            { integer constants are compatible with all integer parameters if
            { integer constants are compatible with all integer parameters if
              the specified value matches the range }
              the specified value matches the range }
@@ -617,16 +617,16 @@ implementation
               (tbinarynode(p).left.nodetype=ordconstn) and
               (tbinarynode(p).left.nodetype=ordconstn) and
               is_integer(p.resulttype.def) and
               is_integer(p.resulttype.def) and
               is_integer(def) and
               is_integer(def) and
-              (tordconstnode(p.left).value>=porddef(def)^.low) and
-              (tordconstnode(p.left).value<=porddef(def)^.high)
+              (tordconstnode(p.left).value>=torddef(def).low) and
+              (tordconstnode(p.left).value<=torddef(def).high)
              )
              )
            { to support ansi/long/wide strings in a proper way }
            { to support ansi/long/wide strings in a proper way }
            { string and string[10] are assumed as equal }
            { string and string[10] are assumed as equal }
            { when searching the correct overloaded procedure   }
            { when searching the correct overloaded procedure   }
              or
              or
              (
              (
-              (def^.deftype=stringdef) and (p.resulttype.def^.deftype=stringdef) and
-              (pstringdef(def)^.string_typ=pstringdef(p.resulttype.def)^.string_typ)
+              (def.deftype=stringdef) and (p.resulttype.def.deftype=stringdef) and
+              (tstringdef(def).string_typ=tstringdef(p.resulttype.def).string_typ)
              )
              )
              or
              or
              (
              (
@@ -641,32 +641,32 @@ implementation
            { set can also be a not yet converted array constructor }
            { set can also be a not yet converted array constructor }
              or
              or
              (
              (
-              (def^.deftype=setdef) and (p.resulttype.def^.deftype=arraydef) and
-              (parraydef(p.resulttype.def)^.IsConstructor) and not(parraydef(p.resulttype.def)^.IsVariant)
+              (def.deftype=setdef) and (p.resulttype.def.deftype=arraydef) and
+              (tarraydef(p.resulttype.def).IsConstructor) and not(tarraydef(p.resulttype.def).IsVariant)
              )
              )
            { in tp7 mode proc -> procvar is allowed }
            { in tp7 mode proc -> procvar is allowed }
              or
              or
              (
              (
               (m_tp_procvar in aktmodeswitches) and
               (m_tp_procvar in aktmodeswitches) and
-              (def^.deftype=procvardef) and (p.left.nodetype=calln) and
-              (proc_to_procvar_equal(pprocdef(tcallnode(p.left).procdefinition),pprocvardef(def)))
+              (def.deftype=procvardef) and (p.left.nodetype=calln) and
+              (proc_to_procvar_equal(tprocdef(tcallnode(p.left).procdefinition),tprocvardef(def)))
              )
              )
              ;
              ;
         end;
         end;
 
 
-      function is_in_limit(def_from,def_to : pdef) : boolean;
+      function is_in_limit(def_from,def_to : tdef) : boolean;
 
 
         begin
         begin
-           is_in_limit:=(def_from^.deftype = orddef) and
-                        (def_to^.deftype = orddef) and
-                        (porddef(def_from)^.low>porddef(def_to)^.low) and
-                        (porddef(def_from)^.high<porddef(def_to)^.high);
+           is_in_limit:=(def_from.deftype = orddef) and
+                        (def_to.deftype = orddef) and
+                        (torddef(def_from).low>torddef(def_to).low) and
+                        (torddef(def_from).high<torddef(def_to).high);
         end;
         end;
 
 
       var
       var
         i : longint;
         i : longint;
         is_const : boolean;
         is_const : boolean;
-        bestord  : porddef;
+        bestord  : torddef;
       begin
       begin
          result:=nil;
          result:=nil;
 
 
@@ -683,7 +683,7 @@ implementation
                exit;
                exit;
 
 
               { check the parameters }
               { check the parameters }
-              pdc:=tparaitem(pprocvardef(right.resulttype.def)^.Para.first);
+              pdc:=tparaitem(tprocvardef(right.resulttype.def).Para.first);
               pt:=tcallparanode(left);
               pt:=tcallparanode(left);
               while assigned(pdc) and assigned(pt) do
               while assigned(pdc) and assigned(pt) do
                 begin
                 begin
@@ -697,7 +697,7 @@ implementation
                    CGMessage(parser_e_illegal_parameter_list);
                    CGMessage(parser_e_illegal_parameter_list);
                 end;
                 end;
 
 
-              procdefinition:=pabstractprocdef(right.resulttype.def);
+              procdefinition:=tabstractprocdef(right.resulttype.def);
            end
            end
          else
          else
          { not a procedure variable }
          { not a procedure variable }
@@ -710,7 +710,7 @@ implementation
                      goto errorexit;
                      goto errorexit;
                 end;
                 end;
 
 
-              aktcallprocsym:=pprocsym(symtableprocentry);
+              aktcallprocsym:=tprocsym(symtableprocentry);
               { do we know the procedure to call ? }
               { do we know the procedure to call ? }
               if not(assigned(procdefinition)) then
               if not(assigned(procdefinition)) then
                 begin
                 begin
@@ -725,9 +725,9 @@ implementation
                      while assigned(symt^.next) and not assigned(srsym) do
                      while assigned(symt^.next) and not assigned(srsym) do
                        begin
                        begin
                           symt:=symt^.next;
                           symt:=symt^.next;
-                          srsym:=searchsymonlyin(symt,actprocsym^.name);
+                          srsym:=searchsymonlyin(symt,actprocsym.name);
                           if assigned(srsym) then
                           if assigned(srsym) then
-                            if srsym^.typ<>procsym then
+                            if srsym.typ<>procsym then
                               begin
                               begin
                                  { reject all that is not a procedure }
                                  { reject all that is not a procedure }
                                  srsym:=nil;
                                  srsym:=nil;
@@ -749,25 +749,25 @@ implementation
                      end;
                      end;
 
 
                    { link all procedures which have the same # of parameters }
                    { link all procedures which have the same # of parameters }
-                   pd:=aktcallprocsym^.definition;
+                   pd:=aktcallprocsym.definition;
                    while assigned(pd) do
                    while assigned(pd) do
                      begin
                      begin
                         { only when the # of parameter are supported by the
                         { only when the # of parameter are supported by the
                           procedure }
                           procedure }
-                        if (paralength>=pd^.minparacount) and (paralength<=pd^.maxparacount) then
+                        if (paralength>=pd.minparacount) and (paralength<=pd.maxparacount) then
                           begin
                           begin
                              new(hp);
                              new(hp);
                              hp^.data:=pd;
                              hp^.data:=pd;
                              hp^.next:=procs;
                              hp^.next:=procs;
-                             hp^.firstpara:=tparaitem(pd^.Para.first);
+                             hp^.firstpara:=tparaitem(pd.Para.first);
                              { if not all parameters are given, then skip the
                              { if not all parameters are given, then skip the
                                default parameters }
                                default parameters }
-                             for i:=1 to pd^.maxparacount-paralength do
+                             for i:=1 to pd.maxparacount-paralength do
                               hp^.firstpara:=tparaitem(hp^.firstPara.next);
                               hp^.firstpara:=tparaitem(hp^.firstPara.next);
                              hp^.nextpara:=hp^.firstpara;
                              hp^.nextpara:=hp^.firstpara;
                              procs:=hp;
                              procs:=hp;
                           end;
                           end;
-                        pd:=pd^.nextoverloaded;
+                        pd:=pd.nextoverloaded;
                      end;
                      end;
 
 
                    { no procedures found? then there is something wrong
                    { no procedures found? then there is something wrong
@@ -779,8 +779,8 @@ implementation
                       if not(assigned(left)) and
                       if not(assigned(left)) and
                          (m_tp_procvar in aktmodeswitches) then
                          (m_tp_procvar in aktmodeswitches) then
                         begin
                         begin
-                          hpt:=cloadnode.create(pprocsym(symtableprocentry),symtableproc);
-                          if (symtableprocentry^.owner^.symtabletype=objectsymtable) and
+                          hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
+                          if (symtableprocentry.owner.symtabletype=objectsymtable) and
                              assigned(methodpointer) then
                              assigned(methodpointer) then
                             tloadnode(hpt).set_mp(methodpointer.getcopy);
                             tloadnode(hpt).set_mp(methodpointer.getcopy);
                           resulttypepass(hpt);
                           resulttypepass(hpt);
@@ -791,7 +791,7 @@ implementation
                           if assigned(left) then
                           if assigned(left) then
                            aktfilepos:=left.fileinfo;
                            aktfilepos:=left.fileinfo;
                           CGMessage(parser_e_wrong_parameter_size);
                           CGMessage(parser_e_wrong_parameter_size);
-                          aktcallprocsym^.write_parameter_lists(nil);
+                          aktcallprocsym.write_parameter_lists(nil);
                         end;
                         end;
                       goto errorexit;
                       goto errorexit;
                     end;
                     end;
@@ -913,9 +913,9 @@ implementation
                         begin
                         begin
                           aktfilepos:=pt.fileinfo;
                           aktfilepos:=pt.fileinfo;
                           CGMessage3(type_e_wrong_parameter_type,tostr(lastpara),
                           CGMessage3(type_e_wrong_parameter_type,tostr(lastpara),
-                            pt.resulttype.def^.typename,lastparatype^.typename);
+                            pt.resulttype.def.typename,lastparatype.typename);
                         end;
                         end;
-                      aktcallprocsym^.write_parameter_lists(nil);
+                      aktcallprocsym.write_parameter_lists(nil);
                       goto errorexit;
                       goto errorexit;
                     end;
                     end;
 
 
@@ -947,10 +947,10 @@ implementation
                                   if not is_equal(pt,hp^.nextPara.paratype.def) then
                                   if not is_equal(pt,hp^.nextPara.paratype.def) then
                                     begin
                                     begin
                                        def_to:=hp^.nextPara.paratype.def;
                                        def_to:=hp^.nextPara.paratype.def;
-                                       if ((def_from^.deftype=orddef) and (def_to^.deftype=orddef)) and
+                                       if ((def_from.deftype=orddef) and (def_to.deftype=orddef)) and
                                          (is_in_limit(def_from,def_to) or
                                          (is_in_limit(def_from,def_to) or
                                          ((hp^.nextPara.paratyp in [vs_var,vs_out]) and
                                          ((hp^.nextPara.paratyp in [vs_var,vs_out]) and
-                                         (def_from^.size=def_to^.size))) then
+                                         (def_from.size=def_to.size))) then
                                          begin
                                          begin
                                             exactmatch:=true;
                                             exactmatch:=true;
                                             conv_to:=def_to;
                                             conv_to:=def_to;
@@ -982,9 +982,9 @@ implementation
                                        else
                                        else
                                          begin
                                          begin
                                            def_to:=hp^.next^.nextPara.paratype.def;
                                            def_to:=hp^.next^.nextPara.paratype.def;
-                                           if (conv_to^.size>def_to^.size) or
-                                              ((porddef(conv_to)^.low<porddef(def_to)^.low) and
-                                              (porddef(conv_to)^.high>porddef(def_to)^.high)) then
+                                           if (conv_to.size>def_to.size) or
+                                              ((torddef(conv_to).low<torddef(def_to).low) and
+                                              (torddef(conv_to).high>torddef(def_to).high)) then
                                              begin
                                              begin
                                                 hp2:=procs;
                                                 hp2:=procs;
                                                 procs:=hp;
                                                 procs:=hp;
@@ -1082,9 +1082,9 @@ implementation
                                   if not is_integer(def_to) then
                                   if not is_integer(def_to) then
                                    internalerror(43297815);
                                    internalerror(43297815);
                                   if (not assigned(bestord)) or
                                   if (not assigned(bestord)) or
-                                     ((porddef(def_to)^.low>bestord^.low) or
-                                      (porddef(def_to)^.high<bestord^.high)) then
-                                   bestord:=porddef(def_to);
+                                     ((torddef(def_to).low>bestord.low) or
+                                      (torddef(def_to).high<bestord.high)) then
+                                   bestord:=torddef(def_to);
                                   hp:=hp^.next;
                                   hp:=hp^.next;
                                 end;
                                 end;
                              end;
                              end;
@@ -1098,7 +1098,7 @@ implementation
                                 begin
                                 begin
                                   hp2:=hp^.next;
                                   hp2:=hp^.next;
                                   { keep matching bestord, dispose the others }
                                   { keep matching bestord, dispose the others }
-                                  if (porddef(hp^.nextPara.paratype.def)=bestord) then
+                                  if (torddef(hp^.nextPara.paratype.def)=bestord) then
                                    begin
                                    begin
                                      hp^.next:=procs;
                                      hp^.next:=procs;
                                      procs:=hp;
                                      procs:=hp;
@@ -1172,7 +1172,7 @@ implementation
                    if not(assigned(procs)) or assigned(procs^.next) then
                    if not(assigned(procs)) or assigned(procs^.next) then
                      begin
                      begin
                         CGMessage(cg_e_cant_choose_overload_function);
                         CGMessage(cg_e_cant_choose_overload_function);
-                        aktcallprocsym^.write_parameter_lists(nil);
+                        aktcallprocsym.write_parameter_lists(nil);
                         goto errorexit;
                         goto errorexit;
                      end;
                      end;
 {$ifdef TEST_PROCSYMS}
 {$ifdef TEST_PROCSYMS}
@@ -1185,24 +1185,24 @@ implementation
 {$endif TEST_PROCSYMS}
 {$endif TEST_PROCSYMS}
                    if make_ref then
                    if make_ref then
                      begin
                      begin
-                        procs^.data^.lastref:=new(pref,init(procs^.data^.lastref,@fileinfo));
-                        inc(procs^.data^.refcount);
-                        if procs^.data^.defref=nil then
-                          procs^.data^.defref:=procs^.data^.lastref;
+                        procs^.data.lastref:=tref.create(procs^.data.lastref,@fileinfo);
+                        inc(procs^.data.refcount);
+                        if procs^.data.defref=nil then
+                          procs^.data.defref:=procs^.data.lastref;
                      end;
                      end;
 
 
                    procdefinition:=procs^.data;
                    procdefinition:=procs^.data;
                    { big error for with statements
                    { big error for with statements
-                   symtableproc:=procdefinition^.owner;
+                   symtableproc:=procdefinition.owner;
                    but neede for overloaded operators !! }
                    but neede for overloaded operators !! }
                    if symtableproc=nil then
                    if symtableproc=nil then
-                     symtableproc:=procdefinition^.owner;
+                     symtableproc:=procdefinition.owner;
 
 
 {$ifdef CHAINPROCSYMS}
 {$ifdef CHAINPROCSYMS}
                    { object with method read;
                    { object with method read;
                      call to read(x) will be a usual procedure call }
                      call to read(x) will be a usual procedure call }
                    if assigned(methodpointer) and
                    if assigned(methodpointer) and
-                     (procdefinition^._class=nil) then
+                     (procdefinition._class=nil) then
                      begin
                      begin
                         { not ok for extended }
                         { not ok for extended }
                         case methodpointer^.nodetype of
                         case methodpointer^.nodetype of
@@ -1217,70 +1217,74 @@ implementation
 
 
               { add needed default parameters }
               { add needed default parameters }
               if assigned(procs) and
               if assigned(procs) and
-                 (paralength<procdefinition^.maxparacount) then
+                 (paralength<procdefinition.maxparacount) then
                begin
                begin
                  { add default parameters, just read back the skipped
                  { add default parameters, just read back the skipped
                    paras starting from firstPara.previous, when not available
                    paras starting from firstPara.previous, when not available
                    (all parameters are default) then start with the last
                    (all parameters are default) then start with the last
                    parameter and read backward (PFV) }
                    parameter and read backward (PFV) }
                  if not assigned(procs^.firstpara) then
                  if not assigned(procs^.firstpara) then
-                  pdc:=tparaitem(procs^.data^.Para.last)
+                  pdc:=tparaitem(procs^.data.Para.last)
                  else
                  else
                   pdc:=tparaitem(procs^.firstPara.previous);
                   pdc:=tparaitem(procs^.firstPara.previous);
                  while assigned(pdc) do
                  while assigned(pdc) do
                   begin
                   begin
                     if not assigned(pdc.defaultvalue) then
                     if not assigned(pdc.defaultvalue) then
                      internalerror(751349858);
                      internalerror(751349858);
-                    left:=ccallparanode.create(genconstsymtree(pconstsym(pdc.defaultvalue)),left);
+                    left:=ccallparanode.create(genconstsymtree(tconstsym(pdc.defaultvalue)),left);
                     pdc:=tparaitem(pdc.previous);
                     pdc:=tparaitem(pdc.previous);
                   end;
                   end;
                end;
                end;
            end;
            end;
 
 
               { handle predefined procedures }
               { handle predefined procedures }
-              is_const:=(pocall_internconst in procdefinition^.proccalloptions) and
+              is_const:=(pocall_internconst in procdefinition.proccalloptions) and
                         ((block_type in [bt_const,bt_type]) or
                         ((block_type in [bt_const,bt_type]) or
                          (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
                          (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
-              if (pocall_internproc in procdefinition^.proccalloptions) or is_const then
+              if (pocall_internproc in procdefinition.proccalloptions) or is_const then
                 begin
                 begin
                    if assigned(left) then
                    if assigned(left) then
                      begin
                      begin
-                       hpt2:=left;
-                       left:=nil;
                      { ptr and settextbuf needs two args }
                      { ptr and settextbuf needs two args }
-                       if assigned(tcallparanode(hpt2).right) then
-                        hpt:=geninlinenode(pprocdef(procdefinition)^.extnumber,is_const,hpt2)
+                       if assigned(tcallparanode(left).right) then
+                        begin
+                          hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
+                          left:=nil;
+                        end
                        else
                        else
-                        hpt:=geninlinenode(pprocdef(procdefinition)^.extnumber,is_const,tcallparanode(hpt2).left);
+                        begin
+                          hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
+                          tcallparanode(left).left:=nil;
+                        end;
                      end
                      end
                    else
                    else
-                     hpt:=geninlinenode(pprocdef(procdefinition)^.extnumber,is_const,nil);
-                   firstpass(hpt);
+                     hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
+                   resulttypepass(hpt);
                    result:=hpt;
                    result:=hpt;
                    goto errorexit;
                    goto errorexit;
                 end;
                 end;
 
 
          { Calling a message method directly ? }
          { Calling a message method directly ? }
          if assigned(procdefinition) and
          if assigned(procdefinition) and
-            (po_containsself in procdefinition^.procoptions) then
+            (po_containsself in procdefinition.procoptions) then
            message(cg_e_cannot_call_message_direct);
            message(cg_e_cannot_call_message_direct);
 
 
          { ensure that the result type is set }
          { ensure that the result type is set }
-         resulttype:=procdefinition^.rettype;
+         resulttype:=procdefinition.rettype;
 
 
          { constructors return their current class type, not the type where the
          { constructors return their current class type, not the type where the
            constructor is declared, this can be different because of inheritance }
            constructor is declared, this can be different because of inheritance }
-         if (procdefinition^.proctypeoption=potype_constructor) then
+         if (procdefinition.proctypeoption=potype_constructor) then
            begin
            begin
              if assigned(methodpointer) and
              if assigned(methodpointer) and
                 assigned(methodpointer.resulttype.def) and
                 assigned(methodpointer.resulttype.def) and
-                (methodpointer.resulttype.def^.deftype=classrefdef) then
-               resulttype:=pclassrefdef(methodpointer.resulttype.def)^.pointertype;
+                (methodpointer.resulttype.def.deftype=classrefdef) then
+               resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype;
            end;
            end;
 
 
          { insert type conversions }
          { insert type conversions }
          if assigned(left) then
          if assigned(left) then
-          tcallparanode(left).insert_typeconv(tparaitem(procdefinition^.Para.first),true);
+          tcallparanode(left).insert_typeconv(tparaitem(procdefinition.Para.first),true);
 
 
       errorexit:
       errorexit:
          { Reset some settings back }
          { Reset some settings back }
@@ -1292,7 +1296,7 @@ implementation
 
 
     function tcallnode.pass_1 : tnode;
     function tcallnode.pass_1 : tnode;
       var
       var
-         hpt,hpt2,inlinecode : tnode;
+         inlinecode : tnode;
          inlined : boolean;
          inlined : boolean;
 {$ifdef m68k}
 {$ifdef m68k}
          regi : tregister;
          regi : tregister;
@@ -1300,8 +1304,6 @@ implementation
          method_must_be_valid : boolean;
          method_must_be_valid : boolean;
       label
       label
         errorexit;
         errorexit;
-      var
-        is_const : boolean;
       begin
       begin
          result:=nil;
          result:=nil;
          inlined:=false;
          inlined:=false;
@@ -1311,13 +1313,13 @@ implementation
            tcallparanode(left).det_registers;
            tcallparanode(left).det_registers;
 
 
          if assigned(procdefinition) and
          if assigned(procdefinition) and
-            (pocall_inline in procdefinition^.proccalloptions) then
+            (pocall_inline in procdefinition.proccalloptions) then
            begin
            begin
               inlinecode:=right;
               inlinecode:=right;
               if assigned(inlinecode) then
               if assigned(inlinecode) then
                 begin
                 begin
                    inlined:=true;
                    inlined:=true;
-                   exclude(procdefinition^.proccalloptions,pocall_inline);
+                   exclude(procdefinition.proccalloptions,pocall_inline);
                 end;
                 end;
               right:=nil;
               right:=nil;
            end;
            end;
@@ -1348,7 +1350,7 @@ implementation
 
 
               { calc the correture value for the register }
               { calc the correture value for the register }
               { handle predefined procedures }
               { handle predefined procedures }
-              if (pocall_inline in procdefinition^.proccalloptions) then
+              if (pocall_inline in procdefinition.proccalloptions) then
                 begin
                 begin
                    if assigned(methodpointer) then
                    if assigned(methodpointer) then
                      CGMessage(cg_e_unable_inline_object_methods);
                      CGMessage(cg_e_unable_inline_object_methods);
@@ -1357,15 +1359,15 @@ implementation
                    { nodetype:=procinlinen; }
                    { nodetype:=procinlinen; }
                    if not assigned(right) then
                    if not assigned(right) then
                      begin
                      begin
-                        if assigned(pprocdef(procdefinition)^.code) then
-                          inlinecode:=cprocinlinenode.create(self,tnode(pprocdef(procdefinition)^.code))
+                        if assigned(tprocdef(procdefinition).code) then
+                          inlinecode:=cprocinlinenode.create(self,tnode(tprocdef(procdefinition).code))
                         else
                         else
                           CGMessage(cg_e_no_code_for_inline_stored);
                           CGMessage(cg_e_no_code_for_inline_stored);
                         if assigned(inlinecode) then
                         if assigned(inlinecode) then
                           begin
                           begin
                              { consider it has not inlined if called
                              { consider it has not inlined if called
                                again inside the args }
                                again inside the args }
-                             exclude(procdefinition^.proccalloptions,pocall_inline);
+                             exclude(procdefinition.proccalloptions,pocall_inline);
                              firstpass(inlinecode);
                              firstpass(inlinecode);
                              inlined:=true;
                              inlined:=true;
                           end;
                           end;
@@ -1379,12 +1381,12 @@ implementation
 
 
 {$ifndef newcg}
 {$ifndef newcg}
 {$ifdef i386}
 {$ifdef i386}
-              incrementregisterpushed(pprocdef(procdefinition)^.usedregisters);
+              incrementregisterpushed(tprocdef(procdefinition).usedregisters);
 {$endif}
 {$endif}
 {$ifdef m68k}
 {$ifdef m68k}
              for regi:=R_D0 to R_A6 do
              for regi:=R_D0 to R_A6 do
                begin
                begin
-                  if (pprocdef(procdefinition)^.usedregisters and ($800 shr word(regi)))<>0 then
+                  if (tprocdef(procdefinition).usedregisters and ($800 shr word(regi)))<>0 then
                     inc(reg_pushes[regi],t_times*2);
                     inc(reg_pushes[regi],t_times*2);
                end;
                end;
 {$endif}
 {$endif}
@@ -1394,13 +1396,13 @@ implementation
          { get a register for the return value }
          { get a register for the return value }
          if (not is_void(resulttype.def)) then
          if (not is_void(resulttype.def)) then
            begin
            begin
-              if (procdefinition^.proctypeoption=potype_constructor) then
+              if (procdefinition.proctypeoption=potype_constructor) then
                 begin
                 begin
                    { extra handling of classes }
                    { extra handling of classes }
                    { methodpointer should be assigned! }
                    { methodpointer should be assigned! }
                    if assigned(methodpointer) and
                    if assigned(methodpointer) and
                       assigned(methodpointer.resulttype.def) and
                       assigned(methodpointer.resulttype.def) and
-                      (methodpointer.resulttype.def^.deftype=classrefdef) then
+                      (methodpointer.resulttype.def.deftype=classrefdef) then
                      begin
                      begin
                         location.loc:=LOC_REGISTER;
                         location.loc:=LOC_REGISTER;
                         registers32:=1;
                         registers32:=1;
@@ -1441,7 +1443,7 @@ implementation
                              registers32:=1;
                              registers32:=1;
                           end;
                           end;
                      end
                      end
-                   else if (resulttype.def^.deftype=floatdef) then
+                   else if (resulttype.def.deftype=floatdef) then
                      begin
                      begin
                         location.loc:=LOC_FPU;
                         location.loc:=LOC_FPU;
                         registersfpu:=1;
                         registersfpu:=1;
@@ -1451,7 +1453,7 @@ implementation
                 end;
                 end;
            end;
            end;
          { a fpu can be used in any procedure !! }
          { a fpu can be used in any procedure !! }
-         registersfpu:=procdefinition^.fpu_used;
+         registersfpu:=procdefinition.fpu_used;
          { if this is a call to a method calc the registers }
          { if this is a call to a method calc the registers }
          if (methodpointer<>nil) then
          if (methodpointer<>nil) then
            begin
            begin
@@ -1463,9 +1465,9 @@ implementation
                           registers32:=1;
                           registers32:=1;
                 else
                 else
                   begin
                   begin
-                     if (procdefinition^.proctypeoption in [potype_constructor,potype_destructor]) and
-                        assigned(symtableproc) and (symtableproc^.symtabletype=withsymtable) and
-                        not pwithsymtable(symtableproc)^.direct_with then
+                     if (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
+                        assigned(symtableproc) and (symtableproc.symtabletype=withsymtable) and
+                        not twithsymtable(symtableproc).direct_with then
                        begin
                        begin
                           CGmessage(cg_e_cannot_call_cons_dest_inside_with);
                           CGmessage(cg_e_cannot_call_cons_dest_inside_with);
                        end; { Is accepted by Delphi !! }
                        end; { Is accepted by Delphi !! }
@@ -1474,9 +1476,9 @@ implementation
 
 
                      { R.Assign is not a constructor !!! }
                      { R.Assign is not a constructor !!! }
                      { but for R^.Assign, R must be valid !! }
                      { but for R^.Assign, R must be valid !! }
-                     if (procdefinition^.proctypeoption=potype_constructor) or
+                     if (procdefinition.proctypeoption=potype_constructor) or
                         ((methodpointer.nodetype=loadn) and
                         ((methodpointer.nodetype=loadn) and
-                        (not(oo_has_virtual in pobjectdef(methodpointer.resulttype.def)^.objectoptions))) then
+                        (not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions))) then
                        method_must_be_valid:=false
                        method_must_be_valid:=false
                      else
                      else
                        method_must_be_valid:=true;
                        method_must_be_valid:=true;
@@ -1484,8 +1486,8 @@ implementation
                      set_varstate(methodpointer,method_must_be_valid);
                      set_varstate(methodpointer,method_must_be_valid);
                      { The object is already used ven if it is called once }
                      { The object is already used ven if it is called once }
                      if (methodpointer.nodetype=loadn) and
                      if (methodpointer.nodetype=loadn) and
-                        (tloadnode(methodpointer).symtableentry^.typ=varsym) then
-                       pvarsym(tloadnode(methodpointer).symtableentry)^.varstate:=vs_used;
+                        (tloadnode(methodpointer).symtableentry.typ=varsym) then
+                       tvarsym(tloadnode(methodpointer).symtableentry).varstate:=vs_used;
 
 
                      registersfpu:=max(methodpointer.registersfpu,registersfpu);
                      registersfpu:=max(methodpointer.registersfpu,registersfpu);
                      registers32:=max(methodpointer.registers32,registers32);
                      registers32:=max(methodpointer.registers32,registers32);
@@ -1519,7 +1521,7 @@ implementation
            end;
            end;
       errorexit:
       errorexit:
          if inlined then
          if inlined then
-           include(procdefinition^.proccalloptions,pocall_inline);
+           include(procdefinition.proccalloptions,pocall_inline);
       end;
       end;
 
 
 
 
@@ -1544,8 +1546,8 @@ implementation
          inlineprocsym:=tcallnode(callp).symtableprocentry;
          inlineprocsym:=tcallnode(callp).symtableprocentry;
          retoffset:=-target_os.size_of_pointer; { less dangerous as zero (PM) }
          retoffset:=-target_os.size_of_pointer; { less dangerous as zero (PM) }
          para_offset:=0;
          para_offset:=0;
-         para_size:=inlineprocsym^.definition^.para_size(target_os.stackalignment);
-         if ret_in_param(inlineprocsym^.definition^.rettype.def) then
+         para_size:=inlineprocsym.definition.para_size(target_os.stackalignment);
+         if ret_in_param(inlineprocsym.definition.rettype.def) then
            para_size:=para_size+target_os.size_of_pointer;
            para_size:=para_size+target_os.size_of_pointer;
          { copy args }
          { copy args }
          if assigned(code) then
          if assigned(code) then
@@ -1556,7 +1558,7 @@ implementation
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
          registersmmx:=code.registersmmx;
          registersmmx:=code.registersmmx;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
-         resulttype:=inlineprocsym^.definition^.rettype;
+         resulttype:=inlineprocsym.definition.rettype;
       end;
       end;
 
 
     destructor tprocinlinenode.destroy;
     destructor tprocinlinenode.destroy;
@@ -1613,7 +1615,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  2001-04-04 22:42:39  peter
+  Revision 1.27  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.26  2001/04/04 22:42:39  peter
     * move constant folding into det_resulttype
     * move constant folding into det_resulttype
 
 
   Revision 1.25  2001/04/02 21:20:30  peter
   Revision 1.25  2001/04/02 21:20:30  peter

+ 8 - 3
compiler/ncgbas.pas

@@ -52,7 +52,7 @@ unit ncgbas;
 
 
     uses
     uses
       globtype,systems,
       globtype,systems,
-      cutils,cobjects,verbose,globals,
+      cutils,cclasses,verbose,globals,
       aasm,symtable,types,
       aasm,symtable,types,
       htypechk,
       htypechk,
       cpubase,cpuasm,
       cpubase,cpuasm,
@@ -108,7 +108,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2000-10-14 10:14:50  peter
+  Revision 1.2  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.1  2000/10/14 10:14:50  peter
     * moehrendorf oct 2000 rewrite
     * moehrendorf oct 2000 rewrite
 
 
-}
+}

+ 76 - 91
compiler/ncnv.pas

@@ -153,14 +153,14 @@ implementation
 
 
         procedure update_constsethi(t:ttype);
         procedure update_constsethi(t:ttype);
         begin
         begin
-          if ((t.def^.deftype=orddef) and
-              (porddef(t.def)^.high>=constsethi)) then
+          if ((t.def.deftype=orddef) and
+              (torddef(t.def).high>=constsethi)) then
             begin
             begin
-               constsethi:=porddef(t.def)^.high;
+               constsethi:=torddef(t.def).high;
                if htype.def=nil then
                if htype.def=nil then
                  begin
                  begin
                     if (constsethi>255) or
                     if (constsethi>255) or
-                       (porddef(t.def)^.low<0) then
+                       (torddef(t.def).low<0) then
                       htype:=u8bittype
                       htype:=u8bittype
                     else
                     else
                       htype:=t;
                       htype:=t;
@@ -168,12 +168,12 @@ implementation
                if constsethi>255 then
                if constsethi>255 then
                  constsethi:=255;
                  constsethi:=255;
             end
             end
-          else if ((t.def^.deftype=enumdef) and
-                  (penumdef(t.def)^.max>=constsethi)) then
+          else if ((t.def.deftype=enumdef) and
+                  (tenumdef(t.def).max>=constsethi)) then
             begin
             begin
                if htype.def=nil then
                if htype.def=nil then
                  htype:=t;
                  htype:=t;
-               constsethi:=penumdef(t.def)^.max;
+               constsethi:=tenumdef(t.def).max;
             end;
             end;
         end;
         end;
 
 
@@ -232,7 +232,7 @@ implementation
                resulttypepass(p3);
                resulttypepass(p3);
               if codegenerror then
               if codegenerror then
                break;
                break;
-              case p2.resulttype.def^.deftype of
+              case p2.resulttype.def.deftype of
                  enumdef,
                  enumdef,
                  orddef:
                  orddef:
                    begin
                    begin
@@ -353,7 +353,7 @@ implementation
            p.free;
            p.free;
          end;
          end;
       { set the initial set type }
       { set the initial set type }
-        constp.resulttype.setdef(new(psetdef,init(htype,constsethi)));
+        constp.resulttype.setdef(tsetdef.create(htype,constsethi));
       { determine the resulttype for the tree }
       { determine the resulttype for the tree }
         resulttypepass(buildp);
         resulttypepass(buildp);
       { set the new tree }
       { set the new tree }
@@ -427,7 +427,7 @@ implementation
          result:=nil;
          result:=nil;
          if left.nodetype=stringconstn then
          if left.nodetype=stringconstn then
           begin
           begin
-             tstringconstnode(left).st_type:=pstringdef(resulttype.def)^.string_typ;
+             tstringconstnode(left).st_type:=tstringdef(resulttype.def).string_typ;
              tstringconstnode(left).resulttype:=resulttype;
              tstringconstnode(left).resulttype:=resulttype;
              result:=left;
              result:=left;
              left:=nil;
              left:=nil;
@@ -443,7 +443,7 @@ implementation
          if left.nodetype=ordconstn then
          if left.nodetype=ordconstn then
            begin
            begin
               hp:=cstringconstnode.createstr(chr(tordconstnode(left).value),st_default);
               hp:=cstringconstnode.createstr(chr(tordconstnode(left).value),st_default);
-              hp.st_type:=pstringdef(resulttype.def)^.string_typ;
+              hp.st_type:=tstringdef(resulttype.def).string_typ;
               resulttypepass(hp);
               resulttypepass(hp);
               result:=hp;
               result:=hp;
            end;
            end;
@@ -558,8 +558,7 @@ implementation
     function ttypeconvnode.det_resulttype:tnode;
     function ttypeconvnode.det_resulttype:tnode;
       var
       var
         hp : tnode;
         hp : tnode;
-        aprocdef : pprocdef;
-        enable_range_check: boolean;
+        aprocdef : tprocdef;
       begin
       begin
         result:=nil;
         result:=nil;
         resulttype:=totype;
         resulttype:=totype;
@@ -573,16 +572,16 @@ implementation
           begin
           begin
           { becuase is_equal only checks the basetype for sets we need to
           { becuase is_equal only checks the basetype for sets we need to
             check here if we are loading a smallset into a normalset }
             check here if we are loading a smallset into a normalset }
-            if (resulttype.def^.deftype=setdef) and
-               (left.resulttype.def^.deftype=setdef) and
-               (psetdef(resulttype.def)^.settype<>smallset) and
-               (psetdef(left.resulttype.def)^.settype=smallset) then
+            if (resulttype.def.deftype=setdef) and
+               (left.resulttype.def.deftype=setdef) and
+               (tsetdef(resulttype.def).settype<>smallset) and
+               (tsetdef(left.resulttype.def).settype=smallset) then
              begin
              begin
              { try to define the set as a normalset if it's a constant set }
              { try to define the set as a normalset if it's a constant set }
                if left.nodetype=setconstn then
                if left.nodetype=setconstn then
                 begin
                 begin
                   resulttype:=left.resulttype;
                   resulttype:=left.resulttype;
-                  psetdef(resulttype.def)^.settype:=normset
+                  tsetdef(resulttype.def).settype:=normset
                 end
                 end
                else
                else
                 convtype:=tc_load_smallset;
                 convtype:=tc_load_smallset;
@@ -618,45 +617,45 @@ implementation
            use an extra check for them.}
            use an extra check for them.}
            if (m_tp_procvar in aktmodeswitches) then
            if (m_tp_procvar in aktmodeswitches) then
             begin
             begin
-              if (resulttype.def^.deftype=procvardef) and
+              if (resulttype.def.deftype=procvardef) and
                  (is_procsym_load(left) or is_procsym_call(left)) then
                  (is_procsym_load(left) or is_procsym_call(left)) then
                begin
                begin
                  if is_procsym_call(left) then
                  if is_procsym_call(left) then
                   begin
                   begin
-                    hp:=cloadnode.create(pprocsym(tcallnode(left).symtableprocentry),
+                    hp:=cloadnode.create(tprocsym(tcallnode(left).symtableprocentry),
                         tcallnode(left).symtableproc);
                         tcallnode(left).symtableproc);
-                    if (tcallnode(left).symtableprocentry^.owner^.symtabletype=objectsymtable) and
+                    if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
                        assigned(tcallnode(left).methodpointer) then
                        assigned(tcallnode(left).methodpointer) then
                       tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
                       tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
                     resulttypepass(hp);
                     resulttypepass(hp);
                     left.free;
                     left.free;
                     left:=hp;
                     left:=hp;
-                    aprocdef:=pprocdef(left.resulttype.def);
+                    aprocdef:=tprocdef(left.resulttype.def);
                   end
                   end
                  else
                  else
                   begin
                   begin
                     if (left.nodetype<>addrn) then
                     if (left.nodetype<>addrn) then
-                      aprocdef:=pprocsym(tloadnode(left).symtableentry)^.definition;
+                      aprocdef:=tprocsym(tloadnode(left).symtableentry).definition;
                   end;
                   end;
                  convtype:=tc_proc_2_procvar;
                  convtype:=tc_proc_2_procvar;
                  { Now check if the procedure we are going to assign to
                  { Now check if the procedure we are going to assign to
                    the procvar,  is compatible with the procvar's type }
                    the procvar,  is compatible with the procvar's type }
                  if assigned(aprocdef) then
                  if assigned(aprocdef) then
                   begin
                   begin
-                    if not proc_to_procvar_equal(aprocdef,pprocvardef(resulttype.def)) then
-                     CGMessage2(type_e_incompatible_types,aprocdef^.typename,resulttype.def^.typename);
+                    if not proc_to_procvar_equal(aprocdef,tprocvardef(resulttype.def)) then
+                     CGMessage2(type_e_incompatible_types,aprocdef.typename,resulttype.def.typename);
                     result:=first_call_helper(convtype);
                     result:=first_call_helper(convtype);
                   end
                   end
                  else
                  else
-                  CGMessage2(type_e_incompatible_types,left.resulttype.def^.typename,resulttype.def^.typename);
+                  CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
                  exit;
                  exit;
                end;
                end;
             end;
             end;
            if nf_explizit in flags then
            if nf_explizit in flags then
             begin
             begin
               { check if the result could be in a register }
               { check if the result could be in a register }
-              if not(pstoreddef(resulttype.def)^.is_intregable) and
-                not(pstoreddef(resulttype.def)^.is_fpuregable) then
+              if not(tstoreddef(resulttype.def).is_intregable) and
+                not(tstoreddef(resulttype.def).is_fpuregable) then
                 make_not_regable(left);
                 make_not_regable(left);
               { boolean to byte are special because the
               { boolean to byte are special because the
                 location can be different }
                 location can be different }
@@ -680,7 +679,7 @@ implementation
               convtype:=tc_equal;
               convtype:=tc_equal;
 
 
               { enum to ordinal will always be s32bit }
               { enum to ordinal will always be s32bit }
-              if (left.resulttype.def^.deftype=enumdef) and
+              if (left.resulttype.def.deftype=enumdef) and
                  is_ordinal(resulttype.def) then
                  is_ordinal(resulttype.def) then
                begin
                begin
                  if left.nodetype=ordconstn then
                  if left.nodetype=ordconstn then
@@ -693,13 +692,13 @@ implementation
                  else
                  else
                   begin
                   begin
                     if isconvertable(s32bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
                     if isconvertable(s32bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
-                      CGMessage2(type_e_incompatible_types,left.resulttype.def^.typename,resulttype.def^.typename);
+                      CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
                   end;
                   end;
                end
                end
 
 
               { ordinal to enumeration }
               { ordinal to enumeration }
               else
               else
-               if (resulttype.def^.deftype=enumdef) and
+               if (resulttype.def.deftype=enumdef) and
                   is_ordinal(left.resulttype.def) then
                   is_ordinal(left.resulttype.def) then
                 begin
                 begin
                   if left.nodetype=ordconstn then
                   if left.nodetype=ordconstn then
@@ -712,7 +711,7 @@ implementation
                   else
                   else
                    begin
                    begin
                      if IsConvertable(left.resulttype.def,s32bittype.def,convtype,ordconstn,false)=0 then
                      if IsConvertable(left.resulttype.def,s32bittype.def,convtype,ordconstn,false)=0 then
-                       CGMessage2(type_e_incompatible_types,left.resulttype.def^.typename,resulttype.def^.typename);
+                       CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
                    end;
                    end;
                 end
                 end
 
 
@@ -750,7 +749,7 @@ implementation
                    else
                    else
                     begin
                     begin
                       if IsConvertable(left.resulttype.def,u8bittype.def,convtype,ordconstn,false)=0 then
                       if IsConvertable(left.resulttype.def,u8bittype.def,convtype,ordconstn,false)=0 then
-                        CGMessage2(type_e_incompatible_types,left.resulttype.def^.typename,resulttype.def^.typename);
+                        CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
                     end;
                     end;
                  end
                  end
 
 
@@ -769,7 +768,7 @@ implementation
                    else
                    else
                     begin
                     begin
                       if IsConvertable(u8bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
                       if IsConvertable(u8bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
-                        CGMessage2(type_e_incompatible_types,left.resulttype.def^.typename,resulttype.def^.typename);
+                        CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
                     end;
                     end;
                  end
                  end
 
 
@@ -778,23 +777,23 @@ implementation
                else
                else
                 begin
                 begin
                   if not(
                   if not(
-                     (left.resulttype.def^.deftype=formaldef) or
-                     (left.resulttype.def^.size=resulttype.def^.size) or
+                     (left.resulttype.def.deftype=formaldef) or
+                     (left.resulttype.def.size=resulttype.def.size) or
                      (is_void(left.resulttype.def)  and
                      (is_void(left.resulttype.def)  and
                       (left.nodetype=derefn))
                       (left.nodetype=derefn))
                      ) then
                      ) then
                     CGMessage(cg_e_illegal_type_conversion);
                     CGMessage(cg_e_illegal_type_conversion);
-                  if ((left.resulttype.def^.deftype=orddef) and
-                      (resulttype.def^.deftype=pointerdef)) or
-                      ((resulttype.def^.deftype=orddef) and
-                       (left.resulttype.def^.deftype=pointerdef)) then
+                  if ((left.resulttype.def.deftype=orddef) and
+                      (resulttype.def.deftype=pointerdef)) or
+                      ((resulttype.def.deftype=orddef) and
+                       (left.resulttype.def.deftype=pointerdef)) then
                     CGMessage(cg_d_pointer_to_longint_conv_not_portable);
                     CGMessage(cg_d_pointer_to_longint_conv_not_portable);
                 end;
                 end;
 
 
                { the conversion into a strutured type is only }
                { the conversion into a strutured type is only }
                { possible, if the source is no register    }
                { possible, if the source is no register    }
-               if ((resulttype.def^.deftype in [recorddef,stringdef,arraydef]) or
-                   ((resulttype.def^.deftype=objectdef) and not(is_class(resulttype.def)))
+               if ((resulttype.def.deftype in [recorddef,stringdef,arraydef]) or
+                   ((resulttype.def.deftype=objectdef) and not(is_class(resulttype.def)))
                   ) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) { and
                   ) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) { and
                    it also works if the assignment is overloaded
                    it also works if the assignment is overloaded
                    YES but this code is not executed if assignment is overloaded (PM)
                    YES but this code is not executed if assignment is overloaded (PM)
@@ -802,7 +801,7 @@ implementation
                  CGMessage(cg_e_illegal_type_conversion);
                  CGMessage(cg_e_illegal_type_conversion);
             end
             end
            else
            else
-            CGMessage2(type_e_incompatible_types,left.resulttype.def^.typename,resulttype.def^.typename);
+            CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
          end;
          end;
 
 
        { tp7 procvar support, when right is not a procvardef and we got a
        { tp7 procvar support, when right is not a procvardef and we got a
@@ -810,8 +809,8 @@ implementation
          result is already done in is_convertible, also no conflict with
          result is already done in is_convertible, also no conflict with
          @procvar is here because that has an extra addrn }
          @procvar is here because that has an extra addrn }
          if (m_tp_procvar in aktmodeswitches) and
          if (m_tp_procvar in aktmodeswitches) and
-            (resulttype.def^.deftype<>procvardef) and
-            (left.resulttype.def^.deftype=procvardef) and
+            (resulttype.def.deftype<>procvardef) and
+            (left.resulttype.def.deftype=procvardef) and
             (left.nodetype=loadn) then
             (left.nodetype=loadn) then
           begin
           begin
             hp:=ccallnode.create(nil,nil,nil,nil);
             hp:=ccallnode.create(nil,nil,nil,nil);
@@ -823,30 +822,11 @@ implementation
         { ordinal contants can be directly converted }
         { ordinal contants can be directly converted }
         if (left.nodetype=ordconstn) and is_ordinal(resulttype.def)  then
         if (left.nodetype=ordconstn) and is_ordinal(resulttype.def)  then
           begin
           begin
-             { range checking is done in cordconstnode.create (PFV) }
-             { disable for explicit type casts (JM) }
-             if (nf_explizit in flags) and
-                (cs_check_range in aktlocalswitches) then
-               begin
-                 exclude(aktlocalswitches,cs_check_range);
-                 enable_range_check := true;
-               end
-             else
-               enable_range_check := false;
-             hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
-             resulttypepass(hp);
-             { do sign extension if necessary (JM) }
-             if not (cs_check_range in aktlocalswitches) and
-                is_signed(resulttype.def) then
-               with tordconstnode(hp) do
-                 case resulttype.def^.size of
-                   1: value := shortint(value);
-                   2: value := smallint(value);
-                   4: value := longint(value);
-                 end;
-             if enable_range_check then
-               include(aktlocalswitches,cs_check_range);
-             result:=hp;
+             { replace the resulttype and recheck the range }
+             left.resulttype:=resulttype;
+             testrange(left.resulttype.def,tordconstnode(left).value,(nf_explizit in flags));
+             result:=left;
+             left:=nil;
              exit;
              exit;
           end;
           end;
 
 
@@ -866,7 +846,7 @@ implementation
       begin
       begin
         first_int_to_int:=nil;
         first_int_to_int:=nil;
         if (left.location.loc<>LOC_REGISTER) and
         if (left.location.loc<>LOC_REGISTER) and
-           (resulttype.def^.size>left.resulttype.def^.size) then
+           (resulttype.def.size>left.resulttype.def.size) then
            location.loc:=LOC_REGISTER;
            location.loc:=LOC_REGISTER;
         if is_64bitint(resulttype.def) then
         if is_64bitint(resulttype.def) then
           registers32:=max(registers32,2)
           registers32:=max(registers32,2)
@@ -894,14 +874,14 @@ implementation
     function ttypeconvnode.first_string_to_string : tnode;
     function ttypeconvnode.first_string_to_string : tnode;
       begin
       begin
          first_string_to_string:=nil;
          first_string_to_string:=nil;
-         if pstringdef(resulttype.def)^.string_typ<>
-            pstringdef(left.resulttype.def)^.string_typ then
+         if tstringdef(resulttype.def).string_typ<>
+            tstringdef(left.resulttype.def).string_typ then
            begin
            begin
              procinfo^.flags:=procinfo^.flags or pi_do_call;
              procinfo^.flags:=procinfo^.flags or pi_do_call;
            end;
            end;
          { for simplicity lets first keep all ansistrings
          { for simplicity lets first keep all ansistrings
            as LOC_MEM, could also become LOC_REGISTER }
            as LOC_MEM, could also become LOC_REGISTER }
-         if pstringdef(resulttype.def)^.string_typ in [st_ansistring,st_widestring] then
+         if tstringdef(resulttype.def).string_typ in [st_ansistring,st_widestring] then
            { we may use ansistrings so no fast exit here }
            { we may use ansistrings so no fast exit here }
            procinfo^.no_fast_exit:=true;
            procinfo^.no_fast_exit:=true;
          location.loc:=LOC_MEM;
          location.loc:=LOC_MEM;
@@ -945,8 +925,8 @@ implementation
          first_real_to_real:=nil;
          first_real_to_real:=nil;
         { comp isn't a floating type }
         { comp isn't a floating type }
 {$ifdef i386}
 {$ifdef i386}
-         if (pfloatdef(resulttype.def)^.typ=s64comp) and
-            (pfloatdef(left.resulttype.def)^.typ<>s64comp) and
+         if (tfloatdef(resulttype.def).typ=s64comp) and
+            (tfloatdef(left.resulttype.def).typ<>s64comp) and
             not (nf_explizit in flags) then
             not (nf_explizit in flags) then
            CGMessage(type_w_convert_real_2_comp);
            CGMessage(type_w_convert_real_2_comp);
 {$endif}
 {$endif}
@@ -988,7 +968,7 @@ implementation
          { byte(boolean) or word(wordbool) or longint(longbool) must
          { byte(boolean) or word(wordbool) or longint(longbool) must
          be accepted for var parameters }
          be accepted for var parameters }
          if (nf_explizit in flags) and
          if (nf_explizit in flags) and
-            (left.resulttype.def^.size=resulttype.def^.size) and
+            (left.resulttype.def.size=resulttype.def.size) and
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
            exit;
            exit;
          location.loc:=LOC_REGISTER;
          location.loc:=LOC_REGISTER;
@@ -1003,7 +983,7 @@ implementation
          { byte(boolean) or word(wordbool) or longint(longbool) must
          { byte(boolean) or word(wordbool) or longint(longbool) must
          be accepted for var parameters }
          be accepted for var parameters }
          if (nf_explizit in flags) and
          if (nf_explizit in flags) and
-            (left.resulttype.def^.size=resulttype.def^.size) and
+            (left.resulttype.def.size=resulttype.def.size) and
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
             (left.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
            exit;
            exit;
          location.loc:=LOC_REGISTER;
          location.loc:=LOC_REGISTER;
@@ -1141,8 +1121,8 @@ implementation
         if nf_explizit in flags then
         if nf_explizit in flags then
          begin
          begin
            { check if the result could be in a register }
            { check if the result could be in a register }
-           if not(pstoreddef(resulttype.def)^.is_intregable) and
-              not(pstoreddef(resulttype.def)^.is_fpuregable) then
+           if not(tstoreddef(resulttype.def).is_intregable) and
+              not(tstoreddef(resulttype.def).is_fpuregable) then
             make_not_regable(left);
             make_not_regable(left);
          end;
          end;
 
 
@@ -1187,16 +1167,16 @@ implementation
          if codegenerror then
          if codegenerror then
            exit;
            exit;
 
 
-         if (right.resulttype.def^.deftype=classrefdef) then
+         if (right.resulttype.def.deftype=classrefdef) then
           begin
           begin
             { left must be a class }
             { left must be a class }
             if is_class(left.resulttype.def) then
             if is_class(left.resulttype.def) then
              begin
              begin
                { the operands must be related }
                { the operands must be related }
-               if (not(pobjectdef(left.resulttype.def)^.is_related(
-                  pobjectdef(pclassrefdef(right.resulttype.def)^.pointertype.def)))) and
-                  (not(pobjectdef(pclassrefdef(right.resulttype.def)^.pointertype.def)^.is_related(
-                  pobjectdef(left.resulttype.def)))) then
+               if (not(tobjectdef(left.resulttype.def).is_related(
+                  tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
+                  (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
+                  tobjectdef(left.resulttype.def)))) then
                  CGMessage(type_e_mismatch);
                  CGMessage(type_e_mismatch);
              end
              end
             else
             else
@@ -1246,21 +1226,21 @@ implementation
          if codegenerror then
          if codegenerror then
            exit;
            exit;
 
 
-         if (right.resulttype.def^.deftype=classrefdef) then
+         if (right.resulttype.def.deftype=classrefdef) then
           begin
           begin
             { left must be a class }
             { left must be a class }
             if is_class(left.resulttype.def) then
             if is_class(left.resulttype.def) then
              begin
              begin
                { the operands must be related }
                { the operands must be related }
-               if (not(pobjectdef(left.resulttype.def)^.is_related(
-                  pobjectdef(pclassrefdef(right.resulttype.def)^.pointertype.def)))) and
-                  (not(pobjectdef(pclassrefdef(right.resulttype.def)^.pointertype.def)^.is_related(
-                  pobjectdef(left.resulttype.def)))) then
+               if (not(tobjectdef(left.resulttype.def).is_related(
+                  tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
+                  (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
+                  tobjectdef(left.resulttype.def)))) then
                  CGMessage(type_e_mismatch);
                  CGMessage(type_e_mismatch);
              end
              end
             else
             else
              CGMessage(type_e_mismatch);
              CGMessage(type_e_mismatch);
-            resulttype:=pclassrefdef(right.resulttype.def)^.pointertype;
+            resulttype:=tclassrefdef(right.resulttype.def).pointertype;
           end
           end
          else
          else
           CGMessage(type_e_mismatch);
           CGMessage(type_e_mismatch);
@@ -1295,7 +1275,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2001-04-04 22:42:39  peter
+  Revision 1.24  2001-04-13 01:22:08  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.23  2001/04/04 22:42:39  peter
     * move constant folding into det_resulttype
     * move constant folding into det_resulttype
 
 
   Revision 1.22  2001/04/02 21:20:30  peter
   Revision 1.22  2001/04/02 21:20:30  peter

+ 29 - 25
compiler/ncon.pas

@@ -36,7 +36,7 @@ interface
        trealconstnode = class(tnode)
        trealconstnode = class(tnode)
           restype : ttype;
           restype : ttype;
           value_real : bestreal;
           value_real : bestreal;
-          lab_real : pasmlabel;
+          lab_real : tasmlabel;
           constructor create(v : bestreal;const t:ttype);virtual;
           constructor create(v : bestreal;const t:ttype);virtual;
           function getcopy : tnode;override;
           function getcopy : tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
@@ -67,7 +67,7 @@ interface
        tstringconstnode = class(tnode)
        tstringconstnode = class(tnode)
           value_str : pchar;
           value_str : pchar;
           len : longint;
           len : longint;
-          lab_str : pasmlabel;
+          lab_str : tasmlabel;
           st_type : tstringtype;
           st_type : tstringtype;
           constructor createstr(const s : string;st:tstringtype);virtual;
           constructor createstr(const s : string;st:tstringtype);virtual;
           constructor createpchar(s : pchar;l : longint);virtual;
           constructor createpchar(s : pchar;l : longint);virtual;
@@ -83,7 +83,7 @@ interface
        tsetconstnode = class(tunarynode)
        tsetconstnode = class(tunarynode)
           restype : ttype;
           restype : ttype;
           value_set : pconstset;
           value_set : pconstset;
-          lab_set : pasmlabel;
+          lab_set : tasmlabel;
           constructor create(s : pconstset;const t:ttype);virtual;
           constructor create(s : pconstset;const t:ttype);virtual;
           destructor destroy;override;
           destructor destroy;override;
           function getcopy : tnode;override;
           function getcopy : tnode;override;
@@ -107,7 +107,7 @@ interface
        cnilnode : class of tnilnode;
        cnilnode : class of tnilnode;
 
 
     function genintconstnode(v : TConstExprInt) : tordconstnode;
     function genintconstnode(v : TConstExprInt) : tordconstnode;
-    function genenumnode(v : penumsym) : tordconstnode;
+    function genenumnode(v : tenumsym) : tordconstnode;
 
 
     { some helper routines }
     { some helper routines }
 {$ifdef INT64FUNCRESOK}
 {$ifdef INT64FUNCRESOK}
@@ -123,7 +123,7 @@ interface
     function is_constresourcestringnode(p : tnode) : boolean;
     function is_constresourcestringnode(p : tnode) : boolean;
     function str_length(p : tnode) : longint;
     function str_length(p : tnode) : longint;
     function is_emptyset(p : tnode):boolean;
     function is_emptyset(p : tnode):boolean;
-    function genconstsymtree(p : pconstsym) : tnode;
+    function genconstsymtree(p : tconstsym) : tnode;
 
 
 implementation
 implementation
 
 
@@ -150,12 +150,12 @@ implementation
       end;
       end;
 
 
 
 
-    function genenumnode(v : penumsym) : tordconstnode;
+    function genenumnode(v : tenumsym) : tordconstnode;
       var
       var
         htype : ttype;
         htype : ttype;
       begin
       begin
-         htype.setdef(v^.definition);
-         genenumnode:=cordconstnode.create(v^.value,htype);
+         htype.setdef(v.definition);
+         genenumnode:=cordconstnode.create(v.value,htype);
       end;
       end;
 
 
 
 
@@ -211,8 +211,8 @@ implementation
     function is_constresourcestringnode(p : tnode) : boolean;
     function is_constresourcestringnode(p : tnode) : boolean;
       begin
       begin
         is_constresourcestringnode:=(p.nodetype=loadn) and
         is_constresourcestringnode:=(p.nodetype=loadn) and
-          (tloadnode(p).symtableentry^.typ=constsym) and
-          (pconstsym(tloadnode(p).symtableentry)^.consttyp=constresourcestring);
+          (tloadnode(p).symtableentry.typ=constsym) and
+          (tconstsym(tloadnode(p).symtableentry).consttyp=constresourcestring);
       end;
       end;
 
 
 
 
@@ -238,43 +238,43 @@ implementation
       end;
       end;
 
 
 
 
-    function genconstsymtree(p : pconstsym) : tnode;
+    function genconstsymtree(p : tconstsym) : tnode;
       var
       var
         p1  : tnode;
         p1  : tnode;
         len : longint;
         len : longint;
         pc  : pchar;
         pc  : pchar;
       begin
       begin
         p1:=nil;
         p1:=nil;
-        case p^.consttyp of
+        case p.consttyp of
           constint :
           constint :
-            p1:=genintconstnode(p^.value);
+            p1:=genintconstnode(p.value);
           conststring :
           conststring :
             begin
             begin
-              len:=p^.len;
+              len:=p.len;
               if not(cs_ansistrings in aktlocalswitches) and (len>255) then
               if not(cs_ansistrings in aktlocalswitches) and (len>255) then
                len:=255;
                len:=255;
               getmem(pc,len+1);
               getmem(pc,len+1);
-              move(pchar(tpointerord(p^.value))^,pc^,len);
+              move(pchar(tpointerord(p.value))^,pc^,len);
               pc[len]:=#0;
               pc[len]:=#0;
               p1:=cstringconstnode.createpchar(pc,len);
               p1:=cstringconstnode.createpchar(pc,len);
             end;
             end;
           constchar :
           constchar :
-            p1:=cordconstnode.create(p^.value,cchartype);
+            p1:=cordconstnode.create(p.value,cchartype);
           constreal :
           constreal :
-            p1:=crealconstnode.create(pbestreal(tpointerord(p^.value))^,pbestrealtype^);
+            p1:=crealconstnode.create(pbestreal(tpointerord(p.value))^,pbestrealtype^);
           constbool :
           constbool :
-            p1:=cordconstnode.create(p^.value,booltype);
+            p1:=cordconstnode.create(p.value,booltype);
           constset :
           constset :
-            p1:=csetconstnode.create(pconstset(tpointerord(p^.value)),p^.consttype);
+            p1:=csetconstnode.create(pconstset(tpointerord(p.value)),p.consttype);
           constord :
           constord :
-            p1:=cordconstnode.create(p^.value,p^.consttype);
+            p1:=cordconstnode.create(p.value,p.consttype);
           constpointer :
           constpointer :
-            p1:=cpointerconstnode.create(p^.value,p^.consttype);
+            p1:=cpointerconstnode.create(p.value,p.consttype);
           constnil :
           constnil :
             p1:=cnilnode.create;
             p1:=cnilnode.create;
           constresourcestring:
           constresourcestring:
             begin
             begin
-              p1:=cloadnode.create(pvarsym(p),pvarsym(p)^.owner);
+              p1:=cloadnode.create(tvarsym(p),tvarsym(p).owner);
               p1.resulttype:=cansistringtype;
               p1.resulttype:=cansistringtype;
             end;
             end;
         end;
         end;
@@ -358,8 +358,7 @@ implementation
       begin
       begin
         result:=nil;
         result:=nil;
         resulttype:=restype;
         resulttype:=restype;
-        if resulttype.def^.deftype=orddef then
-         testrange(resulttype.def,value);
+        testrange(resulttype.def,value,false);
       end;
       end;
 
 
     function tordconstnode.pass_1 : tnode;
     function tordconstnode.pass_1 : tnode;
@@ -645,7 +644,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-04-02 21:20:30  peter
+  Revision 1.17  2001-04-13 01:22:09  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.16  2001/04/02 21:20:30  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.15  2000/12/31 11:14:10  jonas
   Revision 1.15  2000/12/31 11:14:10  jonas

+ 22 - 17
compiler/nflw.pas

@@ -80,9 +80,9 @@ interface
        end;
        end;
 
 
        tgotonode = class(tnode)
        tgotonode = class(tnode)
-          labelnr : pasmlabel;
-          labsym : plabelsym;
-          constructor create(p : pasmlabel);virtual;
+          labelnr : tasmlabel;
+          labsym : tlabelsym;
+          constructor create(p : tasmlabel);virtual;
           function getcopy : tnode;override;
           function getcopy : tnode;override;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
@@ -90,10 +90,10 @@ interface
        end;
        end;
 
 
        tlabelnode = class(tunarynode)
        tlabelnode = class(tunarynode)
-          labelnr : pasmlabel;
+          labelnr : tasmlabel;
           exceptionblock : tnode;
           exceptionblock : tnode;
-          labsym : plabelsym;
-          constructor create(p : pasmlabel;l:tnode);virtual;
+          labsym : tlabelsym;
+          constructor create(p : tasmlabel;l:tnode);virtual;
           function getcopy : tnode;override;
           function getcopy : tnode;override;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
@@ -123,8 +123,8 @@ interface
        end;
        end;
 
 
        tonnode = class(tbinarynode)
        tonnode = class(tbinarynode)
-          exceptsymtable : psymtable;
-          excepttype : pobjectdef;
+          exceptsymtable : tsymtable;
+          excepttype : tobjectdef;
           constructor create(l,r:tnode);virtual;
           constructor create(l,r:tnode);virtual;
           destructor destroy;override;
           destructor destroy;override;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
@@ -362,7 +362,7 @@ implementation
          if not codegenerror then
          if not codegenerror then
           begin
           begin
             if not is_boolean(left.resulttype.def) then
             if not is_boolean(left.resulttype.def) then
-              Message1(type_e_boolean_expr_expected,left.resulttype.def^.typename);
+              Message1(type_e_boolean_expr_expected,left.resulttype.def.typename);
           end;
           end;
 
 
          registers32:=left.registers32;
          registers32:=left.registers32;
@@ -546,11 +546,11 @@ implementation
            in the same lexlevel }
            in the same lexlevel }
          if (hp.nodetype=funcretn) or
          if (hp.nodetype=funcretn) or
             ((hp.nodetype=loadn) and
             ((hp.nodetype=loadn) and
-             ((tloadnode(hp).symtable^.symtablelevel<=1) or
-              (tloadnode(hp).symtable^.symtablelevel=lexlevel))) then
+             ((tloadnode(hp).symtable.symtablelevel<=1) or
+              (tloadnode(hp).symtable.symtablelevel=lexlevel))) then
           begin
           begin
-            if tloadnode(hp).symtableentry^.typ=varsym then
-              pvarsym(tloadnode(hp).symtableentry)^.varstate:=vs_used;
+            if tloadnode(hp).symtableentry.typ=varsym then
+              tvarsym(tloadnode(hp).symtableentry).varstate:=vs_used;
             if (not(is_ordinal(t2.resulttype.def)) or is_64bitint(t2.resulttype.def)) then
             if (not(is_ordinal(t2.resulttype.def)) or is_64bitint(t2.resulttype.def)) then
               CGMessagePos(hp.fileinfo,type_e_ordinal_expr_expected);
               CGMessagePos(hp.fileinfo,type_e_ordinal_expr_expected);
           end
           end
@@ -700,7 +700,7 @@ implementation
                              TGOTONODE
                              TGOTONODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tgotonode.create(p : pasmlabel);
+    constructor tgotonode.create(p : tasmlabel);
 
 
       begin
       begin
         inherited create(goton);
         inherited create(goton);
@@ -741,7 +741,7 @@ implementation
                              TLABELNODE
                              TLABELNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tlabelnode.create(p : pasmlabel;l:tnode);
+    constructor tlabelnode.create(p : tasmlabel;l:tnode);
 
 
       begin
       begin
         inherited create(labeln,l);
         inherited create(labeln,l);
@@ -1012,7 +1012,7 @@ implementation
     destructor tonnode.destroy;
     destructor tonnode.destroy;
       begin
       begin
         if assigned(exceptsymtable) then
         if assigned(exceptsymtable) then
-         dispose(exceptsymtable,done);
+         exceptsymtable.free;
         inherited destroy;
         inherited destroy;
       end;
       end;
 
 
@@ -1136,7 +1136,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2001-04-02 21:20:30  peter
+  Revision 1.16  2001-04-13 01:22:09  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.15  2001/04/02 21:20:30  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.14  2001/03/25 12:27:59  peter
   Revision 1.14  2001/03/25 12:27:59  peter

+ 70 - 66
compiler/ninl.pas

@@ -95,16 +95,16 @@ implementation
         function do_lowhigh(const t:ttype) : tnode;
         function do_lowhigh(const t:ttype) : tnode;
         var
         var
            v    : tconstexprint;
            v    : tconstexprint;
-           enum : penumsym;
+           enum : tenumsym;
            hp   : tnode;
            hp   : tnode;
         begin
         begin
-           case t.def^.deftype of
+           case t.def.deftype of
              orddef:
              orddef:
                begin
                begin
                   if inlinenumber=in_low_x then
                   if inlinenumber=in_low_x then
-                    v:=porddef(t.def)^.low
+                    v:=torddef(t.def).low
                   else
                   else
-                    v:=porddef(t.def)^.high;
+                    v:=torddef(t.def).high;
                   { low/high of torddef are longints, so we need special }
                   { low/high of torddef are longints, so we need special }
                   { handling for cardinal and 64bit types (JM)           }
                   { handling for cardinal and 64bit types (JM)           }
                   if is_signed(t.def) and
                   if is_signed(t.def) and
@@ -127,17 +127,16 @@ implementation
                   if not is_signed(t.def) and
                   if not is_signed(t.def) and
                      is_64bitint(t.def) and
                      is_64bitint(t.def) and
                      (inlinenumber = in_high_x) then
                      (inlinenumber = in_high_x) then
-                    tordconstnode(hp).value :=
-                      tconstexprint(qword($ffffffff) shl 32 or $ffffffff);
+                    tordconstnode(hp).value := -1; { is the same as qword($ffffffffffffffff) }
                   do_lowhigh:=hp;
                   do_lowhigh:=hp;
                end;
                end;
              enumdef:
              enumdef:
                begin
                begin
-                  enum:=penumsym(Penumdef(t.def)^.firstenum);
-                  v:=Penumdef(t.def)^.maxval;
+                  enum:=tenumsym(tenumdef(t.def).firstenum);
+                  v:=tenumdef(t.def).maxval;
                   if inlinenumber=in_high_x then
                   if inlinenumber=in_high_x then
-                    while assigned(enum) and (enum^.value <> v) do
-                      enum:=enum^.nextenum;
+                    while assigned(enum) and (enum.value <> v) do
+                      enum:=enum.nextenum;
                   if not assigned(enum) then
                   if not assigned(enum) then
                     internalerror(309993)
                     internalerror(309993)
                   else
                   else
@@ -178,7 +177,7 @@ implementation
          vl,vl2    : longint;
          vl,vl2    : longint;
          vr        : bestreal;
          vr        : bestreal;
          hp        :  tnode;
          hp        :  tnode;
-         srsym     : psym;
+         srsym     : tsym;
       label
       label
          myexit;
          myexit;
       begin
       begin
@@ -291,14 +290,14 @@ implementation
                  in_const_odd :
                  in_const_odd :
                    begin
                    begin
                      if isreal then
                      if isreal then
-                      CGMessage1(type_e_integer_expr_expected,left.resulttype.def^.typename)
+                      CGMessage1(type_e_integer_expr_expected,left.resulttype.def.typename)
                      else
                      else
                       hp:=cordconstnode.create(byte(odd(vl)),booltype);
                       hp:=cordconstnode.create(byte(odd(vl)),booltype);
                    end;
                    end;
                  in_const_swap_word :
                  in_const_swap_word :
                    begin
                    begin
                      if isreal then
                      if isreal then
-                      CGMessage1(type_e_integer_expr_expected,left.resulttype.def^.typename)
+                      CGMessage1(type_e_integer_expr_expected,left.resulttype.def.typename)
                      else
                      else
                       hp:=cordconstnode.create((vl and $ff) shl 8+(vl shr 8),left.resulttype);
                       hp:=cordconstnode.create((vl and $ff) shl 8+(vl shr 8),left.resulttype);
                    end;
                    end;
@@ -463,10 +462,10 @@ implementation
                       goto myexit;
                       goto myexit;
                     end;
                     end;
                    set_varstate(left,true);
                    set_varstate(left,true);
-                   case left.resulttype.def^.deftype of
+                   case left.resulttype.def.deftype of
                      orddef :
                      orddef :
                        begin
                        begin
-                         case porddef(left.resulttype.def)^.typ of
+                         case torddef(left.resulttype.def).typ of
                            bool8bit,
                            bool8bit,
                            uchar:
                            uchar:
                              begin
                              begin
@@ -537,7 +536,7 @@ implementation
 
 
                   { we don't need string convertions here }
                   { we don't need string convertions here }
                   if (left.nodetype=typeconvn) and
                   if (left.nodetype=typeconvn) and
-                     (ttypeconvnode(left).left.resulttype.def^.deftype=stringdef) then
+                     (ttypeconvnode(left).left.resulttype.def.deftype=stringdef) then
                     begin
                     begin
                        hp:=ttypeconvnode(left).left;
                        hp:=ttypeconvnode(left).left;
                        ttypeconvnode(left).left:=nil;
                        ttypeconvnode(left).left:=nil;
@@ -570,7 +569,7 @@ implementation
                      resulttype:=u8bittype;
                      resulttype:=u8bittype;
 
 
                    { check the type, must be string or char }
                    { check the type, must be string or char }
-                   if (left.resulttype.def^.deftype<>stringdef) and
+                   if (left.resulttype.def.deftype<>stringdef) and
                       (not is_char(left.resulttype.def)) then
                       (not is_char(left.resulttype.def)) then
                      CGMessage(type_e_mismatch);
                      CGMessage(type_e_mismatch);
                 end;
                 end;
@@ -608,8 +607,8 @@ implementation
                      CGMessage(type_e_ordinal_expr_expected)
                      CGMessage(type_e_ordinal_expr_expected)
                    else
                    else
                      begin
                      begin
-                       if (resulttype.def^.deftype=enumdef) and
-                          (penumdef(resulttype.def)^.has_jumps) then
+                       if (resulttype.def.deftype=enumdef) and
+                          (tenumdef(resulttype.def).has_jumps) then
                          CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible);
                          CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible);
                      end;
                      end;
 
 
@@ -643,7 +642,7 @@ implementation
                         valid_for_assign(ppn.left,false);
                         valid_for_assign(ppn.left,false);
                         set_varstate(ppn.left,false);
                         set_varstate(ppn.left,false);
                         { first param must be a string or dynamic array ...}
                         { first param must be a string or dynamic array ...}
-                        if not((ppn.left.resulttype.def^.deftype=stringdef) or
+                        if not((ppn.left.resulttype.def.deftype=stringdef) or
                            (is_dynamic_array(ppn.left.resulttype.def))) then
                            (is_dynamic_array(ppn.left.resulttype.def))) then
                           CGMessage(type_e_mismatch);
                           CGMessage(type_e_mismatch);
 
 
@@ -654,8 +653,8 @@ implementation
 
 
                        { convert shortstrings to openstring parameters }
                        { convert shortstrings to openstring parameters }
                        { (generate the hightree) (JM)                  }
                        { (generate the hightree) (JM)                  }
-                       if (ppn.left.resulttype.def^.deftype = stringdef) and
-                          (pstringdef(ppn.left.resulttype.def)^.string_typ =
+                       if (ppn.left.resulttype.def.deftype = stringdef) and
+                          (tstringdef(ppn.left.resulttype.def).string_typ =
                             st_shortstring) then
                             st_shortstring) then
                          begin
                          begin
                            dummycoll:=tparaitem.create;
                            dummycoll:=tparaitem.create;
@@ -698,7 +697,7 @@ implementation
                        { first param must be var }
                        { first param must be var }
                        valid_for_assign(tcallparanode(left).left,false);
                        valid_for_assign(tcallparanode(left).left,false);
 
 
-                       if (left.resulttype.def^.deftype in [enumdef,pointerdef]) or
+                       if (left.resulttype.def.deftype in [enumdef,pointerdef]) or
                           is_ordinal(left.resulttype.def) then
                           is_ordinal(left.resulttype.def) then
                         begin
                         begin
                           { two paras ? }
                           { two paras ? }
@@ -764,7 +763,7 @@ implementation
                        valid_for_assign(tcallparanode(left).left,false);
                        valid_for_assign(tcallparanode(left).left,false);
                        { check type }
                        { check type }
                        if assigned(left.resulttype.def) and
                        if assigned(left.resulttype.def) and
-                          (left.resulttype.def^.deftype=setdef) then
+                          (left.resulttype.def.deftype=setdef) then
                          begin
                          begin
                             { two paras ? }
                             { two paras ? }
                             if assigned(tcallparanode(left).right) then
                             if assigned(tcallparanode(left).right) then
@@ -772,7 +771,7 @@ implementation
                                  { insert a type conversion       }
                                  { insert a type conversion       }
                                  { to the type of the set elements  }
                                  { to the type of the set elements  }
                                  inserttypeconv(tcallparanode(tcallparanode(left).right).left,
                                  inserttypeconv(tcallparanode(tcallparanode(left).right).left,
-                                   psetdef(left.resulttype.def)^.elementtype);
+                                   tsetdef(left.resulttype.def).elementtype);
                                  { only three parameters are allowed }
                                  { only three parameters are allowed }
                                  if assigned(tcallparanode(tcallparanode(left).right).right) then
                                  if assigned(tcallparanode(tcallparanode(left).right).right) then
                                    CGMessage(cg_e_illegal_expression);
                                    CGMessage(cg_e_illegal_expression);
@@ -789,7 +788,7 @@ implementation
               in_high_x:
               in_high_x:
                 begin
                 begin
                   set_varstate(left,false);
                   set_varstate(left,false);
-                  case left.resulttype.def^.deftype of
+                  case left.resulttype.def.deftype of
                     orddef,
                     orddef,
                     enumdef:
                     enumdef:
                       begin
                       begin
@@ -799,7 +798,7 @@ implementation
                       end;
                       end;
                     setdef:
                     setdef:
                       begin
                       begin
-                        hp:=do_lowhigh(Psetdef(left.resulttype.def)^.elementtype);
+                        hp:=do_lowhigh(tsetdef(left.resulttype.def).elementtype);
                         resulttypepass(hp);
                         resulttypepass(hp);
                         result:=hp;
                         result:=hp;
                       end;
                       end;
@@ -807,7 +806,7 @@ implementation
                       begin
                       begin
                         if inlinenumber=in_low_x then
                         if inlinenumber=in_low_x then
                          begin
                          begin
-                           hp:=cordconstnode.create(Parraydef(left.resulttype.def)^.lowrange,parraydef(left.resulttype.def)^.rangetype);
+                           hp:=cordconstnode.create(tarraydef(left.resulttype.def).lowrange,tarraydef(left.resulttype.def).rangetype);
                            resulttypepass(hp);
                            resulttypepass(hp);
                            result:=hp;
                            result:=hp;
                          end
                          end
@@ -816,14 +815,14 @@ implementation
                            if is_open_array(left.resulttype.def) or
                            if is_open_array(left.resulttype.def) or
                              is_array_of_const(left.resulttype.def) then
                              is_array_of_const(left.resulttype.def) then
                             begin
                             begin
-                              srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
-                              hp:=cloadnode.create(pvarsym(srsym),tloadnode(left).symtable);
+                              srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+tvarsym(tloadnode(left).symtableentry).name);
+                              hp:=cloadnode.create(tvarsym(srsym),tloadnode(left).symtable);
                               resulttypepass(hp);
                               resulttypepass(hp);
                               result:=hp;
                               result:=hp;
                             end
                             end
                            else
                            else
                             begin
                             begin
-                              hp:=cordconstnode.create(Parraydef(left.resulttype.def)^.highrange,parraydef(left.resulttype.def)^.rangetype);
+                              hp:=cordconstnode.create(tarraydef(left.resulttype.def).highrange,tarraydef(left.resulttype.def).rangetype);
                               resulttypepass(hp);
                               resulttypepass(hp);
                               result:=hp;
                               result:=hp;
                             end;
                             end;
@@ -841,14 +840,14 @@ implementation
                          begin
                          begin
                            if is_open_string(left.resulttype.def) then
                            if is_open_string(left.resulttype.def) then
                             begin
                             begin
-                              srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
-                              hp:=cloadnode.create(pvarsym(srsym),tloadnode(left).symtable);
+                              srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+tvarsym(tloadnode(left).symtableentry).name);
+                              hp:=cloadnode.create(tvarsym(srsym),tloadnode(left).symtable);
                               resulttypepass(hp);
                               resulttypepass(hp);
                               result:=hp;
                               result:=hp;
                             end
                             end
                            else
                            else
                             begin
                             begin
-                              hp:=cordconstnode.create(Pstringdef(left.resulttype.def)^.len,u8bittype);
+                              hp:=cordconstnode.create(tstringdef(left.resulttype.def).len,u8bittype);
                               resulttypepass(hp);
                               resulttypepass(hp);
                               result:=hp;
                               result:=hp;
                             end;
                             end;
@@ -1010,7 +1009,7 @@ implementation
     function tinlinenode.pass_1 : tnode;
     function tinlinenode.pass_1 : tnode;
       var
       var
          p1,hp,hpp  :  tnode;
          p1,hp,hpp  :  tnode;
-         srsym : psym;
+         srsym : tsym;
 {$ifndef NOCOLONCHECK}
 {$ifndef NOCOLONCHECK}
          frac_para,length_para : tnode;
          frac_para,length_para : tnode;
 {$endif ndef NOCOLONCHECK}
 {$endif ndef NOCOLONCHECK}
@@ -1052,12 +1051,12 @@ implementation
             begin
             begin
               if push_high_param(left.resulttype.def) then
               if push_high_param(left.resulttype.def) then
                begin
                begin
-                 srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
-                 hp:=caddnode.create(addn,cloadnode.create(pvarsym(srsym),tloadnode(left).symtable),
+                 srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+tvarsym(tloadnode(left).symtableentry).name);
+                 hp:=caddnode.create(addn,cloadnode.create(tvarsym(srsym),tloadnode(left).symtable),
                                   cordconstnode.create(1,s32bittype));
                                   cordconstnode.create(1,s32bittype));
-                 if (left.resulttype.def^.deftype=arraydef) and
-                    (parraydef(left.resulttype.def)^.elesize<>1) then
-                   hp:=caddnode.create(muln,hp,cordconstnode.create(parraydef(left.resulttype.def)^.elesize,s32bittype));
+                 if (left.resulttype.def.deftype=arraydef) and
+                    (tarraydef(left.resulttype.def).elesize<>1) then
+                   hp:=caddnode.create(muln,hp,cordconstnode.create(tarraydef(left.resulttype.def).elesize,s32bittype));
                  firstpass(hp);
                  firstpass(hp);
                  result:=hp;
                  result:=hp;
                end
                end
@@ -1136,7 +1135,7 @@ implementation
                if is_64bitint(left.resulttype.def) or
                if is_64bitint(left.resulttype.def) or
                   { range/overflow checking doesn't work properly }
                   { range/overflow checking doesn't work properly }
                   { with the inc/dec code that's generated (JM)   }
                   { with the inc/dec code that's generated (JM)   }
-                  ((left.resulttype.def^.deftype = orddef) and
+                  ((left.resulttype.def.deftype = orddef) and
                    not(is_char(left.resulttype.def)) and
                    not(is_char(left.resulttype.def)) and
                    not(is_boolean(left.resulttype.def)) and
                    not(is_boolean(left.resulttype.def)) and
                    (aktlocalswitches *
                    (aktlocalswitches *
@@ -1168,7 +1167,7 @@ implementation
                    { return new node }
                    { return new node }
                    result := hpp;
                    result := hpp;
                  end
                  end
-               else if (left.resulttype.def^.deftype in [enumdef,pointerdef]) or
+               else if (left.resulttype.def.deftype in [enumdef,pointerdef]) or
                        is_ordinal(left.resulttype.def) then
                        is_ordinal(left.resulttype.def) then
                  begin
                  begin
                     { two paras ? }
                     { two paras ? }
@@ -1212,15 +1211,15 @@ implementation
                     { file is not typed.                             }
                     { file is not typed.                             }
                     if assigned(hp) and assigned(hp.resulttype.def) then
                     if assigned(hp) and assigned(hp.resulttype.def) then
                       Begin
                       Begin
-                        if (hp.resulttype.def^.deftype=filedef) then
-                        if (pfiledef(hp.resulttype.def)^.filetyp=ft_untyped) then
+                        if (hp.resulttype.def.deftype=filedef) then
+                        if (tfiledef(hp.resulttype.def).filetyp=ft_untyped) then
                           begin
                           begin
                            if (inlinenumber in [in_readln_x,in_writeln_x]) then
                            if (inlinenumber in [in_readln_x,in_writeln_x]) then
                              CGMessage(type_e_no_readln_writeln_for_typed_file)
                              CGMessage(type_e_no_readln_writeln_for_typed_file)
                            else
                            else
                              CGMessage(type_e_no_read_write_for_untyped_file);
                              CGMessage(type_e_no_read_write_for_untyped_file);
                           end
                           end
-                        else if (pfiledef(hp.resulttype.def)^.filetyp=ft_typed) then
+                        else if (tfiledef(hp.resulttype.def).filetyp=ft_typed) then
                          begin
                          begin
                            file_is_typed:=true;
                            file_is_typed:=true;
                            { test the type }
                            { test the type }
@@ -1231,7 +1230,7 @@ implementation
                             begin
                             begin
                               if (tcallparanode(hpp).left.nodetype=typen) then
                               if (tcallparanode(hpp).left.nodetype=typen) then
                                 CGMessage(type_e_cant_read_write_type);
                                 CGMessage(type_e_cant_read_write_type);
-                              if not is_equal(hpp.resulttype.def,pfiledef(hp.resulttype.def)^.typedfiletype.def) then
+                              if not is_equal(hpp.resulttype.def,tfiledef(hp.resulttype.def).typedfiletype.def) then
                                 CGMessage(type_e_mismatch);
                                 CGMessage(type_e_mismatch);
                               { generate the high() value for the shortstring }
                               { generate the high() value for the shortstring }
                               if ((not iswrite) and is_shortstring(tcallparanode(hpp).left.resulttype.def)) or
                               if ((not iswrite) and is_shortstring(tcallparanode(hpp).left.resulttype.def)) or
@@ -1264,14 +1263,14 @@ implementation
                                begin
                                begin
                                  isreal:=false;
                                  isreal:=false;
                                  { support writeln(procvar) }
                                  { support writeln(procvar) }
-                                 if (tcallparanode(hp).left.resulttype.def^.deftype=procvardef) then
+                                 if (tcallparanode(hp).left.resulttype.def.deftype=procvardef) then
                                   begin
                                   begin
                                     p1:=ccallnode.create(nil,nil,nil,nil);
                                     p1:=ccallnode.create(nil,nil,nil,nil);
                                     tcallnode(p1).set_procvar(tcallparanode(hp).left);
                                     tcallnode(p1).set_procvar(tcallparanode(hp).left);
                                     firstpass(p1);
                                     firstpass(p1);
                                     tcallparanode(hp).left:=p1;
                                     tcallparanode(hp).left:=p1;
                                   end;
                                   end;
-                                 case tcallparanode(hp).left.resulttype.def^.deftype of
+                                 case tcallparanode(hp).left.resulttype.def.deftype of
                                    filedef :
                                    filedef :
                                      begin
                                      begin
                                        { only allowed as first parameter }
                                        { only allowed as first parameter }
@@ -1296,7 +1295,7 @@ implementation
                                      end;
                                      end;
                                    orddef :
                                    orddef :
                                      begin
                                      begin
-                                       case porddef(tcallparanode(hp).left.resulttype.def)^.typ of
+                                       case torddef(tcallparanode(hp).left.resulttype.def).typ of
                                          uchar,
                                          uchar,
                                          u32bit,s32bit,
                                          u32bit,s32bit,
                                          u64bit,s64bit:
                                          u64bit,s64bit:
@@ -1348,10 +1347,10 @@ implementation
                                         end;
                                         end;
                                       { can be nil if you use "write(e:0:6)" while e is undeclared (JM) }
                                       { can be nil if you use "write(e:0:6)" while e is undeclared (JM) }
                                       if assigned(tcallparanode(hpp).left.resulttype.def) then
                                       if assigned(tcallparanode(hpp).left.resulttype.def) then
-                                        isreal:=(tcallparanode(hpp).left.resulttype.def^.deftype=floatdef)
+                                        isreal:=(tcallparanode(hpp).left.resulttype.def.deftype=floatdef)
                                       else exit;
                                       else exit;
                                       if (not is_integer(tcallparanode(length_para).left.resulttype.def)) then
                                       if (not is_integer(tcallparanode(length_para).left.resulttype.def)) then
-                                       CGMessage1(type_e_integer_expr_expected,tcallparanode(length_para).left.resulttype.def^.typename)
+                                       CGMessage1(type_e_integer_expr_expected,tcallparanode(length_para).left.resulttype.def.typename)
                                      else
                                      else
                                        tcallparanode(length_para).left:=ctypeconvnode.create(tcallparanode(length_para).left,s32bittype);
                                        tcallparanode(length_para).left:=ctypeconvnode.create(tcallparanode(length_para).left,s32bittype);
                                      if assigned(frac_para) then
                                      if assigned(frac_para) then
@@ -1359,7 +1358,7 @@ implementation
                                          if isreal then
                                          if isreal then
                                           begin
                                           begin
                                             if (not is_integer(tcallparanode(frac_para).left.resulttype.def)) then
                                             if (not is_integer(tcallparanode(frac_para).left.resulttype.def)) then
-                                              CGMessage1(type_e_integer_expr_expected,tcallparanode(frac_para).left.resulttype.def^.typename)
+                                              CGMessage1(type_e_integer_expr_expected,tcallparanode(frac_para).left.resulttype.def.typename)
                                             else
                                             else
                                               tcallparanode(frac_para).left:=ctypeconvnode.create(tcallparanode(frac_para).left,s32bittype);
                                               tcallparanode(frac_para).left:=ctypeconvnode.create(tcallparanode(frac_para).left,s32bittype);
                                           end
                                           end
@@ -1395,8 +1394,8 @@ implementation
                 already done in firstcalln }
                 already done in firstcalln }
               { now we know the type of buffer }
               { now we know the type of buffer }
               srsym:=searchsymonlyin(systemunit,'SETTEXTBUF');
               srsym:=searchsymonlyin(systemunit,'SETTEXTBUF');
-              hp:=ccallparanode.create(cordconstnode.create(tcallparanode(left).left.resulttype.def^.size,s32bittype),left);
-              hp:=ccallnode.create(hp,pprocsym(srsym),systemunit,nil);
+              hp:=ccallparanode.create(cordconstnode.create(tcallparanode(left).left.resulttype.def.size,s32bittype),left);
+              hp:=ccallnode.create(hp,tprocsym(srsym),systemunit,nil);
               left:=nil;
               left:=nil;
               firstpass(hp);
               firstpass(hp);
               result:=hp;
               result:=hp;
@@ -1423,7 +1422,7 @@ implementation
               hp:=left;
               hp:=left;
               { valid string ? }
               { valid string ? }
               if not assigned(hp) or
               if not assigned(hp) or
-                 (tcallparanode(hp).left.resulttype.def^.deftype<>stringdef) or
+                 (tcallparanode(hp).left.resulttype.def.deftype<>stringdef) or
                  (tcallparanode(hp).right=nil) then
                  (tcallparanode(hp).right=nil) then
                 CGMessage(cg_e_illegal_expression);
                 CGMessage(cg_e_illegal_expression);
               { we need a var parameter }
               { we need a var parameter }
@@ -1445,10 +1444,10 @@ implementation
                 CGMessage(cg_e_illegal_expression);
                 CGMessage(cg_e_illegal_expression);
 
 
               isreal:=false;
               isreal:=false;
-              case hp.resulttype.def^.deftype of
+              case hp.resulttype.def.deftype of
                 orddef :
                 orddef :
                   begin
                   begin
-                    case porddef(tcallparanode(hp).left.resulttype.def)^.typ of
+                    case torddef(tcallparanode(hp).left.resulttype.def).typ of
                       u32bit,s32bit,
                       u32bit,s32bit,
                       s64bit,u64bit:
                       s64bit,u64bit:
                         ;
                         ;
@@ -1474,7 +1473,7 @@ implementation
                   firstpass(tcallparanode(hpp).left);
                   firstpass(tcallparanode(hpp).left);
                   set_varstate(tcallparanode(hpp).left,true);
                   set_varstate(tcallparanode(hpp).left,true);
                   if (not is_integer(tcallparanode(hpp).left.resulttype.def)) then
                   if (not is_integer(tcallparanode(hpp).left.resulttype.def)) then
-                    CGMessage1(type_e_integer_expr_expected,tcallparanode(hpp).left.resulttype.def^.typename)
+                    CGMessage1(type_e_integer_expr_expected,tcallparanode(hpp).left.resulttype.def.typename)
                   else
                   else
                     tcallparanode(hpp).left:=ctypeconvnode.create(tcallparanode(hpp).left,s32bittype);
                     tcallparanode(hpp).left:=ctypeconvnode.create(tcallparanode(hpp).left,s32bittype);
                   hpp:=tcallparanode(hpp).right;
                   hpp:=tcallparanode(hpp).right;
@@ -1483,7 +1482,7 @@ implementation
                       if isreal then
                       if isreal then
                        begin
                        begin
                          if (not is_integer(tcallparanode(hpp).left.resulttype.def)) then
                          if (not is_integer(tcallparanode(hpp).left.resulttype.def)) then
-                           CGMessage1(type_e_integer_expr_expected,tcallparanode(hpp).left.resulttype.def^.typename)
+                           CGMessage1(type_e_integer_expr_expected,tcallparanode(hpp).left.resulttype.def.typename)
                          else
                          else
                            begin
                            begin
                              firstpass(tcallparanode(hpp).left);
                              firstpass(tcallparanode(hpp).left);
@@ -1529,8 +1528,8 @@ implementation
                  {code has to be a var parameter}
                  {code has to be a var parameter}
                    if valid_for_assign(tcallparanode(left).left,false) then
                    if valid_for_assign(tcallparanode(left).left,false) then
                     begin
                     begin
-                      if (tcallparanode(left).left.resulttype.def^.deftype <> orddef) or
-                        not(porddef(tcallparanode(left).left.resulttype.def)^.typ in
+                      if (tcallparanode(left).left.resulttype.def.deftype <> orddef) or
+                        not(torddef(tcallparanode(left).left.resulttype.def).typ in
                             [u16bit,s16bit,u32bit,s32bit]) then
                             [u16bit,s16bit,u32bit,s32bit]) then
                        CGMessage(type_e_mismatch);
                        CGMessage(type_e_mismatch);
                     end;
                     end;
@@ -1553,9 +1552,9 @@ implementation
               tcallparanode(hpp).right := hp;
               tcallparanode(hpp).right := hp;
               if valid_for_assign(tcallparanode(hpp).left,false) then
               if valid_for_assign(tcallparanode(hpp).left,false) then
                begin
                begin
-                 If Not((tcallparanode(hpp).left.resulttype.def^.deftype = floatdef) or
-                        ((tcallparanode(hpp).left.resulttype.def^.deftype = orddef) And
-                         (POrdDef(tcallparanode(hpp).left.resulttype.def)^.typ in
+                 If Not((tcallparanode(hpp).left.resulttype.def.deftype = floatdef) or
+                        ((tcallparanode(hpp).left.resulttype.def.deftype = orddef) And
+                         (torddef(tcallparanode(hpp).left.resulttype.def).typ in
                           [u32bit,s32bit,
                           [u32bit,s32bit,
                            u8bit,s8bit,u16bit,s16bit,s64bit,u64bit]))) Then
                            u8bit,s8bit,u16bit,s16bit,s64bit,u64bit]))) Then
                    CGMessage(type_e_mismatch);
                    CGMessage(type_e_mismatch);
@@ -1568,7 +1567,7 @@ implementation
                 exit;
                 exit;
               { if not a stringdef then insert a type conv which
               { if not a stringdef then insert a type conv which
                 does the other type checking }
                 does the other type checking }
-              If (tcallparanode(hp).left.resulttype.def^.deftype<>stringdef) then
+              If (tcallparanode(hp).left.resulttype.def.deftype<>stringdef) then
                begin
                begin
                  tcallparanode(hp).left:=ctypeconvnode.create(tcallparanode(hp).left,cshortstringtype);
                  tcallparanode(hp).left:=ctypeconvnode.create(tcallparanode(hp).left,cshortstringtype);
                  firstpass(tcallparanode(hp).left);
                  firstpass(tcallparanode(hp).left);
@@ -1721,7 +1720,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.35  2001-04-05 21:02:13  peter
+  Revision 1.36  2001-04-13 01:22:09  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.35  2001/04/05 21:02:13  peter
     * fixed fpu inline functions typeconvs
     * fixed fpu inline functions typeconvs
 
 
   Revision 1.34  2001/04/04 22:42:40  peter
   Revision 1.34  2001/04/04 22:42:40  peter

+ 59 - 54
compiler/nld.pas

@@ -32,9 +32,9 @@ interface
 
 
     type
     type
        tloadnode = class(tunarynode)
        tloadnode = class(tunarynode)
-          symtableentry : psym;
-          symtable : psymtable;
-          constructor create(v : psym;st : psymtable);virtual;
+          symtableentry : tsym;
+          symtable : tsymtable;
+          constructor create(v : tsym;st : tsymtable);virtual;
           procedure set_mp(p:tnode);
           procedure set_mp(p:tnode);
           function  getcopy : tnode;override;
           function  getcopy : tnode;override;
           function  pass_1 : tnode;override;
           function  pass_1 : tnode;override;
@@ -113,7 +113,7 @@ implementation
                              TLOADNODE
                              TLOADNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tloadnode.create(v : psym;st : psymtable);
+    constructor tloadnode.create(v : tsym;st : tsymtable);
 
 
       begin
       begin
          inherited create(loadn,nil);
          inherited create(loadn,nil);
@@ -143,16 +143,16 @@ implementation
     function tloadnode.det_resulttype:tnode;
     function tloadnode.det_resulttype:tnode;
       begin
       begin
          result:=nil;
          result:=nil;
-         case symtableentry^.typ of
+         case symtableentry.typ of
            absolutesym,
            absolutesym,
            varsym :
            varsym :
-             resulttype:=pvarsym(symtableentry)^.vartype;
+             resulttype:=tvarsym(symtableentry).vartype;
            constsym :
            constsym :
-             resulttype:=pconstsym(symtableentry)^.consttype;
+             resulttype:=tconstsym(symtableentry).consttype;
            typedconstsym :
            typedconstsym :
-             resulttype:=ptypedconstsym(symtableentry)^.typedconsttype;
+             resulttype:=ttypedconstsym(symtableentry).typedconsttype;
            procsym :
            procsym :
-             resulttype.setdef(pprocsym(symtableentry)^.definition);
+             resulttype.setdef(tprocsym(symtableentry).definition);
            else
            else
              internalerror(534785349);
              internalerror(534785349);
          end;
          end;
@@ -166,12 +166,12 @@ implementation
          result:=nil;
          result:=nil;
 
 
          { optimize simple with loadings }
          { optimize simple with loadings }
-         if (symtable^.symtabletype=withsymtable) and
-            (pwithsymtable(symtable)^.direct_with) and
-            (symtableentry^.typ=varsym) then
+         if (symtable.symtabletype=withsymtable) and
+            (twithsymtable(symtable).direct_with) and
+            (symtableentry.typ=varsym) then
            begin
            begin
-              p1:=tnode(pwithsymtable(symtable)^.withrefnode).getcopy;
-              p1:=csubscriptnode.create(pvarsym(symtableentry),p1);
+              p1:=tnode(twithsymtable(symtable).withrefnode).getcopy;
+              p1:=csubscriptnode.create(tvarsym(symtableentry),p1);
               left:=nil;
               left:=nil;
               firstpass(p1);
               firstpass(p1);
               result:=p1;
               result:=p1;
@@ -185,23 +185,23 @@ implementation
          registersmmx:=0;
          registersmmx:=0;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
          { handle first absolute as it will replace the symtableentry }
          { handle first absolute as it will replace the symtableentry }
-         if symtableentry^.typ=absolutesym then
+         if symtableentry.typ=absolutesym then
            begin
            begin
              { replace the symtableentry when it points to a var, else
              { replace the symtableentry when it points to a var, else
                we are finished }
                we are finished }
-             if pabsolutesym(symtableentry)^.abstyp=tovar then
+             if tabsolutesym(symtableentry).abstyp=tovar then
               begin
               begin
-                symtableentry:=pabsolutesym(symtableentry)^.ref;
-                symtable:=symtableentry^.owner;
+                symtableentry:=tabsolutesym(symtableentry).ref;
+                symtable:=symtableentry.owner;
                 include(flags,nf_absolute);
                 include(flags,nf_absolute);
               end
               end
              else
              else
               exit;
               exit;
            end;
            end;
-         case symtableentry^.typ of
+         case symtableentry.typ of
             funcretsym :
             funcretsym :
               begin
               begin
-                p1:=cfuncretnode.create(pfuncretsym(symtableentry)^.funcretprocinfo);
+                p1:=cfuncretnode.create(tfuncretsym(symtableentry).funcretprocinfo);
                 firstpass(p1);
                 firstpass(p1);
                 { if it's refered as absolute then we need to have the
                 { if it's refered as absolute then we need to have the
                   type of the absolute instead of the function return,
                   type of the absolute instead of the function return,
@@ -216,7 +216,7 @@ implementation
               end;
               end;
             constsym:
             constsym:
               begin
               begin
-                 if pconstsym(symtableentry)^.consttyp=constresourcestring then
+                 if tconstsym(symtableentry).consttyp=constresourcestring then
                    begin
                    begin
                       resulttype:=cansistringtype;
                       resulttype:=cansistringtype;
                       { we use ansistrings so no fast exit here }
                       { we use ansistrings so no fast exit here }
@@ -231,63 +231,63 @@ implementation
                 begin
                 begin
                   { if it's refered by absolute then it's used }
                   { if it's refered by absolute then it's used }
                   if nf_absolute in flags then
                   if nf_absolute in flags then
-                   pvarsym(symtableentry)^.varstate:=vs_used;
-                  if (symtable^.symtabletype in [parasymtable,localsymtable]) and
-                      (lexlevel>symtable^.symtablelevel) then
+                   tvarsym(symtableentry).varstate:=vs_used;
+                  if (symtable.symtabletype in [parasymtable,localsymtable]) and
+                      (lexlevel>symtable.symtablelevel) then
                      begin
                      begin
                        { if the variable is in an other stackframe then we need
                        { if the variable is in an other stackframe then we need
                          a register to dereference }
                          a register to dereference }
-                       if (symtable^.symtablelevel)>0 then
+                       if (symtable.symtablelevel)>0 then
                         begin
                         begin
                           registers32:=1;
                           registers32:=1;
                           { further, the variable can't be put into a register }
                           { further, the variable can't be put into a register }
-                          pvarsym(symtableentry)^.varoptions:=
-                            pvarsym(symtableentry)^.varoptions-[vo_fpuregable,vo_regable];
+                          tvarsym(symtableentry).varoptions:=
+                            tvarsym(symtableentry).varoptions-[vo_fpuregable,vo_regable];
                         end;
                         end;
                      end;
                      end;
-                   if (pvarsym(symtableentry)^.varspez=vs_const) then
+                   if (tvarsym(symtableentry).varspez=vs_const) then
                      location.loc:=LOC_MEM;
                      location.loc:=LOC_MEM;
                    { we need a register for call by reference parameters }
                    { we need a register for call by reference parameters }
-                   if (pvarsym(symtableentry)^.varspez in [vs_var,vs_out]) or
-                      ((pvarsym(symtableentry)^.varspez=vs_const) and
-                      push_addr_param(pvarsym(symtableentry)^.vartype.def)) or
+                   if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
+                      ((tvarsym(symtableentry).varspez=vs_const) and
+                      push_addr_param(tvarsym(symtableentry).vartype.def)) or
                       { call by value open arrays are also indirect addressed }
                       { call by value open arrays are also indirect addressed }
-                      is_open_array(pvarsym(symtableentry)^.vartype.def) then
+                      is_open_array(tvarsym(symtableentry).vartype.def) then
                      registers32:=1;
                      registers32:=1;
-                   if symtable^.symtabletype=withsymtable then
+                   if symtable.symtabletype=withsymtable then
                      inc(registers32);
                      inc(registers32);
 
 
-                   if ([vo_is_thread_var,vo_is_dll_var]*pvarsym(symtableentry)^.varoptions)<>[] then
+                   if ([vo_is_thread_var,vo_is_dll_var]*tvarsym(symtableentry).varoptions)<>[] then
                      registers32:=1;
                      registers32:=1;
                    { count variable references }
                    { count variable references }
 
 
                      { this will create problem with local var set by
                      { this will create problem with local var set by
                      under_procedures
                      under_procedures
-                     if (assigned(pvarsym(symtableentry)^.owner) and assigned(aktprocsym)
-                       and ((pvarsym(symtableentry)^.owner = aktprocsym^.definition^.localst)
-                       or (pvarsym(symtableentry)^.owner = aktprocsym^.definition^.localst))) then }
+                     if (assigned(tvarsym(symtableentry).owner) and assigned(aktprocsym)
+                       and ((tvarsym(symtableentry).owner = aktprocsym.definition.localst)
+                       or (tvarsym(symtableentry).owner = aktprocsym.definition.localst))) then }
                    if t_times<1 then
                    if t_times<1 then
-                     inc(pvarsym(symtableentry)^.refs)
+                     inc(tvarsym(symtableentry).refs)
                    else
                    else
-                     inc(pvarsym(symtableentry)^.refs,t_times);
+                     inc(tvarsym(symtableentry).refs,t_times);
                 end;
                 end;
             typedconstsym :
             typedconstsym :
                 if not(nf_absolute in flags) then
                 if not(nf_absolute in flags) then
-                  resulttype:=ptypedconstsym(symtableentry)^.typedconsttype;
+                  resulttype:=ttypedconstsym(symtableentry).typedconsttype;
             procsym :
             procsym :
                 begin
                 begin
-                   if assigned(pprocsym(symtableentry)^.definition^.nextoverloaded) then
+                   if assigned(tprocsym(symtableentry).definition.nextoverloaded) then
                      CGMessage(parser_e_no_overloaded_procvars);
                      CGMessage(parser_e_no_overloaded_procvars);
-                   resulttype.setdef(pprocsym(symtableentry)^.definition);
+                   resulttype.setdef(tprocsym(symtableentry).definition);
                    { if the owner of the procsym is a object,  }
                    { if the owner of the procsym is a object,  }
                    { left must be set, if left isn't set       }
                    { left must be set, if left isn't set       }
                    { it can be only self                       }
                    { it can be only self                       }
                    { this code is only used in TP procvar mode }
                    { this code is only used in TP procvar mode }
                    if (m_tp_procvar in aktmodeswitches) and
                    if (m_tp_procvar in aktmodeswitches) and
                       not(assigned(left)) and
                       not(assigned(left)) and
-                      (pprocsym(symtableentry)^.owner^.symtabletype=objectsymtable) then
+                      (tprocsym(symtableentry).owner.symtabletype=objectsymtable) then
                     begin
                     begin
-                      left:=cselfnode.create(pobjectdef(symtableentry^.owner^.defowner));
+                      left:=cselfnode.create(tobjectdef(symtableentry.owner.defowner));
                     end;
                     end;
                    { method pointer ? }
                    { method pointer ? }
                    if assigned(left) then
                    if assigned(left) then
@@ -378,8 +378,8 @@ implementation
         valid_for_assign(left,true);
         valid_for_assign(left,true);
 
 
         { check if local proc/func is assigned to procvar }
         { check if local proc/func is assigned to procvar }
-        if right.resulttype.def^.deftype=procvardef then
-          test_local_to_procvar(pprocvardef(right.resulttype.def),left.resulttype.def);
+        if right.resulttype.def.deftype=procvardef then
+          test_local_to_procvar(tprocvardef(right.resulttype.def),left.resulttype.def);
       end;
       end;
 
 
 
 
@@ -590,10 +590,10 @@ implementation
          end;
          end;
          if not assigned(htype.def) then
          if not assigned(htype.def) then
           htype:=voidtype;
           htype:=voidtype;
-         resulttype.setdef(new(parraydef,init(0,len-1,s32bittype)));
-         parraydef(resulttype.def)^.elementtype:=htype;
-         parraydef(resulttype.def)^.IsConstructor:=true;
-         parraydef(resulttype.def)^.IsVariant:=varia;
+         resulttype.setdef(tarraydef.create(0,len-1,s32bittype));
+         tarraydef(resulttype.def).elementtype:=htype;
+         tarraydef(resulttype.def).IsConstructor:=true;
+         tarraydef(resulttype.def).IsVariant:=varia;
       end;
       end;
 
 
 
 
@@ -605,7 +605,7 @@ implementation
         dovariant : boolean;
         dovariant : boolean;
         htype     : ttype;
         htype     : ttype;
       begin
       begin
-        dovariant:=(nf_forcevaria in flags) or parraydef(resulttype.def)^.isvariant;
+        dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
         result:=nil;
         result:=nil;
       { only pass left tree, right tree contains next construct if any }
       { only pass left tree, right tree contains next construct if any }
         if assigned(left) then
         if assigned(left) then
@@ -617,7 +617,7 @@ implementation
               { Insert typeconvs for array of const }
               { Insert typeconvs for array of const }
               if dovariant then
               if dovariant then
                begin
                begin
-                 case hp.left.resulttype.def^.deftype of
+                 case hp.left.resulttype.def.deftype of
                    enumdef :
                    enumdef :
                      begin
                      begin
                        hp.left:=ctypeconvnode.create(hp.left,s32bittype);
                        hp.left:=ctypeconvnode.create(hp.left,s32bittype);
@@ -654,7 +654,7 @@ implementation
                    classrefdef,
                    classrefdef,
                    objectdef : ;
                    objectdef : ;
                    else
                    else
-                     CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def^.typename);
+                     CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
                  end;
                  end;
                end;
                end;
               hp:=tarrayconstructornode(hp.right);
               hp:=tarrayconstructornode(hp.right);
@@ -737,7 +737,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-05 21:03:08  peter
+  Revision 1.14  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/05 21:03:08  peter
     * array constructor fix
     * array constructor fix
 
 
   Revision 1.12  2001/04/04 22:42:40  peter
   Revision 1.12  2001/04/04 22:42:40  peter

+ 39 - 41
compiler/nmat.pas

@@ -82,7 +82,7 @@ implementation
     function tmoddivnode.det_resulttype:tnode;
     function tmoddivnode.det_resulttype:tnode;
       var
       var
          t : tnode;
          t : tnode;
-         rd,ld : pdef;
+         rd,ld : tdef;
          rv,lv : tconstexprint;
          rv,lv : tconstexprint;
       begin
       begin
          result:=nil;
          result:=nil;
@@ -133,22 +133,22 @@ implementation
          { Do the same for qwords and positive constants as well, otherwise things like   }
          { Do the same for qwords and positive constants as well, otherwise things like   }
          { "qword mod 10" are evaluated with int64 as result, which is wrong if the       }
          { "qword mod 10" are evaluated with int64 as result, which is wrong if the       }
          { "qword" was > high(int64) (JM)                                                 }
          { "qword" was > high(int64) (JM)                                                 }
-         if (left.resulttype.def^.deftype=orddef) and (right.resulttype.def^.deftype=orddef) then
-           if (porddef(right.resulttype.def)^.typ in [u32bit,u64bit]) and
+         if (left.resulttype.def.deftype=orddef) and (right.resulttype.def.deftype=orddef) then
+           if (torddef(right.resulttype.def).typ in [u32bit,u64bit]) and
               is_constintnode(left) and
               is_constintnode(left) and
               (tordconstnode(left).value >= 0) then
               (tordconstnode(left).value >= 0) then
              inserttypeconv(left,right.resulttype)
              inserttypeconv(left,right.resulttype)
-           else if (porddef(left.resulttype.def)^.typ in [u32bit,u64bit]) and
+           else if (torddef(left.resulttype.def).typ in [u32bit,u64bit]) and
               is_constintnode(right) and
               is_constintnode(right) and
               (tordconstnode(right).value >= 0) then
               (tordconstnode(right).value >= 0) then
              inserttypeconv(right,left.resulttype);
              inserttypeconv(right,left.resulttype);
 
 
-         if (left.resulttype.def^.deftype=orddef) and (right.resulttype.def^.deftype=orddef) and
+         if (left.resulttype.def.deftype=orddef) and (right.resulttype.def.deftype=orddef) and
             (is_64bitint(left.resulttype.def) or is_64bitint(right.resulttype.def) or
             (is_64bitint(left.resulttype.def) or is_64bitint(right.resulttype.def) or
              { when mixing cardinals and signed numbers, convert everythign to 64bit (JM) }
              { when mixing cardinals and signed numbers, convert everythign to 64bit (JM) }
-             ((porddef(right.resulttype.def)^.typ = u32bit) and
+             ((torddef(right.resulttype.def).typ = u32bit) and
               is_signed(left.resulttype.def)) or
               is_signed(left.resulttype.def)) or
-             ((porddef(left.resulttype.def)^.typ = u32bit) and
+             ((torddef(left.resulttype.def).typ = u32bit) and
               is_signed(right.resulttype.def))) then
               is_signed(right.resulttype.def))) then
            begin
            begin
               rd:=right.resulttype.def;
               rd:=right.resulttype.def;
@@ -158,28 +158,28 @@ implementation
                 CGMessage(type_w_mixed_signed_unsigned);
                 CGMessage(type_w_mixed_signed_unsigned);
               if is_signed(rd) or is_signed(ld) then
               if is_signed(rd) or is_signed(ld) then
                 begin
                 begin
-                   if (porddef(ld)^.typ<>s64bit) then
+                   if (torddef(ld).typ<>s64bit) then
                      inserttypeconv(left,cs64bittype);
                      inserttypeconv(left,cs64bittype);
-                   if (porddef(rd)^.typ<>s64bit) then
+                   if (torddef(rd).typ<>s64bit) then
                      inserttypeconv(right,cs64bittype);
                      inserttypeconv(right,cs64bittype);
                 end
                 end
               else
               else
                 begin
                 begin
-                   if (porddef(ld)^.typ<>u64bit) then
+                   if (torddef(ld).typ<>u64bit) then
                      inserttypeconv(left,cu64bittype);
                      inserttypeconv(left,cu64bittype);
-                   if (porddef(rd)^.typ<>u64bit) then
+                   if (torddef(rd).typ<>u64bit) then
                      inserttypeconv(right,cu64bittype);
                      inserttypeconv(right,cu64bittype);
                 end;
                 end;
               resulttype:=left.resulttype;
               resulttype:=left.resulttype;
            end
            end
          else
          else
            begin
            begin
-              if not(right.resulttype.def^.deftype=orddef) or
-                 not(porddef(right.resulttype.def)^.typ in [s32bit,u32bit]) then
+              if not(right.resulttype.def.deftype=orddef) or
+                 not(torddef(right.resulttype.def).typ in [s32bit,u32bit]) then
                 inserttypeconv(right,s32bittype);
                 inserttypeconv(right,s32bittype);
 
 
-              if not(left.resulttype.def^.deftype=orddef) or
-                 not(porddef(left.resulttype.def)^.typ in [s32bit,u32bit]) then
+              if not(left.resulttype.def.deftype=orddef) or
+                 not(torddef(left.resulttype.def).typ in [s32bit,u32bit]) then
                 inserttypeconv(left,s32bittype);
                 inserttypeconv(left,s32bittype);
 
 
               { the resulttype.def depends on the right side, because the left becomes }
               { the resulttype.def depends on the right side, because the left becomes }
@@ -190,8 +190,6 @@ implementation
 
 
 
 
     function tmoddivnode.pass_1 : tnode;
     function tmoddivnode.pass_1 : tnode;
-      var
-         t : tnode;
       begin
       begin
          result:=nil;
          result:=nil;
          firstpass(left);
          firstpass(left);
@@ -200,7 +198,7 @@ implementation
            exit;
            exit;
 
 
          { 64bit }
          { 64bit }
-         if (left.resulttype.def^.deftype=orddef) and (right.resulttype.def^.deftype=orddef) and
+         if (left.resulttype.def.deftype=orddef) and (right.resulttype.def.deftype=orddef) and
             (is_64bitint(left.resulttype.def) or is_64bitint(right.resulttype.def)) then
             (is_64bitint(left.resulttype.def) or is_64bitint(right.resulttype.def)) then
            begin
            begin
              calcregisters(self,2,0,0);
              calcregisters(self,2,0,0);
@@ -258,7 +256,7 @@ implementation
          { 64 bit ints have their own shift handling }
          { 64 bit ints have their own shift handling }
          if not(is_64bitint(left.resulttype.def)) then
          if not(is_64bitint(left.resulttype.def)) then
            begin
            begin
-              if porddef(left.resulttype.def)^.typ <> u32bit then
+              if torddef(left.resulttype.def).typ <> u32bit then
                inserttypeconv(left,s32bittype);
                inserttypeconv(left,s32bittype);
            end;
            end;
 
 
@@ -270,7 +268,6 @@ implementation
 
 
     function tshlshrnode.pass_1 : tnode;
     function tshlshrnode.pass_1 : tnode;
       var
       var
-         t : tnode;
          regs : longint;
          regs : longint;
       begin
       begin
          result:=nil;
          result:=nil;
@@ -305,7 +302,7 @@ implementation
     function tunaryminusnode.det_resulttype : tnode;
     function tunaryminusnode.det_resulttype : tnode;
       var
       var
          t : tnode;
          t : tnode;
-         minusdef : pprocdef;
+         minusdef : tprocdef;
       begin
       begin
          result:=nil;
          result:=nil;
          resulttypepass(left);
          resulttypepass(left);
@@ -330,7 +327,7 @@ implementation
            end;
            end;
 
 
          resulttype:=left.resulttype;
          resulttype:=left.resulttype;
-         if (left.resulttype.def^.deftype=floatdef) then
+         if (left.resulttype.def.deftype=floatdef) then
            begin
            begin
            end
            end
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
@@ -340,7 +337,7 @@ implementation
                { if saturation is on, left.resulttype.def isn't
                { if saturation is on, left.resulttype.def isn't
                  "mmx able" (FK)
                  "mmx able" (FK)
                if (cs_mmx_saturation in aktlocalswitches^) and
                if (cs_mmx_saturation in aktlocalswitches^) and
-                 (porddef(parraydef(resulttype.def)^.definition)^.typ in
+                 (torddef(tarraydef(resulttype.def).definition).typ in
                  [s32bit,u32bit]) then
                  [s32bit,u32bit]) then
                  CGMessage(type_e_mismatch);
                  CGMessage(type_e_mismatch);
                }
                }
@@ -349,7 +346,7 @@ implementation
          else if is_64bitint(left.resulttype.def) then
          else if is_64bitint(left.resulttype.def) then
            begin
            begin
            end
            end
-         else if (left.resulttype.def^.deftype=orddef) then
+         else if (left.resulttype.def.deftype=orddef) then
            begin
            begin
               inserttypeconv(left,s32bittype);
               inserttypeconv(left,s32bittype);
               resulttype:=left.resulttype;
               resulttype:=left.resulttype;
@@ -357,13 +354,13 @@ implementation
          else
          else
            begin
            begin
               if assigned(overloaded_operators[_minus]) then
               if assigned(overloaded_operators[_minus]) then
-                minusdef:=overloaded_operators[_minus]^.definition
+                minusdef:=overloaded_operators[_minus].definition
               else
               else
                 minusdef:=nil;
                 minusdef:=nil;
               while assigned(minusdef) do
               while assigned(minusdef) do
                 begin
                 begin
-                   if is_equal(tparaitem(minusdef^.para.first).paratype.def,left.resulttype.def) and
-                      (tparaitem(minusdef^.para.first).next=nil) then
+                   if is_equal(tparaitem(minusdef.para.first).paratype.def,left.resulttype.def) and
+                      (tparaitem(minusdef.para.first).next=nil) then
                      begin
                      begin
                         t:=ccallnode.create(ccallparanode.create(left,nil),
                         t:=ccallnode.create(ccallparanode.create(left,nil),
                                             overloaded_operators[_minus],nil,nil);
                                             overloaded_operators[_minus],nil,nil);
@@ -372,7 +369,7 @@ implementation
                         result:=t;
                         result:=t;
                         exit;
                         exit;
                      end;
                      end;
-                   minusdef:=minusdef^.nextoverloaded;
+                   minusdef:=minusdef.nextoverloaded;
                 end;
                 end;
               CGMessage(type_e_mismatch);
               CGMessage(type_e_mismatch);
            end;
            end;
@@ -380,8 +377,6 @@ implementation
 
 
 
 
     function tunaryminusnode.pass_1 : tnode;
     function tunaryminusnode.pass_1 : tnode;
-      var
-         t : tnode;
       begin
       begin
          result:=nil;
          result:=nil;
          firstpass(left);
          firstpass(left);
@@ -394,7 +389,7 @@ implementation
          registersmmx:=left.registersmmx;
          registersmmx:=left.registersmmx;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
-         if (left.resulttype.def^.deftype=floatdef) then
+         if (left.resulttype.def.deftype=floatdef) then
            begin
            begin
              location.loc:=LOC_FPU;
              location.loc:=LOC_FPU;
            end
            end
@@ -414,7 +409,7 @@ implementation
                 registers32:=2;
                 registers32:=2;
               location.loc:=LOC_REGISTER;
               location.loc:=LOC_REGISTER;
            end
            end
-         else if (left.resulttype.def^.deftype=orddef) then
+         else if (left.resulttype.def.deftype=orddef) then
            begin
            begin
               if (left.location.loc<>LOC_REGISTER) and
               if (left.location.loc<>LOC_REGISTER) and
                  (registers32<1) then
                  (registers32<1) then
@@ -437,7 +432,7 @@ implementation
     function tnotnode.det_resulttype : tnode;
     function tnotnode.det_resulttype : tnode;
       var
       var
          t : tnode;
          t : tnode;
-         notdef : pprocdef;
+         notdef : tprocdef;
          v : tconstexprint;
          v : tconstexprint;
       begin
       begin
          result:=nil;
          result:=nil;
@@ -450,7 +445,7 @@ implementation
          if (left.nodetype=ordconstn) then
          if (left.nodetype=ordconstn) then
            begin
            begin
               v:=tordconstnode(left).value;
               v:=tordconstnode(left).value;
-              case porddef(left.resulttype.def)^.typ of
+              case torddef(left.resulttype.def).typ of
                 bool8bit,
                 bool8bit,
                 bool16bit,
                 bool16bit,
                 bool32bit :
                 bool32bit :
@@ -507,13 +502,13 @@ implementation
          else
          else
            begin
            begin
               if assigned(overloaded_operators[_op_not]) then
               if assigned(overloaded_operators[_op_not]) then
-                notdef:=overloaded_operators[_op_not]^.definition
+                notdef:=overloaded_operators[_op_not].definition
               else
               else
                 notdef:=nil;
                 notdef:=nil;
               while assigned(notdef) do
               while assigned(notdef) do
                 begin
                 begin
-                   if is_equal(tparaitem(notdef^.para.first).paratype.def,left.resulttype.def) and
-                      (tparaitem(notdef^.para.first).next=nil) then
+                   if is_equal(tparaitem(notdef.para.first).paratype.def,left.resulttype.def) and
+                      (tparaitem(notdef.para.first).next=nil) then
                      begin
                      begin
                         t:=ccallnode.create(ccallparanode.create(left,nil),
                         t:=ccallnode.create(ccallparanode.create(left,nil),
                                             overloaded_operators[_op_not],nil,nil);
                                             overloaded_operators[_op_not],nil,nil);
@@ -522,7 +517,7 @@ implementation
                         result:=t;
                         result:=t;
                         exit;
                         exit;
                      end;
                      end;
-                   notdef:=notdef^.nextoverloaded;
+                   notdef:=notdef.nextoverloaded;
                 end;
                 end;
               CGMessage(type_e_mismatch);
               CGMessage(type_e_mismatch);
            end;
            end;
@@ -530,8 +525,6 @@ implementation
 
 
 
 
     function tnotnode.pass_1 : tnode;
     function tnotnode.pass_1 : tnode;
-      var
-         t : tnode;
       begin
       begin
          result:=nil;
          result:=nil;
          firstpass(left);
          firstpass(left);
@@ -595,7 +588,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2001-04-05 21:00:27  peter
+  Revision 1.20  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.19  2001/04/05 21:00:27  peter
     * fix constant not evaluation
     * fix constant not evaluation
 
 
   Revision 1.18  2001/04/04 22:42:40  peter
   Revision 1.18  2001/04/04 22:42:40  peter

+ 69 - 64
compiler/nmem.pas

@@ -81,8 +81,8 @@ interface
        end;
        end;
 
 
        tsubscriptnode = class(tunarynode)
        tsubscriptnode = class(tunarynode)
-          vs : pvarsym;
-          constructor create(varsym : psym;l : tnode);virtual;
+          vs : tvarsym;
+          constructor create(varsym : tsym;l : tnode);virtual;
           function getcopy : tnode;override;
           function getcopy : tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
           function docompare(p: tnode): boolean; override;
           function docompare(p: tnode): boolean; override;
@@ -96,17 +96,17 @@ interface
        end;
        end;
 
 
        tselfnode = class(tnode)
        tselfnode = class(tnode)
-          classdef : pobjectdef;
-          constructor create(_class : pobjectdef);virtual;
+          classdef : tobjectdef;
+          constructor create(_class : tobjectdef);virtual;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
           function det_resulttype:tnode;override;
           function det_resulttype:tnode;override;
        end;
        end;
 
 
        twithnode = class(tbinarynode)
        twithnode = class(tbinarynode)
-          withsymtable : pwithsymtable;
+          withsymtable : twithsymtable;
           tablecount : longint;
           tablecount : longint;
-          withreference:preference;
-          constructor create(symtable : pwithsymtable;l,r : tnode;count : longint);virtual;
+          withreference : preference;
+          constructor create(symtable : twithsymtable;l,r : tnode;count : longint);virtual;
           destructor destroy;override;
           destructor destroy;override;
           function getcopy : tnode;override;
           function getcopy : tnode;override;
           function pass_1 : tnode;override;
           function pass_1 : tnode;override;
@@ -158,7 +158,7 @@ implementation
         if codegenerror then
         if codegenerror then
          exit;
          exit;
 
 
-        resulttype.setdef(new(pclassrefdef,init(left.resulttype)));;
+        resulttype.setdef(tclassrefdef.create(left.resulttype));
       end;
       end;
 
 
     function tloadvmtnode.pass_1 : tnode;
     function tloadvmtnode.pass_1 : tnode;
@@ -248,7 +248,7 @@ implementation
         resulttypepass(left);
         resulttypepass(left);
         if codegenerror then
         if codegenerror then
          exit;
          exit;
-        resulttype:=ppointerdef(left.resulttype.def)^.pointertype;
+        resulttype:=tpointerdef(left.resulttype.def).pointertype;
       end;
       end;
 
 
 
 
@@ -293,8 +293,8 @@ implementation
         resulttypepass(left);
         resulttypepass(left);
         if codegenerror then
         if codegenerror then
          exit;
          exit;
-        if (left.resulttype.def^.deftype<>pointerdef) then
-          CGMessage1(type_e_pointer_type_expected,left.resulttype.def^.typename);
+        if (left.resulttype.def.deftype<>pointerdef) then
+          CGMessage1(type_e_pointer_type_expected,left.resulttype.def.typename);
         resulttype:=voidtype;
         resulttype:=voidtype;
       end;
       end;
 
 
@@ -337,7 +337,7 @@ implementation
       var
       var
          hp  : tnode;
          hp  : tnode;
          hp2 : TParaItem;
          hp2 : TParaItem;
-         hp3 : pabstractprocdef;
+         hp3 : tabstractprocdef;
       begin
       begin
         result:=nil;
         result:=nil;
         resulttypepass(left);
         resulttypepass(left);
@@ -379,7 +379,7 @@ implementation
              vecn,
              vecn,
              derefn :
              derefn :
                begin
                begin
-                 if left.resulttype.def^.deftype=procvardef then
+                 if left.resulttype.def.deftype=procvardef then
                    include(flags,nf_procvarload);
                    include(flags,nf_procvarload);
                end;
                end;
            end;
            end;
@@ -394,7 +394,7 @@ implementation
         if left.nodetype=calln then
         if left.nodetype=calln then
          internalerror(200103253)
          internalerror(200103253)
         else
         else
-         if (left.nodetype=loadn) and (tloadnode(left).symtableentry^.typ=procsym) then
+         if (left.nodetype=loadn) and (tloadnode(left).symtableentry.typ=procsym) then
           begin
           begin
             { the address is already available when loading a procedure of object }
             { the address is already available when loading a procedure of object }
             if assigned(tloadnode(left).left) then
             if assigned(tloadnode(left).left) then
@@ -406,26 +406,26 @@ implementation
             if not(m_tp_procvar in aktmodeswitches) then
             if not(m_tp_procvar in aktmodeswitches) then
               begin
               begin
 
 
-                 hp3:=pabstractprocdef(pprocsym(tloadnode(left).symtableentry)^.definition);
+                 hp3:=tabstractprocdef(tprocsym(tloadnode(left).symtableentry).definition);
 
 
                  { create procvardef }
                  { create procvardef }
-                 resulttype.setdef(new(pprocvardef,init));
-                 pprocvardef(resulttype.def)^.proctypeoption:=hp3^.proctypeoption;
-                 pprocvardef(resulttype.def)^.proccalloptions:=hp3^.proccalloptions;
-                 pprocvardef(resulttype.def)^.procoptions:=hp3^.procoptions;
-                 pprocvardef(resulttype.def)^.rettype:=hp3^.rettype;
-                 pprocvardef(resulttype.def)^.symtablelevel:=hp3^.symtablelevel;
+                 resulttype.setdef(tprocvardef.create);
+                 tprocvardef(resulttype.def).proctypeoption:=hp3.proctypeoption;
+                 tprocvardef(resulttype.def).proccalloptions:=hp3.proccalloptions;
+                 tprocvardef(resulttype.def).procoptions:=hp3.procoptions;
+                 tprocvardef(resulttype.def).rettype:=hp3.rettype;
+                 tprocvardef(resulttype.def).symtablelevel:=hp3.symtablelevel;
 
 
                  { method ? then set the methodpointer flag }
                  { method ? then set the methodpointer flag }
-                 if (hp3^.owner^.symtabletype=objectsymtable) then
-                   include(pprocvardef(resulttype.def)^.procoptions,po_methodpointer);
+                 if (hp3.owner.symtabletype=objectsymtable) then
+                   include(tprocvardef(resulttype.def).procoptions,po_methodpointer);
 
 
                  { we need to process the parameters reverse so they are inserted
                  { we need to process the parameters reverse so they are inserted
                    in the correct right2left order (PFV) }
                    in the correct right2left order (PFV) }
-                 hp2:=TParaItem(hp3^.Para.last);
+                 hp2:=TParaItem(hp3.Para.last);
                  while assigned(hp2) do
                  while assigned(hp2) do
                    begin
                    begin
-                      pprocvardef(resulttype.def)^.concatpara(hp2.paratype,hp2.paratyp,hp2.defaultvalue);
+                      tprocvardef(resulttype.def).concatpara(hp2.paratype,hp2.paratyp,hp2.defaultvalue);
                       hp2:=TParaItem(hp2.previous);
                       hp2:=TParaItem(hp2.previous);
                    end;
                    end;
               end
               end
@@ -439,20 +439,20 @@ implementation
             while assigned(hp) and (hp.nodetype in [vecn,derefn,subscriptn]) do
             while assigned(hp) and (hp.nodetype in [vecn,derefn,subscriptn]) do
              hp:=tunarynode(hp).left;
              hp:=tunarynode(hp).left;
             if assigned(hp) and (hp.nodetype=loadn) and
             if assigned(hp) and (hp.nodetype=loadn) and
-               ((tloadnode(hp).symtableentry^.typ=absolutesym) and
-                pabsolutesym(tloadnode(hp).symtableentry)^.absseg) then
+               ((tloadnode(hp).symtableentry.typ=absolutesym) and
+                tabsolutesym(tloadnode(hp).symtableentry).absseg) then
              begin
              begin
                if not(cs_typed_addresses in aktlocalswitches) then
                if not(cs_typed_addresses in aktlocalswitches) then
                  resulttype:=voidfarpointertype
                  resulttype:=voidfarpointertype
                else
                else
-                 resulttype.setdef(new(ppointerdef,initfar(left.resulttype)));
+                 resulttype.setdef(tpointerdef.createfar(left.resulttype));
              end
              end
             else
             else
              begin
              begin
                if not(cs_typed_addresses in aktlocalswitches) then
                if not(cs_typed_addresses in aktlocalswitches) then
                  resulttype:=voidpointertype
                  resulttype:=voidpointertype
                else
                else
-                 resulttype.setdef(new(ppointerdef,init(left.resulttype)));
+                 resulttype.setdef(tpointerdef.create(left.resulttype));
              end;
              end;
           end;
           end;
 
 
@@ -525,7 +525,7 @@ implementation
          set_varstate(left,false);
          set_varstate(left,false);
          dec(parsing_para_level);
          dec(parsing_para_level);
 
 
-         if (left.resulttype.def^.deftype)<>procvardef then
+         if (left.resulttype.def.deftype)<>procvardef then
            CGMessage(cg_e_illegal_expression);
            CGMessage(cg_e_illegal_expression);
 
 
          resulttype:=voidpointertype;
          resulttype:=voidpointertype;
@@ -573,8 +573,8 @@ implementation
          if codegenerror then
          if codegenerror then
           exit;
           exit;
 
 
-         if left.resulttype.def^.deftype=pointerdef then
-          resulttype:=ppointerdef(left.resulttype.def)^.pointertype
+         if left.resulttype.def.deftype=pointerdef then
+          resulttype:=tpointerdef(left.resulttype.def).pointertype
          else
          else
           CGMessage(cg_e_invalid_qualifier);
           CGMessage(cg_e_invalid_qualifier);
       end;
       end;
@@ -600,12 +600,12 @@ implementation
                             TSUBSCRIPTNODE
                             TSUBSCRIPTNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tsubscriptnode.create(varsym : psym;l : tnode);
+    constructor tsubscriptnode.create(varsym : tsym;l : tnode);
 
 
       begin
       begin
          inherited create(subscriptn,l);
          inherited create(subscriptn,l);
-         { vs should be changed to psym! }
-         vs:=pvarsym(varsym);
+         { vs should be changed to tsym! }
+         vs:=tvarsym(varsym);
       end;
       end;
 
 
     function tsubscriptnode.getcopy : tnode;
     function tsubscriptnode.getcopy : tnode;
@@ -625,7 +625,7 @@ implementation
         result:=nil;
         result:=nil;
         resulttypepass(left);
         resulttypepass(left);
         set_varstate(left,false);
         set_varstate(left,false);
-        resulttype:=vs^.vartype;
+        resulttype:=vs.vartype;
       end;
       end;
 
 
 
 
@@ -688,16 +688,16 @@ implementation
           exit;
           exit;
 
 
          { range check only for arrays }
          { range check only for arrays }
-         if (left.resulttype.def^.deftype=arraydef) then
+         if (left.resulttype.def.deftype=arraydef) then
            begin
            begin
-              if (isconvertable(right.resulttype.def,parraydef(left.resulttype.def)^.rangetype.def,
+              if (isconvertable(right.resulttype.def,tarraydef(left.resulttype.def).rangetype.def,
                     ct,ordconstn,false)=0) and
                     ct,ordconstn,false)=0) and
-                 not(is_equal(right.resulttype.def,parraydef(left.resulttype.def)^.rangetype.def)) then
+                 not(is_equal(right.resulttype.def,tarraydef(left.resulttype.def).rangetype.def)) then
                 CGMessage(type_e_mismatch);
                 CGMessage(type_e_mismatch);
            end;
            end;
          { Never convert a boolean or a char !}
          { Never convert a boolean or a char !}
          { maybe type conversion }
          { maybe type conversion }
-         if (right.resulttype.def^.deftype<>enumdef) and
+         if (right.resulttype.def.deftype<>enumdef) and
             not(is_char(right.resulttype.def)) and
             not(is_char(right.resulttype.def)) and
             not(is_boolean(right.resulttype.def)) then
             not(is_boolean(right.resulttype.def)) then
            begin
            begin
@@ -707,27 +707,27 @@ implementation
          { are we accessing a pointer[], then convert the pointer to
          { are we accessing a pointer[], then convert the pointer to
            an array first, in FPC this is allowed for all pointers in
            an array first, in FPC this is allowed for all pointers in
            delphi/tp7 it's only allowed for pchars }
            delphi/tp7 it's only allowed for pchars }
-         if (left.resulttype.def^.deftype=pointerdef) and
+         if (left.resulttype.def.deftype=pointerdef) and
             ((m_fpc in aktmodeswitches) or
             ((m_fpc in aktmodeswitches) or
              is_pchar(left.resulttype.def) or
              is_pchar(left.resulttype.def) or
              is_pwidechar(left.resulttype.def)) then
              is_pwidechar(left.resulttype.def)) then
           begin
           begin
             { convert pointer to array }
             { convert pointer to array }
-            htype.setdef(new(parraydef,init(0,$7fffffff,s32bittype)));
-            parraydef(htype.def)^.elementtype:=ppointerdef(left.resulttype.def)^.pointertype;
+            htype.setdef(tarraydef.create(0,$7fffffff,s32bittype));
+            tarraydef(htype.def).elementtype:=tpointerdef(left.resulttype.def).pointertype;
             inserttypeconv(left,htype);
             inserttypeconv(left,htype);
 
 
-            resulttype:=parraydef(htype.def)^.elementtype;
+            resulttype:=tarraydef(htype.def).elementtype;
           end;
           end;
 
 
          { determine return type }
          { determine return type }
          if not assigned(resulttype.def) then
          if not assigned(resulttype.def) then
-           if left.resulttype.def^.deftype=arraydef then
-             resulttype:=parraydef(left.resulttype.def)^.elementtype
-           else if left.resulttype.def^.deftype=stringdef then
+           if left.resulttype.def.deftype=arraydef then
+             resulttype:=tarraydef(left.resulttype.def).elementtype
+           else if left.resulttype.def.deftype=stringdef then
              begin
              begin
                 { indexed access to strings }
                 { indexed access to strings }
-                case pstringdef(left.resulttype.def)^.string_typ of
+                case tstringdef(left.resulttype.def).string_typ of
                    st_widestring :
                    st_widestring :
                      resulttype:=cwidechartype;
                      resulttype:=cwidechartype;
                    st_ansistring :
                    st_ansistring :
@@ -746,7 +746,7 @@ implementation
     function tvecnode.pass_1 : tnode;
     function tvecnode.pass_1 : tnode;
 {$ifdef consteval}
 {$ifdef consteval}
       var
       var
-         tcsym : ptypedconstsym;
+         tcsym : ttypedconstsym;
 {$endif}
 {$endif}
       begin
       begin
          result:=nil;
          result:=nil;
@@ -761,10 +761,10 @@ implementation
 {$ifdef consteval}
 {$ifdef consteval}
               { constant evaluation }
               { constant evaluation }
               if (left.nodetype=loadn) and
               if (left.nodetype=loadn) and
-                 (left.symtableentry^.typ=typedconstsym) then
+                 (left.symtableentry.typ=typedconstsym) then
                begin
                begin
-                 tcsym:=ptypedconstsym(left.symtableentry);
-                 if tcsym^.defintion^.typ=stringdef then
+                 tcsym:=ttypedconstsym(left.symtableentry);
+                 if tcsym.defintion^.typ=stringdef then
                   begin
                   begin
 
 
                   end;
                   end;
@@ -829,7 +829,7 @@ implementation
                                TSELFNODE
                                TSELFNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tselfnode.create(_class : pobjectdef);
+    constructor tselfnode.create(_class : tobjectdef);
 
 
       begin
       begin
          inherited create(selfn);
          inherited create(selfn);
@@ -845,7 +845,7 @@ implementation
     function tselfnode.pass_1 : tnode;
     function tselfnode.pass_1 : tnode;
       begin
       begin
          result:=nil;
          result:=nil;
-         if (resulttype.def^.deftype=classrefdef) or
+         if (resulttype.def.deftype=classrefdef) or
            is_class(resulttype.def) then
            is_class(resulttype.def) then
            location.loc:=LOC_CREGISTER
            location.loc:=LOC_CREGISTER
          else
          else
@@ -857,7 +857,7 @@ implementation
                                TWITHNODE
                                TWITHNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor twithnode.create(symtable : pwithsymtable;l,r : tnode;count : longint);
+    constructor twithnode.create(symtable : twithsymtable;l,r : tnode;count : longint);
 
 
       begin
       begin
          inherited create(withn,l,r);
          inherited create(withn,l,r);
@@ -870,7 +870,7 @@ implementation
 
 
     destructor twithnode.destroy;
     destructor twithnode.destroy;
       var
       var
-        symt : psymtable;
+        symt : tsymtable;
         i    : longint;
         i    : longint;
       begin
       begin
         symt:=withsymtable;
         symt:=withsymtable;
@@ -878,8 +878,8 @@ implementation
          begin
          begin
            if assigned(symt) then
            if assigned(symt) then
             begin
             begin
-              withsymtable:=pwithsymtable(symt^.next);
-              dispose(symt,done);
+              withsymtable:=twithsymtable(symt.next);
+              symt.free;
             end;
             end;
            symt:=withsymtable;
            symt:=withsymtable;
          end;
          end;
@@ -902,7 +902,7 @@ implementation
 
 
     function twithnode.det_resulttype:tnode;
     function twithnode.det_resulttype:tnode;
       var
       var
-         symtable : pwithsymtable;
+         symtable : twithsymtable;
          i : longint;
          i : longint;
       begin
       begin
          result:=nil;
          result:=nil;
@@ -919,10 +919,10 @@ implementation
             for i:=1 to tablecount do
             for i:=1 to tablecount do
              begin
              begin
                if (left.nodetype=loadn) and
                if (left.nodetype=loadn) and
-                  (tloadnode(left).symtable=aktprocsym^.definition^.localst) then
-                symtable^.direct_with:=true;
-               symtable^.withnode:=self;
-               symtable:=pwithsymtable(symtable^.next);
+                  (tloadnode(left).symtable=aktprocsym.definition.localst) then
+                symtable.direct_with:=true;
+               symtable.withnode:=self;
+               symtable:=twithsymtable(symtable.next);
              end;
              end;
 
 
             resulttypepass(right);
             resulttypepass(right);
@@ -976,7 +976,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2001-04-02 21:20:31  peter
+  Revision 1.17  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.16  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.15  2001/03/23 00:16:07  florian
   Revision 1.15  2001/03/23 00:16:07  florian

+ 8 - 5
compiler/node.pas

@@ -27,7 +27,7 @@ unit node;
 interface
 interface
 
 
     uses
     uses
-       cobjects,cclasses,
+       cclasses,
        globtype,globals,
        globtype,globals,
        cpubase,
        cpubase,
        aasm,
        aasm,
@@ -298,7 +298,6 @@ interface
           fileinfo : tfileposinfo;
           fileinfo : tfileposinfo;
           localswitches : tlocalswitches;
           localswitches : tlocalswitches;
 {$ifdef extdebug}
 {$ifdef extdebug}
-          oldresulttype : ttype; { to detect changed resulttype }
           maxfirstpasscount,
           maxfirstpasscount,
           firstpasscount : longint;
           firstpasscount : longint;
 {$endif extdebug}
 {$endif extdebug}
@@ -351,7 +350,7 @@ interface
        { true- and falselabel                                     }
        { true- and falselabel                                     }
        tparentnode = class(tnode)
        tparentnode = class(tnode)
 {$ifdef newcg}
 {$ifdef newcg}
-          falselabel,truelabel : pasmlabel;
+          falselabel,truelabel : tasmlabel;
 {$endif newcg}
 {$endif newcg}
        end;
        end;
 
 
@@ -430,7 +429,6 @@ implementation
          registersmmx:=0;
          registersmmx:=0;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
-         oldresulttype.reset;
          maxfirstpasscount:=0;
          maxfirstpasscount:=0;
          firstpasscount:=0;
          firstpasscount:=0;
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
@@ -792,7 +790,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2001-04-02 21:20:31  peter
+  Revision 1.15  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.14  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.13  2001/01/13 00:08:09  peter
   Revision 1.13  2001/01/13 00:08:09  peter

+ 8 - 3
compiler/nopt.pas

@@ -84,7 +84,7 @@ var
 
 
 implementation
 implementation
 
 
-uses cutils, htypechk, types, globtype, globals, cpubase, pass_1, ncnv, ncon,
+uses cutils, htypechk, types, globtype, globals, cpubase, ncnv, ncon,
      verbose, symdef, hcodegen;
      verbose, symdef, hcodegen;
 
 
 
 
@@ -196,7 +196,7 @@ begin
 {       doesn't work yet, don't know why (JM)
 {       doesn't work yet, don't know why (JM)
         tc_chararray_2_string:
         tc_chararray_2_string:
           curmaxlen :=
           curmaxlen :=
-            min(ttypeconvnode(left).left.resulttype.def^.size,255); }
+            min(ttypeconvnode(left).left.resulttype.def.size,255); }
         else curmaxlen := 255;
         else curmaxlen := 255;
       end;
       end;
     end
     end
@@ -278,7 +278,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2001-04-02 21:20:31  peter
+  Revision 1.3  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.2  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.1  2001/01/04 11:24:19  jonas
   Revision 1.1  2001/01/04 11:24:19  jonas

+ 21 - 16
compiler/nset.pas

@@ -36,10 +36,10 @@ interface
           _low,_high : TConstExprInt;
           _low,_high : TConstExprInt;
 
 
           { only used by gentreejmp }
           { only used by gentreejmp }
-          _at : pasmlabel;
+          _at : tasmlabel;
 
 
           { label of instruction }
           { label of instruction }
-          statement : pasmlabel;
+          statement : tasmlabel;
 
 
           { is this the first of an case entry, needed to release statement
           { is this the first of an case entry, needed to release statement
             label (PFV) }
             label (PFV) }
@@ -180,26 +180,26 @@ implementation
         t : tnode;
         t : tnode;
         pst : pconstset;
         pst : pconstset;
 
 
-        function createsetconst(psd : psetdef) : pconstset;
+        function createsetconst(psd : tsetdef) : pconstset;
         var
         var
           pcs : pconstset;
           pcs : pconstset;
-          pes : penumsym;
+          pes : tenumsym;
           i : longint;
           i : longint;
         begin
         begin
           new(pcs);
           new(pcs);
-          case psd^.elementtype.def^.deftype of
+          case psd.elementtype.def.deftype of
             enumdef :
             enumdef :
               begin
               begin
-                pes:=penumsym(penumdef(psd^.elementtype.def)^.firstenum);
+                pes:=tenumsym(tenumdef(psd.elementtype.def).firstenum);
                 while assigned(pes) do
                 while assigned(pes) do
                   begin
                   begin
-                    pcs^[pes^.value div 8]:=pcs^[pes^.value div 8] or (1 shl (pes^.value mod 8));
-                    pes:=pes^.nextenum;
+                    pcs^[pes.value div 8]:=pcs^[pes.value div 8] or (1 shl (pes.value mod 8));
+                    pes:=pes.nextenum;
                   end;
                   end;
               end;
               end;
             orddef :
             orddef :
               begin
               begin
-                for i:=porddef(psd^.elementtype.def)^.low to porddef(psd^.elementtype.def)^.high do
+                for i:=torddef(psd.elementtype.def).low to torddef(psd.elementtype.def).high do
                   begin
                   begin
                     pcs^[i div 8]:=pcs^[i div 8] or (1 shl (i mod 8));
                     pcs^[i div 8]:=pcs^[i div 8] or (1 shl (i mod 8));
                   end;
                   end;
@@ -225,13 +225,13 @@ implementation
              exit;
              exit;
           end;
           end;
 
 
-         if right.resulttype.def^.deftype<>setdef then
+         if right.resulttype.def.deftype<>setdef then
            CGMessage(sym_e_set_expected);
            CGMessage(sym_e_set_expected);
 
 
          if (right.nodetype=typen) then
          if (right.nodetype=typen) then
            begin
            begin
              { we need to create a setconstn }
              { we need to create a setconstn }
-             pst:=createsetconst(psetdef(ttypenode(right).resulttype.def));
+             pst:=createsetconst(tsetdef(ttypenode(right).resulttype.def));
              t:=csetconstnode.create(pst,ttypenode(right).resulttype);
              t:=csetconstnode.create(pst,ttypenode(right).resulttype);
              dispose(pst);
              dispose(pst);
              right.free;
              right.free;
@@ -244,8 +244,8 @@ implementation
            exit;
            exit;
 
 
          { type conversion/check }
          { type conversion/check }
-         if assigned(psetdef(right.resulttype.def)^.elementtype.def) then
-          inserttypeconv(left,psetdef(right.resulttype.def)^.elementtype);
+         if assigned(tsetdef(right.resulttype.def).elementtype.def) then
+          inserttypeconv(left,tsetdef(right.resulttype.def).elementtype);
       end;
       end;
 
 
 
 
@@ -264,7 +264,7 @@ implementation
            exit;
            exit;
 
 
          { empty set then return false }
          { empty set then return false }
-         if not assigned(psetdef(right.resulttype.def)^.elementtype.def) then
+         if not assigned(tsetdef(right.resulttype.def).elementtype.def) then
           begin
           begin
             t:=cordconstnode.create(0,booltype);
             t:=cordconstnode.create(0,booltype);
             firstpass(t);
             firstpass(t);
@@ -284,7 +284,7 @@ implementation
          left_right_max;
          left_right_max;
          { this is not allways true due to optimization }
          { this is not allways true due to optimization }
          { but if we don't set this we get problems with optimizing self code }
          { but if we don't set this we get problems with optimizing self code }
-         if psetdef(right.resulttype.def)^.settype<>smallset then
+         if tsetdef(right.resulttype.def).settype<>smallset then
            procinfo^.flags:=procinfo^.flags or pi_do_call
            procinfo^.flags:=procinfo^.flags or pi_do_call
          else
          else
            begin
            begin
@@ -588,7 +588,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-04-02 21:20:31  peter
+  Revision 1.13  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.12  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.11  2000/12/31 11:14:11  jonas
   Revision 1.11  2000/12/31 11:14:11  jonas

+ 27 - 23
compiler/ogbase.pas

@@ -34,7 +34,7 @@ interface
        dos,
        dos,
 {$endif Delphi}
 {$endif Delphi}
        { common }
        { common }
-       cclasses,cobjects,
+       cclasses,
        { targets }
        { targets }
        systems,
        systems,
        { outputwriters }
        { outputwriters }
@@ -51,7 +51,7 @@ interface
        toutputreloc = packed record
        toutputreloc = packed record
           next     : poutputreloc;
           next     : poutputreloc;
           address  : longint;
           address  : longint;
-          symbol   : pasmsymbol;
+          symbol   : tasmsymbol;
           section  : tsection; { only used if symbol=nil }
           section  : tsection; { only used if symbol=nil }
           typ      : relative_type;
           typ      : relative_type;
        end;
        end;
@@ -90,7 +90,7 @@ interface
          function  aligneddatasize:longint;
          function  aligneddatasize:longint;
          procedure alignsection;
          procedure alignsection;
          procedure alloc(l:longint);
          procedure alloc(l:longint);
-         procedure addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+         procedure addsymreloc(ofs:longint;p:tasmsymbol;relative:relative_type);
          procedure addsectionreloc(ofs:longint;sec:tsection;relative:relative_type);
          procedure addsectionreloc(ofs:longint;sec:tsection;relative:relative_type);
        end;
        end;
 
 
@@ -98,7 +98,7 @@ interface
          { section }
          { section }
          currsec   : tsection;
          currsec   : tsection;
          sects     : array[TSection] of tobjectsection;
          sects     : array[TSection] of tobjectsection;
-         localsyms : pdictionary;
+         localsyms : tdictionary;
          constructor create;
          constructor create;
          destructor  destroy;override;
          destructor  destroy;override;
          procedure createsection(sec:tsection);virtual;
          procedure createsection(sec:tsection);virtual;
@@ -108,11 +108,11 @@ interface
          procedure alloc(len:longint);
          procedure alloc(len:longint);
          procedure allocalign(len:longint);
          procedure allocalign(len:longint);
          procedure writebytes(var data;len:longint);
          procedure writebytes(var data;len:longint);
-         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);virtual;abstract;
-         procedure writesymbol(p:pasmsymbol);virtual;abstract;
+         procedure writereloc(data,len:longint;p:tasmsymbol;relative:relative_type);virtual;abstract;
+         procedure writesymbol(p:tasmsymbol);virtual;abstract;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
-         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
-         procedure addsymbol(p:pasmsymbol);
+         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
+         procedure addsymbol(p:tasmsymbol);
        end;
        end;
 
 
        tobjectalloc = class
        tobjectalloc = class
@@ -140,7 +140,7 @@ interface
          destructor  destroy;override;
          destructor  destroy;override;
          function  initwriting(const fn:string):boolean;virtual;
          function  initwriting(const fn:string):boolean;virtual;
          procedure donewriting;virtual;
          procedure donewriting;virtual;
-         procedure exportsymbol(p:pasmsymbol);
+         procedure exportsymbol(p:tasmsymbol);
          property Data:TObjectData read FData write FData;
          property Data:TObjectData read FData write FData;
          property Writer:TObjectWriter read FWriter;
          property Writer:TObjectWriter read FWriter;
        end;
        end;
@@ -173,13 +173,12 @@ interface
       objectoutput : tobjectoutput;
       objectoutput : tobjectoutput;
 
 
       { globals }
       { globals }
-      globalsyms : pdictionary;
+      globalsyms : tdictionary;
 
 
 
 
 implementation
 implementation
 
 
     uses
     uses
-      comphook,
       cutils,globtype,globals,verbose,fmodule;
       cutils,globtype,globals,verbose,fmodule;
 
 
 
 
@@ -330,7 +329,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tobjectsection.addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+    procedure tobjectsection.addsymreloc(ofs:longint;p:tasmsymbol;relative:relative_type);
       var
       var
         r : POutputReloc;
         r : POutputReloc;
       begin
       begin
@@ -370,8 +369,8 @@ implementation
       begin
       begin
         { reset }
         { reset }
         FillChar(Sects,sizeof(Sects),0);
         FillChar(Sects,sizeof(Sects),0);
-        localsyms:=new(pdictionary,init);
-        localsyms^.usehash;
+        localsyms:=tdictionary.create;
+        localsyms.usehash;
       end;
       end;
 
 
 
 
@@ -383,7 +382,7 @@ implementation
         for sec:=low(tsection) to high(tsection) do
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
          if assigned(sects[sec]) then
           sects[sec].free;
           sects[sec].free;
-        dispose(localsyms,done);
+        localsyms.free;
       end;
       end;
 
 
 
 
@@ -441,12 +440,12 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tobjectdata.addsymbol(p:pasmsymbol);
+    procedure tobjectdata.addsymbol(p:tasmsymbol);
       begin
       begin
-        if (p^.bind=AB_LOCAL) then
-         localsyms^.insert(p)
+        if (p.bind=AB_LOCAL) then
+         localsyms.insert(p)
         else
         else
-         globalsyms^.insert(p);
+         globalsyms.insert(p);
       end;
       end;
 
 
 
 
@@ -497,12 +496,12 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tobjectoutput.exportsymbol(p:pasmsymbol);
+    procedure tobjectoutput.exportsymbol(p:tasmsymbol);
       begin
       begin
         { export globals and common symbols, this is needed
         { export globals and common symbols, this is needed
           for .a files }
           for .a files }
-        if p^.bind in [AB_GLOBAL,AB_COMMON] then
-         FWriter.writesym(p^.name);
+        if p.bind in [AB_GLOBAL,AB_COMMON] then
+         FWriter.writesym(p.name);
       end;
       end;
 
 
 
 
@@ -569,7 +568,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-03-05 21:40:38  peter
+  Revision 1.7  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2001/03/05 21:40:38  peter
     * more things for tcoffobjectinput
     * more things for tcoffobjectinput
 
 
   Revision 1.5  2000/12/25 00:07:26  peter
   Revision 1.5  2000/12/25 00:07:26  peter

+ 46 - 41
compiler/ogcoff.pas

@@ -32,7 +32,7 @@ interface
 
 
     uses
     uses
        { common }
        { common }
-       cclasses,cobjects,
+       cclasses,
        { target }
        { target }
        systems,
        systems,
        { assembler }
        { assembler }
@@ -61,10 +61,10 @@ interface
          destructor  destroy;override;
          destructor  destroy;override;
          procedure setsectionsizes(var s:tsecsize);override;
          procedure setsectionsizes(var s:tsecsize);override;
          procedure createsection(sec:tsection);override;
          procedure createsection(sec:tsection);override;
-         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);override;
-         procedure writesymbol(p:pasmsymbol);override;
+         procedure writereloc(data,len:longint;p:tasmsymbol;relative:relative_type);override;
+         procedure writesymbol(p:tasmsymbol);override;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
-         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;nidx,nother,line:longint;reloc:boolean);override;
+         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);override;
        end;
        end;
 
 
        tcoffobjectoutput = class(tobjectoutput)
        tcoffobjectoutput = class(tobjectoutput)
@@ -82,13 +82,13 @@ interface
          function  initwriting(const fn:string):boolean;override;
          function  initwriting(const fn:string):boolean;override;
        end;
        end;
 
 
-       tpasmsymbolarray = array[0..high(word)] of pasmsymbol;
+       ttasmsymbolarray = array[0..high(word)] of tasmsymbol;
 
 
        tcoffobjectinput = class(tobjectinput)
        tcoffobjectinput = class(tobjectinput)
        private
        private
          Fidx2sec  : array[0..255] of tsection;
          Fidx2sec  : array[0..255] of tsection;
          FCoffsyms : tdynamicarray;
          FCoffsyms : tdynamicarray;
-         FSymTbl   : ^tpasmsymbolarray;
+         FSymTbl   : ^ttasmsymbolarray;
          win32     : boolean;
          win32     : boolean;
          procedure read_relocs(s:tcoffsection);
          procedure read_relocs(s:tcoffsection);
          procedure handle_symbols;
          procedure handle_symbols;
@@ -293,33 +293,33 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcoffdata.writesymbol(p:pasmsymbol);
+    procedure tcoffdata.writesymbol(p:tasmsymbol);
       var
       var
         sym : toutputsymbol;
         sym : toutputsymbol;
         s   : string;
         s   : string;
       begin
       begin
         { already written ? }
         { already written ? }
-        if p^.idx<>-1 then
+        if p.idx<>-1 then
          exit;
          exit;
         { be sure that the section will exists }
         { be sure that the section will exists }
-        if (p^.section<>sec_none) and not(assigned(sects[p^.section])) then
-          createsection(p^.section);
+        if (p.section<>sec_none) and not(assigned(sects[p.section])) then
+          createsection(p.section);
         FillChar(sym,sizeof(sym),0);
         FillChar(sym,sizeof(sym),0);
-        sym.value:=p^.size;
-        sym.bind:=p^.bind;
+        sym.value:=p.size;
+        sym.bind:=p.bind;
         sym.typ:=AT_NONE;
         sym.typ:=AT_NONE;
         { if local of global then set the section value to the address
         { if local of global then set the section value to the address
           of the symbol }
           of the symbol }
         if sym.bind in [AB_LOCAL,AB_GLOBAL] then
         if sym.bind in [AB_LOCAL,AB_GLOBAL] then
          begin
          begin
-           sym.section:=p^.section;
-           sym.value:=p^.address+sects[sym.section].mempos;
+           sym.section:=p.section;
+           sym.value:=p.address+sects[sym.section].mempos;
          end;
          end;
         { store the symbol, but not the local ones }
         { store the symbol, but not the local ones }
         if (sym.bind<>AB_LOCAL) then
         if (sym.bind<>AB_LOCAL) then
          begin
          begin
            { symbolname }
            { symbolname }
-           s:=p^.name;
+           s:=p.name;
            if length(s)>8 then
            if length(s)>8 then
             begin
             begin
               sym.nameidx:=FStrs.size+4;
               sym.nameidx:=FStrs.size+4;
@@ -332,18 +332,18 @@ implementation
               sym.namestr:=s;
               sym.namestr:=s;
             end;
             end;
            { update the asmsymbol index }
            { update the asmsymbol index }
-           p^.idx:=FSyms.size div sizeof(TOutputSymbol);
+           p.idx:=FSyms.size div sizeof(TOutputSymbol);
            { write the symbol }
            { write the symbol }
            FSyms.write(sym,sizeof(toutputsymbol));
            FSyms.write(sym,sizeof(toutputsymbol));
          end
          end
         else
         else
          begin
          begin
-           p^.idx:=-2; { local }
+           p.idx:=-2; { local }
          end;
          end;
       end;
       end;
 
 
 
 
-    procedure tcoffdata.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+    procedure tcoffdata.writereloc(data,len:longint;p:tasmsymbol;relative:relative_type);
       var
       var
         curraddr,
         curraddr,
         symaddr : longint;
         symaddr : longint;
@@ -355,11 +355,11 @@ implementation
            { current address }
            { current address }
            curraddr:=sects[currsec].mempos+sects[currsec].datasize;
            curraddr:=sects[currsec].mempos+sects[currsec].datasize;
            { real address of the symbol }
            { real address of the symbol }
-           symaddr:=p^.address;
-           if p^.section<>sec_none then
-            inc(symaddr,sects[p^.section].mempos);
+           symaddr:=p.address;
+           if p.section<>sec_none then
+            inc(symaddr,sects[p.section].mempos);
            { no symbol relocation need inside a section }
            { no symbol relocation need inside a section }
-           if p^.section=currsec then
+           if p.section=currsec then
              begin
              begin
                case relative of
                case relative of
                  relative_false :
                  relative_false :
@@ -381,14 +381,14 @@ implementation
            else
            else
              begin
              begin
                writesymbol(p);
                writesymbol(p);
-               if (p^.section<>sec_none) and (relative<>relative_true) then
-                 sects[currsec].addsectionreloc(curraddr,p^.section,relative)
+               if (p.section<>sec_none) and (relative<>relative_true) then
+                 sects[currsec].addsectionreloc(curraddr,p.section,relative)
                else
                else
                  sects[currsec].addsymreloc(curraddr,p,relative);
                  sects[currsec].addsymreloc(curraddr,p,relative);
                if not win32 then {seems wrong to me (PM) }
                if not win32 then {seems wrong to me (PM) }
                 inc(data,symaddr)
                 inc(data,symaddr)
                else
                else
-                if (relative<>relative_true) and (p^.section<>sec_none) then
+                if (relative<>relative_true) and (p.section<>sec_none) then
                  inc(data,symaddr);
                  inc(data,symaddr);
                if relative=relative_true then
                if relative=relative_true then
                 begin
                 begin
@@ -451,7 +451,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcoffdata.writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;
+    procedure tcoffdata.writesymstabs(section:tsection;offset:longint;p:pchar;ps:tasmsymbol;
                                                  nidx,nother,line:longint;reloc:boolean);
                                                  nidx,nother,line:longint;reloc:boolean);
       var
       var
         stab : coffstab;
         stab : coffstab;
@@ -579,13 +579,13 @@ implementation
            rel.address:=r^.address;
            rel.address:=r^.address;
            if assigned(r^.symbol) then
            if assigned(r^.symbol) then
             begin
             begin
-              if (r^.symbol^.bind=AB_LOCAL) then
-               rel.sym:=2*data.sects[r^.symbol^.section].secsymidx
+              if (r^.symbol.bind=AB_LOCAL) then
+               rel.sym:=2*data.sects[r^.symbol.section].secsymidx
               else
               else
                begin
                begin
-                 if r^.symbol^.idx=-1 then
+                 if r^.symbol.idx=-1 then
                    internalerror(4321);
                    internalerror(4321);
-                 rel.sym:=r^.symbol^.idx+initsym;
+                 rel.sym:=r^.symbol.idx+initsym;
                end;
                end;
             end
             end
            else
            else
@@ -845,7 +845,7 @@ implementation
         rel  : coffreloc;
         rel  : coffreloc;
         rel_type : relative_type;
         rel_type : relative_type;
         i        : longint;
         i        : longint;
-        p        : pasmsymbol;
+        p        : tasmsymbol;
       begin
       begin
         for i:=1 to s.coffrelocs do
         for i:=1 to s.coffrelocs do
          begin
          begin
@@ -882,13 +882,13 @@ implementation
         symidx    : longint;
         symidx    : longint;
         sym       : coffsymbol;
         sym       : coffsymbol;
         strname   : string;
         strname   : string;
-        p         : pasmsymbol;
+        p         : tasmsymbol;
         auxrec    : array[0..17] of byte;
         auxrec    : array[0..17] of byte;
       begin
       begin
         with tcoffdata(data) do
         with tcoffdata(data) do
          begin
          begin
            nsyms:=FCoffSyms.Size div sizeof(CoffSymbol);
            nsyms:=FCoffSyms.Size div sizeof(CoffSymbol);
-           { Allocate memory for symidx -> pasmsymbol table }
+           { Allocate memory for symidx -> tasmsymbol table }
            GetMem(FSymTbl,nsyms*sizeof(pointer));
            GetMem(FSymTbl,nsyms*sizeof(pointer));
            FillChar(FSymTbl^,nsyms*sizeof(pointer),0);
            FillChar(FSymTbl^,nsyms*sizeof(pointer),0);
            { Loop all symbols }
            { Loop all symbols }
@@ -916,17 +916,17 @@ implementation
                   begin
                   begin
                     if sym.section=0 then
                     if sym.section=0 then
                      begin
                      begin
-                       p:=new(pasmsymbol,init(strname,AB_EXTERNAL,AT_FUNCTION));
+                       p:=tasmsymbol.create(strname,AB_EXTERNAL,AT_FUNCTION);
                      end
                      end
                     else
                     else
                      begin
                      begin
-                       p:=new(pasmsymbol,init(strname,AB_GLOBAL,AT_FUNCTION));
+                       p:=tasmsymbol.create(strname,AB_GLOBAL,AT_FUNCTION);
                        sec:=Fidx2sec[sym.section];
                        sec:=Fidx2sec[sym.section];
                        if assigned(sects[sec]) then
                        if assigned(sects[sec]) then
                         begin
                         begin
-                          p^.section:=sec;
+                          p.section:=sec;
                           if sym.value>=sects[sec].mempos then
                           if sym.value>=sects[sec].mempos then
-                           p^.address:=sym.value-sects[sec].mempos
+                           p.address:=sym.value-sects[sec].mempos
                           else
                           else
                            internalerror(432432432);
                            internalerror(432432432);
                         end
                         end
@@ -938,13 +938,13 @@ implementation
                   end;
                   end;
                 COFF_SYM_STATIC :
                 COFF_SYM_STATIC :
                   begin
                   begin
-                    p:=new(pasmsymbol,init(strname,AB_LOCAL,AT_FUNCTION));
+                    p:=tasmsymbol.create(strname,AB_LOCAL,AT_FUNCTION);
                     sec:=Fidx2sec[sym.section];
                     sec:=Fidx2sec[sym.section];
                     if assigned(sects[sec]) then
                     if assigned(sects[sec]) then
                      begin
                      begin
-                       p^.section:=sec;
+                       p.section:=sec;
                        if sym.value>=sects[sec].mempos then
                        if sym.value>=sects[sec].mempos then
-                        p^.address:=sym.value-sects[sec].mempos
+                        p.address:=sym.value-sects[sec].mempos
                        else
                        else
                         begin
                         begin
                           if Str2Sec(strname)<>sec then
                           if Str2Sec(strname)<>sec then
@@ -1088,7 +1088,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2001-04-02 21:20:31  peter
+  Revision 1.12  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.11  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.10  2001/03/13 18:45:07  peter
   Revision 1.10  2001/03/13 18:45:07  peter

+ 33 - 28
compiler/ogelf.pas

@@ -32,7 +32,7 @@ interface
 
 
     uses
     uses
        { common }
        { common }
-       cclasses,cobjects,
+       cclasses,
        { target }
        { target }
        systems,
        systems,
        { assembler }
        { assembler }
@@ -72,10 +72,10 @@ interface
          destructor  destroy;override;
          destructor  destroy;override;
          procedure createsection(sec:tsection);override;
          procedure createsection(sec:tsection);override;
          procedure setsectionsizes(var s:tsecsize);override;
          procedure setsectionsizes(var s:tsecsize);override;
-         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);override;
-         procedure writesymbol(p:pasmsymbol);override;
+         procedure writereloc(data,len:longint;p:tasmsymbol;relative:relative_type);override;
+         procedure writesymbol(p:tasmsymbol);override;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
          procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
-         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;
+         procedure writesymstabs(section:tsection;offset:longint;p:pchar;ps:tasmsymbol;
                                  nidx,nother,line:longint;reloc:boolean);override;
                                  nidx,nother,line:longint;reloc:boolean);override;
        end;
        end;
 
 
@@ -325,28 +325,28 @@ implementation
       end;
       end;
 
 
 
 
-    procedure telf32data.writesymbol(p:pasmsymbol);
+    procedure telf32data.writesymbol(p:tasmsymbol);
       var
       var
         sym : toutputsymbol;
         sym : toutputsymbol;
       begin
       begin
         { already written ? }
         { already written ? }
-        if p^.idx<>-1 then
+        if p.idx<>-1 then
          exit;
          exit;
         { be sure that the section will exists }
         { be sure that the section will exists }
-        if (p^.section<>sec_none) and not(assigned(sects[p^.section])) then
-          createsection(p^.section);
+        if (p.section<>sec_none) and not(assigned(sects[p.section])) then
+          createsection(p.section);
         FillChar(sym,sizeof(sym),0);
         FillChar(sym,sizeof(sym),0);
-        sym.size:=p^.size;
-        sym.bind:=p^.bind;
-        sym.typ:=p^.typ;
+        sym.size:=p.size;
+        sym.bind:=p.bind;
+        sym.typ:=p.typ;
         { if local of global then set the section value to the address
         { if local of global then set the section value to the address
           of the symbol }
           of the symbol }
         case sym.bind of
         case sym.bind of
           AB_LOCAL,
           AB_LOCAL,
           AB_GLOBAL :
           AB_GLOBAL :
             begin
             begin
-              sym.section:=p^.section;
-              sym.value:=p^.address;
+              sym.section:=p.section;
+              sym.value:=p.address;
             end;
             end;
           AB_COMMON :
           AB_COMMON :
             begin
             begin
@@ -358,21 +358,21 @@ implementation
          begin
          begin
            { symbolname, write the #0 separate to overcome 255+1 char not possible }
            { symbolname, write the #0 separate to overcome 255+1 char not possible }
            sym.nameidx:=strtabsect.datasize;
            sym.nameidx:=strtabsect.datasize;
-           strtabsect.writestr(p^.name);
+           strtabsect.writestr(p.name);
            strtabsect.writestr(#0);
            strtabsect.writestr(#0);
            { update the asmsymbol index }
            { update the asmsymbol index }
-           p^.idx:=syms.size div sizeof(toutputsymbol);
+           p.idx:=syms.size div sizeof(toutputsymbol);
            { symbol }
            { symbol }
            Syms.write(sym,sizeof(toutputsymbol));
            Syms.write(sym,sizeof(toutputsymbol));
          end
          end
         else
         else
          begin
          begin
-           p^.idx:=-2; { local }
+           p.idx:=-2; { local }
          end;
          end;
       end;
       end;
 
 
 
 
-    procedure telf32data.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+    procedure telf32data.writereloc(data,len:longint;p:tasmsymbol;relative:relative_type);
       var
       var
         symaddr : longint;
         symaddr : longint;
       begin
       begin
@@ -381,9 +381,9 @@ implementation
         if assigned(p) then
         if assigned(p) then
          begin
          begin
            { real address of the symbol }
            { real address of the symbol }
-           symaddr:=p^.address;
+           symaddr:=p.address;
            { no symbol relocation need inside a section }
            { no symbol relocation need inside a section }
-           if p^.section=currsec then
+           if p.section=currsec then
              begin
              begin
                case relative of
                case relative of
                  relative_false :
                  relative_false :
@@ -402,16 +402,16 @@ implementation
            else
            else
              begin
              begin
                writesymbol(p);
                writesymbol(p);
-               if (p^.section<>sec_none) and (relative<>relative_true) then
+               if (p.section<>sec_none) and (relative<>relative_true) then
                 begin
                 begin
-                  sects[currsec].addsectionreloc(sects[currsec].datasize,p^.section,relative);
+                  sects[currsec].addsectionreloc(sects[currsec].datasize,p.section,relative);
                   inc(data,symaddr);
                   inc(data,symaddr);
                 end
                 end
                else
                else
                 sects[currsec].addsymreloc(sects[currsec].datasize,p,relative);
                 sects[currsec].addsymreloc(sects[currsec].datasize,p,relative);
                if relative=relative_true then
                if relative=relative_true then
                 begin
                 begin
-                  if p^.bind=AB_EXTERNAL then
+                  if p.bind=AB_EXTERNAL then
                    dec(data,len)
                    dec(data,len)
                   else
                   else
                    dec(data,len+sects[currsec].datasize);
                    dec(data,len+sects[currsec].datasize);
@@ -456,7 +456,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure telf32data.writesymstabs(section:tsection;offset:longint;p:pchar;ps:pasmsymbol;
+    procedure telf32data.writesymstabs(section:tsection;offset:longint;p:pchar;ps:tasmsymbol;
                                                  nidx,nother,line:longint;reloc:boolean);
                                                  nidx,nother,line:longint;reloc:boolean);
       var
       var
         stab : telf32stab;
         stab : telf32stab;
@@ -526,13 +526,13 @@ implementation
               rel.address:=r^.address;
               rel.address:=r^.address;
               if assigned(r^.symbol) then
               if assigned(r^.symbol) then
                begin
                begin
-                 if (r^.symbol^.bind=AB_LOCAL) then
-                  relsym:=sects[r^.symbol^.section].secsymidx
+                 if (r^.symbol.bind=AB_LOCAL) then
+                  relsym:=sects[r^.symbol.section].secsymidx
                  else
                  else
                   begin
                   begin
-                    if r^.symbol^.idx=-1 then
+                    if r^.symbol.idx=-1 then
                       internalerror(4321);
                       internalerror(4321);
-                    relsym:=(r^.symbol^.idx+initsym);
+                    relsym:=(r^.symbol.idx+initsym);
                   end;
                   end;
                end
                end
               else
               else
@@ -846,7 +846,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-03-05 21:40:39  peter
+  Revision 1.7  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.6  2001/03/05 21:40:39  peter
     * more things for tcoffobjectinput
     * more things for tcoffobjectinput
 
 
   Revision 1.5  2000/12/25 00:07:26  peter
   Revision 1.5  2000/12/25 00:07:26  peter

+ 11 - 4
compiler/options.pas

@@ -56,8 +56,10 @@ type
     procedure parsecmd(cmd:string);
     procedure parsecmd(cmd:string);
   end;
   end;
 
 
+  TOptionClass=class of toption;
+
 var
 var
-  coption : class of toption;
+  coption : TOptionClass;
 
 
 procedure read_arguments(cmd:string);
 procedure read_arguments(cmd:string);
 
 
@@ -71,7 +73,7 @@ uses
   dos,
   dos,
 {$endif Delphi}
 {$endif Delphi}
   version,systems,
   version,systems,
-  cutils,cobjects,messages
+  cutils,messages
 {$ifdef BrowserLog}
 {$ifdef BrowserLog}
   ,browlog
   ,browlog
 {$endif BrowserLog}
 {$endif BrowserLog}
@@ -771,7 +773,7 @@ begin
                        case More[j] of
                        case More[j] of
                         'B': {bind_win32_dll:=true}
                         'B': {bind_win32_dll:=true}
                              begin
                              begin
-                               {  -WB200000 means set prefered base address
+                               {  -WB200000 means set trefered base address
                                  to $200000, but does not change relocsection boolean
                                  to $200000, but does not change relocsection boolean
                                  this way we can create both relocatble and
                                  this way we can create both relocatble and
                                  non relocatable DLL at a specific base address PM }
                                  non relocatable DLL at a specific base address PM }
@@ -1555,7 +1557,12 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2001-03-25 12:27:31  peter
+  Revision 1.39  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.38  2001/03/25 12:27:31  peter
     * fixed -Se (merged)
     * fixed -Se (merged)
 
 
   Revision 1.37  2001/03/23 00:16:07  florian
   Revision 1.37  2001/03/23 00:16:07  florian

+ 30 - 11
compiler/parser.pas

@@ -36,7 +36,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      cutils,cobjects,cclasses,
+      cutils,cclasses,
       globtype,version,tokens,systems,globals,verbose,
       globtype,version,tokens,systems,globals,verbose,
       symbase,symtable,symsym,fmodule,aasm,
       symbase,symtable,symsym,fmodule,aasm,
       hcodegen,
       hcodegen,
@@ -92,10 +92,10 @@ implementation
           stacksize:=target_info.stacksize;
           stacksize:=target_info.stacksize;
 
 
          { open assembler response }
          { open assembler response }
-         AsmRes.Init(outputexedir+'ppas');
+         AsmRes:=TAsmScript.Create(outputexedir+'ppas');
 
 
          { open deffile }
          { open deffile }
-         DefFile.Init(outputexedir+inputfile+target_os.defext);
+         DefFile:=TDefFile.Create(outputexedir+inputfile+target_os.defext);
 
 
          { list of generated .o files, so the linker can remove them }
          { list of generated .o files, so the linker can remove them }
          SmartLinkOFiles:=TStringList.Create;
          SmartLinkOFiles:=TStringList.Create;
@@ -108,9 +108,17 @@ implementation
          loaded_units.free;
          loaded_units.free;
          usedunits.free;
          usedunits.free;
 
 
+         { if there was an error in the scanner, the scanner is
+           still assinged }
+         if assigned(current_scanner) then
+          begin
+            dispose(current_scanner,done);
+            current_scanner:=nil;
+          end;
+
          { close ppas,deffile }
          { close ppas,deffile }
-         asmres.done;
-         deffile.done;
+         asmres.free;
+         deffile.free;
 
 
          { free list of .o files }
          { free list of .o files }
          SmartLinkOFiles.Free;
          SmartLinkOFiles.Free;
@@ -200,6 +208,7 @@ implementation
          until false;
          until false;
        { free scanner }
        { free scanner }
          dispose(current_scanner,done);
          dispose(current_scanner,done);
+         current_scanner:=nil;
        { close }
        { close }
          dispose(preprocfile,done);
          dispose(preprocfile,done);
       end;
       end;
@@ -221,9 +230,9 @@ implementation
        { symtable }
        { symtable }
          oldrefsymtable,
          oldrefsymtable,
          olddefaultsymtablestack,
          olddefaultsymtablestack,
-         oldsymtablestack : psymtable;
+         oldsymtablestack : tsymtable;
          oldprocprefix    : string;
          oldprocprefix    : string;
-         oldaktprocsym    : pprocsym;
+         oldaktprocsym    : tprocsym;
          oldoverloaded_operators : toverloaded_operators;
          oldoverloaded_operators : toverloaded_operators;
        { cg }
        { cg }
          oldnextlabelnr : longint;
          oldnextlabelnr : longint;
@@ -241,7 +250,7 @@ implementation
          olddebuglist,
          olddebuglist,
          oldwithdebuglist,
          oldwithdebuglist,
          oldconsts     : taasmoutput;
          oldconsts     : taasmoutput;
-         oldasmsymbollist : pdictionary;
+         oldasmsymbollist : tdictionary;
        { resourcestrings }
        { resourcestrings }
          OldResourceStrings : tResourceStrings;
          OldResourceStrings : tResourceStrings;
        { akt.. things }
        { akt.. things }
@@ -363,6 +372,10 @@ implementation
             main_module:=current_module;
             main_module:=current_module;
           end;
           end;
 
 
+         { a unit compiled at command line must be inside the loaded_unit list }
+         if (compile_level=1) then
+           loaded_units.insert(current_module);
+
          { Set the module to use for verbose }
          { Set the module to use for verbose }
          SetCompileModule(current_module);
          SetCompileModule(current_module);
 
 
@@ -461,6 +474,7 @@ implementation
           end;
           end;
        { free scanner }
        { free scanner }
          dispose(current_scanner,done);
          dispose(current_scanner,done);
+         current_scanner:=nil;
        { restore previous scanner !! }
        { restore previous scanner !! }
          current_module.scanner:=prev_scanner;
          current_module.scanner:=prev_scanner;
          if assigned(prev_scanner) then
          if assigned(prev_scanner) then
@@ -567,11 +581,11 @@ implementation
           (* Obsolete code aktprocsym
           (* Obsolete code aktprocsym
              is disposed by the localsymtable disposal (PM)
              is disposed by the localsymtable disposal (PM)
           { Free last aktprocsym }
           { Free last aktprocsym }
-            if assigned(aktprocsym) and (aktprocsym^.owner=nil) then
+            if assigned(aktprocsym) and (aktprocsym.owner=nil) then
              begin
              begin
                { init parts are not needed in units !! }
                { init parts are not needed in units !! }
                if current_module.is_unit then
                if current_module.is_unit then
-                 aktprocsym^.definition^.forwarddef:=false;
+                 aktprocsym.definition.forwarddef:=false;
                dispose(aktprocsym,done);
                dispose(aktprocsym,done);
              end; *)
              end; *)
           end;
           end;
@@ -589,7 +603,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2000-12-25 00:07:27  peter
+  Revision 1.14  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2000/12/25 00:07:27  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 8 - 17
compiler/pass_1.pas

@@ -47,9 +47,10 @@ implementation
 
 
     uses
     uses
       globtype,systems,
       globtype,systems,
-      cutils,cobjects,globals,verbose,
+      cutils,globals,
       hcodegen,symdef,
       hcodegen,symdef,
 {$ifdef extdebug}
 {$ifdef extdebug}
+      verbose,
       htypechk,
       htypechk,
 {$endif extdebug}
 {$endif extdebug}
       tgcpu
       tgcpu
@@ -79,17 +80,12 @@ implementation
            aktfilepos:=p.fileinfo;
            aktfilepos:=p.fileinfo;
            aktlocalswitches:=p.localswitches;
            aktlocalswitches:=p.localswitches;
            hp:=p.det_resulttype;
            hp:=p.det_resulttype;
-//writeln('result: ',nodetype2str[p.nodetype],' ',dword(hp));
            { should the node be replaced? }
            { should the node be replaced? }
            if assigned(hp) then
            if assigned(hp) then
             begin
             begin
                p.free;
                p.free;
                p:=hp;
                p:=hp;
             end;
             end;
-{$ifdef EXTDEBUG}
-           { save resulttype for checking of changes in pass_1 }
-           p.oldresulttype:=p.resulttype;
-{$endif EXTDEBUG}
            aktlocalswitches:=oldlocalswitches;
            aktlocalswitches:=oldlocalswitches;
            aktfilepos:=oldpos;
            aktfilepos:=oldpos;
            if codegenerror then
            if codegenerror then
@@ -149,10 +145,6 @@ implementation
                      p.free;
                      p.free;
                      p:=hp;
                      p:=hp;
                   end;
                   end;
-{$ifdef EXTDEBUG}
-                 { save resulttype for checking of changes in pass_1 }
-                 p.oldresulttype:=p.resulttype;
-{$endif EXTDEBUG}
                end;
                end;
               { first pass }
               { first pass }
               hp:=p.pass_1;
               hp:=p.pass_1;
@@ -162,12 +154,6 @@ implementation
                    p.free;
                    p.free;
                    p:=hp;
                    p:=hp;
                 end;
                 end;
-{$ifdef EXTDEBUG}
-              { check if the resulttype is still the same }
-              if (p.oldresulttype.def<>p.resulttype.def) and
-                 (p.oldresulttype.sym<>p.resulttype.sym) then
-               Comment(V_Warning,'Resulttype change in '+nodetype2str[p.nodetype]+'.pass_1');
-{$endif EXTDEBUG}
               aktlocalswitches:=oldlocalswitches;
               aktlocalswitches:=oldlocalswitches;
               aktfilepos:=oldpos;
               aktfilepos:=oldpos;
               if codegenerror then
               if codegenerror then
@@ -194,7 +180,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-04-02 21:20:31  peter
+  Revision 1.13  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.12  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.11  2000/12/18 21:56:52  peter
   Revision 1.11  2000/12/18 21:56:52  peter

+ 18 - 13
compiler/pass_2.pas

@@ -51,7 +51,7 @@ implementation
      cutils,
      cutils,
 {$endif}
 {$endif}
      globtype,systems,
      globtype,systems,
-     cobjects,globals,
+     cclasses,globals,
      symconst,symbase,symtype,symsym,aasm,
      symconst,symbase,symtype,symsym,aasm,
      pass_1,hcodegen,temp_gen,regvars,nflw,tgcpu;
      pass_1,hcodegen,temp_gen,regvars,nflw,tgcpu;
 
 
@@ -215,12 +215,12 @@ implementation
          do_secondpass:=codegenerror;
          do_secondpass:=codegenerror;
       end;
       end;
 
 
-    procedure clearrefs(p : pnamedindexobject);
+    procedure clearrefs(p : tnamedindexitem);
 
 
       begin
       begin
-         if (psym(p)^.typ=varsym) then
-           if pvarsym(p)^.refs>1 then
-             pvarsym(p)^.refs:=1;
+         if (tsym(p).typ=varsym) then
+           if tvarsym(p).refs>1 then
+             tvarsym(p).refs:=1;
       end;
       end;
 
 
     procedure generatecode(var p : tnode);
     procedure generatecode(var p : tnode);
@@ -237,8 +237,8 @@ implementation
          clearregistercount;
          clearregistercount;
          use_esp_stackframe:=false;
          use_esp_stackframe:=false;
          aktexceptblock:=nil;
          aktexceptblock:=nil;
-         symtablestack^.foreach(@clearrefs);
-         symtablestack^.next^.foreach(@clearrefs);
+         symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs);
+         symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs);
          if not(do_firstpass(p)) then
          if not(do_firstpass(p)) then
            begin
            begin
              if (cs_regalloc in aktglobalswitches) and
              if (cs_regalloc in aktglobalswitches) and
@@ -258,8 +258,8 @@ implementation
                                    if assigned(aktprocsym) then
                                    if assigned(aktprocsym) then
                                      begin
                                      begin
                                        if not(assigned(procinfo^._class)) and
                                        if not(assigned(procinfo^._class)) and
-                                          not(aktprocsym^.definition^.proctypeoption in [potype_constructor,potype_destructor]) and
-                                          not(po_interrupt in aktprocsym^.definition^.procoptions) and
+                                          not(aktprocsym.definition.proctypeoption in [potype_constructor,potype_destructor]) and
+                                          not(po_interrupt in aktprocsym.definition.procoptions) and
                                           ((procinfo^.flags and pi_do_call)=0) and
                                           ((procinfo^.flags and pi_do_call)=0) and
                                           (lexlevel>=normal_function_level) then
                                           (lexlevel>=normal_function_level) then
                                          begin
                                          begin
@@ -278,7 +278,7 @@ implementation
                                              dec(procinfo^.retoffset,4);
                                              dec(procinfo^.retoffset,4);
 
 
                                            dec(procinfo^.para_offset,4);
                                            dec(procinfo^.para_offset,4);
-                                           aktprocsym^.definition^.parast^.address_fixup:=procinfo^.para_offset;
+                                           aktprocsym.definition.parast.address_fixup:=procinfo^.para_offset;
                                          end;
                                          end;
                                      end;
                                      end;
                                     *)
                                     *)
@@ -289,12 +289,12 @@ implementation
               cleanup_regvars(procinfo^.aktexitcode);
               cleanup_regvars(procinfo^.aktexitcode);
 
 
               if assigned(aktprocsym) and
               if assigned(aktprocsym) and
-                 (pocall_inline in aktprocsym^.definition^.proccalloptions) then
+                 (pocall_inline in aktprocsym.definition.proccalloptions) then
                 make_const_global:=true;
                 make_const_global:=true;
               do_secondpass(p);
               do_secondpass(p);
 
 
               if assigned(procinfo^.def) then
               if assigned(procinfo^.def) then
-                procinfo^.def^.fpu_used:=p.registersfpu;
+                procinfo^.def.fpu_used:=p.registersfpu;
 
 
            end;
            end;
          procinfo^.aktproccode.concatlist(exprasmlist);
          procinfo^.aktproccode.concatlist(exprasmlist);
@@ -304,7 +304,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-02 21:20:31  peter
+  Revision 1.14  2001-04-13 01:22:10  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.12  2000/12/25 00:07:27  peter
   Revision 1.12  2000/12/25 00:07:27  peter

+ 15 - 10
compiler/pbase.pas

@@ -27,7 +27,7 @@ unit pbase;
 interface
 interface
 
 
     uses
     uses
-       cutils,cobjects,cclasses,
+       cutils,cclasses,
        tokens,globals,
        tokens,globals,
        symconst,symbase,symtype,symdef,symsym,symtable
        symconst,symbase,symtype,symdef,symsym,symtable
 {$ifdef fixLeaksOnError}
 {$ifdef fixLeaksOnError}
@@ -41,7 +41,7 @@ interface
 
 
        { sspecial for handling procedure vars }
        { sspecial for handling procedure vars }
        getprocvar : boolean = false;
        getprocvar : boolean = false;
-       getprocvardef : pprocvardef = nil;
+       getprocvardef : tprocvardef = nil;
 
 
     type
     type
        { listitem }
        { listitem }
@@ -64,10 +64,10 @@ interface
 
 
        { for operators }
        { for operators }
        optoken : ttoken;
        optoken : ttoken;
-       opsym : pvarsym;
+       otsym : tvarsym;
 
 
        { symtable were unit references are stored }
        { symtable were unit references are stored }
-       refsymtable : psymtable;
+       refsymtable : tsymtable;
 
 
        { true, if only routine headers should be parsed }
        { true, if only routine headers should be parsed }
        parse_only : boolean;
        parse_only : boolean;
@@ -100,7 +100,7 @@ interface
 
 
     { consume a symbol, if not found give an error and
     { consume a symbol, if not found give an error and
       and return an errorsym }
       and return an errorsym }
-    function consume_sym(var srsym:psym;var srsymtable:psymtable):boolean;
+    function consume_sym(var srsym:tsym;var srsymtable:tsymtable):boolean;
 
 
     { reads a list of identifiers into a string list }
     { reads a list of identifiers into a string list }
     function idlist : tidstringlist;
     function idlist : tidstringlist;
@@ -244,7 +244,7 @@ implementation
 
 
 
 
 
 
-    function consume_sym(var srsym:psym;var srsymtable:psymtable):boolean;
+    function consume_sym(var srsym:tsym;var srsymtable:tsymtable):boolean;
       begin
       begin
         { first check for identifier }
         { first check for identifier }
         if token<>_ID then
         if token<>_ID then
@@ -258,15 +258,15 @@ implementation
         searchsym(pattern,srsym,srsymtable);
         searchsym(pattern,srsym,srsymtable);
         if assigned(srsym) then
         if assigned(srsym) then
          begin
          begin
-           if (srsym^.typ=unitsym) then
+           if (srsym.typ=unitsym) then
             begin
             begin
               { only allow unit.symbol access if the name was
               { only allow unit.symbol access if the name was
                 found in the current module }
                 found in the current module }
-              if srsym^.owner^.unitid=0 then
+              if srsym.owner.unitid=0 then
                begin
                begin
                  consume(_ID);
                  consume(_ID);
                  consume(_POINT);
                  consume(_POINT);
-                 srsymtable:=punitsym(srsym)^.unitsymtable;
+                 srsymtable:=tunitsym(srsym).unitsymtable;
                  srsym:=searchsymonlyin(srsymtable,pattern);
                  srsym:=searchsymonlyin(srsymtable,pattern);
                end
                end
               else
               else
@@ -322,7 +322,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2001-04-02 21:20:31  peter
+  Revision 1.10  2001-04-13 01:22:11  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.9  2001/04/02 21:20:31  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.8  2001/03/11 22:58:49  peter
   Revision 1.8  2001/03/11 22:58:49  peter

+ 91 - 89
compiler/pdecl.pas

@@ -27,8 +27,6 @@ unit pdecl;
 interface
 interface
 
 
     uses
     uses
-      { common }
-      cobjects,
       { global }
       { global }
       globals,
       globals,
       { symtable }
       { symtable }
@@ -36,7 +34,7 @@ interface
       { pass_1 }
       { pass_1 }
       node;
       node;
 
 
-    function  readconstant(const name:string;const filepos:tfileposinfo):pconstsym;
+    function  readconstant(const name:string;const filepos:tfileposinfo):tconstsym;
 
 
     procedure const_dec;
     procedure const_dec;
     procedure label_dec;
     procedure label_dec;
@@ -49,7 +47,7 @@ implementation
 
 
     uses
     uses
        { common }
        { common }
-       cutils,
+       cutils,cclasses,
        { global }
        { global }
        globtype,tokens,verbose,
        globtype,tokens,verbose,
        systems,
        systems,
@@ -58,16 +56,15 @@ implementation
        { symtable }
        { symtable }
        symconst,symbase,symtype,symdef,symtable,
        symconst,symbase,symtype,symdef,symtable,
        { pass 1 }
        { pass 1 }
-       pass_1,
        nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
        nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
        { parser }
        { parser }
        scanner,
        scanner,
        pbase,pexpr,ptype,ptconst,pdecsub,pdecvar,pdecobj;
        pbase,pexpr,ptype,ptconst,pdecsub,pdecvar,pdecobj;
 
 
 
 
-    function readconstant(const name:string;const filepos:tfileposinfo):pconstsym;
+    function readconstant(const name:string;const filepos:tfileposinfo):tconstsym;
       var
       var
-        hp : pconstsym;
+        hp : tconstsym;
         p : tnode;
         p : tnode;
         ps : pconstset;
         ps : pconstset;
         pd : pbestreal;
         pd : pbestreal;
@@ -85,42 +82,42 @@ implementation
            ordconstn:
            ordconstn:
              begin
              begin
                 if is_constintnode(p) then
                 if is_constintnode(p) then
-                  hp:=new(pconstsym,init_typed(name,constint,tordconstnode(p).value,tordconstnode(p).resulttype))
+                  hp:=tconstsym.create_typed(name,constint,tordconstnode(p).value,tordconstnode(p).resulttype)
                 else if is_constcharnode(p) then
                 else if is_constcharnode(p) then
-                  hp:=new(pconstsym,init(name,constchar,tordconstnode(p).value))
+                  hp:=tconstsym.create(name,constchar,tordconstnode(p).value)
                 else if is_constboolnode(p) then
                 else if is_constboolnode(p) then
-                  hp:=new(pconstsym,init(name,constbool,tordconstnode(p).value))
-                else if p.resulttype.def^.deftype=enumdef then
-                  hp:=new(pconstsym,init_typed(name,constord,tordconstnode(p).value,p.resulttype))
-                else if p.resulttype.def^.deftype=pointerdef then
-                  hp:=new(pconstsym,init_typed(name,constord,tordconstnode(p).value,p.resulttype))
+                  hp:=tconstsym.create(name,constbool,tordconstnode(p).value)
+                else if p.resulttype.def.deftype=enumdef then
+                  hp:=tconstsym.create_typed(name,constord,tordconstnode(p).value,p.resulttype)
+                else if p.resulttype.def.deftype=pointerdef then
+                  hp:=tconstsym.create_typed(name,constord,tordconstnode(p).value,p.resulttype)
                 else internalerror(111);
                 else internalerror(111);
              end;
              end;
            stringconstn:
            stringconstn:
              begin
              begin
                 getmem(sp,tstringconstnode(p).len+1);
                 getmem(sp,tstringconstnode(p).len+1);
                 move(tstringconstnode(p).value_str^,sp^,tstringconstnode(p).len+1);
                 move(tstringconstnode(p).value_str^,sp^,tstringconstnode(p).len+1);
-                hp:=new(pconstsym,init_string(name,conststring,sp,tstringconstnode(p).len));
+                hp:=tconstsym.create_string(name,conststring,sp,tstringconstnode(p).len);
              end;
              end;
            realconstn :
            realconstn :
              begin
              begin
                 new(pd);
                 new(pd);
                 pd^:=trealconstnode(p).value_real;
                 pd^:=trealconstnode(p).value_real;
-                hp:=new(pconstsym,init(name,constreal,longint(pd)));
+                hp:=tconstsym.create(name,constreal,longint(pd));
              end;
              end;
            setconstn :
            setconstn :
              begin
              begin
                new(ps);
                new(ps);
                ps^:=tsetconstnode(p).value_set^;
                ps^:=tsetconstnode(p).value_set^;
-               hp:=new(pconstsym,init_typed(name,constset,longint(ps),p.resulttype));
+               hp:=tconstsym.create_typed(name,constset,longint(ps),p.resulttype);
              end;
              end;
            pointerconstn :
            pointerconstn :
              begin
              begin
-               hp:=new(pconstsym,init_typed(name,constpointer,tordconstnode(p).value,p.resulttype));
+               hp:=tconstsym.create_typed(name,constpointer,tordconstnode(p).value,p.resulttype);
              end;
              end;
            niln :
            niln :
              begin
              begin
-               hp:=new(pconstsym,init_typed(name,constnil,0,p.resulttype));
+               hp:=tconstsym.create_typed(name,constnil,0,p.resulttype);
              end;
              end;
            else
            else
              Message(cg_e_illegal_expression);
              Message(cg_e_illegal_expression);
@@ -135,7 +132,7 @@ implementation
       var
       var
          name : stringid;
          name : stringid;
          tt  : ttype;
          tt  : ttype;
-         sym : psym;
+         sym : tsym;
          storetokenpos,filepos : tfileposinfo;
          storetokenpos,filepos : tfileposinfo;
          old_block_type : tblock_type;
          old_block_type : tblock_type;
          skipequal : boolean;
          skipequal : boolean;
@@ -154,7 +151,7 @@ implementation
                    consume(_EQUAL);
                    consume(_EQUAL);
                    sym:=readconstant(name,filepos);
                    sym:=readconstant(name,filepos);
                    if assigned(sym) then
                    if assigned(sym) then
-                    symtablestack^.insert(sym);
+                    symtablestack.insert(sym);
                    consume(_SEMICOLON);
                    consume(_SEMICOLON);
                 end;
                 end;
 
 
@@ -176,19 +173,19 @@ implementation
                    if m_delphi in aktmodeswitches then
                    if m_delphi in aktmodeswitches then
                      begin
                      begin
                        if assigned(readtypesym) then
                        if assigned(readtypesym) then
-                        sym:=new(ptypedconstsym,initsym(name,readtypesym,true))
+                        sym:=ttypedconstsym.createsym(name,readtypesym,true)
                        else
                        else
-                        sym:=new(ptypedconstsym,init(name,def,true))
+                        sym:=ttypedconstsym.create(name,def,true)
                      end
                      end
                    else
                    else
 {$endif DELPHI_CONST_IN_RODATA}
 {$endif DELPHI_CONST_IN_RODATA}
                      begin
                      begin
-                       sym:=new(ptypedconstsym,inittype(name,tt,false))
+                       sym:=ttypedconstsym.createtype(name,tt,false)
                      end;
                      end;
                    akttokenpos:=storetokenpos;
                    akttokenpos:=storetokenpos;
-                   symtablestack^.insert(sym);
+                   symtablestack.insert(sym);
                    { procvar can have proc directives }
                    { procvar can have proc directives }
-                   if (tt.def^.deftype=procvardef) then
+                   if (tt.def.deftype=procvardef) then
                     begin
                     begin
                       { support p : procedure;stdcall=nil; }
                       { support p : procedure;stdcall=nil; }
                       if (token=_SEMICOLON) then
                       if (token=_SEMICOLON) then
@@ -215,10 +212,10 @@ implementation
                       consume(_EQUAL);
                       consume(_EQUAL);
 {$ifdef DELPHI_CONST_IN_RODATA}
 {$ifdef DELPHI_CONST_IN_RODATA}
                       if m_delphi in aktmodeswitches then
                       if m_delphi in aktmodeswitches then
-                       readtypedconst(tt,ptypedconstsym(sym),true)
+                       readtypedconst(tt,ttypedconstsym(sym),true)
                       else
                       else
 {$endif DELPHI_CONST_IN_RODATA}
 {$endif DELPHI_CONST_IN_RODATA}
-                       readtypedconst(tt,ptypedconstsym(sym),false);
+                       readtypedconst(tt,ttypedconstsym(sym),false);
                       consume(_SEMICOLON);
                       consume(_SEMICOLON);
                     end;
                     end;
                 end;
                 end;
@@ -234,7 +231,7 @@ implementation
 
 
     procedure label_dec;
     procedure label_dec;
       var
       var
-         hl : pasmlabel;
+         hl : tasmlabel;
       begin
       begin
          consume(_LABEL);
          consume(_LABEL);
          if not(cs_support_goto in aktmoduleswitches) then
          if not(cs_support_goto in aktmoduleswitches) then
@@ -248,11 +245,11 @@ implementation
                   begin
                   begin
                     getdatalabel(hl);
                     getdatalabel(hl);
                     { we still want a warning if unused }
                     { we still want a warning if unused }
-                    hl^.refs:=0;
+                    hl.refs:=0;
                   end
                   end
                 else
                 else
                   getlabel(hl);
                   getlabel(hl);
-                symtablestack^.insert(new(plabelsym,init(pattern,hl)));
+                symtablestack.insert(tlabelsym.create(pattern,hl));
                 consume(token);
                 consume(token);
              end;
              end;
            if token<>_SEMICOLON then consume(_COMMA);
            if token<>_SEMICOLON then consume(_COMMA);
@@ -262,21 +259,21 @@ implementation
 
 
 
 
     { search in symtablestack used, but not defined type }
     { search in symtablestack used, but not defined type }
-    procedure resolve_type_forward(p : pnamedindexobject);
+    procedure resolve_type_forward(p : tnamedindexitem);
       var
       var
-        hpd,pd : pdef;
+        hpd,pd : tdef;
         stpos  : tfileposinfo;
         stpos  : tfileposinfo;
         again  : boolean;
         again  : boolean;
-        srsym  : psym;
-        srsymtable : psymtable;
+        srsym  : tsym;
+        srsymtable : tsymtable;
       begin
       begin
          { Check only typesyms or record/object fields }
          { Check only typesyms or record/object fields }
-         case psym(p)^.typ of
+         case tsym(p).typ of
            typesym :
            typesym :
-             pd:=ptypesym(p)^.restype.def;
+             pd:=ttypesym(p).restype.def;
            varsym :
            varsym :
-             if (psym(p)^.owner^.symtabletype in [objectsymtable,recordsymtable]) then
-               pd:=pvarsym(p)^.vartype.def
+             if (tsym(p).owner.symtabletype in [objectsymtable,recordsymtable]) then
+               pd:=tvarsym(p).vartype.def
              else
              else
                exit;
                exit;
            else
            else
@@ -284,80 +281,80 @@ implementation
          end;
          end;
          repeat
          repeat
            again:=false;
            again:=false;
-           case pd^.deftype of
+           case pd.deftype of
              arraydef :
              arraydef :
                begin
                begin
                  { elementtype could also be defined using a forwarddef }
                  { elementtype could also be defined using a forwarddef }
-                 pd:=parraydef(pd)^.elementtype.def;
+                 pd:=tarraydef(pd).elementtype.def;
                  again:=true;
                  again:=true;
                end;
                end;
              pointerdef,
              pointerdef,
              classrefdef :
              classrefdef :
                begin
                begin
                  { classrefdef inherits from pointerdef }
                  { classrefdef inherits from pointerdef }
-                 hpd:=ppointerdef(pd)^.pointertype.def;
+                 hpd:=tpointerdef(pd).pointertype.def;
                  { still a forward def ? }
                  { still a forward def ? }
-                 if hpd^.deftype=forwarddef then
+                 if hpd.deftype=forwarddef then
                   begin
                   begin
                     { try to resolve the forward }
                     { try to resolve the forward }
                     { get the correct position for it }
                     { get the correct position for it }
                     stpos:=akttokenpos;
                     stpos:=akttokenpos;
-                    akttokenpos:=pforwarddef(hpd)^.forwardpos;
+                    akttokenpos:=tforwarddef(hpd).forwardpos;
                     resolving_forward:=true;
                     resolving_forward:=true;
                     make_ref:=false;
                     make_ref:=false;
-                    searchsym(pforwarddef(hpd)^.tosymname,srsym,srsymtable);
+                    searchsym(tforwarddef(hpd).tosymname,srsym,srsymtable);
                     make_ref:=true;
                     make_ref:=true;
                     resolving_forward:=false;
                     resolving_forward:=false;
                     akttokenpos:=stpos;
                     akttokenpos:=stpos;
                     { we don't need the forwarddef anymore, dispose it }
                     { we don't need the forwarddef anymore, dispose it }
-                    dispose(hpd,done);
-                    ppointerdef(pd)^.pointertype.def:=nil; { if error occurs }
+                    hpd.free;
+                    tpointerdef(pd).pointertype.def:=nil; { if error occurs }
                     { was a type sym found ? }
                     { was a type sym found ? }
                     if assigned(srsym) and
                     if assigned(srsym) and
-                       (srsym^.typ=typesym) then
+                       (srsym.typ=typesym) then
                      begin
                      begin
-                       ppointerdef(pd)^.pointertype.setsym(srsym);
+                       tpointerdef(pd).pointertype.setsym(srsym);
                        { avoid wrong unused warnings web bug 801 PM }
                        { avoid wrong unused warnings web bug 801 PM }
-                       inc(pstoredsym(srsym)^.refs);
+                       inc(tstoredsym(srsym).refs);
 {$ifdef GDB}
 {$ifdef GDB}
                        if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist) and
                        if (cs_debuginfo in aktmoduleswitches) and assigned(debuglist) and
-                          (psym(p)^.owner^.symtabletype in [globalsymtable,staticsymtable]) then
+                          (tsym(p).owner.symtabletype in [globalsymtable,staticsymtable]) then
                         begin
                         begin
-                          ptypesym(p)^.isusedinstab := true;
-                          ptypesym(p)^.concatstabto(debuglist);
+                          ttypesym(p).isusedinstab := true;
+                          ttypesym(p).concatstabto(debuglist);
                         end;
                         end;
 {$endif GDB}
 {$endif GDB}
                        { we need a class type for classrefdef }
                        { we need a class type for classrefdef }
-                       if (pd^.deftype=classrefdef) and
-                          not(is_class(ptypesym(srsym)^.restype.def)) then
-                         Message1(type_e_class_type_expected,ptypesym(srsym)^.restype.def^.typename);
+                       if (pd.deftype=classrefdef) and
+                          not(is_class(ttypesym(srsym).restype.def)) then
+                         Message1(type_e_class_type_expected,ttypesym(srsym).restype.def.typename);
                      end
                      end
                     else
                     else
                      begin
                      begin
-                       MessagePos1(psym(p)^.fileinfo,sym_e_forward_type_not_resolved,psym(p)^.realname);
+                       MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
                        { try to recover }
                        { try to recover }
-                       ppointerdef(pd)^.pointertype:=generrortype;
+                       tpointerdef(pd).pointertype:=generrortype;
                      end;
                      end;
                   end;
                   end;
                end;
                end;
              recorddef :
              recorddef :
-               precorddef(pd)^.symtable^.foreach({$ifdef FPCPROCVAR}@{$endif}resolve_type_forward);
+               trecorddef(pd).symtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}resolve_type_forward);
              objectdef :
              objectdef :
                begin
                begin
                  if not(m_fpc in aktmodeswitches) and
                  if not(m_fpc in aktmodeswitches) and
-                    (oo_is_forward in pobjectdef(pd)^.objectoptions) then
+                    (oo_is_forward in tobjectdef(pd).objectoptions) then
                   begin
                   begin
                     { only give an error as the implementation may follow in an
                     { only give an error as the implementation may follow in an
                       other type block which is allowed by FPC modes }
                       other type block which is allowed by FPC modes }
-                    MessagePos1(psym(p)^.fileinfo,sym_e_forward_type_not_resolved,psym(p)^.realname);
+                    MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
                   end
                   end
                  else
                  else
                   begin
                   begin
                     { Check all fields of the object declaration, but don't
                     { Check all fields of the object declaration, but don't
                       check objectdefs in objects/records, because these
                       check objectdefs in objects/records, because these
                       can't exist (anonymous objects aren't allowed) }
                       can't exist (anonymous objects aren't allowed) }
-                    if not(psym(p)^.owner^.symtabletype in [objectsymtable,recordsymtable]) then
-                     pobjectdef(pd)^.symtable^.foreach({$ifdef FPCPROCVAR}@{$endif}resolve_type_forward);
+                    if not(tsym(p).owner.symtabletype in [objectsymtable,recordsymtable]) then
+                     tobjectdef(pd).symtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}resolve_type_forward);
                   end;
                   end;
                end;
                end;
           end;
           end;
@@ -369,9 +366,9 @@ implementation
     procedure type_dec;
     procedure type_dec;
       var
       var
          typename,orgtypename : stringid;
          typename,orgtypename : stringid;
-         newtype  : ptypesym;
-         sym      : psym;
-         srsymtable : psymtable;
+         newtype  : ttypesym;
+         sym      : tsym;
+         srsymtable : tsymtable;
          tt       : ttype;
          tt       : ttype;
          defpos,storetokenpos : tfileposinfo;
          defpos,storetokenpos : tfileposinfo;
          old_block_type : tblock_type;
          old_block_type : tblock_type;
@@ -395,18 +392,18 @@ implementation
            { found a symbol with this name? }
            { found a symbol with this name? }
            if assigned(sym) then
            if assigned(sym) then
             begin
             begin
-              if (sym^.typ=typesym) then
+              if (sym.typ=typesym) then
                begin
                begin
                  if ((token=_CLASS) or
                  if ((token=_CLASS) or
                      (token=_INTERFACE)) and
                      (token=_INTERFACE)) and
-                    (assigned(ptypesym(sym)^.restype.def)) and
-                    is_class_or_interface(ptypesym(sym)^.restype.def) and
-                    (oo_is_forward in pobjectdef(ptypesym(sym)^.restype.def)^.objectoptions) then
+                    (assigned(ttypesym(sym).restype.def)) and
+                    is_class_or_interface(ttypesym(sym).restype.def) and
+                    (oo_is_forward in tobjectdef(ttypesym(sym).restype.def).objectoptions) then
                   begin
                   begin
                     { we can ignore the result   }
                     { we can ignore the result   }
                     { the definition is modified }
                     { the definition is modified }
-                    object_dec(orgtypename,pobjectdef(ptypesym(sym)^.restype.def));
-                    newtype:=ptypesym(sym);
+                    object_dec(orgtypename,tobjectdef(ttypesym(sym).restype.def));
+                    newtype:=ttypesym(sym);
                   end;
                   end;
                end;
                end;
             end;
             end;
@@ -418,33 +415,33 @@ implementation
                 will give an error (PFV) }
                 will give an error (PFV) }
               tt:=generrortype;
               tt:=generrortype;
               storetokenpos:=akttokenpos;
               storetokenpos:=akttokenpos;
-              newtype:=new(ptypesym,init(orgtypename,tt));
-              symtablestack^.insert(newtype);
+              newtype:=ttypesym.create(orgtypename,tt);
+              symtablestack.insert(newtype);
               akttokenpos:=defpos;
               akttokenpos:=defpos;
               akttokenpos:=storetokenpos;
               akttokenpos:=storetokenpos;
               { read the type definition }
               { read the type definition }
               read_type(tt,orgtypename);
               read_type(tt,orgtypename);
               { update the definition of the type }
               { update the definition of the type }
-              newtype^.restype:=tt;
+              newtype.restype:=tt;
               if not assigned(tt.sym) then
               if not assigned(tt.sym) then
                 tt.sym:=newtype;
                 tt.sym:=newtype;
-              if assigned(tt.def) and not assigned(tt.def^.typesym) then
-                tt.def^.typesym:=newtype;
+              if assigned(tt.def) and not assigned(tt.def.typesym) then
+                tt.def.typesym:=newtype;
               { KAZ: handle TGUID declaration in system unit }
               { KAZ: handle TGUID declaration in system unit }
               if (cs_compilesystem in aktmoduleswitches) and not assigned(rec_tguid) and
               if (cs_compilesystem in aktmoduleswitches) and not assigned(rec_tguid) and
                  (typename='TGUID') and { name: TGUID and size=16 bytes that is 128 bits }
                  (typename='TGUID') and { name: TGUID and size=16 bytes that is 128 bits }
-                 assigned(tt.def) and (tt.def^.deftype=recorddef) and (tt.def^.size=16) then
-                rec_tguid:=precorddef(tt.def);
+                 assigned(tt.def) and (tt.def.deftype=recorddef) and (tt.def.size=16) then
+                rec_tguid:=trecorddef(tt.def);
             end;
             end;
-           if assigned(newtype^.restype.def) then
+           if assigned(newtype.restype.def) then
             begin
             begin
-              case newtype^.restype.def^.deftype of
+              case newtype.restype.def.deftype of
                 pointerdef :
                 pointerdef :
                   begin
                   begin
                     consume(_SEMICOLON);
                     consume(_SEMICOLON);
                     if try_to_consume(_FAR) then
                     if try_to_consume(_FAR) then
                      begin
                      begin
-                       ppointerdef(newtype^.restype.def)^.is_far:=true;
+                       tpointerdef(newtype.restype.def).is_far:=true;
                        consume(_SEMICOLON);
                        consume(_SEMICOLON);
                      end;
                      end;
                   end;
                   end;
@@ -452,7 +449,7 @@ implementation
                   begin
                   begin
                     if not is_proc_directive(token) then
                     if not is_proc_directive(token) then
                      consume(_SEMICOLON);
                      consume(_SEMICOLON);
-                    parse_var_proc_directives(psym(newtype));
+                    parse_var_proc_directives(tsym(newtype));
                   end;
                   end;
                 else
                 else
                   consume(_SEMICOLON);
                   consume(_SEMICOLON);
@@ -460,7 +457,7 @@ implementation
             end;
             end;
          until token<>_ID;
          until token<>_ID;
          typecanbeforward:=false;
          typecanbeforward:=false;
-         symtablestack^.foreach({$ifdef FPCPROCVAR}@{$endif}resolve_type_forward);
+         symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}resolve_type_forward);
          block_type:=old_block_type;
          block_type:=old_block_type;
       end;
       end;
 
 
@@ -479,7 +476,7 @@ implementation
     { the top symbol table of symtablestack                }
     { the top symbol table of symtablestack                }
       begin
       begin
         consume(_THREADVAR);
         consume(_THREADVAR);
-        if not(symtablestack^.symtabletype in [staticsymtable,globalsymtable]) then
+        if not(symtablestack.symtabletype in [staticsymtable,globalsymtable]) then
           message(parser_e_threadvars_only_sg);
           message(parser_e_threadvars_only_sg);
         read_var_decs(false,false,true);
         read_var_decs(false,false,true);
       end;
       end;
@@ -494,7 +491,7 @@ implementation
          sp : pchar;
          sp : pchar;
       begin
       begin
          consume(_RESOURCESTRING);
          consume(_RESOURCESTRING);
-         if not(symtablestack^.symtabletype in [staticsymtable,globalsymtable]) then
+         if not(symtablestack.symtabletype in [staticsymtable,globalsymtable]) then
            message(parser_e_resourcestring_only_sg);
            message(parser_e_resourcestring_only_sg);
          old_block_type:=block_type;
          old_block_type:=block_type;
          block_type:=bt_const;
          block_type:=bt_const;
@@ -517,7 +514,7 @@ implementation
                                 getmem(sp,2);
                                 getmem(sp,2);
                                 sp[0]:=chr(tordconstnode(p).value);
                                 sp[0]:=chr(tordconstnode(p).value);
                                 sp[1]:=#0;
                                 sp[1]:=#0;
-                                symtablestack^.insert(new(pconstsym,init_string(name,constresourcestring,sp,1)));
+                                symtablestack.insert(tconstsym.create_string(name,constresourcestring,sp,1));
                              end
                              end
                            else
                            else
                              Message(cg_e_illegal_expression);
                              Message(cg_e_illegal_expression);
@@ -526,7 +523,7 @@ implementation
                         begin
                         begin
                            getmem(sp,tstringconstnode(p).len+1);
                            getmem(sp,tstringconstnode(p).len+1);
                            move(tstringconstnode(p).value_str^,sp^,tstringconstnode(p).len+1);
                            move(tstringconstnode(p).value_str^,sp^,tstringconstnode(p).len+1);
-                           symtablestack^.insert(new(pconstsym,init_string(name,constresourcestring,sp,tstringconstnode(p).len)));
+                           symtablestack.insert(tconstsym.create_string(name,constresourcestring,sp,tstringconstnode(p).len));
                         end;
                         end;
                       else
                       else
                         Message(cg_e_illegal_expression);
                         Message(cg_e_illegal_expression);
@@ -544,7 +541,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.28  2001-04-04 22:43:50  peter
+  Revision 1.29  2001-04-13 01:22:11  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.28  2001/04/04 22:43:50  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.27  2001/04/04 21:30:43  florian
   Revision 1.27  2001/04/04 21:30:43  florian

+ 172 - 302
compiler/pdecobj.pas

@@ -30,30 +30,27 @@ interface
       globtype,symtype,symdef;
       globtype,symtype,symdef;
 
 
     { parses a object declaration }
     { parses a object declaration }
-    function object_dec(const n : stringid;fd : pobjectdef) : pdef;
+    function object_dec(const n : stringid;fd : tobjectdef) : tdef;
 
 
 implementation
 implementation
 
 
     uses
     uses
-      cutils,cobjects,cclasses,
+      cutils,cclasses,
       globals,verbose,systems,tokens,
       globals,verbose,systems,tokens,
       aasm,symconst,symbase,symsym,symtable,types,
       aasm,symconst,symbase,symsym,symtable,types,
-{$ifdef GDB}
-      gdb,
-{$endif}
       hcodegen,hcgdata,
       hcodegen,hcgdata,
       node,nld,ncon,ncnv,pass_1,
       node,nld,ncon,ncnv,pass_1,
       scanner,
       scanner,
       pbase,pexpr,pdecsub,pdecvar,ptype;
       pbase,pexpr,pdecsub,pdecvar,ptype;
 
 
-    function object_dec(const n : stringid;fd : pobjectdef) : pdef;
+    function object_dec(const n : stringid;fd : tobjectdef) : tdef;
     { this function parses an object or class declaration }
     { this function parses an object or class declaration }
       var
       var
          actmembertype : tsymoptions;
          actmembertype : tsymoptions;
          there_is_a_destructor : boolean;
          there_is_a_destructor : boolean;
          classtype : tobjectdeftype;
          classtype : tobjectdeftype;
-         childof : pobjectdef;
-         aktclass : pobjectdef;
+         childof : tobjectdef;
+         aktclass : tobjectdef;
 
 
       procedure constructor_head;
       procedure constructor_head;
 
 
@@ -64,21 +61,21 @@ implementation
            parse_proc_head(potype_constructor);
            parse_proc_head(potype_constructor);
            dec(lexlevel);
            dec(lexlevel);
 
 
-           if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'INIT') then
+           if (cs_constructor_name in aktglobalswitches) and (aktprocsym.name<>'INIT') then
             Message(parser_e_constructorname_must_be_init);
             Message(parser_e_constructorname_must_be_init);
 
 
-           include(aktclass^.objectoptions,oo_has_constructor);
+           include(aktclass.objectoptions,oo_has_constructor);
            consume(_SEMICOLON);
            consume(_SEMICOLON);
              begin
              begin
                 if is_class(aktclass) then
                 if is_class(aktclass) then
                   begin
                   begin
                      { CLASS constructors return the created instance }
                      { CLASS constructors return the created instance }
-                     aktprocsym^.definition^.rettype.def:=aktclass;
+                     aktprocsym.definition.rettype.def:=aktclass;
                   end
                   end
                 else
                 else
                   begin
                   begin
                      { OBJECT constructors return a boolean }
                      { OBJECT constructors return a boolean }
-                     aktprocsym^.definition^.rettype:=booltype;
+                     aktprocsym.definition.rettype:=booltype;
                   end;
                   end;
              end;
              end;
         end;
         end;
@@ -87,38 +84,38 @@ implementation
       procedure property_dec;
       procedure property_dec;
 
 
         var
         var
-           sym : psym;
+           sym : tsym;
            propertyparas : tlinkedlist;
            propertyparas : tlinkedlist;
 
 
         { returns the matching procedure to access a property }
         { returns the matching procedure to access a property }
-        function get_procdef : pprocdef;
+        function get_procdef : tprocdef;
 
 
           var
           var
-             p : pprocdef;
+             p : tprocdef;
 
 
           begin
           begin
-             p:=pprocsym(sym)^.definition;
+             p:=tprocsym(sym).definition;
              get_procdef:=nil;
              get_procdef:=nil;
              while assigned(p) do
              while assigned(p) do
                begin
                begin
-                  if equal_paras(p^.para,propertyparas,cp_value_equal_const) or convertable_paras(p^.para,propertyparas,cp_value_equal_const) then {MvdV: Ozerski 14.03.01}
+                  if equal_paras(p.para,propertyparas,cp_value_equal_const) or convertable_paras(p.para,propertyparas,cp_value_equal_const) then {MvdV: Ozerski 14.03.01}
                     break;
                     break;
-                  p:=p^.nextoverloaded;
+                  p:=p.nextoverloaded;
                end;
                end;
              get_procdef:=p;
              get_procdef:=p;
           end;
           end;
 
 
         var
         var
            hp2,datacoll : tparaitem;
            hp2,datacoll : tparaitem;
-           p : ppropertysym;
-           overriden : psym;
+           p : tpropertysym;
+           overriden : tsym;
            hs : string;
            hs : string;
            varspez : tvarspez;
            varspez : tvarspez;
            sc : tidstringlist;
            sc : tidstringlist;
            s : string;
            s : string;
            tt : ttype;
            tt : ttype;
            declarepos : tfileposinfo;
            declarepos : tfileposinfo;
-           pp : pprocdef;
+           pp : tprocdef;
            pt : tnode;
            pt : tnode;
            propname : stringid;
            propname : stringid;
 
 
@@ -132,7 +129,7 @@ implementation
            datacoll:=nil;
            datacoll:=nil;
            if token=_ID then
            if token=_ID then
              begin
              begin
-                p:=new(ppropertysym,init(orgpattern));
+                p:=tpropertysym.create(orgpattern);
                 propname:=pattern;
                 propname:=pattern;
                 consume(_ID);
                 consume(_ID);
                 { property parameters ? }
                 { property parameters ? }
@@ -181,9 +178,9 @@ implementation
                                  consume(_ARRAY);
                                  consume(_ARRAY);
                                  consume(_OF);
                                  consume(_OF);
                                  { define range and type of range }
                                  { define range and type of range }
-                                 tt.setdef(new(parraydef,init(0,-1,s32bittype)));
+                                 tt.setdef(tarraydef.create(0,-1,s32bittype));
                                  { define field type }
                                  { define field type }
-                                 single_type(parraydef(tt.def)^.elementtype,s,false);
+                                 single_type(tarraydef(tt.def).elementtype,s,false);
                               end
                               end
                             else
                             else
                               single_type(tt,s,false);
                               single_type(tt,s,false);
@@ -213,7 +210,7 @@ implementation
                 if (token=_COLON) or not(propertyparas.empty) then
                 if (token=_COLON) or not(propertyparas.empty) then
                   begin
                   begin
                      consume(_COLON);
                      consume(_COLON);
-                     single_type(p^.proptype,hs,false);
+                     single_type(p.proptype,hs,false);
                      if (idtoken=_INDEX) then
                      if (idtoken=_INDEX) then
                        begin
                        begin
                           consume(_INDEX);
                           consume(_INDEX);
@@ -221,51 +218,51 @@ implementation
                           if is_constnode(pt) and
                           if is_constnode(pt) and
                              is_ordinal(pt.resulttype.def) and
                              is_ordinal(pt.resulttype.def) and
                              (not is_64bitint(pt.resulttype.def)) then
                              (not is_64bitint(pt.resulttype.def)) then
-                            p^.index:=tordconstnode(pt).value
+                            p.index:=tordconstnode(pt).value
                           else
                           else
                             begin
                             begin
                               Message(parser_e_invalid_property_index_value);
                               Message(parser_e_invalid_property_index_value);
-                              p^.index:=0;
+                              p.index:=0;
                             end;
                             end;
-                          p^.indextype.setdef(pt.resulttype.def);
-                          include(p^.propoptions,ppo_indexed);
+                          p.indextype.setdef(pt.resulttype.def);
+                          include(p.propoptions,ppo_indexed);
                           { concat a longint to the para template }
                           { concat a longint to the para template }
                           hp2:=TParaItem.Create;
                           hp2:=TParaItem.Create;
                           hp2.paratyp:=vs_value;
                           hp2.paratyp:=vs_value;
-                          hp2.paratype:=p^.indextype;
+                          hp2.paratype:=p.indextype;
                           propertyparas.insert(hp2);
                           propertyparas.insert(hp2);
                           pt.free;
                           pt.free;
                        end;
                        end;
                      { the parser need to know if a property has parameters }
                      { the parser need to know if a property has parameters }
                      if not(propertyparas.empty) then
                      if not(propertyparas.empty) then
-                       include(p^.propoptions,ppo_hasparameters);
+                       include(p.propoptions,ppo_hasparameters);
                   end
                   end
                 else
                 else
                   begin
                   begin
                      { do an property override }
                      { do an property override }
                      overriden:=search_class_member(aktclass,propname);
                      overriden:=search_class_member(aktclass,propname);
-                     if assigned(overriden) and (overriden^.typ=propertysym) then
+                     if assigned(overriden) and (overriden.typ=propertysym) then
                        begin
                        begin
-                         p^.dooverride(ppropertysym(overriden));
+                         p.dooverride(tpropertysym(overriden));
                        end
                        end
                      else
                      else
                        begin
                        begin
-                         p^.proptype:=generrortype;
+                         p.proptype:=generrortype;
                          message(parser_e_no_property_found_to_override);
                          message(parser_e_no_property_found_to_override);
                        end;
                        end;
                   end;
                   end;
                 if (sp_published in current_object_option) and
                 if (sp_published in current_object_option) and
-                   not(p^.proptype.def^.is_publishable) then
+                   not(p.proptype.def.is_publishable) then
                   Message(parser_e_cant_publish_that_property);
                   Message(parser_e_cant_publish_that_property);
 
 
                 { create data defcoll to allow correct parameter checks }
                 { create data defcoll to allow correct parameter checks }
                 datacoll:=TParaItem.Create;
                 datacoll:=TParaItem.Create;
                 datacoll.paratyp:=vs_value;
                 datacoll.paratyp:=vs_value;
-                datacoll.paratype:=p^.proptype;
+                datacoll.paratype:=p.proptype;
 
 
                 if (idtoken=_READ) then
                 if (idtoken=_READ) then
                   begin
                   begin
-                     p^.readaccess^.clear;
+                     p.readaccess.clear;
                      consume(_READ);
                      consume(_READ);
                      sym:=search_class_member(aktclass,pattern);
                      sym:=search_class_member(aktclass,pattern);
                      if not(assigned(sym)) then
                      if not(assigned(sym)) then
@@ -277,12 +274,12 @@ implementation
                        begin
                        begin
                           consume(_ID);
                           consume(_ID);
                           while (token=_POINT) and
                           while (token=_POINT) and
-                                ((sym^.typ=varsym) and
-                                 (pvarsym(sym)^.vartype.def^.deftype=recorddef)) do
+                                ((sym.typ=varsym) and
+                                 (tvarsym(sym).vartype.def.deftype=recorddef)) do
                            begin
                            begin
-                             p^.readaccess^.addsym(sym);
+                             p.readaccess.addsym(sym);
                              consume(_POINT);
                              consume(_POINT);
-                             sym:=searchsymonlyin(precorddef(pvarsym(sym)^.vartype.def)^.symtable,pattern);
+                             sym:=searchsymonlyin(trecorddef(tvarsym(sym).vartype.def).symtable,pattern);
                              if not assigned(sym) then
                              if not assigned(sym) then
                                Message1(sym_e_illegal_field,pattern);
                                Message1(sym_e_illegal_field,pattern);
                              consume(_ID);
                              consume(_ID);
@@ -292,30 +289,30 @@ implementation
                      if assigned(sym) then
                      if assigned(sym) then
                        begin
                        begin
                           { search the matching definition }
                           { search the matching definition }
-                          case sym^.typ of
+                          case sym.typ of
                             procsym :
                             procsym :
                               begin
                               begin
                                  pp:=get_procdef;
                                  pp:=get_procdef;
                                  if not(assigned(pp)) or
                                  if not(assigned(pp)) or
-                                    not(is_equal(pp^.rettype.def,p^.proptype.def)) then
+                                    not(is_equal(pp.rettype.def,p.proptype.def)) then
                                    Message(parser_e_ill_property_access_sym);
                                    Message(parser_e_ill_property_access_sym);
-                                 p^.readaccess^.setdef(pp);
+                                 p.readaccess.setdef(pp);
                               end;
                               end;
                             varsym :
                             varsym :
                               begin
                               begin
                                 if not(propertyparas.empty) or
                                 if not(propertyparas.empty) or
-                                   not(is_equal(pvarsym(sym)^.vartype.def,p^.proptype.def)) then
+                                   not(is_equal(tvarsym(sym).vartype.def,p.proptype.def)) then
                                   Message(parser_e_ill_property_access_sym);
                                   Message(parser_e_ill_property_access_sym);
                               end;
                               end;
                             else
                             else
                               Message(parser_e_ill_property_access_sym);
                               Message(parser_e_ill_property_access_sym);
                           end;
                           end;
-                          p^.readaccess^.addsym(sym);
+                          p.readaccess.addsym(sym);
                        end;
                        end;
                   end;
                   end;
                 if (idtoken=_WRITE) then
                 if (idtoken=_WRITE) then
                   begin
                   begin
-                     p^.writeaccess^.clear;
+                     p.writeaccess.clear;
                      consume(_WRITE);
                      consume(_WRITE);
                      sym:=search_class_member(aktclass,pattern);
                      sym:=search_class_member(aktclass,pattern);
                      if not(assigned(sym)) then
                      if not(assigned(sym)) then
@@ -327,12 +324,12 @@ implementation
                        begin
                        begin
                           consume(_ID);
                           consume(_ID);
                           while (token=_POINT) and
                           while (token=_POINT) and
-                                ((sym^.typ=varsym) and
-                                 (pvarsym(sym)^.vartype.def^.deftype=recorddef)) do
+                                ((sym.typ=varsym) and
+                                 (tvarsym(sym).vartype.def.deftype=recorddef)) do
                            begin
                            begin
-                             p^.writeaccess^.addsym(sym);
+                             p.writeaccess.addsym(sym);
                              consume(_POINT);
                              consume(_POINT);
-                             sym:=searchsymonlyin(precorddef(pvarsym(sym)^.vartype.def)^.symtable,pattern);
+                             sym:=searchsymonlyin(trecorddef(tvarsym(sym).vartype.def).symtable,pattern);
                              if not assigned(sym) then
                              if not assigned(sym) then
                                Message1(sym_e_illegal_field,pattern);
                                Message1(sym_e_illegal_field,pattern);
                              consume(_ID);
                              consume(_ID);
@@ -342,7 +339,7 @@ implementation
                      if assigned(sym) then
                      if assigned(sym) then
                        begin
                        begin
                           { search the matching definition }
                           { search the matching definition }
-                          case sym^.typ of
+                          case sym.typ of
                             procsym :
                             procsym :
                               begin
                               begin
                                  { insert data entry to check access method }
                                  { insert data entry to check access method }
@@ -352,25 +349,25 @@ implementation
                                  propertyparas.remove(datacoll);
                                  propertyparas.remove(datacoll);
                                  if not(assigned(pp)) then
                                  if not(assigned(pp)) then
                                    Message(parser_e_ill_property_access_sym);
                                    Message(parser_e_ill_property_access_sym);
-                                 p^.writeaccess^.setdef(pp);
+                                 p.writeaccess.setdef(pp);
                               end;
                               end;
                             varsym :
                             varsym :
                               begin
                               begin
                                  if not(propertyparas.empty) or
                                  if not(propertyparas.empty) or
-                                    not(is_equal(pvarsym(sym)^.vartype.def,p^.proptype.def)) then
+                                    not(is_equal(tvarsym(sym).vartype.def,p.proptype.def)) then
                                    Message(parser_e_ill_property_access_sym);
                                    Message(parser_e_ill_property_access_sym);
                               end
                               end
                             else
                             else
                               Message(parser_e_ill_property_access_sym);
                               Message(parser_e_ill_property_access_sym);
                           end;
                           end;
-                          p^.writeaccess^.addsym(sym);
+                          p.writeaccess.addsym(sym);
                        end;
                        end;
                   end;
                   end;
-                include(p^.propoptions,ppo_stored);
+                include(p.propoptions,ppo_stored);
                 if (idtoken=_STORED) then
                 if (idtoken=_STORED) then
                   begin
                   begin
                      consume(_STORED);
                      consume(_STORED);
-                     p^.storedaccess^.clear;
+                     p.storedaccess.clear;
                      case token of
                      case token of
                         _ID:
                         _ID:
                            { in the case that idtoken=_DEFAULT }
                            { in the case that idtoken=_DEFAULT }
@@ -389,12 +386,12 @@ implementation
                                   begin
                                   begin
                                      consume(_ID);
                                      consume(_ID);
                                      while (token=_POINT) and
                                      while (token=_POINT) and
-                                           ((sym^.typ=varsym) and
-                                            (pvarsym(sym)^.vartype.def^.deftype=recorddef)) do
+                                           ((sym.typ=varsym) and
+                                            (tvarsym(sym).vartype.def.deftype=recorddef)) do
                                       begin
                                       begin
-                                        p^.storedaccess^.addsym(sym);
+                                        p.storedaccess.addsym(sym);
                                         consume(_POINT);
                                         consume(_POINT);
-                                        sym:=searchsymonlyin(precorddef(pvarsym(sym)^.vartype.def)^.symtable,pattern);
+                                        sym:=searchsymonlyin(trecorddef(tvarsym(sym).vartype.def).symtable,pattern);
                                         if not assigned(sym) then
                                         if not assigned(sym) then
                                           Message1(sym_e_illegal_field,pattern);
                                           Message1(sym_e_illegal_field,pattern);
                                         consume(_ID);
                                         consume(_ID);
@@ -404,39 +401,39 @@ implementation
                                 if assigned(sym) then
                                 if assigned(sym) then
                                   begin
                                   begin
                                      { only non array properties can be stored }
                                      { only non array properties can be stored }
-                                     case sym^.typ of
+                                     case sym.typ of
                                        procsym :
                                        procsym :
                                          begin
                                          begin
-                                           pp:=pprocsym(sym)^.definition;
+                                           pp:=tprocsym(sym).definition;
                                            while assigned(pp) do
                                            while assigned(pp) do
                                              begin
                                              begin
                                                 { the stored function shouldn't have any parameters }
                                                 { the stored function shouldn't have any parameters }
-                                                if pp^.Para.empty then
+                                                if pp.Para.empty then
                                                   break;
                                                   break;
-                                                 pp:=pp^.nextoverloaded;
+                                                 pp:=pp.nextoverloaded;
                                              end;
                                              end;
                                            { found we a procedure and does it really return a bool? }
                                            { found we a procedure and does it really return a bool? }
                                            if not(assigned(pp)) or
                                            if not(assigned(pp)) or
-                                              not(is_boolean(pp^.rettype.def)) then
+                                              not(is_boolean(pp.rettype.def)) then
                                              Message(parser_e_ill_property_storage_sym);
                                              Message(parser_e_ill_property_storage_sym);
-                                           p^.storedaccess^.setdef(pp);
+                                           p.storedaccess.setdef(pp);
                                          end;
                                          end;
                                        varsym :
                                        varsym :
                                          begin
                                          begin
                                            if not(propertyparas.empty) or
                                            if not(propertyparas.empty) or
-                                              not(is_boolean(pvarsym(sym)^.vartype.def)) then
+                                              not(is_boolean(tvarsym(sym).vartype.def)) then
                                              Message(parser_e_stored_property_must_be_boolean);
                                              Message(parser_e_stored_property_must_be_boolean);
                                          end;
                                          end;
                                        else
                                        else
                                          Message(parser_e_ill_property_storage_sym);
                                          Message(parser_e_ill_property_storage_sym);
                                      end;
                                      end;
-                                     p^.storedaccess^.addsym(sym);
+                                     p.storedaccess.addsym(sym);
                                   end;
                                   end;
                              end;
                              end;
                         _FALSE:
                         _FALSE:
                           begin
                           begin
                              consume(_FALSE);
                              consume(_FALSE);
-                             exclude(p^.propoptions,ppo_stored);
+                             exclude(p.propoptions,ppo_stored);
                           end;
                           end;
                         _TRUE:
                         _TRUE:
                           consume(_TRUE);
                           consume(_TRUE);
@@ -445,37 +442,37 @@ implementation
                 if (idtoken=_DEFAULT) then
                 if (idtoken=_DEFAULT) then
                   begin
                   begin
                      consume(_DEFAULT);
                      consume(_DEFAULT);
-                     if not(is_ordinal(p^.proptype.def) or
-                            is_64bitint(p^.proptype.def) or
-                            ((p^.proptype.def^.deftype=setdef) and
-                             (psetdef(p^.proptype.def)^.settype=smallset))) or
+                     if not(is_ordinal(p.proptype.def) or
+                            is_64bitint(p.proptype.def) or
+                            ((p.proptype.def.deftype=setdef) and
+                             (tsetdef(p.proptype.def).settype=smallset))) or
                         not(propertyparas.empty) then
                         not(propertyparas.empty) then
                        Message(parser_e_property_cant_have_a_default_value);
                        Message(parser_e_property_cant_have_a_default_value);
                      { Get the result of the default, the firstpass is
                      { Get the result of the default, the firstpass is
                        needed to support values like -1 }
                        needed to support values like -1 }
                      pt:=comp_expr(true);
                      pt:=comp_expr(true);
-                     if (p^.proptype.def^.deftype=setdef) and
+                     if (p.proptype.def.deftype=setdef) and
                         (pt.nodetype=arrayconstructorn) then
                         (pt.nodetype=arrayconstructorn) then
                        begin
                        begin
                          arrayconstructor_to_set(tarrayconstructornode(pt));
                          arrayconstructor_to_set(tarrayconstructornode(pt));
                          do_resulttypepass(pt);
                          do_resulttypepass(pt);
                        end;
                        end;
-                     inserttypeconv(pt,p^.proptype);
+                     inserttypeconv(pt,p.proptype);
                      if not(is_constnode(pt)) then
                      if not(is_constnode(pt)) then
                        Message(parser_e_property_default_value_must_const);
                        Message(parser_e_property_default_value_must_const);
 
 
                      if pt.nodetype=setconstn then
                      if pt.nodetype=setconstn then
-                       p^.default:=plongint(tsetconstnode(pt).value_set)^
+                       p.default:=plongint(tsetconstnode(pt).value_set)^
                      else
                      else
-                       p^.default:=tordconstnode(pt).value;
+                       p.default:=tordconstnode(pt).value;
                      pt.free;
                      pt.free;
                   end
                   end
                 else if (idtoken=_NODEFAULT) then
                 else if (idtoken=_NODEFAULT) then
                   begin
                   begin
                      consume(_NODEFAULT);
                      consume(_NODEFAULT);
-                     p^.default:=0;
+                     p.default:=0;
                   end;
                   end;
-                symtablestack^.insert(p);
+                symtablestack.insert(p);
                 { default property ? }
                 { default property ? }
                 consume(_SEMICOLON);
                 consume(_SEMICOLON);
                 if (idtoken=_DEFAULT) then
                 if (idtoken=_DEFAULT) then
@@ -485,11 +482,11 @@ implementation
                      p2:=search_default_property(aktclass);
                      p2:=search_default_property(aktclass);
                      if assigned(p2) then
                      if assigned(p2) then
                        message1(parser_e_only_one_default_property,
                        message1(parser_e_only_one_default_property,
-                         pobjectdef(p2^.owner^.defowner)^.objname^)
+                         tobjectdef(p2.owner.defowner)^.objname^)
                      else
                      else
                      }
                      }
                        begin
                        begin
-                          include(p^.propoptions,ppo_defaultproperty);
+                          include(p.propoptions,ppo_defaultproperty);
                           if propertyparas.empty then
                           if propertyparas.empty then
                             message(parser_e_property_need_paras);
                             message(parser_e_property_need_paras);
                        end;
                        end;
@@ -514,27 +511,24 @@ implementation
            inc(lexlevel);
            inc(lexlevel);
            parse_proc_head(potype_destructor);
            parse_proc_head(potype_destructor);
            dec(lexlevel);
            dec(lexlevel);
-           if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'DONE') then
+           if (cs_constructor_name in aktglobalswitches) and (aktprocsym.name<>'DONE') then
             Message(parser_e_destructorname_must_be_done);
             Message(parser_e_destructorname_must_be_done);
-           include(aktclass^.objectoptions,oo_has_destructor);
+           include(aktclass.objectoptions,oo_has_destructor);
            consume(_SEMICOLON);
            consume(_SEMICOLON);
-           if not(aktprocsym^.definition^.Para.empty) then
+           if not(aktprocsym.definition.Para.empty) then
              if not (m_tp in aktmodeswitches) then
              if not (m_tp in aktmodeswitches) then
                Message(parser_e_no_paras_for_destructor);
                Message(parser_e_no_paras_for_destructor);
            { no return value }
            { no return value }
-           aktprocsym^.definition^.rettype:=voidtype;
+           aktprocsym.definition.rettype:=voidtype;
         end;
         end;
 
 
       var
       var
          hs      : string;
          hs      : string;
-         pcrd       : pclassrefdef;
+         pcrd       : tclassrefdef;
          tt     : ttype;
          tt     : ttype;
          oldprocinfo : pprocinfo;
          oldprocinfo : pprocinfo;
-         oldprocsym : pprocsym;
+         oldprocsym : tprocsym;
          oldparse_only : boolean;
          oldparse_only : boolean;
-         methodnametable,intmessagetable,
-         strmessagetable,classnamelabel,
-         fieldtablelabel : pasmlabel;
          storetypecanbeforward : boolean;
          storetypecanbeforward : boolean;
 
 
       procedure setclassattributes;
       procedure setclassattributes;
@@ -542,12 +536,12 @@ implementation
         begin
         begin
            if classtype=odt_class then
            if classtype=odt_class then
              begin
              begin
-                aktclass^.objecttype:=odt_class;
+                aktclass.objecttype:=odt_class;
                 if (cs_generate_rtti in aktlocalswitches) or
                 if (cs_generate_rtti in aktlocalswitches) or
-                    (assigned(aktclass^.childof) and
-                     (oo_can_have_published in aktclass^.childof^.objectoptions)) then
+                    (assigned(aktclass.childof) and
+                     (oo_can_have_published in aktclass.childof.objectoptions)) then
                   begin
                   begin
-                     include(aktclass^.objectoptions,oo_can_have_published);
+                     include(aktclass.objectoptions,oo_can_have_published);
                      { in "publishable" classes the default access type is published }
                      { in "publishable" classes the default access type is published }
                      actmembertype:=[sp_published];
                      actmembertype:=[sp_published];
                      { don't know if this is necessary (FK) }
                      { don't know if this is necessary (FK) }
@@ -562,7 +556,7 @@ implementation
            if assigned(fd) then
            if assigned(fd) then
              aktclass:=fd
              aktclass:=fd
            else
            else
-             aktclass:=new(pobjectdef,init(classtype,n,nil));
+             aktclass:=tobjectdef.create(classtype,n,nil);
            { is the current class tobject?   }
            { is the current class tobject?   }
            { so you could define your own tobject }
            { so you could define your own tobject }
            if (cs_compilesystem in aktmoduleswitches) and (classtype=odt_class) and (upper(n)='TOBJECT') then
            if (cs_compilesystem in aktmoduleswitches) and (classtype=odt_class) and (upper(n)='TOBJECT') then
@@ -577,160 +571,30 @@ implementation
                   odt_interfacecom:
                   odt_interfacecom:
                     childof:=interface_iunknown;
                     childof:=interface_iunknown;
                 end;
                 end;
-                if (oo_is_forward in childof^.objectoptions) then
-                  Message1(parser_e_forward_declaration_must_be_resolved,childof^.objname^);
-                aktclass^.set_parent(childof);
+                if (oo_is_forward in childof.objectoptions) then
+                  Message1(parser_e_forward_declaration_must_be_resolved,childof.objname^);
+                aktclass.set_parent(childof);
              end;
              end;
          end;
          end;
 
 
-      { generates the vmt for classes as well as for objects }
-      procedure writevmt;
-
-        var
-           vmtlist : taasmoutput;
-{$ifdef WITHDMT}
-           dmtlabel : pasmlabel;
-{$endif WITHDMT}
-           interfacetable : pasmlabel;
-
-        begin
-{$ifdef WITHDMT}
-           dmtlabel:=gendmt(aktclass);
-{$endif WITHDMT}
-           { this generates the entries }
-           vmtlist:=TAasmoutput.Create;
-           genvmt(vmtlist,aktclass);
-
-           { write tables for classes, this must be done before the actual
-             class is written, because we need the labels defined }
-           if classtype=odt_class then
-            begin
-              methodnametable:=genpublishedmethodstable(aktclass);
-              fieldtablelabel:=aktclass^.generate_field_table;
-              { rtti }
-              if (oo_can_have_published in aktclass^.objectoptions) then
-               aktclass^.generate_rtti;
-              { write class name }
-              getdatalabel(classnamelabel);
-              dataSegment.concat(Tai_label.Create(classnamelabel));
-              dataSegment.concat(Tai_const.Create_8bit(length(aktclass^.objname^)));
-              dataSegment.concat(Tai_string.Create(aktclass^.objname^));
-              { generate message and dynamic tables }
-              if (oo_has_msgstr in aktclass^.objectoptions) then
-                strmessagetable:=genstrmsgtab(aktclass);
-              if (oo_has_msgint in aktclass^.objectoptions) then
-                intmessagetable:=genintmsgtab(aktclass)
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-              if aktclass^.implementedinterfaces^.count>0 then
-                interfacetable:=genintftable(aktclass);
-            end;
-
-          { write debug info }
-{$ifdef GDB}
-          if (cs_debuginfo in aktmoduleswitches) then
-           begin
-             do_count_dbx:=true;
-             if assigned(aktclass^.owner) and assigned(aktclass^.owner^.name) then
-               dataSegment.concat(Tai_stabs.Create(strpnew('"vmt_'+aktclass^.owner^.name^+n+':S'+
-                 typeglobalnumber('__vtbl_ptr_type')+'",'+tostr(N_STSYM)+',0,0,'+aktclass^.vmt_mangledname)));
-           end;
-{$endif GDB}
-           dataSegment.concat(Tai_symbol.Createdataname_global(aktclass^.vmt_mangledname,0));
-
-           { determine the size with symtable^.datasize, because }
-           { size gives back 4 for classes                    }
-           dataSegment.concat(Tai_const.Create_32bit(aktclass^.symtable^.datasize));
-           dataSegment.concat(Tai_const.Create_32bit(-aktclass^.symtable^.datasize));
-{$ifdef WITHDMT}
-           if classtype=ct_object then
-             begin
-                if assigned(dmtlabel) then
-                  dataSegment.concat(Tai_const_symbol.Create(dmtlabel)))
-                else
-                  dataSegment.concat(Tai_const.Create_32bit(0));
-             end;
-{$endif WITHDMT}
-           { write pointer to parent VMT, this isn't implemented in TP }
-           { but this is not used in FPC ? (PM) }
-           { it's not used yet, but the delphi-operators as and is need it (FK) }
-           { it is not written for parents that don't have any vmt !! }
-           if assigned(aktclass^.childof) and
-              (oo_has_vmt in aktclass^.childof^.objectoptions) then
-             dataSegment.concat(Tai_const_symbol.Createname(aktclass^.childof^.vmt_mangledname))
-           else
-             dataSegment.concat(Tai_const.Create_32bit(0));
-
-           { write extended info for classes, for the order see rtl/inc/objpash.inc }
-           if classtype=odt_class then
-            begin
-              { pointer to class name string }
-              dataSegment.concat(Tai_const_symbol.Create(classnamelabel));
-              { pointer to dynamic table }
-              if (oo_has_msgint in aktclass^.objectoptions) then
-                dataSegment.concat(Tai_const_symbol.Create(intmessagetable))
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-              { pointer to method table }
-              if assigned(methodnametable) then
-                dataSegment.concat(Tai_const_symbol.Create(methodnametable))
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-              { pointer to field table }
-              dataSegment.concat(Tai_const_symbol.Create(fieldtablelabel));
-              { pointer to type info of published section }
-              if (oo_can_have_published in aktclass^.objectoptions) then
-                dataSegment.concat(Tai_const_symbol.Createname(aktclass^.rtti_name))
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-              { inittable for con-/destruction }
-              {
-              if aktclass^.needs_inittable then
-              }
-              { we generate the init table for classes always, because needs_inittable }
-              { for classes is always false, it applies only for objects               }
-              dataSegment.concat(Tai_const_symbol.Create(aktclass^.get_inittable_label));
-              {
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-              }
-              { auto table }
-              dataSegment.concat(Tai_const.Create_32bit(0));
-              { interface table }
-              if aktclass^.implementedinterfaces^.count>0 then
-                dataSegment.concat(Tai_const_symbol.Create(interfacetable))
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-              { table for string messages }
-              if (oo_has_msgstr in aktclass^.objectoptions) then
-                dataSegment.concat(Tai_const_symbol.Create(strmessagetable))
-              else
-                dataSegment.concat(Tai_const.Create_32bit(0));
-            end;
-           dataSegment.concatlist(vmtlist);
-           vmtlist.free;
-           { write the size of the VMT }
-           dataSegment.concat(Tai_symbol_end.Createname(aktclass^.vmt_mangledname));
-        end;
-
       procedure setinterfacemethodoptions;
       procedure setinterfacemethodoptions;
 
 
         var
         var
           i: longint;
           i: longint;
-          defs: pindexarray;
-          pd: pprocdef;
+          defs: TIndexArray;
+          pd: tprocdef;
         begin
         begin
-          include(aktclass^.objectoptions,oo_has_virtual);
-          defs:=aktclass^.symtable^.defindex;
-          for i:=1 to defs^.count do
+          include(aktclass.objectoptions,oo_has_virtual);
+          defs:=aktclass.symtable.defindex;
+          for i:=1 to defs.count do
             begin
             begin
-              pd:=pprocdef(defs^.search(i));
-              if pd^.deftype=procdef then
+              pd:=tprocdef(defs.search(i));
+              if pd.deftype=procdef then
                 begin
                 begin
-                  pd^.extnumber:=aktclass^.lastvtableindex;
-                  inc(aktclass^.lastvtableindex);
-                  include(pd^.procoptions,po_virtualmethod);
-                  pd^.forwarddef:=false;
+                  pd.extnumber:=aktclass.lastvtableindex;
+                  inc(aktclass.lastvtableindex);
+                  include(pd.procoptions,po_virtualmethod);
+                  pd.forwarddef:=false;
                 end;
                 end;
             end;
             end;
         end;
         end;
@@ -764,11 +628,11 @@ implementation
                        { also anonym objects aren't allow (o : object a : longint; end;) }
                        { also anonym objects aren't allow (o : object a : longint; end;) }
                        if n='' then
                        if n='' then
                          Message(parser_f_no_anonym_objects);
                          Message(parser_f_no_anonym_objects);
-                       aktclass:=new(pobjectdef,init(classtype,n,nil));
+                       aktclass:=tobjectdef.create(classtype,n,nil);
                        if (cs_compilesystem in aktmoduleswitches) and
                        if (cs_compilesystem in aktmoduleswitches) and
                           (classtype=odt_interfacecom) and (upper(n)='IUNKNOWN') then
                           (classtype=odt_interfacecom) and (upper(n)='IUNKNOWN') then
                          interface_iunknown:=aktclass;
                          interface_iunknown:=aktclass;
-                       include(aktclass^.objectoptions,oo_is_forward);
+                       include(aktclass.objectoptions,oo_is_forward);
                        object_dec:=aktclass;
                        object_dec:=aktclass;
                        typecanbeforward:=storetypecanbeforward;
                        typecanbeforward:=storetypecanbeforward;
                        readobjecttype:=false;
                        readobjecttype:=false;
@@ -787,16 +651,16 @@ implementation
                         single_type(tt,hs,typecanbeforward);
                         single_type(tt,hs,typecanbeforward);
 
 
                         { accept hp1, if is a forward def or a class }
                         { accept hp1, if is a forward def or a class }
-                        if (tt.def^.deftype=forwarddef) or
+                        if (tt.def.deftype=forwarddef) or
                            is_class(tt.def) then
                            is_class(tt.def) then
                           begin
                           begin
-                             pcrd:=new(pclassrefdef,init(tt));
+                             pcrd:=tclassrefdef.create(tt);
                              object_dec:=pcrd;
                              object_dec:=pcrd;
                           end
                           end
                         else
                         else
                           begin
                           begin
                              object_dec:=generrortype.def;
                              object_dec:=generrortype.def;
-                             Message1(type_e_class_type_expected,generrortype.def^.typename);
+                             Message1(type_e_class_type_expected,generrortype.def.typename);
                           end;
                           end;
                         typecanbeforward:=storetypecanbeforward;
                         typecanbeforward:=storetypecanbeforward;
                         readobjecttype:=false;
                         readobjecttype:=false;
@@ -808,14 +672,14 @@ implementation
                         { also anonym objects aren't allow (o : object a : longint; end;) }
                         { also anonym objects aren't allow (o : object a : longint; end;) }
                         if n='' then
                         if n='' then
                           Message(parser_f_no_anonym_objects);
                           Message(parser_f_no_anonym_objects);
-                        aktclass:=new(pobjectdef,init(odt_class,n,nil));
+                        aktclass:=tobjectdef.create(odt_class,n,nil);
                         if (cs_compilesystem in aktmoduleswitches) and (upper(n)='TOBJECT') then
                         if (cs_compilesystem in aktmoduleswitches) and (upper(n)='TOBJECT') then
                           class_tobject:=aktclass;
                           class_tobject:=aktclass;
-                        aktclass^.objecttype:=odt_class;
-                        include(aktclass^.objectoptions,oo_is_forward);
+                        aktclass.objecttype:=odt_class;
+                        include(aktclass.objectoptions,oo_is_forward);
                         { all classes must have a vmt !!  at offset zero }
                         { all classes must have a vmt !!  at offset zero }
-                        if not(oo_has_vmt in aktclass^.objectoptions) then
-                          aktclass^.insertvmt;
+                        if not(oo_has_vmt in aktclass.objectoptions) then
+                          aktclass.insertvmt;
 
 
                         object_dec:=aktclass;
                         object_dec:=aktclass;
                         typecanbeforward:=storetypecanbeforward;
                         typecanbeforward:=storetypecanbeforward;
@@ -833,24 +697,24 @@ implementation
 
 
       procedure readimplementedinterfaces;
       procedure readimplementedinterfaces;
         var
         var
-          implintf: pobjectdef;
+          implintf: tobjectdef;
           tt      : ttype;
           tt      : ttype;
         begin
         begin
           while try_to_consume(_COMMA) do begin
           while try_to_consume(_COMMA) do begin
             id_type(tt,pattern,false);
             id_type(tt,pattern,false);
-            implintf:=pobjectdef(tt.def);
-            if (tt.def^.deftype<>objectdef) then begin
-              Message1(type_e_interface_type_expected,tt.def^.typename);
+            implintf:=tobjectdef(tt.def);
+            if (tt.def.deftype<>objectdef) then begin
+              Message1(type_e_interface_type_expected,tt.def.typename);
               Continue; { omit }
               Continue; { omit }
             end;
             end;
             if not is_interface(implintf) then begin
             if not is_interface(implintf) then begin
-              Message1(type_e_interface_type_expected,implintf^.typename);
+              Message1(type_e_interface_type_expected,implintf.typename);
               Continue; { omit }
               Continue; { omit }
             end;
             end;
-            if aktclass^.implementedinterfaces^.searchintf(tt.def)<>-1 then
-              Message1(sym_e_duplicate_id,tt.def^.name)
+            if aktclass.implementedinterfaces.searchintf(tt.def)<>-1 then
+              Message1(sym_e_duplicate_id,tt.def.name)
             else
             else
-              aktclass^.implementedinterfaces^.addintf(tt.def);
+              aktclass.implementedinterfaces.addintf(tt.def);
           end;
           end;
         end;
         end;
 
 
@@ -861,10 +725,10 @@ implementation
           p:=comp_expr(true);
           p:=comp_expr(true);
           if p.nodetype=stringconstn then
           if p.nodetype=stringconstn then
             begin
             begin
-              aktclass^.iidstr:=stringdup(strpas(tstringconstnode(p).value_str)); { or upper? }
+              aktclass.iidstr:=stringdup(strpas(tstringconstnode(p).value_str)); { or upper? }
               p.free;
               p.free;
-              aktclass^.isiidguidvalid:=string2guid(aktclass^.iidstr^,aktclass^.iidguid);
-              if (classtype=odt_interfacecom) and not aktclass^.isiidguidvalid then
+              aktclass.isiidguidvalid:=string2guid(aktclass.iidstr^,aktclass.iidguid);
+              if (classtype=odt_interfacecom) and not aktclass.isiidguidvalid then
                 Message(parser_e_improper_guid_syntax);
                 Message(parser_e_improper_guid_syntax);
             end
             end
           else
           else
@@ -882,14 +746,14 @@ implementation
              begin
              begin
                 consume(_LKLAMMER);
                 consume(_LKLAMMER);
                 id_type(tt,pattern,false);
                 id_type(tt,pattern,false);
-                childof:=pobjectdef(tt.def);
+                childof:=tobjectdef(tt.def);
                 if (not assigned(childof)) or
                 if (not assigned(childof)) or
-                   (childof^.deftype<>objectdef) then
+                   (childof.deftype<>objectdef) then
                  begin
                  begin
                    if assigned(childof) then
                    if assigned(childof) then
-                    Message1(type_e_class_type_expected,childof^.typename);
+                    Message1(type_e_class_type_expected,childof.typename);
                    childof:=nil;
                    childof:=nil;
-                   aktclass:=new(pobjectdef,init(classtype,n,nil));
+                   aktclass:=tobjectdef.create(classtype,n,nil);
                  end
                  end
                 else
                 else
                  begin
                  begin
@@ -915,18 +779,18 @@ implementation
                      correct field addresses }
                      correct field addresses }
                    if assigned(fd) then
                    if assigned(fd) then
                     begin
                     begin
-                      if (oo_is_forward in childof^.objectoptions) then
-                       Message1(parser_e_forward_declaration_must_be_resolved,childof^.objname^);
+                      if (oo_is_forward in childof.objectoptions) then
+                       Message1(parser_e_forward_declaration_must_be_resolved,childof.objname^);
                       aktclass:=fd;
                       aktclass:=fd;
                       { we must inherit several options !!
                       { we must inherit several options !!
                         this was missing !!
                         this was missing !!
                         all is now done in set_parent
                         all is now done in set_parent
                         including symtable datasize setting PM }
                         including symtable datasize setting PM }
-                      fd^.set_parent(childof);
+                      fd.set_parent(childof);
                     end
                     end
                    else
                    else
-                    aktclass:=new(pobjectdef,init(classtype,n,childof));
-                   if aktclass^.objecttype=odt_class then
+                    aktclass:=tobjectdef.create(classtype,n,childof);
+                   if aktclass.objecttype=odt_class then
                     readimplementedinterfaces;
                     readimplementedinterfaces;
                  end;
                  end;
                 consume(_RKLAMMER);
                 consume(_RKLAMMER);
@@ -935,7 +799,7 @@ implementation
            else if classtype in [odt_class,odt_interfacecom] then
            else if classtype in [odt_class,odt_interfacecom] then
              setclassparent
              setclassparent
            else
            else
-             aktclass:=new(pobjectdef,init(classtype,n,nil));
+             aktclass:=tobjectdef.create(classtype,n,nil);
            { read GUID }
            { read GUID }
              if (classtype in [odt_interfacecom,odt_interfacecorba]) and
              if (classtype in [odt_interfacecom,odt_interfacecorba]) and
                 try_to_consume(_LECKKLAMMER) then
                 try_to_consume(_LECKKLAMMER) then
@@ -950,28 +814,28 @@ implementation
         begin
         begin
            if is_cppclass(aktclass) then
            if is_cppclass(aktclass) then
              begin
              begin
-                include(aktprocsym^.definition^.proccalloptions,pocall_cppdecl);
-                aktprocsym^.definition^.setmangledname(
-                  target_os.Cprefix+aktprocsym^.definition^.cplusplusmangledname);
+                include(aktprocsym.definition.proccalloptions,pocall_cppdecl);
+                aktprocsym.definition.setmangledname(
+                  target_os.Cprefix+aktprocsym.definition.cplusplusmangledname);
              end;
              end;
         end;
         end;
 
 
       var
       var
-        temppd : pprocdef;
+        temppd : tprocdef;
+        ch : tclassheader;
       begin
       begin
          {Nowadays aktprocsym may already have a value, so we need to save
          {Nowadays aktprocsym may already have a value, so we need to save
           it.}
           it.}
          oldprocsym:=aktprocsym;
          oldprocsym:=aktprocsym;
          { forward is resolved }
          { forward is resolved }
          if assigned(fd) then
          if assigned(fd) then
-           exclude(fd^.objectoptions,oo_is_forward);
+           exclude(fd.objectoptions,oo_is_forward);
 
 
          there_is_a_destructor:=false;
          there_is_a_destructor:=false;
          actmembertype:=[sp_public];
          actmembertype:=[sp_public];
 
 
          { objects and class types can't be declared local }
          { objects and class types can't be declared local }
-         if (symtablestack^.symtabletype<>globalsymtable) and
-           (symtablestack^.symtabletype<>staticsymtable) then
+         if not(symtablestack.symtabletype in [globalsymtable,staticsymtable]) then
            Message(parser_e_no_local_objects);
            Message(parser_e_no_local_objects);
 
 
          storetypecanbeforward:=typecanbeforward;
          storetypecanbeforward:=typecanbeforward;
@@ -996,8 +860,8 @@ implementation
          setclassattributes;
          setclassattributes;
 
 
          aktobjectdef:=aktclass;
          aktobjectdef:=aktclass;
-         aktclass^.symtable^.next:=symtablestack;
-         symtablestack:=aktclass^.symtable;
+         aktclass.symtable.next:=symtablestack;
+         symtablestack:=aktclass.symtable;
          testcurobject:=1;
          testcurobject:=1;
          curobjectname:=Upper(n);
          curobjectname:=Upper(n);
 
 
@@ -1013,9 +877,9 @@ implementation
           { Parse componenten }
           { Parse componenten }
             repeat
             repeat
               if (sp_private in actmembertype) then
               if (sp_private in actmembertype) then
-                include(aktclass^.objectoptions,oo_has_private);
+                include(aktclass.objectoptions,oo_has_private);
               if (sp_protected in actmembertype) then
               if (sp_protected in actmembertype) then
-                include(aktclass^.objectoptions,oo_has_protected);
+                include(aktclass.objectoptions,oo_has_protected);
               case token of
               case token of
               _ID : begin
               _ID : begin
                       case idtoken of
                       case idtoken of
@@ -1044,7 +908,7 @@ implementation
                                     if is_interface(aktclass) then
                                     if is_interface(aktclass) then
                                       Message(parser_e_no_access_specifier_in_interfaces)
                                       Message(parser_e_no_access_specifier_in_interfaces)
                                     else
                                     else
-                                      if not(oo_can_have_published in aktclass^.objectoptions) then
+                                      if not(oo_can_have_published in aktclass.objectoptions) then
                                         Message(parser_e_cant_have_published);
                                         Message(parser_e_cant_have_published);
                                     consume(_PUBLISHED);
                                     consume(_PUBLISHED);
                                     current_object_option:=[sp_published];
                                     current_object_option:=[sp_published];
@@ -1068,14 +932,14 @@ implementation
 {$endif newcg}
 {$endif newcg}
                       { check if there are duplicates }
                       { check if there are duplicates }
                       check_identical_proc(temppd);
                       check_identical_proc(temppd);
-                      if (po_msgint in aktprocsym^.definition^.procoptions) then
-                        include(aktclass^.objectoptions,oo_has_msgint);
+                      if (po_msgint in aktprocsym.definition.procoptions) then
+                        include(aktclass.objectoptions,oo_has_msgint);
 
 
-                      if (po_msgstr in aktprocsym^.definition^.procoptions) then
-                        include(aktclass^.objectoptions,oo_has_msgstr);
+                      if (po_msgstr in aktprocsym.definition.procoptions) then
+                        include(aktclass.objectoptions,oo_has_msgstr);
 
 
-                      if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-                        include(aktclass^.objectoptions,oo_has_virtual);
+                      if (po_virtualmethod in aktprocsym.definition.procoptions) then
+                        include(aktclass.objectoptions,oo_has_virtual);
 
 
                       chkcpp;
                       chkcpp;
 
 
@@ -1092,8 +956,8 @@ implementation
 {$ifndef newcg}
 {$ifndef newcg}
                       parse_object_proc_directives(aktprocsym);
                       parse_object_proc_directives(aktprocsym);
 {$endif newcg}
 {$endif newcg}
-                      if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-                        include(aktclass^.objectoptions,oo_has_virtual);
+                      if (po_virtualmethod in aktprocsym.definition.procoptions) then
+                        include(aktclass.objectoptions,oo_has_virtual);
 
 
                       chkcpp;
                       chkcpp;
 
 
@@ -1113,8 +977,8 @@ implementation
 {$ifndef newcg}
 {$ifndef newcg}
                       parse_object_proc_directives(aktprocsym);
                       parse_object_proc_directives(aktprocsym);
 {$endif newcg}
 {$endif newcg}
-                      if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-                        include(aktclass^.objectoptions,oo_has_virtual);
+                      if (po_virtualmethod in aktprocsym.definition.procoptions) then
+                        include(aktclass.objectoptions,oo_has_virtual);
 
 
                       chkcpp;
                       chkcpp;
 
 
@@ -1135,25 +999,26 @@ implementation
          typecanbeforward:=storetypecanbeforward;
          typecanbeforward:=storetypecanbeforward;
 
 
          { generate vmt space if needed }
          { generate vmt space if needed }
-         if not(oo_has_vmt in aktclass^.objectoptions) and
-            (([oo_has_virtual,oo_has_constructor,oo_has_destructor]*aktclass^.objectoptions<>[]) or
+         if not(oo_has_vmt in aktclass.objectoptions) and
+            (([oo_has_virtual,oo_has_constructor,oo_has_destructor]*aktclass.objectoptions<>[]) or
              (classtype in [odt_class])
              (classtype in [odt_class])
             ) then
             ) then
-           aktclass^.insertvmt;
+           aktclass.insertvmt;
          if (cs_create_smart in aktmoduleswitches) then
          if (cs_create_smart in aktmoduleswitches) then
            dataSegment.concat(Tai_cut.Create);
            dataSegment.concat(Tai_cut.Create);
 
 
+         ch:=tclassheader.create(aktclass);
          if is_interface(aktclass) then
          if is_interface(aktclass) then
-           writeinterfaceids(aktclass);
-
-         if (oo_has_vmt in aktclass^.objectoptions) then
-           writevmt;
+           ch.writeinterfaceids;
+         if (oo_has_vmt in aktclass.objectoptions) then
+           ch.writevmt;
+         ch.free;
 
 
          if is_interface(aktclass) then
          if is_interface(aktclass) then
            setinterfacemethodoptions;
            setinterfacemethodoptions;
 
 
          { restore old state }
          { restore old state }
-         symtablestack:=symtablestack^.next;
+         symtablestack:=symtablestack.next;
          aktobjectdef:=nil;
          aktobjectdef:=nil;
          {Restore procinfo}
          {Restore procinfo}
          dispose(procinfo,done);
          dispose(procinfo,done);
@@ -1167,7 +1032,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  2001-04-04 22:43:51  peter
+  Revision 1.21  2001-04-13 01:22:11  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.20  2001/04/04 22:43:51  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.19  2001/04/04 21:30:43  florian
   Revision 1.19  2001/04/04 21:30:43  florian

+ 581 - 620
compiler/pdecsub.pas

@@ -27,7 +27,7 @@ unit pdecsub;
 interface
 interface
 
 
     uses
     uses
-      cobjects,tokens,symconst,symtype,symdef,symsym;
+      tokens,symconst,symtype,symdef,symsym;
 
 
     const
     const
       pd_global    = $1;    { directive must be global }
       pd_global    = $1;    { directive must be global }
@@ -40,16 +40,16 @@ interface
       pd_notobjintf= $80;   { directive can not be used interface declaration }
       pd_notobjintf= $80;   { directive can not be used interface declaration }
 
 
     function  is_proc_directive(tok:ttoken):boolean;
     function  is_proc_directive(tok:ttoken):boolean;
-    function  check_identical_proc(var p : pprocdef) : boolean;
+    function  check_identical_proc(var p : tprocdef) : boolean;
 
 
-    procedure parameter_dec(aktprocdef:pabstractprocdef);
+    procedure parameter_dec(aktprocdef:tabstractprocdef);
 
 
     procedure parse_proc_directives(var pdflags:word);
     procedure parse_proc_directives(var pdflags:word);
 
 
     procedure parse_proc_head(options:tproctypeoption);
     procedure parse_proc_head(options:tproctypeoption);
     procedure parse_proc_dec;
     procedure parse_proc_dec;
-    procedure parse_var_proc_directives(var sym : psym);
-    procedure parse_object_proc_directives(var sym : pprocsym);
+    procedure parse_var_proc_directives(var sym : tsym);
+    procedure parse_object_proc_directives(var sym : tprocsym);
 
 
 
 
 implementation
 implementation
@@ -61,7 +61,7 @@ implementation
        strings,
        strings,
 {$endif delphi}
 {$endif delphi}
        { common }
        { common }
-       cutils,
+       cutils,cclasses,
        { global }
        { global }
        globtype,globals,verbose,
        globtype,globals,verbose,
        systems,
        systems,
@@ -70,7 +70,7 @@ implementation
        { symtable }
        { symtable }
        symbase,symtable,types,
        symbase,symtable,types,
        { pass 1 }
        { pass 1 }
-       node,pass_1,htypechk,
+       node,htypechk,
        nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
        nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
        { parser }
        { parser }
        fmodule,scanner,
        fmodule,scanner,
@@ -86,7 +86,7 @@ implementation
        ;
        ;
 
 
 
 
-    procedure parameter_dec(aktprocdef:pabstractprocdef);
+    procedure parameter_dec(aktprocdef:tabstractprocdef);
       {
       {
         handle_procvar needs the same changes
         handle_procvar needs the same changes
       }
       }
@@ -99,18 +99,18 @@ implementation
         htype,
         htype,
         tt      : ttype;
         tt      : ttype;
         hvs,
         hvs,
-        vs      : Pvarsym;
-        srsym   : psym;
+        vs      : tvarsym;
+        srsym   : tsym;
         hs1,hs2 : string;
         hs1,hs2 : string;
         varspez : Tvarspez;
         varspez : Tvarspez;
         inserthigh : boolean;
         inserthigh : boolean;
-        pdefaultvalue : pconstsym;
+        tdefaultvalue : tconstsym;
         defaultrequired : boolean;
         defaultrequired : boolean;
       begin
       begin
         { reset }
         { reset }
         defaultrequired:=false;
         defaultrequired:=false;
         { parsing a proc or procvar ? }
         { parsing a proc or procvar ? }
-        is_procvar:=(aktprocdef^.deftype=procvardef);
+        is_procvar:=(aktprocdef.deftype=procvardef);
         consume(_LKLAMMER);
         consume(_LKLAMMER);
         { Delphi/Kylix supports nonsense like }
         { Delphi/Kylix supports nonsense like }
         { procedure p();                      }
         { procedure p();                      }
@@ -130,7 +130,7 @@ implementation
           else
           else
               varspez:=vs_value;
               varspez:=vs_value;
           inserthigh:=false;
           inserthigh:=false;
-          pdefaultvalue:=nil;
+          tdefaultvalue:=nil;
           tt.reset;
           tt.reset;
           { self is only allowed in procvars and class methods }
           { self is only allowed in procvars and class methods }
           if (idtoken=_SELF) and
           if (idtoken=_SELF) and
@@ -145,17 +145,17 @@ implementation
                  hs2:=hs2+tostr(length('self'))+'self';
                  hs2:=hs2+tostr(length('self'))+'self';
 {$endif UseNiceNames}
 {$endif UseNiceNames}
                  htype.setdef(procinfo^._class);
                  htype.setdef(procinfo^._class);
-                 vs:=new(Pvarsym,init('@',htype));
-                 vs^.varspez:=vs_var;
+                 vs:=tvarsym.create('@',htype);
+                 vs.varspez:=vs_var;
                { insert the sym in the parasymtable }
                { insert the sym in the parasymtable }
-                 pprocdef(aktprocdef)^.parast^.insert(vs);
-                 include(aktprocdef^.procoptions,po_containsself);
-                 inc(procinfo^.selfpointer_offset,vs^.address);
+                 tprocdef(aktprocdef).parast.insert(vs);
+                 include(aktprocdef.procoptions,po_containsself);
+                 inc(procinfo^.selfpointer_offset,vs.address);
                end;
                end;
               consume(idtoken);
               consume(idtoken);
               consume(_COLON);
               consume(_COLON);
               single_type(tt,hs1,false);
               single_type(tt,hs1,false);
-              aktprocdef^.concatpara(tt,vs_value,nil);
+              aktprocdef.concatpara(tt,vs_value,nil);
               { check the types for procedures only }
               { check the types for procedures only }
               if not is_procvar then
               if not is_procvar then
                CheckTypes(tt.def,procinfo^._class);
                CheckTypes(tt.def,procinfo^._class);
@@ -177,7 +177,7 @@ implementation
                      consume(_ARRAY);
                      consume(_ARRAY);
                      consume(_OF);
                      consume(_OF);
                    { define range and type of range }
                    { define range and type of range }
-                     tt.setdef(new(Parraydef,init(0,-1,s32bittype)));
+                     tt.setdef(tarraydef.create(0,-1,s32bittype));
                    { array of const ? }
                    { array of const ? }
                      if (token=_CONST) and (m_objpas in aktmodeswitches) then
                      if (token=_CONST) and (m_objpas in aktmodeswitches) then
                       begin
                       begin
@@ -185,14 +185,14 @@ implementation
                         srsym:=searchsymonlyin(systemunit,'TVARREC');
                         srsym:=searchsymonlyin(systemunit,'TVARREC');
                         if not assigned(srsym) then
                         if not assigned(srsym) then
                          InternalError(1234124);
                          InternalError(1234124);
-                        Parraydef(tt.def)^.elementtype:=ptypesym(srsym)^.restype;
-                        Parraydef(tt.def)^.IsArrayOfConst:=true;
+                        tarraydef(tt.def).elementtype:=ttypesym(srsym).restype;
+                        tarraydef(tt.def).IsArrayOfConst:=true;
                         hs1:='array_of_const';
                         hs1:='array_of_const';
                       end
                       end
                      else
                      else
                       begin
                       begin
                         { define field type }
                         { define field type }
-                        single_type(parraydef(tt.def)^.elementtype,hs1,false);
+                        single_type(tarraydef(tt.def).elementtype,hs1,false);
                         hs1:='array_of_'+hs1;
                         hs1:='array_of_'+hs1;
                       end;
                       end;
                      inserthigh:=true;
                      inserthigh:=true;
@@ -229,9 +229,9 @@ implementation
                             Comment(V_Error,'default value only allowed for one parameter');
                             Comment(V_Error,'default value only allowed for one parameter');
                            sc.add(s,hpos);
                            sc.add(s,hpos);
                            { prefix 'def' to the parameter name }
                            { prefix 'def' to the parameter name }
-                           pdefaultvalue:=ReadConstant('$def'+Upper(s),hpos);
-                           if assigned(pdefaultvalue) then
-                            pprocdef(aktprocdef)^.parast^.insert(pdefaultvalue);
+                           tdefaultvalue:=ReadConstant('$def'+Upper(s),hpos);
+                           if assigned(tdefaultvalue) then
+                            tprocdef(aktprocdef).parast.insert(tdefaultvalue);
                            defaultrequired:=true;
                            defaultrequired:=true;
                          end
                          end
                         else
                         else
@@ -252,12 +252,12 @@ implementation
                   tt:=cformaltype;
                   tt:=cformaltype;
                 end;
                 end;
                if not is_procvar then
                if not is_procvar then
-                hs2:=pprocdef(aktprocdef)^.mangledname;
+                hs2:=tprocdef(aktprocdef).mangledname;
                storetokenpos:=akttokenpos;
                storetokenpos:=akttokenpos;
                while not sc.empty do
                while not sc.empty do
                 begin
                 begin
                   s:=sc.get(akttokenpos);
                   s:=sc.get(akttokenpos);
-                  aktprocdef^.concatpara(tt,varspez,pdefaultvalue);
+                  aktprocdef.concatpara(tt,varspez,tdefaultvalue);
                   { For proc vars we only need the definitions }
                   { For proc vars we only need the definitions }
                   if not is_procvar then
                   if not is_procvar then
                    begin
                    begin
@@ -266,32 +266,32 @@ implementation
 {$else UseNiceNames}
 {$else UseNiceNames}
                      hs2:=hs2+tostr(length(hs1))+hs1;
                      hs2:=hs2+tostr(length(hs1))+hs1;
 {$endif UseNiceNames}
 {$endif UseNiceNames}
-                     vs:=new(pvarsym,init(s,tt));
-                     vs^.varspez:=varspez;
+                     vs:=tvarsym.create(s,tt);
+                     vs.varspez:=varspez;
                    { we have to add this to avoid var param to be in registers !!!}
                    { we have to add this to avoid var param to be in registers !!!}
                    { I don't understand the comment above,                          }
                    { I don't understand the comment above,                          }
                    { but I suppose the comment is wrong and                         }
                    { but I suppose the comment is wrong and                         }
                    { it means that the address of var parameters can be placed      }
                    { it means that the address of var parameters can be placed      }
                    { in a register (FK)                                             }
                    { in a register (FK)                                             }
                      if (varspez in [vs_var,vs_const,vs_out]) and push_addr_param(tt.def) then
                      if (varspez in [vs_var,vs_const,vs_out]) and push_addr_param(tt.def) then
-                       include(vs^.varoptions,vo_regable);
+                       include(vs.varoptions,vo_regable);
 
 
                    { insert the sym in the parasymtable }
                    { insert the sym in the parasymtable }
-                     pprocdef(aktprocdef)^.parast^.insert(vs);
+                     tprocdef(aktprocdef).parast.insert(vs);
 
 
                    { do we need a local copy? Then rename the varsym, do this after the
                    { do we need a local copy? Then rename the varsym, do this after the
                      insert so the dup id checking is done correctly }
                      insert so the dup id checking is done correctly }
                      if (varspez=vs_value) and
                      if (varspez=vs_value) and
                         push_addr_param(tt.def) and
                         push_addr_param(tt.def) and
                         not(is_open_array(tt.def) or is_array_of_const(tt.def)) then
                         not(is_open_array(tt.def) or is_array_of_const(tt.def)) then
-                       pprocdef(aktprocdef)^.parast^.rename(vs^.name,'val'+vs^.name);
+                       tprocdef(aktprocdef).parast.rename(vs.name,'val'+vs.name);
 
 
                    { also need to push a high value? }
                    { also need to push a high value? }
                      if inserthigh then
                      if inserthigh then
                       begin
                       begin
-                        hvs:=new(Pvarsym,init('$high'+Upper(s),s32bittype));
-                        hvs^.varspez:=vs_const;
-                        pprocdef(aktprocdef)^.parast^.insert(hvs);
+                        hvs:=tvarsym.create('$high'+Upper(s),s32bittype);
+                        hvs.varspez:=vs_const;
+                        tprocdef(aktprocdef).parast.insert(hvs);
                       end;
                       end;
 
 
                    end;
                    end;
@@ -305,7 +305,7 @@ implementation
             end;
             end;
           { set the new mangled name }
           { set the new mangled name }
           if not is_procvar then
           if not is_procvar then
-            pprocdef(aktprocdef)^.setmangledname(hs2);
+            tprocdef(aktprocdef).setmangledname(hs2);
         until not try_to_consume(_SEMICOLON);
         until not try_to_consume(_SEMICOLON);
         dec(testcurobject);
         dec(testcurobject);
         consume(_RKLAMMER);
         consume(_RKLAMMER);
@@ -316,12 +316,12 @@ implementation
 
 
 procedure parse_proc_head(options:tproctypeoption);
 procedure parse_proc_head(options:tproctypeoption);
 var orgsp,sp:stringid;
 var orgsp,sp:stringid;
-    pd:Pprocdef;
+    pd:tprocdef;
     paramoffset:longint;
     paramoffset:longint;
-    sym:Psym;
+    sym:tsym;
     hs:string;
     hs:string;
-    st : psymtable;
-    srsymtable : psymtable;
+    st : tsymtable;
+    srsymtable : tsymtable;
     overloaded_level:word;
     overloaded_level:word;
     storepos,procstartfilepos : tfileposinfo;
     storepos,procstartfilepos : tfileposinfo;
     i: longint;
     i: longint;
@@ -347,8 +347,8 @@ begin
     { examine interface map: function/procedure iname.functionname=locfuncname }
     { examine interface map: function/procedure iname.functionname=locfuncname }
     if parse_only and
     if parse_only and
        assigned(procinfo^._class) and
        assigned(procinfo^._class) and
-       assigned(procinfo^._class^.implementedinterfaces) and
-       (procinfo^._class^.implementedinterfaces^.count>0) and
+       assigned(procinfo^._class.implementedinterfaces) and
+       (procinfo^._class.implementedinterfaces.count>0) and
        try_to_consume(_POINT) then
        try_to_consume(_POINT) then
       begin
       begin
          storepos:=akttokenpos;
          storepos:=akttokenpos;
@@ -362,10 +362,10 @@ begin
           end;
           end;
          akttokenpos:=storepos;
          akttokenpos:=storepos;
          { load proc name }
          { load proc name }
-         if sym^.typ=typesym then
-           i:=procinfo^._class^.implementedinterfaces^.searchintf(ptypesym(sym)^.restype.def);
+         if sym.typ=typesym then
+           i:=procinfo^._class.implementedinterfaces.searchintf(ttypesym(sym).restype.def);
          { qualifier is interface name? }
          { qualifier is interface name? }
-         if (sym^.typ<>typesym) or (ptypesym(sym)^.restype.def^.deftype<>objectdef) or
+         if (sym.typ<>typesym) or (ttypesym(sym).restype.def.deftype<>objectdef) or
             (i=-1) then
             (i=-1) then
            begin
            begin
               Message(parser_e_interface_id_expected);
               Message(parser_e_interface_id_expected);
@@ -373,14 +373,14 @@ begin
            end
            end
          else
          else
            begin
            begin
-              aktprocsym:=pprocsym(procinfo^._class^.implementedinterfaces^.interfaces(i)^.symtable^.search(sp));
+              aktprocsym:=tprocsym(procinfo^._class.implementedinterfaces.interfaces(i).symtable.search(sp));
               if not(assigned(aktprocsym)) then
               if not(assigned(aktprocsym)) then
                 Message(parser_e_methode_id_expected);
                 Message(parser_e_methode_id_expected);
            end;
            end;
          consume(_ID);
          consume(_ID);
          consume(_EQUAL);
          consume(_EQUAL);
          if (token=_ID) and assigned(aktprocsym) then
          if (token=_ID) and assigned(aktprocsym) then
-           procinfo^._class^.implementedinterfaces^.addmappings(i,sp,pattern);
+           procinfo^._class.implementedinterfaces.addmappings(i,sp,pattern);
          consume(_ID);
          consume(_ID);
          exit;
          exit;
     end;
     end;
@@ -406,8 +406,8 @@ begin
      procstartfilepos:=akttokenpos;
      procstartfilepos:=akttokenpos;
      consume(_ID);
      consume(_ID);
      { qualifier is class name ? }
      { qualifier is class name ? }
-     if (sym^.typ<>typesym) or
-        (ptypesym(sym)^.restype.def^.deftype<>objectdef) then
+     if (sym.typ<>typesym) or
+        (ttypesym(sym).restype.def.deftype<>objectdef) then
        begin
        begin
           Message(parser_e_class_id_expected);
           Message(parser_e_class_id_expected);
           aktprocsym:=nil;
           aktprocsym:=nil;
@@ -415,9 +415,9 @@ begin
      else
      else
        begin
        begin
           { used to allow private syms to be seen }
           { used to allow private syms to be seen }
-          aktobjectdef:=pobjectdef(ptypesym(sym)^.restype.def);
-          procinfo^._class:=pobjectdef(ptypesym(sym)^.restype.def);
-          aktprocsym:=pprocsym(procinfo^._class^.symtable^.search(sp));
+          aktobjectdef:=tobjectdef(ttypesym(sym).restype.def);
+          procinfo^._class:=tobjectdef(ttypesym(sym).restype.def);
+          aktprocsym:=tprocsym(procinfo^._class.symtable.search(sp));
           {The procedure has been found. So it is
           {The procedure has been found. So it is
            a global one. Set the flags to mark this.}
            a global one. Set the flags to mark this.}
           procinfo^.flags:=procinfo^.flags or pi_is_global;
           procinfo^.flags:=procinfo^.flags or pi_is_global;
@@ -435,7 +435,7 @@ begin
         Message(parser_e_constructors_always_objects);
         Message(parser_e_constructors_always_objects);
 
 
      akttokenpos:=procstartfilepos;
      akttokenpos:=procstartfilepos;
-     aktprocsym:=pprocsym(symtablestack^.search(sp));
+     aktprocsym:=tprocsym(symtablestack.search(sp));
 
 
      if not(parse_only) then
      if not(parse_only) then
        begin
        begin
@@ -447,14 +447,14 @@ begin
           We need to find out if the procedure is global. If it is
           We need to find out if the procedure is global. If it is
           global, it is in the global symtable.}
           global, it is in the global symtable.}
          if not assigned(aktprocsym) and
          if not assigned(aktprocsym) and
-            (symtablestack^.symtabletype=staticsymtable) then
+            (symtablestack.symtabletype=staticsymtable) then
           begin
           begin
             {Search the procedure in the global symtable.}
             {Search the procedure in the global symtable.}
-            aktprocsym:=Pprocsym(search_a_symtable(sp,globalsymtable));
+            aktprocsym:=tprocsym(search_a_symtable(sp,globalsymtable));
             if assigned(aktprocsym) then
             if assigned(aktprocsym) then
              begin
              begin
                {Check if it is a procedure.}
                {Check if it is a procedure.}
-               if aktprocsym^.typ<>procsym then
+               if aktprocsym.typ<>procsym then
                 DuplicateSym(aktprocsym);
                 DuplicateSym(aktprocsym);
                {The procedure has been found. So it is
                {The procedure has been found. So it is
                 a global one. Set the flags to mark this.}
                 a global one. Set the flags to mark this.}
@@ -469,7 +469,7 @@ begin
   if assigned(procinfo^._class) then
   if assigned(procinfo^._class) then
    begin
    begin
      if (pos('_$$_',procprefix)=0) then
      if (pos('_$$_',procprefix)=0) then
-      hs:=procprefix+'_$$_'+upper(procinfo^._class^.objname^)+'_$$_'+sp
+      hs:=procprefix+'_$$_'+upper(procinfo^._class.objname^)+'_$$_'+sp
      else
      else
       hs:=procprefix+'_$'+sp;
       hs:=procprefix+'_$'+sp;
    end
    end
@@ -484,7 +484,7 @@ begin
   if assigned(procinfo^._class) then
   if assigned(procinfo^._class) then
    begin
    begin
      if (pos('_5Class_',procprefix)=0) then
      if (pos('_5Class_',procprefix)=0) then
-      hs:=procprefix+'_5Class_'+procinfo^._class^.name^+'_'+tostr(length(sp))+sp
+      hs:=procprefix+'_5Class_'+procinfo^._class.name^+'_'+tostr(length(sp))+sp
      else
      else
       hs:=procprefix+'_'+tostr(length(sp))+sp;
       hs:=procprefix+'_'+tostr(length(sp))+sp;
    end
    end
@@ -501,15 +501,15 @@ begin
    begin
    begin
      { Check if overloaded is a procsym, we use a different error message
      { Check if overloaded is a procsym, we use a different error message
        for tp7 so it looks more compatible }
        for tp7 so it looks more compatible }
-     if aktprocsym^.typ<>procsym then
+     if aktprocsym.typ<>procsym then
       begin
       begin
         if (m_fpc in aktmodeswitches) then
         if (m_fpc in aktmodeswitches) then
-         Message1(parser_e_overloaded_no_procedure,aktprocsym^.realname)
+         Message1(parser_e_overloaded_no_procedure,aktprocsym.realname)
         else
         else
          DuplicateSym(aktprocsym);
          DuplicateSym(aktprocsym);
         { try to recover by creating a new aktprocsym }
         { try to recover by creating a new aktprocsym }
         akttokenpos:=procstartfilepos;
         akttokenpos:=procstartfilepos;
-        aktprocsym:=new(pprocsym,init(orgsp));
+        aktprocsym:=tprocsym.create(orgsp);
       end;
       end;
    end
    end
   else
   else
@@ -521,30 +521,28 @@ begin
      if (options=potype_operator) then
      if (options=potype_operator) then
        begin
        begin
           { create the procsym with saving the original case }
           { create the procsym with saving the original case }
-          aktprocsym:=new(pprocsym,init('$'+sp));
+          aktprocsym:=tprocsym.create('$'+sp);
           { the only problem is that nextoverloaded might not be in a unit
           { the only problem is that nextoverloaded might not be in a unit
             known for the unit itself }
             known for the unit itself }
           { not anymore PM }
           { not anymore PM }
           if assigned(overloaded_operators[optoken]) then
           if assigned(overloaded_operators[optoken]) then
-            aktprocsym^.definition:=overloaded_operators[optoken]^.definition;
-{$ifndef DONOTCHAINOPERATORS}
+            aktprocsym.definition:=overloaded_operators[optoken].definition;
           overloaded_operators[optoken]:=aktprocsym;
           overloaded_operators[optoken]:=aktprocsym;
-{$endif DONOTCHAINOPERATORS}
        end
        end
       else
       else
-       aktprocsym:=new(pprocsym,init(orgsp));
-     symtablestack^.insert(aktprocsym);
+       aktprocsym:=tprocsym.create(orgsp);
+     symtablestack.insert(aktprocsym);
    end;
    end;
 
 
   st:=symtablestack;
   st:=symtablestack;
-  pd:=new(pprocdef,init);
-  pd^.symtablelevel:=symtablestack^.symtablelevel;
+  pd:=tprocdef.create;
+  pd.symtablelevel:=symtablestack.symtablelevel;
 
 
   if assigned(procinfo^._class) then
   if assigned(procinfo^._class) then
-    pd^._class := procinfo^._class;
+    pd._class := procinfo^._class;
 
 
   { set the options from the caller (podestructor or poconstructor) }
   { set the options from the caller (podestructor or poconstructor) }
-  pd^.proctypeoption:=options;
+  pd.proctypeoption:=options;
 
 
   { calculate the offset of the parameters }
   { calculate the offset of the parameters }
   paramoffset:=8;
   paramoffset:=8;
@@ -556,12 +554,12 @@ begin
       inc(paramoffset,target_os.size_of_pointer);
       inc(paramoffset,target_os.size_of_pointer);
       { this is needed to get correct framepointer push for local
       { this is needed to get correct framepointer push for local
         forward functions !! }
         forward functions !! }
-      pd^.parast^.symtablelevel:=lexlevel;
+      pd.parast.symtablelevel:=lexlevel;
     end;
     end;
 
 
   if assigned (procinfo^._Class)  and
   if assigned (procinfo^._Class)  and
      is_object(procinfo^._Class) and
      is_object(procinfo^._Class) and
-     (pd^.proctypeoption in [potype_constructor,potype_destructor]) then
+     (pd.proctypeoption in [potype_constructor,potype_destructor]) then
     inc(paramoffset,target_os.size_of_pointer);
     inc(paramoffset,target_os.size_of_pointer);
 
 
   { self pointer offset                       }
   { self pointer offset                       }
@@ -569,27 +567,27 @@ begin
   if assigned(procinfo^._class) and (lexlevel=normal_function_level) then
   if assigned(procinfo^._class) and (lexlevel=normal_function_level) then
     begin
     begin
       procinfo^.selfpointer_offset:=paramoffset;
       procinfo^.selfpointer_offset:=paramoffset;
-      if assigned(aktprocsym^.definition) and
-         not(po_containsself in aktprocsym^.definition^.procoptions) then
+      if assigned(aktprocsym.definition) and
+         not(po_containsself in aktprocsym.definition.procoptions) then
         inc(paramoffset,target_os.size_of_pointer);
         inc(paramoffset,target_os.size_of_pointer);
     end;
     end;
 
 
   { con/-destructor flag ? }
   { con/-destructor flag ? }
   if assigned (procinfo^._Class) and
   if assigned (procinfo^._Class) and
      is_class(procinfo^._class) and
      is_class(procinfo^._class) and
-     (pd^.proctypeoption in [potype_destructor,potype_constructor]) then
+     (pd.proctypeoption in [potype_destructor,potype_constructor]) then
     inc(paramoffset,target_os.size_of_pointer);
     inc(paramoffset,target_os.size_of_pointer);
 
 
   procinfo^.para_offset:=paramoffset;
   procinfo^.para_offset:=paramoffset;
 
 
-  pd^.parast^.datasize:=0;
+  pd.parast.datasize:=0;
 
 
-  pd^.nextoverloaded:=aktprocsym^.definition;
-  aktprocsym^.definition:=pd;
+  pd.nextoverloaded:=aktprocsym.definition;
+  aktprocsym.definition:=pd;
   { this is probably obsolete now PM }
   { this is probably obsolete now PM }
-  aktprocsym^.definition^.fileinfo:=procstartfilepos;
-  aktprocsym^.definition^.setmangledname(hs);
-  aktprocsym^.definition^.procsym:=aktprocsym;
+  aktprocsym.definition.fileinfo:=procstartfilepos;
+  aktprocsym.definition.setmangledname(hs);
+  aktprocsym.definition.procsym:=aktprocsym;
 
 
   if not parse_only then
   if not parse_only then
     begin
     begin
@@ -597,12 +595,12 @@ begin
        { we need another procprefix !!! }
        { we need another procprefix !!! }
        { count, but only those in the same unit !!}
        { count, but only those in the same unit !!}
        while assigned(pd) and
        while assigned(pd) and
-          (pd^.owner^.symtabletype in [globalsymtable,staticsymtable]) do
+          (pd.owner.symtabletype in [globalsymtable,staticsymtable]) do
          begin
          begin
             { only count already implemented functions }
             { only count already implemented functions }
-            if  not(pd^.forwarddef) then
+            if  not(pd.forwarddef) then
               inc(overloaded_level);
               inc(overloaded_level);
-            pd:=pd^.nextoverloaded;
+            pd:=pd.nextoverloaded;
          end;
          end;
        if overloaded_level>0 then
        if overloaded_level>0 then
          procprefix:=hs+'$'+tostr(overloaded_level)+'$'
          procprefix:=hs+'$'+tostr(overloaded_level)+'$'
@@ -615,7 +613,7 @@ begin
     definitions of args defs in staticsymtable for
     definitions of args defs in staticsymtable for
     implementation of a global method }
     implementation of a global method }
   if token=_LKLAMMER then
   if token=_LKLAMMER then
-    parameter_dec(aktprocsym^.definition);
+    parameter_dec(aktprocsym.definition);
 
 
   { so we only restore the symtable now }
   { so we only restore the symtable now }
   symtablestack:=st;
   symtablestack:=st;
@@ -644,8 +642,8 @@ begin
                    parse_proc_head(potype_none);
                    parse_proc_head(potype_none);
                    if token<>_COLON then
                    if token<>_COLON then
                     begin
                     begin
-                       if not(is_interface(aktprocsym^.definition^._class)) and
-                          not(aktprocsym^.definition^.forwarddef) or
+                       if not(is_interface(aktprocsym.definition._class)) and
+                          not(aktprocsym.definition.forwarddef) or
                          (m_repeat_forward in aktmodeswitches) then
                          (m_repeat_forward in aktmodeswitches) then
                        begin
                        begin
                          consume(_COLON);
                          consume(_COLON);
@@ -656,15 +654,15 @@ begin
                     begin
                     begin
                       consume(_COLON);
                       consume(_COLON);
                       inc(testcurobject);
                       inc(testcurobject);
-                      single_type(aktprocsym^.definition^.rettype,hs,false);
-                      aktprocsym^.definition^.test_if_fpu_result;
+                      single_type(aktprocsym.definition.rettype,hs,false);
+                      aktprocsym.definition.test_if_fpu_result;
                       dec(testcurobject);
                       dec(testcurobject);
                     end;
                     end;
                  end;
                  end;
     _PROCEDURE : begin
     _PROCEDURE : begin
                    consume(_PROCEDURE);
                    consume(_PROCEDURE);
                    parse_proc_head(potype_none);
                    parse_proc_head(potype_none);
-                   aktprocsym^.definition^.rettype:=voidtype;
+                   aktprocsym.definition.rettype:=voidtype;
                  end;
                  end;
   _CONSTRUCTOR : begin
   _CONSTRUCTOR : begin
                    consume(_CONSTRUCTOR);
                    consume(_CONSTRUCTOR);
@@ -673,18 +671,18 @@ begin
                       is_class(procinfo^._class) then
                       is_class(procinfo^._class) then
                     begin
                     begin
                       { CLASS constructors return the created instance }
                       { CLASS constructors return the created instance }
-                      aktprocsym^.definition^.rettype.setdef(procinfo^._class);
+                      aktprocsym.definition.rettype.setdef(procinfo^._class);
                     end
                     end
                    else
                    else
                     begin
                     begin
                       { OBJECT constructors return a boolean }
                       { OBJECT constructors return a boolean }
-                      aktprocsym^.definition^.rettype:=booltype;
+                      aktprocsym.definition.rettype:=booltype;
                     end;
                     end;
                  end;
                  end;
    _DESTRUCTOR : begin
    _DESTRUCTOR : begin
                    consume(_DESTRUCTOR);
                    consume(_DESTRUCTOR);
                    parse_proc_head(potype_destructor);
                    parse_proc_head(potype_destructor);
-                   aktprocsym^.definition^.rettype:=voidtype;
+                   aktprocsym.definition.rettype:=voidtype;
                  end;
                  end;
      _OPERATOR : begin
      _OPERATOR : begin
                    if lexlevel>normal_function_level then
                    if lexlevel>normal_function_level then
@@ -706,48 +704,48 @@ begin
                    parse_proc_head(potype_operator);
                    parse_proc_head(potype_operator);
                    if token<>_ID then
                    if token<>_ID then
                      begin
                      begin
-                        opsym:=nil;
+                        otsym:=nil;
                         if not(m_result in aktmodeswitches) then
                         if not(m_result in aktmodeswitches) then
                           consume(_ID);
                           consume(_ID);
                      end
                      end
                    else
                    else
                      begin
                      begin
-                       opsym:=new(pvarsym,init(pattern,voidtype));
+                       otsym:=tvarsym.create(pattern,voidtype);
                        consume(_ID);
                        consume(_ID);
                      end;
                      end;
                    if not try_to_consume(_COLON) then
                    if not try_to_consume(_COLON) then
                      begin
                      begin
                        consume(_COLON);
                        consume(_COLON);
-                       aktprocsym^.definition^.rettype:=generrortype;
+                       aktprocsym.definition.rettype:=generrortype;
                        consume_all_until(_SEMICOLON);
                        consume_all_until(_SEMICOLON);
                      end
                      end
                    else
                    else
                     begin
                     begin
-                      single_type(aktprocsym^.definition^.rettype,hs,false);
-                      aktprocsym^.definition^.test_if_fpu_result;
+                      single_type(aktprocsym.definition.rettype,hs,false);
+                      aktprocsym.definition.test_if_fpu_result;
                       if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
                       if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
-                         ((aktprocsym^.definition^.rettype.def^.deftype<>
-                         orddef) or (porddef(aktprocsym^.definition^.
-                         rettype.def)^.typ<>bool8bit)) then
+                         ((aktprocsym.definition.rettype.def.deftype<>
+                         orddef) or (torddef(aktprocsym.definition.
+                         rettype.def).typ<>bool8bit)) then
                         Message(parser_e_comparative_operator_return_boolean);
                         Message(parser_e_comparative_operator_return_boolean);
-                       if assigned(opsym) then
-                         opsym^.vartype.def:=aktprocsym^.definition^.rettype.def;
+                       if assigned(otsym) then
+                         otsym.vartype.def:=aktprocsym.definition.rettype.def;
                        { We need to add the return type in the mangledname
                        { We need to add the return type in the mangledname
                          to allow overloading with just different results !! (PM) }
                          to allow overloading with just different results !! (PM) }
-                       aktprocsym^.definition^.setmangledname(
-                         aktprocsym^.definition^.mangledname+'$$'+hs);
+                       aktprocsym.definition.setmangledname(
+                         aktprocsym.definition.mangledname+'$$'+hs);
                        if (optoken=_ASSIGNMENT) and
                        if (optoken=_ASSIGNMENT) and
-                          is_equal(aktprocsym^.definition^.rettype.def,
-                             pvarsym(aktprocsym^.definition^.parast^.symindex^.first)^.vartype.def) then
+                          is_equal(aktprocsym.definition.rettype.def,
+                             tvarsym(aktprocsym.definition.parast.symindex.first).vartype.def) then
                          message(parser_e_no_such_assignment)
                          message(parser_e_no_such_assignment)
-                       else if not isoperatoracceptable(aktprocsym^.definition,optoken) then
+                       else if not isoperatoracceptable(aktprocsym.definition,optoken) then
                          Message(parser_e_overload_impossible);
                          Message(parser_e_overload_impossible);
                      end;
                      end;
                  end;
                  end;
   end;
   end;
   if isclassmethod and
   if isclassmethod and
      assigned(aktprocsym) then
      assigned(aktprocsym) then
-    include(aktprocsym^.definition^.procoptions,po_classmethod);
+    include(aktprocsym.definition.procoptions,po_classmethod);
   { support procedure proc;stdcall export; in Delphi mode only }
   { support procedure proc;stdcall export; in Delphi mode only }
   if not((m_delphi in aktmodeswitches) and
   if not((m_delphi in aktmodeswitches) and
      is_proc_directive(token)) then
      is_proc_directive(token)) then
@@ -779,10 +777,10 @@ begin
   { only os/2 needs this }
   { only os/2 needs this }
   if target_info.target=target_i386_os2 then
   if target_info.target=target_i386_os2 then
    begin
    begin
-     aktprocsym^.definition^.aliasnames.insert(aktprocsym^.realname);
+     aktprocsym.definition.aliasnames.insert(aktprocsym.realname);
      procinfo^.exported:=true;
      procinfo^.exported:=true;
      if cs_link_deffile in aktglobalswitches then
      if cs_link_deffile in aktglobalswitches then
-       deffile.AddExport(aktprocsym^.definition^.mangledname);
+       deffile.AddExport(aktprocsym.definition.mangledname);
    end;
    end;
 end;
 end;
 
 
@@ -794,7 +792,7 @@ end;
 
 
 procedure pd_forward;
 procedure pd_forward;
 begin
 begin
-  aktprocsym^.definition^.forwarddef:=true;
+  aktprocsym.definition.forwarddef:=true;
 end;
 end;
 
 
 procedure pd_stdcall;
 procedure pd_stdcall;
@@ -808,24 +806,24 @@ end;
 procedure pd_alias;
 procedure pd_alias;
 begin
 begin
   consume(_COLON);
   consume(_COLON);
-  aktprocsym^.definition^.aliasnames.insert(get_stringconst);
+  aktprocsym.definition.aliasnames.insert(get_stringconst);
 end;
 end;
 
 
 procedure pd_asmname;
 procedure pd_asmname;
 begin
 begin
-  aktprocsym^.definition^.setmangledname(target_os.Cprefix+pattern);
+  aktprocsym.definition.setmangledname(target_os.Cprefix+pattern);
   if token=_CCHAR then
   if token=_CCHAR then
     consume(_CCHAR)
     consume(_CCHAR)
   else
   else
     consume(_CSTRING);
     consume(_CSTRING);
   { we don't need anything else }
   { we don't need anything else }
-  aktprocsym^.definition^.forwarddef:=false;
+  aktprocsym.definition.forwarddef:=false;
 end;
 end;
 
 
 procedure pd_intern;
 procedure pd_intern;
 begin
 begin
   consume(_COLON);
   consume(_COLON);
-  aktprocsym^.definition^.extnumber:=get_intconst;
+  aktprocsym.definition.extnumber:=get_intconst;
 end;
 end;
 
 
 procedure pd_interrupt;
 procedure pd_interrupt;
@@ -840,17 +838,17 @@ end;
 
 
 procedure pd_system;
 procedure pd_system;
 begin
 begin
-  aktprocsym^.definition^.setmangledname(aktprocsym^.realname);
+  aktprocsym.definition.setmangledname(aktprocsym.realname);
 end;
 end;
 
 
 procedure pd_abstract;
 procedure pd_abstract;
 begin
 begin
-  if (po_virtualmethod in aktprocsym^.definition^.procoptions) then
-    include(aktprocsym^.definition^.procoptions,po_abstractmethod)
+  if (po_virtualmethod in aktprocsym.definition.procoptions) then
+    include(aktprocsym.definition.procoptions,po_abstractmethod)
   else
   else
     Message(parser_e_only_virtual_methods_abstract);
     Message(parser_e_only_virtual_methods_abstract);
   { the method is defined }
   { the method is defined }
-  aktprocsym^.definition^.forwarddef:=false;
+  aktprocsym.definition.forwarddef:=false;
 end;
 end;
 
 
 procedure pd_virtual;
 procedure pd_virtual;
@@ -859,19 +857,19 @@ var
   pt : tnode;
   pt : tnode;
 {$endif WITHDMT}
 {$endif WITHDMT}
 begin
 begin
-  if (aktprocsym^.definition^.proctypeoption=potype_constructor) and
-     is_object(aktprocsym^.definition^._class) then
+  if (aktprocsym.definition.proctypeoption=potype_constructor) and
+     is_object(aktprocsym.definition._class) then
     Message(parser_e_constructor_cannot_be_not_virtual);
     Message(parser_e_constructor_cannot_be_not_virtual);
 {$ifdef WITHDMT}
 {$ifdef WITHDMT}
-  if is_object(aktprocsym^.definition^._class) and
+  if is_object(aktprocsym.definition._class) and
     (token<>_SEMICOLON) then
     (token<>_SEMICOLON) then
     begin
     begin
        { any type of parameter is allowed here! }
        { any type of parameter is allowed here! }
        pt:=comp_expr(true);
        pt:=comp_expr(true);
        if is_constintnode(pt) then
        if is_constintnode(pt) then
          begin
          begin
-           include(aktprocsym^.definition^.procoptions,po_msgint);
-           aktprocsym^.definition^.messageinf.i:=pt^.value;
+           include(aktprocsym.definition.procoptions,po_msgint);
+           aktprocsym.definition.messageinf.i:=pt^.value;
          end
          end
        else
        else
          Message(parser_e_ill_msg_expr);
          Message(parser_e_ill_msg_expr);
@@ -884,14 +882,14 @@ procedure pd_static;
 begin
 begin
   if (cs_static_keyword in aktmoduleswitches) then
   if (cs_static_keyword in aktmoduleswitches) then
     begin
     begin
-      include(aktprocsym^.symoptions,sp_static);
-      include(aktprocsym^.definition^.procoptions,po_staticmethod);
+      include(aktprocsym.symoptions,sp_static);
+      include(aktprocsym.definition.procoptions,po_staticmethod);
     end;
     end;
 end;
 end;
 
 
 procedure pd_override;
 procedure pd_override;
 begin
 begin
-  if not(is_class_or_interface(aktprocsym^.definition^._class)) then
+  if not(is_class_or_interface(aktprocsym.definition._class)) then
     Message(parser_e_no_object_override);
     Message(parser_e_no_object_override);
 end;
 end;
 
 
@@ -904,22 +902,22 @@ var
   pt : tnode;
   pt : tnode;
 begin
 begin
   { check parameter type }
   { check parameter type }
-  if not(po_containsself in aktprocsym^.definition^.procoptions) and
-     ((aktprocsym^.definition^.minparacount<>1) or
-      (aktprocsym^.definition^.maxparacount<>1) or
-      (TParaItem(aktprocsym^.definition^.Para.first).paratyp<>vs_var)) then
+  if not(po_containsself in aktprocsym.definition.procoptions) and
+     ((aktprocsym.definition.minparacount<>1) or
+      (aktprocsym.definition.maxparacount<>1) or
+      (TParaItem(aktprocsym.definition.Para.first).paratyp<>vs_var)) then
    Message(parser_e_ill_msg_param);
    Message(parser_e_ill_msg_param);
   pt:=comp_expr(true);
   pt:=comp_expr(true);
   if pt.nodetype=stringconstn then
   if pt.nodetype=stringconstn then
     begin
     begin
-      include(aktprocsym^.definition^.procoptions,po_msgstr);
-      aktprocsym^.definition^.messageinf.str:=strnew(tstringconstnode(pt).value_str);
+      include(aktprocsym.definition.procoptions,po_msgstr);
+      aktprocsym.definition.messageinf.str:=strnew(tstringconstnode(pt).value_str);
     end
     end
   else
   else
    if is_constintnode(pt) then
    if is_constintnode(pt) then
     begin
     begin
-      include(aktprocsym^.definition^.procoptions,po_msgint);
-      aktprocsym^.definition^.messageinf.i:=tordconstnode(pt).value;
+      include(aktprocsym.definition.procoptions,po_msgint);
+      aktprocsym.definition.messageinf.i:=tordconstnode(pt).value;
     end
     end
   else
   else
     Message(parser_e_ill_msg_expr);
     Message(parser_e_ill_msg_expr);
@@ -927,56 +925,56 @@ begin
 end;
 end;
 
 
 
 
-procedure resetvaluepara(p:pnamedindexobject);
+procedure resetvaluepara(p:tnamedindexitem);
 begin
 begin
-  if psym(p)^.typ=varsym then
-    with pvarsym(p)^ do
+  if tsym(p).typ=varsym then
+    with tvarsym(p) do
        if copy(name,1,3)='val' then
        if copy(name,1,3)='val' then
-          aktprocsym^.definition^.parast^.symsearch^.rename(name,copy(name,4,length(name)));
+          aktprocsym.definition.parast.symsearch.rename(name,copy(name,4,length(name)));
 end;
 end;
 
 
 
 
 procedure pd_cdecl;
 procedure pd_cdecl;
 begin
 begin
-  if aktprocsym^.definition^.deftype<>procvardef then
-    aktprocsym^.definition^.setmangledname(target_os.Cprefix+aktprocsym^.realname);
+  if aktprocsym.definition.deftype<>procvardef then
+    aktprocsym.definition.setmangledname(target_os.Cprefix+aktprocsym.realname);
   { do not copy on local !! }
   { do not copy on local !! }
-  if (aktprocsym^.definition^.deftype=procdef) and
-     assigned(aktprocsym^.definition^.parast) then
-    aktprocsym^.definition^.parast^.foreach({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
+  if (aktprocsym.definition.deftype=procdef) and
+     assigned(aktprocsym.definition.parast) then
+    aktprocsym.definition.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
 end;
 end;
 
 
 procedure pd_cppdecl;
 procedure pd_cppdecl;
 begin
 begin
-  if aktprocsym^.definition^.deftype<>procvardef then
-    aktprocsym^.definition^.setmangledname(
-      target_os.Cprefix+aktprocsym^.definition^.cplusplusmangledname);
+  if aktprocsym.definition.deftype<>procvardef then
+    aktprocsym.definition.setmangledname(
+      target_os.Cprefix+aktprocsym.definition.cplusplusmangledname);
   { do not copy on local !! }
   { do not copy on local !! }
-  if (aktprocsym^.definition^.deftype=procdef) and
-     assigned(aktprocsym^.definition^.parast) then
-    aktprocsym^.definition^.parast^.foreach({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
+  if (aktprocsym.definition.deftype=procdef) and
+     assigned(aktprocsym.definition.parast) then
+    aktprocsym.definition.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}resetvaluepara);
 end;
 end;
 
 
 
 
 procedure pd_pascal;
 procedure pd_pascal;
-var st,parast : psymtable;
-    lastps,ps : psym;
+var st,parast : tsymtable;
+    lastps,ps : tsym;
 begin
 begin
-   new(st,init(parasymtable));
-   parast:=aktprocsym^.definition^.parast;
+   st:=tparasymtable.create;
+   parast:=aktprocsym.definition.parast;
    lastps:=nil;
    lastps:=nil;
-   while assigned(parast^.symindex^.first) and (lastps<>psym(parast^.symindex^.first)) do
+   while assigned(parast.symindex.first) and (lastps<>tsym(parast.symindex.first)) do
      begin
      begin
-       ps:=psym(parast^.symindex^.first);
-       while assigned(ps^.indexnext) and (psym(ps^.indexnext)<>lastps) do
-         ps:=psym(ps^.indexnext);
-       ps^.owner:=st;
+       ps:=tsym(parast.symindex.first);
+       while assigned(ps.indexnext) and (tsym(ps.indexnext)<>lastps) do
+         ps:=tsym(ps.indexnext);
+       ps.owner:=st;
        { recalculate the corrected offset }
        { recalculate the corrected offset }
        { the really_insert_in_data procedure
        { the really_insert_in_data procedure
          for parasymtable should only calculateoffset PM }
          for parasymtable should only calculateoffset PM }
-       pstoredsym(ps)^.insert_in_data;
+       tstoredsym(ps).insert_in_data;
        { reset the owner correctly }
        { reset the owner correctly }
-       ps^.owner:=parast;
+       ps.owner:=parast;
        lastps:=ps;
        lastps:=ps;
      end;
      end;
 end;
 end;
@@ -996,8 +994,8 @@ end;
 
 
 procedure pd_syscall;
 procedure pd_syscall;
 begin
 begin
-  aktprocsym^.definition^.forwarddef:=false;
-  aktprocsym^.definition^.extnumber:=get_intconst;
+  aktprocsym.definition.forwarddef:=false;
+  aktprocsym.definition.extnumber:=get_intconst;
 end;
 end;
 
 
 
 
@@ -1015,7 +1013,7 @@ var
   import_name : string;
   import_name : string;
   import_nr   : word;
   import_nr   : word;
 begin
 begin
-  aktprocsym^.definition^.forwarddef:=false;
+  aktprocsym.definition.forwarddef:=false;
 { If the procedure should be imported from a DLL, a constant string follows.
 { If the procedure should be imported from a DLL, a constant string follows.
   This isn't really correct, an contant string expression follows
   This isn't really correct, an contant string expression follows
   so we check if an semicolon follows, else a string constant have to
   so we check if an semicolon follows, else a string constant have to
@@ -1037,12 +1035,12 @@ begin
          import_nr:=get_intconst;
          import_nr:=get_intconst;
        end;
        end;
       if (import_nr=0) and (import_name='') then
       if (import_nr=0) and (import_name='') then
-        {if (aktprocsym^.definition^.options and pocdecl)<>0 then
-          import_name:=aktprocsym^.definition^.mangledname
+        {if (aktprocsym.definition.options and pocdecl)<>0 then
+          import_name:=aktprocsym.definition.mangledname
         else
         else
           Message(parser_w_empty_import_name);}
           Message(parser_w_empty_import_name);}
         { this should work both for win32 and Linux !! PM }
         { this should work both for win32 and Linux !! PM }
-        import_name:=aktprocsym^.realname;
+        import_name:=aktprocsym.realname;
       if not(current_module.uses_imports) then
       if not(current_module.uses_imports) then
        begin
        begin
          current_module.uses_imports:=true;
          current_module.uses_imports:=true;
@@ -1051,14 +1049,14 @@ begin
       if not(m_repeat_forward in aktmodeswitches) then
       if not(m_repeat_forward in aktmodeswitches) then
         begin
         begin
           { we can only have one overloaded here ! }
           { we can only have one overloaded here ! }
-          if assigned(aktprocsym^.definition^.nextoverloaded) then
-            importlib.importprocedure(aktprocsym^.definition^.nextoverloaded^.mangledname,
+          if assigned(aktprocsym.definition.nextoverloaded) then
+            importlib.importprocedure(aktprocsym.definition.nextoverloaded.mangledname,
               import_dll,import_nr,import_name)
               import_dll,import_nr,import_name)
           else
           else
-            importlib.importprocedure(aktprocsym^.mangledname,import_dll,import_nr,import_name);
+            importlib.importprocedure(aktprocsym.mangledname,import_dll,import_nr,import_name);
         end
         end
       else
       else
-        importlib.importprocedure(aktprocsym^.mangledname,import_dll,import_nr,import_name);
+        importlib.importprocedure(aktprocsym.mangledname,import_dll,import_nr,import_name);
     end
     end
   else
   else
     begin
     begin
@@ -1066,18 +1064,18 @@ begin
        begin
        begin
          consume(_NAME);
          consume(_NAME);
          import_name:=get_stringconst;
          import_name:=get_stringconst;
-         aktprocsym^.definition^.setmangledname(import_name);
+         aktprocsym.definition.setmangledname(import_name);
          if target_info.DllScanSupported then
          if target_info.DllScanSupported then
            current_module.externals.insert(tExternalsItem.create(import_name));
            current_module.externals.insert(tExternalsItem.create(import_name));
        end
        end
       else
       else
        begin
        begin
          { external shouldn't override the cdecl/system name }
          { external shouldn't override the cdecl/system name }
-         if not (pocall_clearstack in aktprocsym^.definition^.proccalloptions) then
+         if not (pocall_clearstack in aktprocsym.definition.proccalloptions) then
           begin
           begin
-            aktprocsym^.definition^.setmangledname(aktprocsym^.realname);
+            aktprocsym.definition.setmangledname(aktprocsym.realname);
             if target_info.DllScanSupported then
             if target_info.DllScanSupported then
-             current_module.externals.insert(tExternalsItem.create(aktprocsym^.realname));
+             current_module.externals.insert(tExternalsItem.create(aktprocsym.realname));
           end;
           end;
        end;
        end;
     end;
     end;
@@ -1400,493 +1398,456 @@ const
    );
    );
 
 
 
 
-function is_proc_directive(tok:ttoken):boolean;
-var
-  i : longint;
-begin
-  is_proc_directive:=false;
-  for i:=1 to num_proc_directives do
-   if proc_direcdata[i].idtok=idtoken then
-    begin
-      is_proc_directive:=true;
-      exit;
-    end;
-end;
+    function is_proc_directive(tok:ttoken):boolean;
+      var
+        i : longint;
+      begin
+        is_proc_directive:=false;
+        for i:=1 to num_proc_directives do
+         if proc_direcdata[i].idtok=idtoken then
+          begin
+            is_proc_directive:=true;
+            exit;
+          end;
+      end;
 
 
 
 
-function parse_proc_direc(var pdflags:word):boolean;
-{
-  Parse the procedure directive, returns true if a correct directive is found
-}
-var
-  p     : longint;
-  found : boolean;
-  name  : string;
-begin
-  parse_proc_direc:=false;
-  name:=pattern;
-  found:=false;
-  for p:=1 to num_proc_directives do
-   if proc_direcdata[p].idtok=idtoken then
-    begin
-      found:=true;
-      break;
-    end;
+    function parse_proc_direc(var pdflags:word):boolean;
+      {
+        Parse the procedure directive, returns true if a correct directive is found
+      }
+      var
+        p     : longint;
+        found : boolean;
+        name  : string;
+      begin
+        parse_proc_direc:=false;
+        name:=pattern;
+        found:=false;
+        for p:=1 to num_proc_directives do
+         if proc_direcdata[p].idtok=idtoken then
+          begin
+            found:=true;
+            break;
+          end;
 
 
-{ Check if the procedure directive is known }
-  if not found then
-   begin
-      { parsing a procvar type the name can be any
-        next variable !! }
-      if (pdflags and (pd_procvar or pd_object))=0 then
-        Message1(parser_w_unknown_proc_directive_ignored,name);
-      exit;
-   end;
+      { Check if the procedure directive is known }
+        if not found then
+         begin
+            { parsing a procvar type the name can be any
+              next variable !! }
+            if (pdflags and (pd_procvar or pd_object))=0 then
+              Message1(parser_w_unknown_proc_directive_ignored,name);
+            exit;
+         end;
 
 
-  { static needs a special treatment }
-  if (idtoken=_STATIC) and not (cs_static_keyword in aktmoduleswitches) then
-    exit;
+        { static needs a special treatment }
+        if (idtoken=_STATIC) and not (cs_static_keyword in aktmoduleswitches) then
+          exit;
 
 
-{ Conflicts between directives ? }
-  if (aktprocsym^.definition^.proctypeoption in proc_direcdata[p].mutexclpotype) or
-     ((aktprocsym^.definition^.proccalloptions*proc_direcdata[p].mutexclpocall)<>[]) or
-     ((aktprocsym^.definition^.procoptions*proc_direcdata[p].mutexclpo)<>[]) then
-   begin
-     Message1(parser_e_proc_dir_conflict,name);
-     exit;
-   end;
+      { Conflicts between directives ? }
+        if (aktprocsym.definition.proctypeoption in proc_direcdata[p].mutexclpotype) or
+           ((aktprocsym.definition.proccalloptions*proc_direcdata[p].mutexclpocall)<>[]) or
+           ((aktprocsym.definition.procoptions*proc_direcdata[p].mutexclpo)<>[]) then
+         begin
+           Message1(parser_e_proc_dir_conflict,name);
+           exit;
+         end;
 
 
-{ Check if the directive is only for objects }
-  if ((proc_direcdata[p].pd_flags and pd_object)<>0) and
-     not assigned(aktprocsym^.definition^._class) then
-    begin
-      exit;
-    end;
-{ check if method and directive not for object public }
-  if ((proc_direcdata[p].pd_flags and pd_notobject)<>0) and
-     assigned(aktprocsym^.definition^._class) then
-    begin
-      exit;
-    end;
+      { Check if the directive is only for objects }
+        if ((proc_direcdata[p].pd_flags and pd_object)<>0) and
+           not assigned(aktprocsym.definition._class) then
+          begin
+            exit;
+          end;
+      { check if method and directive not for object public }
+        if ((proc_direcdata[p].pd_flags and pd_notobject)<>0) and
+           assigned(aktprocsym.definition._class) then
+          begin
+            exit;
+          end;
 
 
-{ check if method and directive not for interface }
-  if ((proc_direcdata[p].pd_flags and pd_notobjintf)<>0) and
-     is_interface(aktprocsym^.definition^._class) then
-    begin
-      exit;
-    end;
+      { check if method and directive not for interface }
+        if ((proc_direcdata[p].pd_flags and pd_notobjintf)<>0) and
+           is_interface(aktprocsym.definition._class) then
+          begin
+            exit;
+          end;
 
 
-{ consume directive, and turn flag on }
-  consume(token);
-  parse_proc_direc:=true;
+      { consume directive, and turn flag on }
+        consume(token);
+        parse_proc_direc:=true;
 
 
-{ Check the pd_flags if the directive should be allowed }
-  if ((pdflags and pd_interface)<>0) and
-     ((proc_direcdata[p].pd_flags and pd_interface)=0) then
-    begin
-      Message1(parser_e_proc_dir_not_allowed_in_interface,name);
-      exit;
-    end;
-  if ((pdflags and pd_implemen)<>0) and
-     ((proc_direcdata[p].pd_flags and pd_implemen)=0) then
-    begin
-      Message1(parser_e_proc_dir_not_allowed_in_implementation,name);
-      exit;
-    end;
-  if ((pdflags and pd_procvar)<>0) and
-     ((proc_direcdata[p].pd_flags and pd_procvar)=0) then
-    begin
-      Message1(parser_e_proc_dir_not_allowed_in_procvar,name);
-      exit;
-    end;
+      { Check the pd_flags if the directive should be allowed }
+        if ((pdflags and pd_interface)<>0) and
+           ((proc_direcdata[p].pd_flags and pd_interface)=0) then
+          begin
+            Message1(parser_e_proc_dir_not_allowed_in_interface,name);
+            exit;
+          end;
+        if ((pdflags and pd_implemen)<>0) and
+           ((proc_direcdata[p].pd_flags and pd_implemen)=0) then
+          begin
+            Message1(parser_e_proc_dir_not_allowed_in_implementation,name);
+            exit;
+          end;
+        if ((pdflags and pd_procvar)<>0) and
+           ((proc_direcdata[p].pd_flags and pd_procvar)=0) then
+          begin
+            Message1(parser_e_proc_dir_not_allowed_in_procvar,name);
+            exit;
+          end;
 
 
-{ Return the new pd_flags }
-  if (proc_direcdata[p].pd_flags and pd_body)=0 then
-    pdflags:=pdflags and (not pd_body);
-  if (proc_direcdata[p].pd_flags and pd_global)<>0 then
-    pdflags:=pdflags or pd_global;
+      { Return the new pd_flags }
+        if (proc_direcdata[p].pd_flags and pd_body)=0 then
+          pdflags:=pdflags and (not pd_body);
+        if (proc_direcdata[p].pd_flags and pd_global)<>0 then
+          pdflags:=pdflags or pd_global;
 
 
-{ Add the correct flag }
-  aktprocsym^.definition^.proccalloptions:=aktprocsym^.definition^.proccalloptions+proc_direcdata[p].pocall;
-  aktprocsym^.definition^.procoptions:=aktprocsym^.definition^.procoptions+proc_direcdata[p].pooption;
+      { Add the correct flag }
+        aktprocsym.definition.proccalloptions:=aktprocsym.definition.proccalloptions+proc_direcdata[p].pocall;
+        aktprocsym.definition.procoptions:=aktprocsym.definition.procoptions+proc_direcdata[p].pooption;
 
 
- { Adjust positions of args for cdecl or stdcall }
-   if (aktprocsym^.definition^.deftype=procdef) and
-      (([pocall_cdecl,pocall_cppdecl,pocall_stdcall]*aktprocsym^.definition^.proccalloptions)<>[]) then
-     pstoredsymtable(aktprocsym^.definition^.parast)^.set_alignment(target_os.size_of_longint);
+       { Adjust positions of args for cdecl or stdcall }
+         if (aktprocsym.definition.deftype=procdef) and
+            (([pocall_cdecl,pocall_cppdecl,pocall_stdcall]*aktprocsym.definition.proccalloptions)<>[]) then
+           tstoredsymtable(aktprocsym.definition.parast).set_alignment(target_os.size_of_longint);
 
 
-{ Call the handler }
-  if pointer({$ifndef FPCPROCVAR}@{$endif}proc_direcdata[p].handler)<>nil then
-    proc_direcdata[p].handler{$ifdef FPCPROCVAR}(){$endif};
-end;
+      { Call the handler }
+        if pointer({$ifndef FPCPROCVAR}@{$endif}proc_direcdata[p].handler)<>nil then
+          proc_direcdata[p].handler{$ifdef FPCPROCVAR}(){$endif};
+      end;
 
 
 
 
-procedure parse_proc_directives(var pdflags:word);
-{
-  Parse the procedure directives. It does not matter if procedure directives
-  are written using ;procdir; or ['procdir'] syntax.
-}
-var
-  res : boolean;
-begin
-  while token in [_ID,_LECKKLAMMER] do
-   begin
-     if try_to_consume(_LECKKLAMMER) then
-      begin
-        repeat
-          parse_proc_direc(pdflags);
-        until not try_to_consume(_COMMA);
-        consume(_RECKKLAMMER);
-        { we always expect at least '[];' }
-        res:=true;
-      end
-     else
-      res:=parse_proc_direc(pdflags);
-   { A procedure directive normally followed by a semicolon, but in
-     a const section we should stop when _EQUAL is found }
-     if res then
+    procedure parse_proc_directives(var pdflags:word);
+      {
+        Parse the procedure directives. It does not matter if procedure directives
+        are written using ;procdir; or ['procdir'] syntax.
+      }
+      var
+        res : boolean;
       begin
       begin
-        if (block_type=bt_const) and
-           (token=_EQUAL) then
-         break;
-        { support procedure proc;stdcall export; in Delphi mode only }
-        if not((m_delphi in aktmodeswitches) and
-               is_proc_directive(token)) then
-         consume(_SEMICOLON);
-      end
-     else
-      break;
-   end;
-end;
+        while token in [_ID,_LECKKLAMMER] do
+         begin
+           if try_to_consume(_LECKKLAMMER) then
+            begin
+              repeat
+                parse_proc_direc(pdflags);
+              until not try_to_consume(_COMMA);
+              consume(_RECKKLAMMER);
+              { we always expect at least '[];' }
+              res:=true;
+            end
+           else
+            res:=parse_proc_direc(pdflags);
+         { A procedure directive normally followed by a semicolon, but in
+           a const section we should stop when _EQUAL is found }
+           if res then
+            begin
+              if (block_type=bt_const) and
+                 (token=_EQUAL) then
+               break;
+              { support procedure proc;stdcall export; in Delphi mode only }
+              if not((m_delphi in aktmodeswitches) and
+                     is_proc_directive(token)) then
+               consume(_SEMICOLON);
+            end
+           else
+            break;
+         end;
+      end;
 
 
-procedure parse_var_proc_directives(var sym : psym);
-var
-  pdflags : word;
-  oldsym  : pprocsym;
-  pd      : pabstractprocdef;
-begin
-  oldsym:=aktprocsym;
-  pdflags:=pd_procvar;
-  { we create a temporary aktprocsym to read the directives }
-  aktprocsym:=new(pprocsym,init(sym^.name));
-  case sym^.typ of
-    varsym :
-      pd:=pabstractprocdef(pvarsym(sym)^.vartype.def);
-    typedconstsym :
-      pd:=pabstractprocdef(ptypedconstsym(sym)^.typedconsttype.def);
-    typesym :
-      pd:=pabstractprocdef(ptypesym(sym)^.restype.def);
-    else
-      internalerror(994932432);
-  end;
-  if pd^.deftype<>procvardef then
-   internalerror(994932433);
-  pabstractprocdef(aktprocsym^.definition):=pd;
-  { names should never be used anyway }
-  inc(lexlevel);
-  parse_proc_directives(pdflags);
-  dec(lexlevel);
-  aktprocsym^.definition:=nil;
-  dispose(aktprocsym,done);
-  aktprocsym:=oldsym;
-end;
+
+    procedure parse_var_proc_directives(var sym : tsym);
+      var
+        pdflags : word;
+        oldsym  : tprocsym;
+        pd      : tabstractprocdef;
+      begin
+        oldsym:=aktprocsym;
+        pdflags:=pd_procvar;
+        { we create a temporary aktprocsym to read the directives }
+        aktprocsym:=tprocsym.create(sym.name);
+        case sym.typ of
+          varsym :
+            pd:=tabstractprocdef(tvarsym(sym).vartype.def);
+          typedconstsym :
+            pd:=tabstractprocdef(ttypedconstsym(sym).typedconsttype.def);
+          typesym :
+            pd:=tabstractprocdef(ttypesym(sym).restype.def);
+          else
+            internalerror(994932432);
+        end;
+        if pd.deftype<>procvardef then
+         internalerror(994932433);
+        tabstractprocdef(aktprocsym.definition):=pd;
+        { names should never be used anyway }
+        inc(lexlevel);
+        parse_proc_directives(pdflags);
+        dec(lexlevel);
+        aktprocsym.definition:=nil;
+        aktprocsym.free;
+        aktprocsym:=oldsym;
+      end;
 
 
 
 
-procedure parse_object_proc_directives(var sym : pprocsym);
-var
-  pdflags : word;
-begin
-  pdflags:=pd_object;
-  inc(lexlevel);
-  parse_proc_directives(pdflags);
-  dec(lexlevel);
-  if (po_containsself in aktprocsym^.definition^.procoptions) and
-     (([po_msgstr,po_msgint]*aktprocsym^.definition^.procoptions)=[]) then
-    Message(parser_e_self_in_non_message_handler);
-end;
+    procedure parse_object_proc_directives(var sym : tprocsym);
+      var
+        pdflags : word;
+      begin
+        pdflags:=pd_object;
+        inc(lexlevel);
+        parse_proc_directives(pdflags);
+        dec(lexlevel);
+        if (po_containsself in aktprocsym.definition.procoptions) and
+           (([po_msgstr,po_msgint]*aktprocsym.definition.procoptions)=[]) then
+          Message(parser_e_self_in_non_message_handler);
+      end;
 
 
-{***************************************************************************}
 
 
-function check_identical_proc(var p : pprocdef) : boolean;
-{
-  Search for idendical definitions,
-  if there is a forward, then kill this.
+    function check_identical_proc(var p : tprocdef) : boolean;
+      {
+        Search for idendical definitions,
+        if there is a forward, then kill this.
 
 
-  Returns the result of the forward check.
+        Returns the result of the forward check.
 
 
-  Removed from unter_dec to keep the source readable
-}
-var
-  hd,pd : Pprocdef;
-  storeparast : psymtable;
-  ad,fd : psym;
-  s : string;
-begin
-  check_identical_proc:=false;
-  p:=nil;
-  pd:=aktprocsym^.definition;
-  if assigned(pd) then
-   begin
-   { Is there an overload/forward ? }
-     if assigned(pd^.nextoverloaded) then
+        Removed from unter_dec to keep the source readable
+      }
+      var
+        hd,pd : tprocdef;
+        ad,fd : tsym;
       begin
       begin
-      { walk the procdef list }
-        while (assigned(pd)) and (assigned(pd^.nextoverloaded)) do
+        check_identical_proc:=false;
+        p:=nil;
+        pd:=aktprocsym.definition;
+        if assigned(pd) then
          begin
          begin
-           hd:=pd^.nextoverloaded;
-
-           { check the parameters }
-           if (not(m_repeat_forward in aktmodeswitches) and
-               (aktprocsym^.definition^.maxparacount=0)) or
-              (equal_paras(aktprocsym^.definition^.para,hd^.para,cp_none) and
-              { for operators equal_paras is not enough !! }
-              ((aktprocsym^.definition^.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
-               is_equal(hd^.rettype.def,aktprocsym^.definition^.rettype.def))) then
-             begin
-               if not equal_paras(aktprocsym^.definition^.para,hd^.para,cp_all) and
-                  ((m_repeat_forward in aktmodeswitches) or
-                   (aktprocsym^.definition^.maxparacount>0)) then
-                 begin
-                    MessagePos1(aktprocsym^.definition^.fileinfo,parser_e_header_dont_match_forward,
-                                aktprocsym^.definition^.fullprocname);
-                    exit;
-                 end;
-               if hd^.forwarddef then
-               { remove the forward definition  but don't delete it,      }
-               { the symtable is the owner !!  }
-                 begin
-                 { Check if the procedure type and return type are correct }
-                   if (hd^.proctypeoption<>aktprocsym^.definition^.proctypeoption) or
-                      (not(is_equal(hd^.rettype.def,aktprocsym^.definition^.rettype.def)) and
-                      (m_repeat_forward in aktmodeswitches)) then
-                     begin
-                       MessagePos1(aktprocsym^.definition^.fileinfo,parser_e_header_dont_match_forward,
-                                   aktprocsym^.definition^.fullprocname);
-                       exit;
-                     end;
-                   { Check calling convention, no check for internconst,internproc which
-                     are only defined in interface or implementation }
-                   if (hd^.proccalloptions-[pocall_internconst,pocall_internproc]<>
-                       aktprocsym^.definition^.proccalloptions-[pocall_internconst,pocall_internproc]) then
-                    begin
-                      { only trigger an error, becuase it doesn't hurt, for delphi check
-                        if the current implementation has no proccalloptions, then
-                        take the options from the interface }
-                      if (m_delphi in aktmodeswitches) then
-                       begin
-                         if (aktprocsym^.definition^.proccalloptions=[]) then
-                          aktprocsym^.definition^.proccalloptions:=hd^.proccalloptions
-                         else
-                          MessagePos(aktprocsym^.definition^.fileinfo,parser_e_call_convention_dont_match_forward);
-                       end
-                      else
-                       MessagePos(aktprocsym^.definition^.fileinfo,parser_e_call_convention_dont_match_forward);
-                      { set the mangledname to the interface name so it doesn't trigger
-                        the Note about different manglednames (PFV) }
-                      aktprocsym^.definition^.setmangledname(hd^.mangledname);
-                    end;
-                   { manglednames are equal? }
-                   hd^.count:=false;
-                   if (m_repeat_forward in aktmodeswitches) or
-                      aktprocsym^.definition^.haspara then
-                    begin
-                      if (hd^.mangledname<>aktprocsym^.definition^.mangledname) then
+         { Is there an overload/forward ? }
+           if assigned(pd.nextoverloaded) then
+            begin
+            { walk the procdef list }
+              while (assigned(pd)) and (assigned(pd.nextoverloaded)) do
+               begin
+                 hd:=pd.nextoverloaded;
+
+                 { check the parameters }
+                 if (not(m_repeat_forward in aktmodeswitches) and
+                     (aktprocsym.definition.maxparacount=0)) or
+                    (equal_paras(aktprocsym.definition.para,hd.para,cp_none) and
+                    { for operators equal_paras is not enough !! }
+                    ((aktprocsym.definition.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
+                     is_equal(hd.rettype.def,aktprocsym.definition.rettype.def))) then
+                   begin
+                     if not equal_paras(aktprocsym.definition.para,hd.para,cp_all) and
+                        ((m_repeat_forward in aktmodeswitches) or
+                         (aktprocsym.definition.maxparacount>0)) then
                        begin
                        begin
-                         if not(po_external in aktprocsym^.definition^.procoptions) then
-                           MessagePos2(aktprocsym^.definition^.fileinfo,parser_n_interface_name_diff_implementation_name,hd^.mangledname,
-                             aktprocsym^.definition^.mangledname);
-                       { reset the mangledname of the interface part to be sure }
-                       { this is wrong because the mangled name might have been used already !! }
-                          if hd^.is_used then
-                            renameasmsymbol(hd^.mangledname,aktprocsym^.definition^.mangledname);
-                          hd^.setmangledname(aktprocsym^.definition^.mangledname);
-                       { so we need to keep the name of interface !!
-                         No!!!! The procedure directives can change the mangledname.
-                         I fixed this by first calling check_identical_proc and then doing
-                         the proc directives, but this is not a good solution.(DM)}
-                         { this is also wrong (PM)
-                         aktprocsym^.definition^.setmangledname(hd^.mangledname);}
-                       end
-                      else
+                          MessagePos1(aktprocsym.definition.fileinfo,parser_e_header_dont_match_forward,
+                                      aktprocsym.definition.fullprocname);
+                          exit;
+                       end;
+                     if hd.forwarddef then
+                     { remove the forward definition  but don't delete it,      }
+                     { the symtable is the owner !!  }
                        begin
                        begin
-                       { If mangled names are equal, therefore    }
-                       { they have the same number of parameters  }
-                       { Therefore we can check the name of these }
-                       { parameters...                      }
-                         if hd^.forwarddef and aktprocsym^.definition^.forwarddef then
+                       { Check if the procedure type and return type are correct }
+                         if (hd.proctypeoption<>aktprocsym.definition.proctypeoption) or
+                            (not(is_equal(hd.rettype.def,aktprocsym.definition.rettype.def)) and
+                            (m_repeat_forward in aktmodeswitches)) then
                            begin
                            begin
-                             MessagePos1(aktprocsym^.definition^.fileinfo,
-                                         parser_e_function_already_declared_public_forward,
-                                         aktprocsym^.definition^.fullprocname);
-                             check_identical_proc:=true;
-                           { Remove other forward from the list to reduce errors }
-                             pd^.nextoverloaded:=pd^.nextoverloaded^.nextoverloaded;
+                             MessagePos1(aktprocsym.definition.fileinfo,parser_e_header_dont_match_forward,
+                                         aktprocsym.definition.fullprocname);
                              exit;
                              exit;
                            end;
                            end;
-                         ad:=psym(hd^.parast^.symindex^.first);
-                         fd:=psym(aktprocsym^.definition^.parast^.symindex^.first);
-                         if assigned(ad) and assigned(fd) then
-                           begin
-                             while assigned(ad) and assigned(fd) do
-                               begin
-                                 s:=ad^.name;
-                                 if s<>fd^.name then
+                         { Check calling convention, no check for internconst,internproc which
+                           are only defined in interface or implementation }
+                         if (hd.proccalloptions-[pocall_internconst,pocall_internproc]<>
+                             aktprocsym.definition.proccalloptions-[pocall_internconst,pocall_internproc]) then
+                          begin
+                            { only trigger an error, becuase it doesn't hurt, for delphi check
+                              if the current implementation has no proccalloptions, then
+                              take the options from the interface }
+                            if (m_delphi in aktmodeswitches) then
+                             begin
+                               if (aktprocsym.definition.proccalloptions=[]) then
+                                aktprocsym.definition.proccalloptions:=hd.proccalloptions
+                               else
+                                MessagePos(aktprocsym.definition.fileinfo,parser_e_call_convention_dont_match_forward);
+                             end
+                            else
+                             MessagePos(aktprocsym.definition.fileinfo,parser_e_call_convention_dont_match_forward);
+                            { set the mangledname to the interface name so it doesn't trigger
+                              the Note about different manglednames (PFV) }
+                            aktprocsym.definition.setmangledname(hd.mangledname);
+                          end;
+                         { manglednames are equal? }
+                         hd.count:=false;
+                         if (m_repeat_forward in aktmodeswitches) or
+                            aktprocsym.definition.haspara then
+                          begin
+                            if (hd.mangledname<>aktprocsym.definition.mangledname) then
+                             begin
+                               if not(po_external in aktprocsym.definition.procoptions) then
+                                 MessagePos2(aktprocsym.definition.fileinfo,parser_n_interface_name_diff_implementation_name,hd.mangledname,
+                                   aktprocsym.definition.mangledname);
+                             { reset the mangledname of the interface part to be sure }
+                             { this is wrong because the mangled name might have been used already !! }
+                                if hd.is_used then
+                                  renameasmsymbol(hd.mangledname,aktprocsym.definition.mangledname);
+                                hd.setmangledname(aktprocsym.definition.mangledname);
+                             end
+                            else
+                             begin
+                             { If mangled names are equal, therefore    }
+                             { they have the same number of parameters  }
+                             { Therefore we can check the name of these }
+                             { parameters...                      }
+                               if hd.forwarddef and aktprocsym.definition.forwarddef then
+                                 begin
+                                   MessagePos1(aktprocsym.definition.fileinfo,
+                                               parser_e_function_already_declared_public_forward,
+                                               aktprocsym.definition.fullprocname);
+                                   check_identical_proc:=true;
+                                 { Remove other forward from the list to reduce errors }
+                                   pd.nextoverloaded:=pd.nextoverloaded.nextoverloaded;
+                                   exit;
+                                 end;
+                               { both symtables are in the same order from left to right }
+                               ad:=tsym(hd.parast.symindex.first);
+                               fd:=tsym(aktprocsym.definition.parast.symindex.first);
+                               while assigned(ad) and assigned(fd) do
+                                begin
+                                  if ad.name<>fd.name then
                                    begin
                                    begin
-                                     MessagePos3(aktprocsym^.definition^.fileinfo,parser_e_header_different_var_names,
-                                       aktprocsym^.name,s,fd^.name);
+                                     MessagePos3(aktprocsym.definition.fileinfo,parser_e_header_different_var_names,
+                                                 aktprocsym.name,ad.name,fd.name);
                                      break;
                                      break;
                                    end;
                                    end;
-                               { it is impossible to have a nil pointer }
-                               { for only one parameter - since they    }
-                               { have the same number of parameters.    }
-                               { Left = next parameter.          }
-                                 ad:=psym(ad^.left);
-                                 fd:=psym(fd^.left);
-                               end;
-                           end;
-                       end;
-                    end;
-                 { also the para_offset }
-                   hd^.parast^.address_fixup:=aktprocsym^.definition^.parast^.address_fixup;
-                   hd^.count:=true;
-
-                 { remove pd^.nextoverloaded from the list }
-                 { and add aktprocsym^.definition }
-                   pd^.nextoverloaded:=pd^.nextoverloaded^.nextoverloaded;
-                   hd^.nextoverloaded:=aktprocsym^.definition^.nextoverloaded;
-                 { Alert! All fields of aktprocsym^.definition that are modified
-                   by the procdir handlers must be copied here!.}
-                   hd^.forwarddef:=false;
-                   hd^.hasforward:=true;
-                   hd^.proccalloptions:=hd^.proccalloptions + aktprocsym^.definition^.proccalloptions;
-                   hd^.procoptions:=hd^.procoptions + aktprocsym^.definition^.procoptions;
-                   if aktprocsym^.definition^.extnumber=-1 then
-                     aktprocsym^.definition^.extnumber:=hd^.extnumber
-                   else
-                     if hd^.extnumber=-1 then
-                       hd^.extnumber:=aktprocsym^.definition^.extnumber;
-                   { copy all aliasnames }
-                   while not aktprocsym^.definition^.aliasnames.empty do
-                    hd^.aliasnames.insert(aktprocsym^.definition^.aliasnames.getfirst);
-                   { switch parast for warning in implementation  PM }
-                   if (m_repeat_forward in aktmodeswitches) or
-                      aktprocsym^.definition^.haspara then
-                     begin
-                        storeparast:=hd^.parast;
-                        hd^.parast:=aktprocsym^.definition^.parast;
-                        aktprocsym^.definition^.parast:=storeparast;
-                     end;
-                   if pd=aktprocsym^.definition then
-                     p:=nil
-                   else
-                     p:=pd;
-                   aktprocsym^.definition:=hd;
-                   check_identical_proc:=true;
-                 end
-               else
-               { abstract methods aren't forward defined, but this }
-               { needs another error message                   }
-                 if not(po_abstractmethod in pd^.nextoverloaded^.procoptions) then
-                   MessagePos(aktprocsym^.definition^.fileinfo,parser_e_overloaded_have_same_parameters)
-                 else
-                   MessagePos(aktprocsym^.definition^.fileinfo,parser_e_abstract_no_definition);
-               break;
-             end;
+                                  ad:=tsym(ad.indexnext);
+                                  fd:=tsym(fd.indexnext);
+                                end;
+                             end;
+                          end;
+                       { also the para_offset }
+                         hd.parast.address_fixup:=aktprocsym.definition.parast.address_fixup;
+                         hd.count:=true;
+
+                       { remove pd.nextoverloaded from the list }
+                       { and add aktprocsym.definition }
+                         pd.nextoverloaded:=pd.nextoverloaded.nextoverloaded;
+                         hd.nextoverloaded:=aktprocsym.definition.nextoverloaded;
+                       { Alert! All fields of aktprocsym.definition that are modified
+                         by the procdir handlers must be copied here!.}
+                         hd.forwarddef:=false;
+                         hd.hasforward:=true;
+                         hd.proccalloptions:=hd.proccalloptions + aktprocsym.definition.proccalloptions;
+                         hd.procoptions:=hd.procoptions + aktprocsym.definition.procoptions;
+                         if aktprocsym.definition.extnumber=-1 then
+                           aktprocsym.definition.extnumber:=hd.extnumber
+                         else
+                           if hd.extnumber=-1 then
+                             hd.extnumber:=aktprocsym.definition.extnumber;
+                         { copy all aliasnames }
+                         while not aktprocsym.definition.aliasnames.empty do
+                          hd.aliasnames.insert(aktprocsym.definition.aliasnames.getfirst);
+                         { switch parast for warning in implementation  PM
+                           This can't be done, because the parasymtable is also
+                           stored in the ppu and loaded when only the interface
+                           units are loaded. Using the implementation parast can
+                           cause problems with redefined types in units only included
+                           in the implementation uses (PFV) }
+                         {if (m_repeat_forward in aktmodeswitches) or
+                            aktprocsym.definition.haspara then
+                           begin
+                              storeparast:=hd.parast;
+                              hd.parast:=aktprocsym.definition.parast;
+                              aktprocsym.definition.parast:=storeparast;
+                           end;}
+                         if pd=aktprocsym.definition then
+                           p:=nil
+                         else
+                           p:=pd;
+                         aktprocsym.definition:=hd;
+                         check_identical_proc:=true;
+                       end
+                     else
+                     { abstract methods aren't forward defined, but this }
+                     { needs another error message                   }
+                       if not(po_abstractmethod in pd.nextoverloaded.procoptions) then
+                         MessagePos(aktprocsym.definition.fileinfo,parser_e_overloaded_have_same_parameters)
+                       else
+                         MessagePos(aktprocsym.definition.fileinfo,parser_e_abstract_no_definition);
+                     break;
+                   end;
 
 
-           { check for allowing overload directive }
-           if not(m_fpc in aktmodeswitches) then
-            begin
-              { overload directive turns on overloading }
-              if ((po_overload in aktprocsym^.definition^.procoptions) or
-                  ((po_overload in hd^.procoptions))) then
-               begin
-                 { check if all procs have overloading, but not if the proc was
-                   already declared forward, then the check is already done }
-                 if not(hd^.hasforward) and
-                    (aktprocsym^.definition^.forwarddef=hd^.forwarddef) and
-                    not((po_overload in aktprocsym^.definition^.procoptions) and
-                        ((po_overload in hd^.procoptions))) then
+                 { check for allowing overload directive }
+                 if not(m_fpc in aktmodeswitches) then
                   begin
                   begin
-                    MessagePos1(aktprocsym^.definition^.fileinfo,parser_e_no_overload_for_all_procs,aktprocsym^.realname);
-                    break;
-                  end;
-               end
-              else
-               begin
-                 if not(hd^.forwarddef) then
-                  begin
-                    MessagePos(aktprocsym^.definition^.fileinfo,parser_e_procedure_overloading_is_off);
-                    break;
+                    { overload directive turns on overloading }
+                    if ((po_overload in aktprocsym.definition.procoptions) or
+                        ((po_overload in hd.procoptions))) then
+                     begin
+                       { check if all procs have overloading, but not if the proc was
+                         already declared forward, then the check is already done }
+                       if not(hd.hasforward) and
+                          (aktprocsym.definition.forwarddef=hd.forwarddef) and
+                          not((po_overload in aktprocsym.definition.procoptions) and
+                              ((po_overload in hd.procoptions))) then
+                        begin
+                          MessagePos1(aktprocsym.definition.fileinfo,parser_e_no_overload_for_all_procs,aktprocsym.realname);
+                          break;
+                        end;
+                     end
+                    else
+                     begin
+                       if not(hd.forwarddef) then
+                        begin
+                          MessagePos(aktprocsym.definition.fileinfo,parser_e_procedure_overloading_is_off);
+                          break;
+                        end;
+                     end;
                   end;
                   end;
+
+                 { try next overloaded }
+                 pd:=pd.nextoverloaded;
                end;
                end;
+            end
+           else
+            begin
+            { there is no overloaded, so its always identical with itself }
+              check_identical_proc:=true;
             end;
             end;
-
-           { try next overloaded }
-           pd:=pd^.nextoverloaded;
          end;
          end;
-      end
-     else
-      begin
-      { there is no overloaded, so its always identical with itself }
-        check_identical_proc:=true;
+      { insert otsym only in the right symtable }
+        if ((procinfo^.flags and pi_operator)<>0) and assigned(otsym)
+           and not parse_only then
+          begin
+            if ret_in_param(aktprocsym.definition.rettype.def) then
+              begin
+                tprocdef(aktprocsym.definition).parast.insert(otsym);
+              { this increases the data size }
+              { correct this to get the right ret $value }
+                dec(tprocdef(aktprocsym.definition).parast.datasize,otsym.getpushsize);
+                { this allows to read the funcretoffset }
+                otsym.address:=-4;
+                otsym.varspez:=vs_var;
+              end
+            else
+              tprocdef(aktprocsym.definition).localst.insert(otsym);
+          end;
       end;
       end;
-   end;
-{ insert opsym only in the right symtable }
-  if ((procinfo^.flags and pi_operator)<>0) and assigned(opsym)
-     and not parse_only then
-    begin
-      if ret_in_param(aktprocsym^.definition^.rettype.def) then
-        begin
-          pprocdef(aktprocsym^.definition)^.parast^.insert(opsym);
-        { this increases the data size }
-        { correct this to get the right ret $value }
-          dec(pprocdef(aktprocsym^.definition)^.parast^.datasize,opsym^.getpushsize);
-          { this allows to read the funcretoffset }
-          opsym^.address:=-4;
-          opsym^.varspez:=vs_var;
-        end
-      else
-        pprocdef(aktprocsym^.definition)^.localst^.insert(opsym);
-    end;
-end;
-
-
 
 
-procedure checkvaluepara(p:pnamedindexobject);
-var
-  vs : pvarsym;
-  s  : string;
-begin
-  with pvarsym(p)^ do
-   begin
-     if copy(name,1,3)='val' then
-      begin
-        s:=Copy(name,4,255);
-        if not(po_assembler in aktprocsym^.definition^.procoptions) then
-         begin
-           vs:=new(Pvarsym,init(s,vartype));
-           vs^.fileinfo:=fileinfo;
-           vs^.varspez:=varspez;
-           aktprocsym^.definition^.localst^.insert(vs);
-           include(vs^.varoptions,vo_is_local_copy);
-           vs^.varstate:=vs_assigned;
-           localvarsym:=vs;
-           inc(refs); { the para was used to set the local copy ! }
-           { warnings only on local copy ! }
-           varstate:=vs_used;
-         end
-        else
-         begin
-           aktprocsym^.definition^.parast^.rename(name,s);
-         end;
-      end;
-   end;
-end;
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2001-04-04 22:43:52  peter
+  Revision 1.18  2001-04-13 01:22:11  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.17  2001/04/04 22:43:52  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.16  2001/04/02 21:20:33  peter
   Revision 1.16  2001/04/02 21:20:33  peter

+ 93 - 88
compiler/pdecvar.pas

@@ -34,14 +34,14 @@ implementation
 
 
     uses
     uses
        { common }
        { common }
-       cutils,cobjects,
+       cutils,
        { global }
        { global }
        globtype,globals,tokens,verbose,
        globtype,globals,tokens,verbose,
        systems,
        systems,
        { symtable }
        { symtable }
        symconst,symbase,symtype,symdef,symsym,symtable,types,fmodule,
        symconst,symbase,symtype,symdef,symsym,symtable,types,fmodule,
        { pass 1 }
        { pass 1 }
-       node,pass_1,
+       node,
        nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
        nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
        { parser }
        { parser }
        scanner,
        scanner,
@@ -62,27 +62,27 @@ implementation
     { => the procedure is also used to read     }
     { => the procedure is also used to read     }
     { a sequence of variable declaration        }
     { a sequence of variable declaration        }
 
 
-      procedure insert_syms(st : psymtable;sc : tidstringlist;tt : ttype;is_threadvar : boolean);
-      { inserts the symbols of sc in st with def as definition or sym as ptypesym, sc is disposed }
+      procedure insert_syms(st : tsymtable;sc : tidstringlist;tt : ttype;is_threadvar : boolean);
+      { inserts the symbols of sc in st with def as definition or sym as ttypesym, sc is disposed }
         var
         var
            s : string;
            s : string;
            filepos : tfileposinfo;
            filepos : tfileposinfo;
-           ss : pvarsym;
+           ss : tvarsym;
         begin
         begin
            filepos:=akttokenpos;
            filepos:=akttokenpos;
            while not sc.empty do
            while not sc.empty do
              begin
              begin
                 s:=sc.get(akttokenpos);
                 s:=sc.get(akttokenpos);
-                ss:=new(pvarsym,init(s,tt));
+                ss:=tvarsym.Create(s,tt);
                 if is_threadvar then
                 if is_threadvar then
-                  include(ss^.varoptions,vo_is_thread_var);
-                st^.insert(ss);
+                  include(ss.varoptions,vo_is_thread_var);
+                st.insert(ss);
                 { static data fields are inserted in the globalsymtable }
                 { static data fields are inserted in the globalsymtable }
-                if (st^.symtabletype=objectsymtable) and
+                if (st.symtabletype=objectsymtable) and
                    (sp_static in current_object_option) then
                    (sp_static in current_object_option) then
                   begin
                   begin
-                     s:='$'+lower(st^.name^)+'_'+upper(s);
-                     st^.defowner^.owner^.insert(new(pvarsym,init(s,tt)));
+                     s:='$'+lower(st.name^)+'_'+upper(s);
+                     st.defowner.owner.insert(tvarsym.create(s,tt));
                   end;
                   end;
              end;
              end;
 {$ifdef fixLeaksOnError}
 {$ifdef fixLeaksOnError}
@@ -98,14 +98,14 @@ implementation
          s : stringid;
          s : stringid;
          old_block_type : tblock_type;
          old_block_type : tblock_type;
          declarepos,storetokenpos : tfileposinfo;
          declarepos,storetokenpos : tfileposinfo;
-         oldsymtablestack : psymtable;
+         oldsymtablestack : tsymtable;
          symdone : boolean;
          symdone : boolean;
          { to handle absolute }
          { to handle absolute }
-         abssym : pabsolutesym;
+         abssym : tabsolutesym;
          l    : longint;
          l    : longint;
          code : integer;
          code : integer;
          { c var }
          { c var }
-         newtype : ptypesym;
+         newtype : ttypesym;
          is_dll,
          is_dll,
          is_gpc_name,is_cdecl,extern_aktvarsym,export_aktvarsym : boolean;
          is_gpc_name,is_cdecl,extern_aktvarsym,export_aktvarsym : boolean;
          old_current_object_option : tsymoptions;
          old_current_object_option : tsymoptions;
@@ -113,17 +113,17 @@ implementation
          C_name : string;
          C_name : string;
          tt,casetype : ttype;
          tt,casetype : ttype;
          { Delphi initialized vars }
          { Delphi initialized vars }
-         pconstsym : ptypedconstsym;
+         tconstsym : ttypedconstsym;
          { maxsize contains the max. size of a variant }
          { maxsize contains the max. size of a variant }
          { startvarrec contains the start of the variant part of a record }
          { startvarrec contains the start of the variant part of a record }
          maxsize,maxalignment,startvarrecalign,startvarrecsize : longint;
          maxsize,maxalignment,startvarrecalign,startvarrecsize : longint;
          pt : tnode;
          pt : tnode;
-         srsym : psym;
-         srsymtable : psymtable;
-         unionsymtable : psymtable;
+         srsym : tsym;
+         srsymtable : tsymtable;
+         unionsymtable : tsymtable;
          offset : longint;
          offset : longint;
-         uniondef : precorddef;
-         unionsym : pvarsym;
+         uniondef : trecorddef;
+         unionsym : tvarsym;
          uniontype : ttype;
          uniontype : ttype;
       begin
       begin
          old_current_object_option:=current_object_option;
          old_current_object_option:=current_object_option;
@@ -166,13 +166,13 @@ implementation
                 { for records, don't search the recordsymtable for
                 { for records, don't search the recordsymtable for
                   the symbols of the types }
                   the symbols of the types }
                     oldsymtablestack:=symtablestack;
                     oldsymtablestack:=symtablestack;
-                    symtablestack:=symtablestack^.next;
+                    symtablestack:=symtablestack.next;
                 read_type(tt,'');
                 read_type(tt,'');
                     symtablestack:=oldsymtablestack;
                     symtablestack:=oldsymtablestack;
                   end
                   end
                  else
                  else
                   read_type(tt,'');
                   read_type(tt,'');
-             if (variantrecordlevel>0) and tt.def^.needs_inittable then
+             if (variantrecordlevel>0) and tt.def.needs_inittable then
                Message(parser_e_cant_use_inittable_here);
                Message(parser_e_cant_use_inittable_here);
              ignore_equal:=false;
              ignore_equal:=false;
              symdone:=false;
              symdone:=false;
@@ -187,9 +187,9 @@ implementation
                      writeln('problem with strContStack in pdecl (3)');
                      writeln('problem with strContStack in pdecl (3)');
 {$endif fixLeaksOnError}
 {$endif fixLeaksOnError}
                   sc.free;
                   sc.free;
-                  aktvarsym:=new(pvarsym,init_C(s,target_os.Cprefix+C_name,tt));
-                  include(aktvarsym^.varoptions,vo_is_external);
-                  symtablestack^.insert(aktvarsym);
+                  aktvarsym:=tvarsym.create_C(s,target_os.Cprefix+C_name,tt);
+                  include(aktvarsym.varoptions,vo_is_external);
+                  symtablestack.insert(aktvarsym);
                   akttokenpos:=storetokenpos;
                   akttokenpos:=storetokenpos;
                   symdone:=true;
                   symdone:=true;
                end;
                end;
@@ -212,14 +212,14 @@ implementation
                  begin
                  begin
                    consume_sym(srsym,srsymtable);
                    consume_sym(srsym,srsymtable);
                    { we should check the result type of srsym }
                    { we should check the result type of srsym }
-                   if not (srsym^.typ in [varsym,typedconstsym,funcretsym]) then
+                   if not (srsym.typ in [varsym,typedconstsym,funcretsym]) then
                      Message(parser_e_absolute_only_to_var_or_const);
                      Message(parser_e_absolute_only_to_var_or_const);
                    storetokenpos:=akttokenpos;
                    storetokenpos:=akttokenpos;
                    akttokenpos:=declarepos;
                    akttokenpos:=declarepos;
-                   abssym:=new(pabsolutesym,init(s,tt));
-                   abssym^.abstyp:=tovar;
-                   abssym^.ref:=pstoredsym(srsym);
-                   symtablestack^.insert(abssym);
+                   abssym:=tabsolutesym.create(s,tt);
+                   abssym.abstyp:=tovar;
+                   abssym.ref:=tstoredsym(srsym);
+                   symtablestack.insert(abssym);
                    akttokenpos:=storetokenpos;
                    akttokenpos:=storetokenpos;
                  end
                  end
                 else
                 else
@@ -227,12 +227,12 @@ implementation
                   begin
                   begin
                     storetokenpos:=akttokenpos;
                     storetokenpos:=akttokenpos;
                     akttokenpos:=declarepos;
                     akttokenpos:=declarepos;
-                    abssym:=new(pabsolutesym,init(s,tt));
+                    abssym:=tabsolutesym.create(s,tt);
                     s:=pattern;
                     s:=pattern;
                     consume(token);
                     consume(token);
-                    abssym^.abstyp:=toasm;
-                    abssym^.asmname:=stringdup(s);
-                    symtablestack^.insert(abssym);
+                    abssym.abstyp:=toasm;
+                    abssym.asmname:=stringdup(s);
+                    symtablestack.insert(abssym);
                     akttokenpos:=storetokenpos;
                     akttokenpos:=storetokenpos;
                   end
                   end
                 else
                 else
@@ -245,12 +245,12 @@ implementation
                      begin
                      begin
                        storetokenpos:=akttokenpos;
                        storetokenpos:=akttokenpos;
                        akttokenpos:=declarepos;
                        akttokenpos:=declarepos;
-                       abssym:=new(pabsolutesym,init(s,tt));
-                       abssym^.abstyp:=toaddr;
-                       abssym^.absseg:=false;
+                       abssym:=tabsolutesym.create(s,tt);
+                       abssym.abstyp:=toaddr;
+                       abssym.absseg:=false;
                        s:=pattern;
                        s:=pattern;
                        consume(_INTCONST);
                        consume(_INTCONST);
-                       val(s,abssym^.address,code);
+                       val(s,abssym.address,code);
                        if (token=_COLON) and
                        if (token=_COLON) and
                          (target_info.target=target_i386_go32v2) then
                          (target_info.target=target_i386_go32v2) then
                         begin
                         begin
@@ -258,10 +258,10 @@ implementation
                           s:=pattern;
                           s:=pattern;
                           consume(_INTCONST);
                           consume(_INTCONST);
                           val(s,l,code);
                           val(s,l,code);
-                          abssym^.address:=abssym^.address shl 4+l;
-                          abssym^.absseg:=true;
+                          abssym.address:=abssym.address shl 4+l;
+                          abssym.absseg:=true;
                         end;
                         end;
-                       symtablestack^.insert(abssym);
+                       symtablestack.insert(abssym);
                        akttokenpos:=storetokenpos;
                        akttokenpos:=storetokenpos;
                      end
                      end
                     else
                     else
@@ -277,31 +277,31 @@ implementation
                - in record or object
                - in record or object
                - ... (PM) }
                - ... (PM) }
              if (m_delphi in aktmodeswitches) and (token=_EQUAL) and
              if (m_delphi in aktmodeswitches) and (token=_EQUAL) and
-                not (symtablestack^.symtabletype in [parasymtable]) and
+                not (symtablestack.symtabletype in [parasymtable]) and
                 not is_record and not is_object then
                 not is_record and not is_object then
                begin
                begin
                   storetokenpos:=akttokenpos;
                   storetokenpos:=akttokenpos;
                   s:=sc.get(akttokenpos);
                   s:=sc.get(akttokenpos);
                   if not sc.empty then
                   if not sc.empty then
                     Message(parser_e_initialized_only_one_var);
                     Message(parser_e_initialized_only_one_var);
-                  pconstsym:=new(ptypedconstsym,inittype(s,tt,false));
-                  symtablestack^.insert(pconstsym);
+                  tconstsym:=ttypedconstsym.createtype(s,tt,false);
+                  symtablestack.insert(tconstsym);
                   akttokenpos:=storetokenpos;
                   akttokenpos:=storetokenpos;
                   consume(_EQUAL);
                   consume(_EQUAL);
-                  readtypedconst(tt,pconstsym,false);
+                  readtypedconst(tt,tconstsym,false);
                   symdone:=true;
                   symdone:=true;
                end;
                end;
              { for a record there doesn't need to be a ; before the END or ) }
              { for a record there doesn't need to be a ; before the END or ) }
              if not((is_record or is_object) and (token in [_END,_RKLAMMER])) then
              if not((is_record or is_object) and (token in [_END,_RKLAMMER])) then
                consume(_SEMICOLON);
                consume(_SEMICOLON);
              { procvar handling }
              { procvar handling }
-             if (tt.def^.deftype=procvardef) and (tt.def^.typesym=nil) then
+             if (tt.def.deftype=procvardef) and (tt.def.typesym=nil) then
                begin
                begin
-                  newtype:=new(ptypesym,init('unnamed',tt));
-                  parse_var_proc_directives(psym(newtype));
-                  newtype^.restype.def:=nil;
-                  tt.def^.typesym:=nil;
-                  dispose(newtype,done);
+                  newtype:=ttypesym.create('unnamed',tt);
+                  parse_var_proc_directives(tsym(newtype));
+                  newtype.restype.def:=nil;
+                  tt.def.typesym:=nil;
+                  newtype.free;
                end;
                end;
              { Check for variable directives }
              { Check for variable directives }
              if not symdone and (token=_ID) then
              if not symdone and (token=_ID) then
@@ -344,7 +344,7 @@ implementation
                     begin
                     begin
                       consume(_ID);
                       consume(_ID);
                       if extern_aktvarsym or
                       if extern_aktvarsym or
-                         (symtablestack^.symtabletype in [parasymtable,localsymtable]) then
+                         (symtablestack.symtabletype in [parasymtable,localsymtable]) then
                        Message(parser_e_not_external_and_export)
                        Message(parser_e_not_external_and_export)
                       else
                       else
                        export_aktvarsym:=true;
                        export_aktvarsym:=true;
@@ -368,19 +368,19 @@ implementation
                    storetokenpos:=akttokenpos;
                    storetokenpos:=akttokenpos;
                    akttokenpos:=declarepos;
                    akttokenpos:=declarepos;
                    if is_dll then
                    if is_dll then
-                    aktvarsym:=new(pvarsym,init_dll(s,tt))
+                    aktvarsym:=tvarsym.create_dll(s,tt)
                    else
                    else
-                    aktvarsym:=new(pvarsym,init_C(s,C_name,tt));
+                    aktvarsym:=tvarsym.create_C(s,C_name,tt);
                    { set some vars options }
                    { set some vars options }
                    if export_aktvarsym then
                    if export_aktvarsym then
                     begin
                     begin
-                      inc(aktvarsym^.refs);
-                      include(aktvarsym^.varoptions,vo_is_exported);
+                      inc(aktvarsym.refs);
+                      include(aktvarsym.varoptions,vo_is_exported);
                     end;
                     end;
                    if extern_aktvarsym then
                    if extern_aktvarsym then
-                    include(aktvarsym^.varoptions,vo_is_external);
+                    include(aktvarsym.varoptions,vo_is_external);
                    { insert in the stack/datasegment }
                    { insert in the stack/datasegment }
-                   symtablestack^.insert(aktvarsym);
+                   symtablestack.insert(aktvarsym);
                    akttokenpos:=storetokenpos;
                    akttokenpos:=storetokenpos;
                    { now we can insert it in the import lib if its a dll, or
                    { now we can insert it in the import lib if its a dll, or
                      add it to the externals }
                      add it to the externals }
@@ -393,11 +393,11 @@ implementation
                             current_module.uses_imports:=true;
                             current_module.uses_imports:=true;
                             importlib.preparelib(current_module.modulename^);
                             importlib.preparelib(current_module.modulename^);
                           end;
                           end;
-                         importlib.importvariable(aktvarsym^.mangledname,dll_name,C_name)
+                         importlib.importvariable(aktvarsym.mangledname,dll_name,C_name)
                        end
                        end
                       else
                       else
                        if target_info.DllScanSupported then
                        if target_info.DllScanSupported then
-                        current_module.Externals.insert(tExternalsItem.create(aktvarsym^.mangledname));
+                        current_module.Externals.insert(tExternalsItem.create(aktvarsym.mangledname));
                     end;
                     end;
                    symdone:=true;
                    symdone:=true;
                  end
                  end
@@ -424,7 +424,7 @@ implementation
                    end
                    end
                   else
                   else
                    if (sp_published in current_object_option) and
                    if (sp_published in current_object_option) and
-                      not(oo_can_have_published in pobjectdef(tt.def)^.objectoptions) then
+                      not(oo_can_have_published in tobjectdef(tt.def).objectoptions) then
                     begin
                     begin
                       Message(parser_e_only_publishable_classes_can__be_published);
                       Message(parser_e_only_publishable_classes_can__be_published);
                       exclude(current_object_option,sp_published);
                       exclude(current_object_option,sp_published);
@@ -442,12 +442,12 @@ implementation
               s:=pattern;
               s:=pattern;
               searchsym(s,srsym,srsymtable);
               searchsym(s,srsym,srsymtable);
               { may be only a type: }
               { may be only a type: }
-              if assigned(srsym) and (srsym^.typ in [typesym,unitsym]) then
+              if assigned(srsym) and (srsym.typ in [typesym,unitsym]) then
                begin
                begin
                  { for records, don't search the recordsymtable for
                  { for records, don't search the recordsymtable for
                    the symbols of the types }
                    the symbols of the types }
                  oldsymtablestack:=symtablestack;
                  oldsymtablestack:=symtablestack;
-                 symtablestack:=symtablestack^.next;
+                 symtablestack:=symtablestack.next;
                  read_type(casetype,'');
                  read_type(casetype,'');
                  symtablestack:=oldsymtablestack;
                  symtablestack:=oldsymtablestack;
                end
                end
@@ -458,22 +458,22 @@ implementation
                   { for records, don't search the recordsymtable for
                   { for records, don't search the recordsymtable for
                     the symbols of the types }
                     the symbols of the types }
                   oldsymtablestack:=symtablestack;
                   oldsymtablestack:=symtablestack;
-                  symtablestack:=symtablestack^.next;
+                  symtablestack:=symtablestack.next;
                   read_type(casetype,'');
                   read_type(casetype,'');
                   symtablestack:=oldsymtablestack;
                   symtablestack:=oldsymtablestack;
-                  symtablestack^.insert(new(pvarsym,init(s,casetype)));
+                  symtablestack.insert(tvarsym.create(s,casetype));
                 end;
                 end;
               if not(is_ordinal(casetype.def)) or is_64bitint(casetype.def)  then
               if not(is_ordinal(casetype.def)) or is_64bitint(casetype.def)  then
                Message(type_e_ordinal_expr_expected);
                Message(type_e_ordinal_expr_expected);
               consume(_OF);
               consume(_OF);
-              UnionSymtable:=new(pstoredsymtable,init(recordsymtable));
-              UnionSymtable^.next:=symtablestack;
+              UnionSymtable:=trecordsymtable.create;
+              Unionsymtable.next:=symtablestack;
               registerdef:=false;
               registerdef:=false;
-              UnionDef:=new(precorddef,init(unionsymtable));
+              UnionDef:=trecorddef.create(unionsymtable);
               registerdef:=true;
               registerdef:=true;
               symtablestack:=UnionSymtable;
               symtablestack:=UnionSymtable;
-              startvarrecsize:=symtablestack^.datasize;
-              startvarrecalign:=symtablestack^.dataalignment;
+              startvarrecsize:=symtablestack.datasize;
+              startvarrecalign:=symtablestack.dataalignment;
               repeat
               repeat
                 repeat
                 repeat
                   pt:=comp_expr(true);
                   pt:=comp_expr(true);
@@ -494,33 +494,33 @@ implementation
                 dec(variantrecordlevel);
                 dec(variantrecordlevel);
                 consume(_RKLAMMER);
                 consume(_RKLAMMER);
                 { calculates maximal variant size }
                 { calculates maximal variant size }
-                maxsize:=max(maxsize,symtablestack^.datasize);
-                maxalignment:=max(maxalignment,symtablestack^.dataalignment);
+                maxsize:=max(maxsize,symtablestack.datasize);
+                maxalignment:=max(maxalignment,symtablestack.dataalignment);
                 { the items of the next variant are overlayed }
                 { the items of the next variant are overlayed }
-                symtablestack^.datasize:=startvarrecsize;
-                symtablestack^.dataalignment:=startvarrecalign;
+                symtablestack.datasize:=startvarrecsize;
+                symtablestack.dataalignment:=startvarrecalign;
                 if (token<>_END) and (token<>_RKLAMMER) then
                 if (token<>_END) and (token<>_RKLAMMER) then
                   consume(_SEMICOLON)
                   consume(_SEMICOLON)
                 else
                 else
                   break;
                   break;
               until (token=_END) or (token=_RKLAMMER);
               until (token=_END) or (token=_RKLAMMER);
               { at last set the record size to that of the biggest variant }
               { at last set the record size to that of the biggest variant }
-              symtablestack^.datasize:=maxsize;
-              symtablestack^.dataalignment:=maxalignment;
+              symtablestack.datasize:=maxsize;
+              symtablestack.dataalignment:=maxalignment;
               uniontype.def:=uniondef;
               uniontype.def:=uniondef;
               uniontype.sym:=nil;
               uniontype.sym:=nil;
-              UnionSym:=new(pvarsym,init('case',uniontype));
-              symtablestack:=symtablestack^.next;
-              { we do NOT call symtablestack^.insert
+              UnionSym:=tvarsym.create('case',uniontype);
+              symtablestack:=symtablestack.next;
+              { we do NOT call symtablestack.insert
                on purpose PM }
                on purpose PM }
-              offset:=align_from_size(symtablestack^.datasize,maxalignment);
-              symtablestack^.datasize:=offset+unionsymtable^.datasize;
-              if maxalignment>symtablestack^.dataalignment then
-                symtablestack^.dataalignment:=maxalignment;
-              pstoredsymtable(UnionSymtable)^.Insert_in(symtablestack,offset);
-              UnionSym^.owner:=nil;
-              dispose(unionsym,done);
-              dispose(uniondef,done);
+              offset:=align_from_size(symtablestack.datasize,maxalignment);
+              symtablestack.datasize:=offset+unionsymtable.datasize;
+              if maxalignment>symtablestack.dataalignment then
+                symtablestack.dataalignment:=maxalignment;
+              trecordsymtable(Unionsymtable).Insert_in(symtablestack,offset);
+              Unionsym.owner:=nil;
+              unionsym.free;
+              uniondef.free;
            end;
            end;
          block_type:=old_block_type;
          block_type:=old_block_type;
          current_object_option:=old_current_object_option;
          current_object_option:=old_current_object_option;
@@ -529,7 +529,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2001-04-04 22:43:52  peter
+  Revision 1.15  2001-04-13 01:22:12  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.14  2001/04/04 22:43:52  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.13  2001/04/04 21:30:45  florian
   Revision 1.13  2001/04/04 21:30:45  florian

+ 19 - 14
compiler/pexports.pas

@@ -39,9 +39,9 @@ implementation
        globals,tokens,verbose,
        globals,tokens,verbose,
        systems,
        systems,
        { symtable }
        { symtable }
-       symconst,symbase,symtype,symdef,symsym,symtable,
+       symconst,symbase,symtype,symdef,symsym,
        { pass 1 }
        { pass 1 }
-       node,pass_1,
+       node,
        ncon,
        ncon,
        { parser }
        { parser }
        scanner,
        scanner,
@@ -58,8 +58,8 @@ implementation
          DefString : string;
          DefString : string;
          InternalProcName : string;
          InternalProcName : string;
          pt               : tnode;
          pt               : tnode;
-         srsym            : psym;
-         srsymtable : psymtable;
+         srsym            : tsym;
+         srsymtable : tsymtable;
       begin
       begin
          DefString:='';
          DefString:='';
          InternalProcName:='';
          InternalProcName:='';
@@ -72,16 +72,16 @@ implementation
                    orgs:=orgpattern;
                    orgs:=orgpattern;
                    consume_sym(srsym,srsymtable);
                    consume_sym(srsym,srsymtable);
                    hp.sym:=srsym;
                    hp.sym:=srsym;
-                   if ((hp.sym^.typ<>procsym) or
+                   if ((hp.sym.typ<>procsym) or
                        ((tf_need_export in target_info.flags) and
                        ((tf_need_export in target_info.flags) and
-                        not(po_exports in pprocdef(pprocsym(srsym)^.definition)^.procoptions)
+                        not(po_exports in tprocdef(tprocsym(srsym).definition).procoptions)
                        )
                        )
                       ) and
                       ) and
-                      (srsym^.typ<>varsym) and (srsym^.typ<>typedconstsym) then
+                      (srsym.typ<>varsym) and (srsym.typ<>typedconstsym) then
                     Message(parser_e_illegal_symbol_exported)
                     Message(parser_e_illegal_symbol_exported)
                    else
                    else
                     begin
                     begin
-                      InternalProcName:=srsym^.mangledname;
+                      InternalProcName:=srsym.mangledname;
                       { This is wrong if the first is not
                       { This is wrong if the first is not
                         an underline }
                         an underline }
                       if InternalProcName[1]='_' then
                       if InternalProcName[1]='_' then
@@ -93,7 +93,7 @@ implementation
                         end;
                         end;
                       if length(InternalProcName)<2 then
                       if length(InternalProcName)<2 then
                        Message(parser_e_procname_to_short_for_export);
                        Message(parser_e_procname_to_short_for_export);
-                      DefString:=srsym^.realname+'='+InternalProcName;
+                      DefString:=srsym.realname+'='+InternalProcName;
                     end;
                     end;
                    if (idtoken=_INDEX) then
                    if (idtoken=_INDEX) then
                     begin
                     begin
@@ -109,9 +109,9 @@ implementation
                       hp.options:=hp.options or eo_index;
                       hp.options:=hp.options or eo_index;
                       pt.free;
                       pt.free;
                       if target_os.id=os_i386_win32 then
                       if target_os.id=os_i386_win32 then
-                       DefString:=srsym^.realname+'='+InternalProcName+' @ '+tostr(hp.index)
+                       DefString:=srsym.realname+'='+InternalProcName+' @ '+tostr(hp.index)
                       else
                       else
-                       DefString:=srsym^.realname+'='+InternalProcName; {Index ignored!}
+                       DefString:=srsym.realname+'='+InternalProcName; {Index ignored!}
                     end;
                     end;
                    if (idtoken=_NAME) then
                    if (idtoken=_NAME) then
                     begin
                     begin
@@ -132,7 +132,7 @@ implementation
                     begin
                     begin
                       consume(_RESIDENT);
                       consume(_RESIDENT);
                       hp.options:=hp.options or eo_resident;
                       hp.options:=hp.options or eo_resident;
-                      DefString:=srsym^.realname+'='+InternalProcName;{Resident ignored!}
+                      DefString:=srsym.realname+'='+InternalProcName;{Resident ignored!}
                     end;
                     end;
                    if (DefString<>'') and UseDeffileForExport then
                    if (DefString<>'') and UseDeffileForExport then
                     DefFile.AddExport(DefString);
                     DefFile.AddExport(DefString);
@@ -142,7 +142,7 @@ implementation
                       hp.name:=stringdup(orgs);
                       hp.name:=stringdup(orgs);
                       hp.options:=hp.options or eo_name;
                       hp.options:=hp.options or eo_name;
                     end;
                     end;
-                   if hp.sym^.typ=procsym then
+                   if hp.sym.typ=procsym then
                     exportlib.exportprocedure(hp)
                     exportlib.exportprocedure(hp)
                    else
                    else
                     exportlib.exportvar(hp);
                     exportlib.exportvar(hp);
@@ -163,7 +163,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-04 22:43:52  peter
+  Revision 1.14  2001-04-13 01:22:12  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2001/04/04 22:43:52  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.12  2001/03/11 22:58:50  peter
   Revision 1.12  2001/03/11 22:58:50  peter

File diff suppressed because it is too large
+ 190 - 187
compiler/pexpr.pas


+ 129 - 146
compiler/pmodules.pas

@@ -45,9 +45,9 @@ implementation
 
 
     uses
     uses
        globtype,version,systems,tokens,
        globtype,version,systems,tokens,
-       cutils,cobjects,comphook,
+       cutils,comphook,
        globals,verbose,fmodule,finput,
        globals,verbose,fmodule,finput,
-       symconst,symbase,symppu,symdef,symsym,symtable,aasm,types,
+       symconst,symbase,symppu,symdef,symsym,symtable,aasm,
 {$ifdef newcg}
 {$ifdef newcg}
        cgbase,
        cgbase,
 {$else newcg}
 {$else newcg}
@@ -76,16 +76,19 @@ implementation
            (not current_module.linkOtherSharedLibs.Empty) then
            (not current_module.linkOtherSharedLibs.Empty) then
          begin
          begin
            { Init DLLScanner }
            { Init DLLScanner }
+           DLLScanner:=nil;
            case target_info.target of
            case target_info.target of
+             target_none :
+               ;
 {$ifdef i386}
 {$ifdef i386}
   {$ifndef NOTARGETWIN32}
   {$ifndef NOTARGETWIN32}
              target_i386_win32 :
              target_i386_win32 :
                DLLScanner:=tDLLscannerWin32.create;
                DLLScanner:=tDLLscannerWin32.create;
-  {$endif}
+  {$endif NOTARGETWIN32}
 {$endif}
 {$endif}
-             else
-               internalerror(769795413);
            end;
            end;
+           if DLLScanner=nil then
+            internalerror(200104121);
            { Walk all shared libs }
            { Walk all shared libs }
            While not current_module.linkOtherSharedLibs.Empty do
            While not current_module.linkOtherSharedLibs.Empty do
             begin
             begin
@@ -405,7 +408,8 @@ implementation
            pu:=tused_unit(pu.next);
            pu:=tused_unit(pu.next);
          end;
          end;
       { ok, now load the unit }
       { ok, now load the unit }
-        current_module.globalsymtable:=new(punitsymtable,loadasunit);
+        current_module.globalsymtable:=tglobalsymtable.create(current_module.modulename^);
+        tglobalsymtable(current_module.globalsymtable).load;
       { now only read the implementation part }
       { now only read the implementation part }
         current_module.in_implementation:=true;
         current_module.in_implementation:=true;
       { load the used units from implementation }
       { load the used units from implementation }
@@ -445,7 +449,7 @@ implementation
          end;
          end;
         { load browser info if stored }
         { load browser info if stored }
         if ((current_module.flags and uf_has_browser)<>0) and load_refs then
         if ((current_module.flags and uf_has_browser)<>0) and load_refs then
-          punitsymtable(current_module.globalsymtable)^.load_symtable_refs;
+          tglobalsymtable(current_module.globalsymtable).load_symtable_refs;
         { remove the map, it's not needed anymore }
         { remove the map, it's not needed anymore }
         dispose(current_module.map);
         dispose(current_module.map);
         current_module.map:=nil;
         current_module.map:=nil;
@@ -456,7 +460,7 @@ implementation
       const
       const
         ImplIntf : array[boolean] of string[15]=('interface','implementation');
         ImplIntf : array[boolean] of string[15]=('interface','implementation');
       var
       var
-        st : punitsymtable;
+        st : tglobalsymtable;
         second_time : boolean;
         second_time : boolean;
         old_current_ppu : pppufile;
         old_current_ppu : pppufile;
         old_current_module,hp,hp2 : tmodule;
         old_current_module,hp,hp2 : tmodule;
@@ -556,7 +560,7 @@ implementation
                    { is already compiled              }
                    { is already compiled              }
                    { else there is a cyclic unit use  }
                    { else there is a cyclic unit use  }
                    if assigned(hp.globalsymtable) then
                    if assigned(hp.globalsymtable) then
-                     st:=punitsymtable(hp.globalsymtable)
+                     st:=tglobalsymtable(hp.globalsymtable)
                    else
                    else
                     begin
                     begin
                     { both units in interface ? }
                     { both units in interface ? }
@@ -657,7 +661,7 @@ implementation
     procedure loaddefaultunits;
     procedure loaddefaultunits;
       var
       var
         hp : tmodule;
         hp : tmodule;
-        unitsym : punitsym;
+        unitsym : tunitsym;
       begin
       begin
       { are we compiling the system unit? }
       { are we compiling the system unit? }
         if (cs_compilesystem in aktmoduleswitches) then
         if (cs_compilesystem in aktmoduleswitches) then
@@ -669,51 +673,42 @@ implementation
          end;
          end;
      { insert the system unit, it is allways the first }
      { insert the system unit, it is allways the first }
         hp:=loadunit('SYSTEM',true);
         hp:=loadunit('SYSTEM',true);
-        systemunit:=hp.globalsymtable;
+        systemunit:=tglobalsymtable(hp.globalsymtable);
         { it's always the first unit }
         { it's always the first unit }
-        systemunit^.next:=nil;
+        systemunit.next:=nil;
         symtablestack:=systemunit;
         symtablestack:=systemunit;
         { add to the used units }
         { add to the used units }
         current_module.used_units.concat(tused_unit.create(hp,true));
         current_module.used_units.concat(tused_unit.create(hp,true));
-        unitsym:=new(punitsym,init('System',systemunit));
-        inc(unitsym^.refs);
-        refsymtable^.insert(unitsym);
+        unitsym:=tunitsym.create('System',systemunit);
+        inc(unitsym.refs);
+        refsymtable.insert(unitsym);
         { read default constant definitions }
         { read default constant definitions }
         make_ref:=false;
         make_ref:=false;
         readconstdefs;
         readconstdefs;
-        { if POWER is defined in the RTL then use it for starstar overloading }
-{$ifdef DONOTCHAINOPERATORS}
-        getsym('POWER',false);
-{$endif DONOTCHAINOPERATORS}
         make_ref:=true;
         make_ref:=true;
-{$ifdef DONOTCHAINOPERATORS}
-        { Code now in chainoperators PM }
-        if assigned(srsym) and (srsym^.typ=procsym) and (overloaded_operators[_STARSTAR]=nil) then
-          overloaded_operators[_STARSTAR]:=pprocsym(srsym);
-{$endif DONOTCHAINOPERATORS}
       { Objpas unit? }
       { Objpas unit? }
         if m_objpas in aktmodeswitches then
         if m_objpas in aktmodeswitches then
          begin
          begin
            hp:=loadunit('ObjPas',false);
            hp:=loadunit('ObjPas',false);
-           psymtable(hp.globalsymtable)^.next:=symtablestack;
+           tsymtable(hp.globalsymtable).next:=symtablestack;
            symtablestack:=hp.globalsymtable;
            symtablestack:=hp.globalsymtable;
            { add to the used units }
            { add to the used units }
            current_module.used_units.concat(tused_unit.create(hp,true));
            current_module.used_units.concat(tused_unit.create(hp,true));
-           unitsym:=new(punitsym,init('ObjPas',hp.globalsymtable));
-           inc(unitsym^.refs);
-           refsymtable^.insert(unitsym);
+           unitsym:=tunitsym.create('ObjPas',hp.globalsymtable);
+           inc(unitsym.refs);
+           refsymtable.insert(unitsym);
          end;
          end;
       { Profile unit? Needed for go32v2 only }
       { Profile unit? Needed for go32v2 only }
         if (cs_profile in aktmoduleswitches) and (target_info.target=target_i386_go32v2) then
         if (cs_profile in aktmoduleswitches) and (target_info.target=target_i386_go32v2) then
          begin
          begin
            hp:=loadunit('Profile',false);
            hp:=loadunit('Profile',false);
-           psymtable(hp.globalsymtable)^.next:=symtablestack;
+           tsymtable(hp.globalsymtable).next:=symtablestack;
            symtablestack:=hp.globalsymtable;
            symtablestack:=hp.globalsymtable;
            { add to the used units }
            { add to the used units }
            current_module.used_units.concat(tused_unit.create(hp,true));
            current_module.used_units.concat(tused_unit.create(hp,true));
-           unitsym:=new(punitsym,init('Profile',hp.globalsymtable));
-           inc(unitsym^.refs);
-           refsymtable^.insert(unitsym);
+           unitsym:=tunitsym.create('Profile',hp.globalsymtable);
+           inc(unitsym.refs);
+           refsymtable.insert(unitsym);
          end;
          end;
       { Units only required for main module }
       { Units only required for main module }
         if not(current_module.is_unit) then
         if not(current_module.is_unit) then
@@ -722,25 +717,25 @@ implementation
            if (cs_gdb_heaptrc in aktglobalswitches) then
            if (cs_gdb_heaptrc in aktglobalswitches) then
             begin
             begin
               hp:=loadunit('HeapTrc',false);
               hp:=loadunit('HeapTrc',false);
-              psymtable(hp.globalsymtable)^.next:=symtablestack;
+              tsymtable(hp.globalsymtable).next:=symtablestack;
               symtablestack:=hp.globalsymtable;
               symtablestack:=hp.globalsymtable;
               { add to the used units }
               { add to the used units }
               current_module.used_units.concat(tused_unit.create(hp,true));
               current_module.used_units.concat(tused_unit.create(hp,true));
-              unitsym:=new(punitsym,init('HeapTrc',hp.globalsymtable));
-              inc(unitsym^.refs);
-              refsymtable^.insert(unitsym);
+              unitsym:=tunitsym.create('HeapTrc',hp.globalsymtable);
+              inc(unitsym.refs);
+              refsymtable.insert(unitsym);
             end;
             end;
            { Lineinfo unit }
            { Lineinfo unit }
            if (cs_gdb_lineinfo in aktglobalswitches) then
            if (cs_gdb_lineinfo in aktglobalswitches) then
             begin
             begin
               hp:=loadunit('LineInfo',false);
               hp:=loadunit('LineInfo',false);
-              psymtable(hp.globalsymtable)^.next:=symtablestack;
+              tsymtable(hp.globalsymtable).next:=symtablestack;
               symtablestack:=hp.globalsymtable;
               symtablestack:=hp.globalsymtable;
               { add to the used units }
               { add to the used units }
               current_module.used_units.concat(tused_unit.create(hp,true));
               current_module.used_units.concat(tused_unit.create(hp,true));
-              unitsym:=new(punitsym,init('LineInfo',hp.globalsymtable));
-              inc(unitsym^.refs);
-              refsymtable^.insert(unitsym);
+              unitsym:=tunitsym.create('LineInfo',hp.globalsymtable);
+              inc(unitsym.refs);
+              refsymtable.insert(unitsym);
             end;
             end;
          end;
          end;
       { save default symtablestack }
       { save default symtablestack }
@@ -754,9 +749,9 @@ implementation
          pu,
          pu,
          hp : tused_unit;
          hp : tused_unit;
          hp2 : tmodule;
          hp2 : tmodule;
-         hp3 : psymtable;
-         oldprocsym:Pprocsym;
-         unitsym : punitsym;
+         hp3 : tsymtable;
+         oldprocsym:tprocsym;
+         unitsym : tunitsym;
       begin
       begin
          oldprocsym:=aktprocsym;
          oldprocsym:=aktprocsym;
          consume(_USES);
          consume(_USES);
@@ -788,12 +783,12 @@ implementation
               tused_unit(current_module.used_units.last).in_uses:=true;
               tused_unit(current_module.used_units.last).in_uses:=true;
               if current_module.compiled then
               if current_module.compiled then
                 exit;
                 exit;
-              unitsym:=new(punitsym,init(sorg,hp2.globalsymtable));
+              unitsym:=tunitsym.create(sorg,hp2.globalsymtable);
               { never claim about unused unit if
               { never claim about unused unit if
                 there is init or finalize code  PM }
                 there is init or finalize code  PM }
               if (hp2.flags and (uf_init or uf_finalize))<>0 then
               if (hp2.flags and (uf_init or uf_finalize))<>0 then
-                inc(unitsym^.refs);
-              refsymtable^.insert(unitsym);
+                inc(unitsym.refs);
+              refsymtable.insert(unitsym);
             end
             end
            else
            else
             Message1(sym_e_duplicate_id,s);
             Message1(sym_e_duplicate_id,s);
@@ -819,9 +814,9 @@ implementation
                  (cs_gdb_dbx in aktglobalswitches) and
                  (cs_gdb_dbx in aktglobalswitches) and
                 not hp.is_stab_written then
                 not hp.is_stab_written then
                 begin
                 begin
-                   punitsymtable(hp.u.globalsymtable)^.concattypestabto(debuglist);
+                   tglobalsymtable(hp.u.globalsymtable).concattypestabto(debuglist);
                    hp.is_stab_written:=true;
                    hp.is_stab_written:=true;
-                   hp.unitid:=psymtable(hp.u.globalsymtable)^.unitid;
+                   hp.unitid:=tsymtable(hp.u.globalsymtable).unitid;
                 end;
                 end;
 {$EndIf GDB}
 {$EndIf GDB}
               if hp.in_uses then
               if hp.in_uses then
@@ -832,14 +827,14 @@ implementation
                         { insert units only once ! }
                         { insert units only once ! }
                         if hp.u.globalsymtable=hp3 then
                         if hp.u.globalsymtable=hp3 then
                           break;
                           break;
-                        hp3:=hp3^.next;
+                        hp3:=hp3.next;
                         { unit isn't inserted }
                         { unit isn't inserted }
                         if hp3=nil then
                         if hp3=nil then
                           begin
                           begin
-                             psymtable(hp.u.globalsymtable)^.next:=symtablestack;
-                             symtablestack:=psymtable(hp.u.globalsymtable);
+                             tsymtable(hp.u.globalsymtable).next:=symtablestack;
+                             symtablestack:=tsymtable(hp.u.globalsymtable);
 {$ifdef CHAINPROCSYMS}
 {$ifdef CHAINPROCSYMS}
-                             symtablestack^.chainprocsyms;
+                             symtablestack.chainprocsyms;
 {$endif CHAINPROCSYMS}
 {$endif CHAINPROCSYMS}
 {$ifdef DEBUG}
 {$ifdef DEBUG}
                              test_symtablestack;
                              test_symtablestack;
@@ -863,13 +858,13 @@ implementation
          if (cs_gdb_dbx in aktglobalswitches) then
          if (cs_gdb_dbx in aktglobalswitches) then
            begin
            begin
              debugList.concat(Tai_asm_comment.Create(strpnew('EINCL of global '+
              debugList.concat(Tai_asm_comment.Create(strpnew('EINCL of global '+
-               punitsymtable(current_module.globalsymtable)^.name^+' has index '+
-               tostr(punitsymtable(current_module.globalsymtable)^.unitid))));
+               tglobalsymtable(current_module.globalsymtable).name^+' has index '+
+               tostr(tglobalsymtable(current_module.globalsymtable).unitid))));
              debugList.concat(Tai_stabs.Create(strpnew('"'+
              debugList.concat(Tai_stabs.Create(strpnew('"'+
-               punitsymtable(current_module.globalsymtable)^.name^+'",'+
+               tglobalsymtable(current_module.globalsymtable).name^+'",'+
                tostr(N_EINCL)+',0,0,0')));
                tostr(N_EINCL)+',0,0,0')));
-             punitsymtable(current_module.globalsymtable)^.dbx_count_ok:={true}false;
-             dbx_counter:=punitsymtable(current_module.globalsymtable)^.prev_dbx_counter;
+             tglobalsymtable(current_module.globalsymtable).dbx_count_ok:={true}false;
+             dbx_counter:=tglobalsymtable(current_module.globalsymtable).prev_dbx_counter;
              do_count_dbx:=false;
              do_count_dbx:=false;
            end;
            end;
 
 
@@ -880,9 +875,9 @@ implementation
               if (cs_debuginfo in aktmoduleswitches) and
               if (cs_debuginfo in aktmoduleswitches) and
                 not hp.is_stab_written then
                 not hp.is_stab_written then
                 begin
                 begin
-                   punitsymtable(hp.u.globalsymtable)^.concattypestabto(debuglist);
+                   tglobalsymtable(hp.u.globalsymtable).concattypestabto(debuglist);
                    hp.is_stab_written:=true;
                    hp.is_stab_written:=true;
-                   hp.unitid:=psymtable(hp.u.globalsymtable)^.unitid;
+                   hp.unitid:=tsymtable(hp.u.globalsymtable).unitid;
                 end;
                 end;
               hp:=tused_unit(hp.next);
               hp:=tused_unit(hp.next);
            end;
            end;
@@ -890,16 +885,16 @@ implementation
             assigned(current_module.localsymtable) then
             assigned(current_module.localsymtable) then
            begin
            begin
               { all types }
               { all types }
-              punitsymtable(current_module.localsymtable)^.concattypestabto(debuglist);
+              tstaticsymtable(current_module.localsymtable).concattypestabto(debuglist);
               { and all local symbols}
               { and all local symbols}
-              punitsymtable(current_module.localsymtable)^.concatstabto(debuglist);
+              tstaticsymtable(current_module.localsymtable).concatstabto(debuglist);
            end
            end
          else if assigned(current_module.globalsymtable) then
          else if assigned(current_module.globalsymtable) then
            begin
            begin
               { all types }
               { all types }
-              punitsymtable(current_module.globalsymtable)^.concattypestabto(debuglist);
+              tglobalsymtable(current_module.globalsymtable).concattypestabto(debuglist);
               { and all local symbols}
               { and all local symbols}
-              punitsymtable(current_module.globalsymtable)^.concatstabto(debuglist);
+              tglobalsymtable(current_module.globalsymtable).concatstabto(debuglist);
            end;
            end;
        end;
        end;
 {$Else GDB}
 {$Else GDB}
@@ -908,13 +903,11 @@ implementation
 {$EndIf GDB}
 {$EndIf GDB}
 
 
 
 
-    procedure parse_implementation_uses(symt:Psymtable);
+    procedure parse_implementation_uses(symt:tsymtable);
       begin
       begin
          if token=_USES then
          if token=_USES then
            begin
            begin
-              symt^.symtabletype:=unitsymtable;
               loadunits;
               loadunits;
-              symt^.symtabletype:=globalsymtable;
 {$ifdef DEBUG}
 {$ifdef DEBUG}
               test_symtablestack;
               test_symtablestack;
 {$endif DEBUG}
 {$endif DEBUG}
@@ -944,30 +937,30 @@ implementation
       end;
       end;
 
 
 
 
-    procedure gen_main_procsym(const name:string;options:tproctypeoption;st:psymtable);
+    procedure gen_main_procsym(const name:string;options:tproctypeoption;st:tsymtable);
       var
       var
-        stt : psymtable;
+        stt : tsymtable;
       begin
       begin
         {Generate a procsym for main}
         {Generate a procsym for main}
         make_ref:=false;
         make_ref:=false;
-        aktprocsym:=new(Pprocsym,init('$'+name));
+        aktprocsym:=tprocsym.create('$'+name);
         { main are allways used }
         { main are allways used }
-        inc(aktprocsym^.refs);
+        inc(aktprocsym.refs);
         {Try to insert in in static symtable ! }
         {Try to insert in in static symtable ! }
         stt:=symtablestack;
         stt:=symtablestack;
         symtablestack:=st;
         symtablestack:=st;
-        aktprocsym^.definition:=new(Pprocdef,init);
+        aktprocsym.definition:=tprocdef.create;
         symtablestack:=stt;
         symtablestack:=stt;
-        aktprocsym^.definition^.proctypeoption:=options;
-        aktprocsym^.definition^.setmangledname(target_os.cprefix+name);
-        aktprocsym^.definition^.forwarddef:=false;
+        aktprocsym.definition.proctypeoption:=options;
+        aktprocsym.definition.setmangledname(target_os.cprefix+name);
+        aktprocsym.definition.forwarddef:=false;
         make_ref:=true;
         make_ref:=true;
         { The localst is a local symtable. Change it into the static
         { The localst is a local symtable. Change it into the static
           symtable }
           symtable }
-        dispose(aktprocsym^.definition^.localst,done);
-        aktprocsym^.definition^.localst:=st;
+        aktprocsym.definition.localst.free;
+        aktprocsym.definition.localst:=st;
         { and insert the procsym in symtable }
         { and insert the procsym in symtable }
-        st^.insert(aktprocsym);
+        st.insert(aktprocsym);
         { set some informations about the main program }
         { set some informations about the main program }
         with procinfo^ do
         with procinfo^ do
          begin
          begin
@@ -997,8 +990,8 @@ implementation
 
 
       var
       var
          main_file: tinputfile;
          main_file: tinputfile;
-         st     : psymtable;
-         unitst : punitsymtable;
+         st     : tsymtable;
+         unitst : tglobalsymtable;
 {$ifdef GDB}
 {$ifdef GDB}
          pu     : tused_unit;
          pu     : tused_unit;
 {$endif GDB}
 {$endif GDB}
@@ -1073,9 +1066,9 @@ implementation
          parse_only:=true;
          parse_only:=true;
 
 
          { generate now the global symboltable }
          { generate now the global symboltable }
-         st:=new(punitsymtable,init(globalsymtable,current_module.modulename^));
+         st:=tglobalsymtable.create(current_module.modulename^);
          refsymtable:=st;
          refsymtable:=st;
-         unitst:=punitsymtable(st);
+         unitst:=tglobalsymtable(st);
          { define first as local to overcome dependency conflicts }
          { define first as local to overcome dependency conflicts }
          current_module.localsymtable:=st;
          current_module.localsymtable:=st;
 
 
@@ -1083,11 +1076,7 @@ implementation
          { inside the unit itself (PM)                }
          { inside the unit itself (PM)                }
          { this also forbids to have another symbol      }
          { this also forbids to have another symbol      }
          { with the same name as the unit                  }
          { with the same name as the unit                  }
-         refsymtable^.insert(new(punitsym,init(current_module.realmodulename^,unitst)));
-
-         { a unit compiled at command line must be inside the loaded_unit list }
-         if (compile_level=1) then
-           loaded_units.insert(current_module);
+         refsymtable.insert(tunitsym.create(current_module.realmodulename^,unitst));
 
 
          { load default units, like the system unit }
          { load default units, like the system unit }
          loaddefaultunits;
          loaddefaultunits;
@@ -1101,7 +1090,6 @@ implementation
            begin
            begin
               if token=_USES then
               if token=_USES then
                 begin
                 begin
-                   unitst^.symtabletype:=unitsymtable;
                    loadunits;
                    loadunits;
                    { has it been compiled at a higher level ?}
                    { has it been compiled at a higher level ?}
                    if current_module.compiled then
                    if current_module.compiled then
@@ -1112,16 +1100,15 @@ implementation
                         RestoreUnitSyms;
                         RestoreUnitSyms;
                         exit;
                         exit;
                      end;
                      end;
-                   unitst^.symtabletype:=globalsymtable;
                 end;
                 end;
               { ... but insert the symbol table later }
               { ... but insert the symbol table later }
-              st^.next:=symtablestack;
+              st.next:=symtablestack;
               symtablestack:=st;
               symtablestack:=st;
            end
            end
          else
          else
          { while compiling a system unit, some types are directly inserted }
          { while compiling a system unit, some types are directly inserted }
            begin
            begin
-              st^.next:=symtablestack;
+              st.next:=symtablestack;
               symtablestack:=st;
               symtablestack:=st;
               insert_intern_types(st);
               insert_intern_types(st);
            end;
            end;
@@ -1159,7 +1146,7 @@ implementation
 
 
          if not(cs_compilesystem in aktmoduleswitches) then
          if not(cs_compilesystem in aktmoduleswitches) then
            if (Errorcount=0) then
            if (Errorcount=0) then
-             writeunitas(current_module.ppufilename^,punitsymtable(symtablestack),true);
+             writeunitas(current_module.ppufilename^,tglobalsymtable(symtablestack),true);
 
 
          { Parse the implementation section }
          { Parse the implementation section }
          consume(_IMPLEMENTATION);
          consume(_IMPLEMENTATION);
@@ -1169,12 +1156,12 @@ implementation
          parse_only:=false;
          parse_only:=false;
 
 
          { generates static symbol table }
          { generates static symbol table }
-         st:=new(punitsymtable,init(staticsymtable,current_module.modulename^));
+         st:=tstaticsymtable.create(current_module.modulename^);
          current_module.localsymtable:=st;
          current_module.localsymtable:=st;
 
 
          { remove the globalsymtable from the symtable stack }
          { remove the globalsymtable from the symtable stack }
          { to reinsert it after loading the implementation units }
          { to reinsert it after loading the implementation units }
-         symtablestack:=unitst^.next;
+         symtablestack:=unitst.next;
 
 
          { we don't want implementation units symbols in unitsymtable !! PM }
          { we don't want implementation units symbols in unitsymtable !! PM }
          refsymtable:=st;
          refsymtable:=st;
@@ -1198,12 +1185,10 @@ implementation
          refsymtable:=st;
          refsymtable:=st;
 
 
          { but reinsert the global symtable as lasts }
          { but reinsert the global symtable as lasts }
-         unitst^.next:=symtablestack;
+         unitst.next:=symtablestack;
          symtablestack:=unitst;
          symtablestack:=unitst;
 
 
-{$ifndef DONOTCHAINOPERATORS}
-         pstoredsymtable(symtablestack)^.chainoperators;
-{$endif DONOTCHAINOPERATORS}
+         tstoredsymtable(symtablestack).chainoperators;
 
 
 {$ifdef DEBUG}
 {$ifdef DEBUG}
          test_symtablestack;
          test_symtablestack;
@@ -1226,18 +1211,18 @@ implementation
          { Compile the unit }
          { Compile the unit }
          codegen_newprocedure;
          codegen_newprocedure;
          gen_main_procsym(current_module.modulename^+'_init',potype_unitinit,st);
          gen_main_procsym(current_module.modulename^+'_init',potype_unitinit,st);
-         aktprocsym^.definition^.aliasnames.insert('INIT$$'+current_module.modulename^);
-         aktprocsym^.definition^.aliasnames.insert(target_os.cprefix+current_module.modulename^+'_init');
+         aktprocsym.definition.aliasnames.insert('INIT$$'+current_module.modulename^);
+         aktprocsym.definition.aliasnames.insert(target_os.cprefix+current_module.modulename^+'_init');
          compile_proc_body(true,false);
          compile_proc_body(true,false);
          codegen_doneprocedure;
          codegen_doneprocedure;
 
 
          { avoid self recursive destructor call !! PM }
          { avoid self recursive destructor call !! PM }
-         aktprocsym^.definition^.localst:=nil;
+         aktprocsym.definition.localst:=nil;
 
 
          { if the unit contains ansi/widestrings, initialization and
          { if the unit contains ansi/widestrings, initialization and
            finalization code must be forced }
            finalization code must be forced }
-         force_init_final:=needs_init_final(current_module.globalsymtable)
-           or needs_init_final(current_module.localsymtable);
+         force_init_final:=tglobalsymtable(current_module.globalsymtable).needs_init_final or
+                           tstaticsymtable(current_module.localsymtable).needs_init_final;
 
 
          { should we force unit initialization? }
          { should we force unit initialization? }
          { this is a hack, but how can it be done better ? }
          { this is a hack, but how can it be done better ? }
@@ -1258,8 +1243,8 @@ implementation
               { Compile the finalize }
               { Compile the finalize }
               codegen_newprocedure;
               codegen_newprocedure;
               gen_main_procsym(current_module.modulename^+'_finalize',potype_unitfinalize,st);
               gen_main_procsym(current_module.modulename^+'_finalize',potype_unitfinalize,st);
-              aktprocsym^.definition^.aliasnames.insert('FINALIZE$$'+current_module.modulename^);
-              aktprocsym^.definition^.aliasnames.insert(target_os.cprefix+current_module.modulename^+'_finalize');
+              aktprocsym.definition.aliasnames.insert('FINALIZE$$'+current_module.modulename^);
+              aktprocsym.definition.aliasnames.insert(target_os.cprefix+current_module.modulename^+'_finalize');
               compile_proc_body(true,false);
               compile_proc_body(true,false);
               codegen_doneprocedure;
               codegen_doneprocedure;
            end
            end
@@ -1285,19 +1270,19 @@ implementation
           end;
           end;
 
 
          { avoid self recursive destructor call !! PM }
          { avoid self recursive destructor call !! PM }
-         aktprocsym^.definition^.localst:=nil;
+         aktprocsym.definition.localst:=nil;
          { absence does not matter here !! }
          { absence does not matter here !! }
-         aktprocsym^.definition^.forwarddef:=false;
+         aktprocsym.definition.forwarddef:=false;
          { test static symtable }
          { test static symtable }
          if (Errorcount=0) then
          if (Errorcount=0) then
            begin
            begin
-             pstoredsymtable(st)^.allsymbolsused;
-             pstoredsymtable(st)^.allunitsused;
-             pstoredsymtable(st)^.allprivatesused;
+             tstoredsymtable(st).allsymbolsused;
+             tstoredsymtable(st).allunitsused;
+             tstoredsymtable(st).allprivatesused;
            end;
            end;
 
 
          { size of the static data }
          { size of the static data }
-         datasize:=st^.datasize;
+         datasize:=st.datasize;
 
 
 {$ifdef GDB}
 {$ifdef GDB}
          { add all used definitions even for implementation}
          { add all used definitions even for implementation}
@@ -1307,12 +1292,12 @@ implementation
             if assigned(current_module.globalsymtable) then
             if assigned(current_module.globalsymtable) then
               begin
               begin
                  { all types }
                  { all types }
-                 punitsymtable(current_module.globalsymtable)^.concattypestabto(debuglist);
+                 tglobalsymtable(current_module.globalsymtable).concattypestabto(debuglist);
                  { and all local symbols}
                  { and all local symbols}
-                 punitsymtable(current_module.globalsymtable)^.concatstabto(debuglist);
+                 tglobalsymtable(current_module.globalsymtable).concatstabto(debuglist);
               end;
               end;
             { all local types }
             { all local types }
-            punitsymtable(st)^.concattypestabto(debuglist);
+            tglobalsymtable(st)^.concattypestabto(debuglist);
             { and all local symbols}
             { and all local symbols}
             st^.concatstabto(debuglist);
             st^.concatstabto(debuglist);
 {$else New_GDB}
 {$else New_GDB}
@@ -1326,15 +1311,13 @@ implementation
          { tests, if all (interface) forwards are resolved }
          { tests, if all (interface) forwards are resolved }
          if (Errorcount=0) then
          if (Errorcount=0) then
            begin
            begin
-             pstoredsymtable(symtablestack)^.check_forwards;
-             pstoredsymtable(symtablestack)^.allprivatesused;
+             tstoredsymtable(symtablestack).check_forwards;
+             tstoredsymtable(symtablestack).allprivatesused;
            end;
            end;
 
 
-         { now we have a correct unit, change the symtable type }
          current_module.in_implementation:=false;
          current_module.in_implementation:=false;
-         symtablestack^.symtabletype:=unitsymtable;
 {$ifdef GDB}
 {$ifdef GDB}
-         punitsymtable(symtablestack)^.is_stab_written:=false;
+         tglobalsymtable(symtablestack).is_stab_written:=false;
 {$endif GDB}
 {$endif GDB}
 
 
          { leave when we got an error }
          { leave when we got an error }
@@ -1363,7 +1346,7 @@ implementation
          store_interface_crc:=current_module.interface_crc;
          store_interface_crc:=current_module.interface_crc;
          store_crc:=current_module.crc;
          store_crc:=current_module.crc;
          if (Errorcount=0) then
          if (Errorcount=0) then
-           writeunitas(current_module.ppufilename^,punitsymtable(symtablestack),false);
+           writeunitas(current_module.ppufilename^,tglobalsymtable(symtablestack),false);
 
 
          if not(cs_compilesystem in aktmoduleswitches) then
          if not(cs_compilesystem in aktmoduleswitches) then
            if store_interface_crc<>current_module.interface_crc then
            if store_interface_crc<>current_module.interface_crc then
@@ -1382,7 +1365,7 @@ implementation
          while assigned(pu) do
          while assigned(pu) do
            begin
            begin
               if assigned(pu.u.globalsymtable) then
               if assigned(pu.u.globalsymtable) then
-                punitsymtable(pu.u.globalsymtable)^.is_stab_written:=false;
+                tglobalsymtable(pu.u.globalsymtable).is_stab_written:=false;
               pu:=tused_unit(pu.next);
               pu:=tused_unit(pu.next);
            end;
            end;
 {$endif GDB}
 {$endif GDB}
@@ -1390,7 +1373,7 @@ implementation
          { remove static symtable (=refsymtable) here to save some mem }
          { remove static symtable (=refsymtable) here to save some mem }
          if not (cs_local_browser in aktmoduleswitches) then
          if not (cs_local_browser in aktmoduleswitches) then
            begin
            begin
-              dispose(st,done);
+              st.free;
               current_module.localsymtable:=nil;
               current_module.localsymtable:=nil;
            end;
            end;
 
 
@@ -1417,7 +1400,7 @@ implementation
     procedure proc_program(islibrary : boolean);
     procedure proc_program(islibrary : boolean);
       var
       var
          main_file: tinputfile;
          main_file: tinputfile;
-         st    : psymtable;
+         st    : tsymtable;
          hp    : tmodule;
          hp    : tmodule;
       begin
       begin
          DLLsource:=islibrary;
          DLLsource:=islibrary;
@@ -1491,14 +1474,10 @@ implementation
 
 
          { insert after the unit symbol tables the static symbol table }
          { insert after the unit symbol tables the static symbol table }
          { of the program                                             }
          { of the program                                             }
-         st:=new(punitsymtable,init(staticsymtable,current_module.modulename^));
+         st:=tstaticsymtable.create(current_module.modulename^);;
          current_module.localsymtable:=st;
          current_module.localsymtable:=st;
          refsymtable:=st;
          refsymtable:=st;
 
 
-         { a unit compiled at command line must be inside the loaded_unit list }
-         if (compile_level=1) then
-           loaded_units.insert(current_module);
-
          { load standard units (system,objpas,profile unit) }
          { load standard units (system,objpas,profile unit) }
          loaddefaultunits;
          loaddefaultunits;
 
 
@@ -1509,9 +1488,7 @@ implementation
          if token=_USES then
          if token=_USES then
            loadunits;
            loadunits;
 
 
-{$ifndef DONOTCHAINOPERATORS}
-         pstoredsymtable(symtablestack)^.chainoperators;
-{$endif DONOTCHAINOPERATORS}
+         tstoredsymtable(symtablestack).chainoperators;
 
 
          { reset ranges/stabs in exported definitions }
          { reset ranges/stabs in exported definitions }
          reset_global_defs;
          reset_global_defs;
@@ -1521,7 +1498,7 @@ implementation
 
 
          {Insert the name of the main program into the symbol table.}
          {Insert the name of the main program into the symbol table.}
          if current_module.realmodulename^<>'' then
          if current_module.realmodulename^<>'' then
-           st^.insert(new(punitsym,init(current_module.realmodulename^,punitsymtable(st))));
+           st.insert(tunitsym.create(current_module.realmodulename^,tglobalsymtable(st)));
 
 
          { ...is also constsymtable, this is the symtable where }
          { ...is also constsymtable, this is the symtable where }
          { the elements of enumeration types are inserted       }
          { the elements of enumeration types are inserted       }
@@ -1536,22 +1513,23 @@ implementation
           from the bootstrap code.}
           from the bootstrap code.}
          codegen_newprocedure;
          codegen_newprocedure;
          gen_main_procsym('main',potype_proginit,st);
          gen_main_procsym('main',potype_proginit,st);
-         aktprocsym^.definition^.aliasnames.insert('program_init');
-         aktprocsym^.definition^.aliasnames.insert('PASCALMAIN');
-         aktprocsym^.definition^.aliasnames.insert(target_os.cprefix+'main');
+         aktprocsym.definition.aliasnames.insert('program_init');
+         aktprocsym.definition.aliasnames.insert('PASCALMAIN');
+         aktprocsym.definition.aliasnames.insert(target_os.cprefix+'main');
 {$ifdef m68k}
 {$ifdef m68k}
          if target_info.target=target_m68k_PalmOS then
          if target_info.target=target_m68k_PalmOS then
-           aktprocsym^.definition^.aliasnames.insert('PilotMain');
+           aktprocsym.definition.aliasnames.insert('PilotMain');
 {$endif m68k}
 {$endif m68k}
          compile_proc_body(true,false);
          compile_proc_body(true,false);
 
 
          { avoid self recursive destructor call !! PM }
          { avoid self recursive destructor call !! PM }
-         aktprocsym^.definition^.localst:=nil;
+         aktprocsym.definition.localst:=nil;
 
 
-         { consider these symbols as global ones }
-         { for browser }
+         { consider these symbols as global ones for browser
+           but the typecasting of the globalsymtable with tglobalsymtable
+           can then lead to problems (PFV)
          current_module.globalsymtable:=current_module.localsymtable;
          current_module.globalsymtable:=current_module.localsymtable;
-         current_module.localsymtable:=nil;
+         current_module.localsymtable:=nil;}
 
 
          If ResourceStrings.ResStrCount>0 then
          If ResourceStrings.ResStrCount>0 then
           begin
           begin
@@ -1572,8 +1550,8 @@ implementation
               { Compile the finalize }
               { Compile the finalize }
               codegen_newprocedure;
               codegen_newprocedure;
               gen_main_procsym(current_module.modulename^+'_finalize',potype_unitfinalize,st);
               gen_main_procsym(current_module.modulename^+'_finalize',potype_unitfinalize,st);
-              aktprocsym^.definition^.aliasnames.insert('FINALIZE$$'+current_module.modulename^);
-              aktprocsym^.definition^.aliasnames.insert(target_os.cprefix+current_module.modulename^+'_finalize');
+              aktprocsym.definition.aliasnames.insert('FINALIZE$$'+current_module.modulename^);
+              aktprocsym.definition.aliasnames.insert(target_os.cprefix+current_module.modulename^+'_finalize');
               compile_proc_body(true,false);
               compile_proc_body(true,false);
               codegen_doneprocedure;
               codegen_doneprocedure;
            end;
            end;
@@ -1595,9 +1573,9 @@ implementation
          { test static symtable }
          { test static symtable }
          if (Errorcount=0) then
          if (Errorcount=0) then
            begin
            begin
-             pstoredsymtable(st)^.allsymbolsused;
-             pstoredsymtable(st)^.allunitsused;
-             pstoredsymtable(st)^.allprivatesused;
+             tstoredsymtable(st).allsymbolsused;
+             tstoredsymtable(st).allunitsused;
+             tstoredsymtable(st).allprivatesused;
            end;
            end;
 
 
          { generate imports }
          { generate imports }
@@ -1615,7 +1593,7 @@ implementation
          insertheap;
          insertheap;
          inserttargetspecific;
          inserttargetspecific;
 
 
-         datasize:=symtablestack^.datasize;
+         datasize:=symtablestack.datasize;
 
 
          { finish asmlist by adding segment starts }
          { finish asmlist by adding segment starts }
          insertsegment;
          insertsegment;
@@ -1661,7 +1639,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  2001-04-02 21:20:33  peter
+  Revision 1.27  2001-04-13 01:22:12  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.26  2001/04/02 21:20:33  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.25  2001/03/13 18:45:07  peter
   Revision 1.25  2001/03/13 18:45:07  peter

+ 5 - 2
compiler/ppheap.pas

@@ -75,6 +75,7 @@ implementation
     begin
     begin
        if not pp_heap_inited then
        if not pp_heap_inited then
          begin
          begin
+            keepreleased:=true;
             SetHeapTraceOutput('heap.log');
             SetHeapTraceOutput('heap.log');
             SetHeapExtraInfo(sizeof(textra_info),
             SetHeapExtraInfo(sizeof(textra_info),
                              {$ifdef FPCPROCVAR}@{$endif}set_extra_info,
                              {$ifdef FPCPROCVAR}@{$endif}set_extra_info,
@@ -89,8 +90,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2001-04-11 12:36:26  peter
-    * use new heaptrc version
+  Revision 1.7  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
 
 
   Revision 1.5  2001/03/13 18:43:17  peter
   Revision 1.5  2001/03/13 18:43:17  peter
     * made memdebug and heaptrc compilable again
     * made memdebug and heaptrc compilable again

+ 97 - 101
compiler/pstatmnt.pas

@@ -135,12 +135,12 @@ implementation
     function case_statement : tnode;
     function case_statement : tnode;
       var
       var
          { contains the label number of currently parsed case block }
          { contains the label number of currently parsed case block }
-         aktcaselabel : pasmlabel;
+         aktcaselabel : tasmlabel;
          firstlabel : boolean;
          firstlabel : boolean;
          root : pcaserecord;
          root : pcaserecord;
 
 
          { the typ of the case expression }
          { the typ of the case expression }
-         casedef : pdef;
+         casedef : tdef;
 
 
       procedure newcaselabel(l,h : TConstExprInt;first:boolean);
       procedure newcaselabel(l,h : TConstExprInt;first:boolean);
 
 
@@ -237,8 +237,8 @@ implementation
                         CGMessage(parser_e_case_lower_less_than_upper_bound);
                         CGMessage(parser_e_case_lower_less_than_upper_bound);
                       if not casedeferror then
                       if not casedeferror then
                        begin
                        begin
-                         testrange(casedef,hl1);
-                         testrange(casedef,hl2);
+                         testrange(casedef,hl1,false);
+                         testrange(casedef,hl2,false);
                        end;
                        end;
                     end
                     end
                   else
                   else
@@ -252,7 +252,7 @@ implementation
                     CGMessage(parser_e_case_mismatch);
                     CGMessage(parser_e_case_mismatch);
                   hl1:=get_ordinal_value(p);
                   hl1:=get_ordinal_value(p);
                   if not casedeferror then
                   if not casedeferror then
-                    testrange(casedef,hl1);
+                    testrange(casedef,hl1,false);
                   newcaselabel(hl1,hl1,firstlabel);
                   newcaselabel(hl1,hl1,firstlabel);
                end;
                end;
              p.free;
              p.free;
@@ -378,8 +378,8 @@ implementation
       var
       var
          right,p : tnode;
          right,p : tnode;
          i,levelcount : longint;
          i,levelcount : longint;
-         withsymtable,symtab : psymtable;
-         obj : pobjectdef;
+         withsymtable,symtab : tsymtable;
+         obj : tobjectdef;
          hp : tnode;
          hp : tnode;
       begin
       begin
          p:=comp_expr(true);
          p:=comp_expr(true);
@@ -387,51 +387,42 @@ implementation
          set_varstate(p,false);
          set_varstate(p,false);
          right:=nil;
          right:=nil;
          if (not codegenerror) and
          if (not codegenerror) and
-            (p.resulttype.def^.deftype in [objectdef,recorddef]) then
+            (p.resulttype.def.deftype in [objectdef,recorddef]) then
           begin
           begin
-            case p.resulttype.def^.deftype of
+            case p.resulttype.def.deftype of
              objectdef : begin
              objectdef : begin
-                           obj:=pobjectdef(p.resulttype.def);
-                           withsymtable:=new(pwithsymtable,init);
-                           withsymtable^.symsearch:=obj^.symtable^.symsearch;
-                           withsymtable^.defowner:=obj;
-                           symtab:=withsymtable;
+                           obj:=tobjectdef(p.resulttype.def);
+                           symtab:=twithsymtable.Create(obj,obj.symtable.symsearch);
+                           withsymtable:=symtab;
                            if (p.nodetype=loadn) and
                            if (p.nodetype=loadn) and
-                              (tloadnode(p).symtable=aktprocsym^.definition^.localst) then
-                             pwithsymtable(symtab)^.direct_with:=true;
-                           {symtab^.withnode:=p; not yet allocated !! }
-                           pwithsymtable(symtab)^.withrefnode:=p;
+                              (tloadnode(p).symtable=aktprocsym.definition.localst) then
+                             twithsymtable(symtab).direct_with:=true;
+                           twithsymtable(symtab).withrefnode:=p;
                            levelcount:=1;
                            levelcount:=1;
-                           obj:=obj^.childof;
+                           obj:=obj.childof;
                            while assigned(obj) do
                            while assigned(obj) do
                             begin
                             begin
-                              symtab^.next:=new(pwithsymtable,init);
-                              symtab:=symtab^.next;
-                              symtab^.symsearch:=obj^.symtable^.symsearch;
+                              symtab.next:=twithsymtable.create(obj,obj.symtable.symsearch);
+                              symtab:=symtab.next;
                               if (p.nodetype=loadn) and
                               if (p.nodetype=loadn) and
-                                 (tloadnode(p).symtable=aktprocsym^.definition^.localst) then
-                                pwithsymtable(symtab)^.direct_with:=true;
-                              {symtab^.withnode:=p; not yet allocated !! }
-                              pwithsymtable(symtab)^.withrefnode:=p;
-                              symtab^.defowner:=obj;
-                              obj:=obj^.childof;
+                                 (tloadnode(p).symtable=aktprocsym.definition.localst) then
+                                twithsymtable(symtab).direct_with:=true;
+                              twithsymtable(symtab).withrefnode:=p;
+                              obj:=obj.childof;
                               inc(levelcount);
                               inc(levelcount);
                             end;
                             end;
-                           symtab^.next:=symtablestack;
+                           symtab.next:=symtablestack;
                            symtablestack:=withsymtable;
                            symtablestack:=withsymtable;
                          end;
                          end;
              recorddef : begin
              recorddef : begin
-                           symtab:=precorddef(p.resulttype.def)^.symtable;
+                           symtab:=trecorddef(p.resulttype.def).symtable;
                            levelcount:=1;
                            levelcount:=1;
-                           withsymtable:=new(pwithsymtable,init);
-                           withsymtable^.symsearch:=symtab^.symsearch;
+                           withsymtable:=twithsymtable.create(trecorddef(p.resulttype.def),symtab.symsearch);
                            if (p.nodetype=loadn) and
                            if (p.nodetype=loadn) and
-                              (tloadnode(p).symtable=aktprocsym^.definition^.localst) then
-                           pwithsymtable(withsymtable)^.direct_with:=true;
-                           {symtab^.withnode:=p; not yet allocated !! }
-                           pwithsymtable(withsymtable)^.withrefnode:=p;
-                           withsymtable^.defowner:=precorddef(p.resulttype.def);
-                           withsymtable^.next:=symtablestack;
+                              (tloadnode(p).symtable=aktprocsym.definition.localst) then
+                           twithsymtable(withsymtable).direct_with:=true;
+                           twithsymtable(withsymtable).withrefnode:=p;
+                           withsymtable.next:=symtablestack;
                            symtablestack:=withsymtable;
                            symtablestack:=withsymtable;
                         end;
                         end;
             end;
             end;
@@ -449,8 +440,8 @@ implementation
                 right:=nil;
                 right:=nil;
              end;
              end;
             for i:=1 to levelcount do
             for i:=1 to levelcount do
-             symtablestack:=symtablestack^.next;
-            _with_statement:=cwithnode.create(pwithsymtable(withsymtable),p,right,levelcount);
+             symtablestack:=symtablestack.next;
+            _with_statement:=cwithnode.create(twithsymtable(withsymtable),p,right,levelcount);
           end
           end
          else
          else
           begin
           begin
@@ -518,12 +509,12 @@ implementation
          p_try_block,p_finally_block,first,last,
          p_try_block,p_finally_block,first,last,
          p_default,p_specific,hp : tnode;
          p_default,p_specific,hp : tnode;
          ot : ttype;
          ot : ttype;
-         sym : pvarsym;
+         sym : tvarsym;
          old_block_type : tblock_type;
          old_block_type : tblock_type;
-         exceptsymtable : psymtable;
+         exceptsymtable : tsymtable;
          objname,objrealname : stringid;
          objname,objrealname : stringid;
-         srsym : psym;
-         srsymtable : psymtable;
+         srsym : tsym;
+         srsymtable : tsymtable;
 
 
       begin
       begin
          procinfo^.flags:=procinfo^.flags or pi_uses_exceptions;
          procinfo^.flags:=procinfo^.flags or pi_uses_exceptions;
@@ -584,24 +575,24 @@ implementation
                           if try_to_consume(_COLON) then
                           if try_to_consume(_COLON) then
                             begin
                             begin
                                consume_sym(srsym,srsymtable);
                                consume_sym(srsym,srsymtable);
-                               if (srsym^.typ=typesym) and
-                                  is_class(ptypesym(srsym)^.restype.def) then
+                               if (srsym.typ=typesym) and
+                                  is_class(ttypesym(srsym).restype.def) then
                                  begin
                                  begin
-                                    ot:=ptypesym(srsym)^.restype;
-                                    sym:=new(pvarsym,init(objrealname,ot));
+                                    ot:=ttypesym(srsym).restype;
+                                    sym:=tvarsym.create(objrealname,ot);
                                  end
                                  end
                                else
                                else
                                  begin
                                  begin
-                                    sym:=new(pvarsym,init(objrealname,generrortype));
-                                    if (srsym^.typ=typesym) then
-                                      Message1(type_e_class_type_expected,ptypesym(srsym)^.restype.def^.typename)
+                                    sym:=tvarsym.create(objrealname,generrortype);
+                                    if (srsym.typ=typesym) then
+                                      Message1(type_e_class_type_expected,ttypesym(srsym).restype.def.typename)
                                     else
                                     else
-                                      Message1(type_e_class_type_expected,ot.def^.typename);
+                                      Message1(type_e_class_type_expected,ot.def.typename);
                                  end;
                                  end;
-                               exceptsymtable:=new(pstoredsymtable,init(stt_exceptsymtable));
-                               exceptsymtable^.insert(sym);
+                               exceptsymtable:=tstt_exceptsymtable.create;
+                               exceptsymtable.insert(sym);
                                { insert the exception symtable stack }
                                { insert the exception symtable stack }
-                               exceptsymtable^.next:=symtablestack;
+                               exceptsymtable.next:=symtablestack;
                                symtablestack:=exceptsymtable;
                                symtablestack:=exceptsymtable;
                             end
                             end
                           else
                           else
@@ -614,10 +605,10 @@ implementation
                                   srsym:=generrorsym;
                                   srsym:=generrorsym;
                                 end;
                                 end;
                                { support unit.identifier }
                                { support unit.identifier }
-                               if srsym^.typ=unitsym then
+                               if srsym.typ=unitsym then
                                  begin
                                  begin
                                     consume(_POINT);
                                     consume(_POINT);
-                                    srsym:=searchsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
+                                    srsym:=searchsymonlyin(tunitsym(srsym).unitsymtable,pattern);
                                     if srsym=nil then
                                     if srsym=nil then
                                      begin
                                      begin
                                        identifier_not_found(orgpattern);
                                        identifier_not_found(orgpattern);
@@ -627,16 +618,16 @@ implementation
                                  end;
                                  end;
                                { check if type is valid, must be done here because
                                { check if type is valid, must be done here because
                                  with "e: Exception" the e is not necessary }
                                  with "e: Exception" the e is not necessary }
-                               if (srsym^.typ=typesym) and
-                                  is_class(ptypesym(srsym)^.restype.def) then
-                                 ot:=ptypesym(srsym)^.restype
+                               if (srsym.typ=typesym) and
+                                  is_class(ttypesym(srsym).restype.def) then
+                                 ot:=ttypesym(srsym).restype
                                else
                                else
                                  begin
                                  begin
                                     ot:=generrortype;
                                     ot:=generrortype;
-                                    if (srsym^.typ=typesym) then
-                                      Message1(type_e_class_type_expected,ptypesym(srsym)^.restype.def^.typename)
+                                    if (srsym.typ=typesym) then
+                                      Message1(type_e_class_type_expected,ttypesym(srsym).restype.def.typename)
                                     else
                                     else
-                                      Message1(type_e_class_type_expected,ot.def^.typename);
+                                      Message1(type_e_class_type_expected,ot.def.typename);
                                  end;
                                  end;
                                exceptsymtable:=nil;
                                exceptsymtable:=nil;
                             end;
                             end;
@@ -645,7 +636,7 @@ implementation
                        consume(_ID);
                        consume(_ID);
                      consume(_DO);
                      consume(_DO);
                      hp:=connode.create(nil,statement);
                      hp:=connode.create(nil,statement);
-                     if ot.def^.deftype=errordef then
+                     if ot.def.deftype=errordef then
                        begin
                        begin
                           hp.free;
                           hp.free;
                           hp:=cerrornode.create;
                           hp:=cerrornode.create;
@@ -665,7 +656,7 @@ implementation
                      { that last and hp are errornodes (JM)                            }
                      { that last and hp are errornodes (JM)                            }
                      if last.nodetype = onn then
                      if last.nodetype = onn then
                        begin
                        begin
-                         tonnode(last).excepttype:=pobjectdef(ot.def);
+                         tonnode(last).excepttype:=tobjectdef(ot.def);
                          tonnode(last).exceptsymtable:=exceptsymtable;
                          tonnode(last).exceptsymtable:=exceptsymtable;
                        end;
                        end;
                      { remove exception symtable }
                      { remove exception symtable }
@@ -673,7 +664,7 @@ implementation
                        begin
                        begin
                          dellexlevel;
                          dellexlevel;
                          if last.nodetype <> onn then
                          if last.nodetype <> onn then
-                           dispose(exceptsymtable,done);
+                           exceptsymtable.free;
                        end;
                        end;
                      if not try_to_consume(_SEMICOLON) then
                      if not try_to_consume(_SEMICOLON) then
                         break;
                         break;
@@ -748,11 +739,11 @@ implementation
              begin
              begin
                if not target_asm.allowdirect then
                if not target_asm.allowdirect then
                  Message(parser_f_direct_assembler_not_allowed);
                  Message(parser_f_direct_assembler_not_allowed);
-               if (pocall_inline in aktprocsym^.definition^.proccalloptions) then
+               if (pocall_inline in aktprocsym.definition.proccalloptions) then
                  Begin
                  Begin
                     Message1(parser_w_not_supported_for_inline,'direct asm');
                     Message1(parser_w_not_supported_for_inline,'direct asm');
                     Message(parser_w_inlining_disabled);
                     Message(parser_w_inlining_disabled);
-                    exclude(aktprocsym^.definition^.proccalloptions,pocall_inline);
+                    exclude(aktprocsym.definition.proccalloptions,pocall_inline);
                  End;
                  End;
                asmstat:=tasmnode(ra386dir.assemble);
                asmstat:=tasmnode(ra386dir.assemble);
              end;
              end;
@@ -839,8 +830,8 @@ implementation
         p,p2     : tnode;
         p,p2     : tnode;
         again    : boolean; { dummy for do_proc_call }
         again    : boolean; { dummy for do_proc_call }
         destructorname : stringid;
         destructorname : stringid;
-        sym      : psym;
-        classh   : pobjectdef;
+        sym      : tsym;
+        classh   : tobjectdef;
         destructorpos,
         destructorpos,
         storepos : tfileposinfo;
         storepos : tfileposinfo;
         is_new   : boolean;
         is_new   : boolean;
@@ -867,9 +858,9 @@ implementation
             destructorpos:=akttokenpos;
             destructorpos:=akttokenpos;
             consume(_ID);
             consume(_ID);
 
 
-            if (p.resulttype.def^.deftype<>pointerdef) then
+            if (p.resulttype.def.deftype<>pointerdef) then
               begin
               begin
-                 Message1(type_e_pointer_type_expected,p.resulttype.def^.typename);
+                 Message1(type_e_pointer_type_expected,p.resulttype.def.typename);
                  p.free;
                  p.free;
                  p:=factor(false);
                  p:=factor(false);
                  p.free;
                  p.free;
@@ -878,7 +869,7 @@ implementation
                  exit;
                  exit;
               end;
               end;
             { first parameter must be an object or class }
             { first parameter must be an object or class }
-            if ppointerdef(p.resulttype.def)^.pointertype.def^.deftype<>objectdef then
+            if tpointerdef(p.resulttype.def).pointertype.def.deftype<>objectdef then
               begin
               begin
                  Message(parser_e_pointer_to_class_expected);
                  Message(parser_e_pointer_to_class_expected);
                  p.free;
                  p.free;
@@ -888,7 +879,7 @@ implementation
                  exit;
                  exit;
               end;
               end;
             { check, if the first parameter is a pointer to a _class_ }
             { check, if the first parameter is a pointer to a _class_ }
-            classh:=pobjectdef(ppointerdef(p.resulttype.def)^.pointertype.def);
+            classh:=tobjectdef(tpointerdef(p.resulttype.def).pointertype.def);
             if is_class(classh) then
             if is_class(classh) then
               begin
               begin
                  Message(parser_e_no_new_or_dispose_for_classes);
                  Message(parser_e_no_new_or_dispose_for_classes);
@@ -905,7 +896,7 @@ implementation
 
 
             { the second parameter of new/dispose must be a call }
             { the second parameter of new/dispose must be a call }
             { to a cons-/destructor                              }
             { to a cons-/destructor                              }
-            if (not assigned(sym)) or (sym^.typ<>procsym) then
+            if (not assigned(sym)) or (sym.typ<>procsym) then
               begin
               begin
                  if is_new then
                  if is_new then
                   Message(parser_e_expr_have_to_be_constructor_call)
                   Message(parser_e_expr_have_to_be_constructor_call)
@@ -921,7 +912,7 @@ implementation
                 else
                 else
                  p2:=chdisposenode.create(p);
                  p2:=chdisposenode.create(p);
                 do_resulttypepass(p2);
                 do_resulttypepass(p2);
-                p2.resulttype:=ppointerdef(p.resulttype.def)^.pointertype;
+                p2.resulttype:=tpointerdef(p.resulttype.def).pointertype;
                 if is_new then
                 if is_new then
                   do_member_read(false,sym,p2,again)
                   do_member_read(false,sym,p2,again)
                 else
                 else
@@ -930,7 +921,7 @@ implementation
                       do_member_read(false,sym,p2,again)
                       do_member_read(false,sym,p2,again)
                     else
                     else
                       begin
                       begin
-                        p2:=ccallnode.create(nil,pprocsym(sym),sym^.owner,p2);
+                        p2:=ccallnode.create(nil,tprocsym(sym),sym.owner,p2);
                         { support dispose(p,done()); }
                         { support dispose(p,done()); }
                         if try_to_consume(_LKLAMMER) then
                         if try_to_consume(_LKLAMMER) then
                           begin
                           begin
@@ -951,7 +942,7 @@ implementation
                  begin
                  begin
                    if is_new then
                    if is_new then
                     begin
                     begin
-                      if (tcallnode(p2).procdefinition^.proctypeoption<>potype_constructor) then
+                      if (tcallnode(p2).procdefinition.proctypeoption<>potype_constructor) then
                         Message(parser_e_expr_have_to_be_constructor_call);
                         Message(parser_e_expr_have_to_be_constructor_call);
                       p2:=cnewnode.create(p2);
                       p2:=cnewnode.create(p2);
                       do_resulttypepass(p2);
                       do_resulttypepass(p2);
@@ -960,7 +951,7 @@ implementation
                     end
                     end
                    else
                    else
                     begin
                     begin
-                      if (tcallnode(p2).procdefinition^.proctypeoption<>potype_destructor) then
+                      if (tcallnode(p2).procdefinition.proctypeoption<>potype_destructor) then
                         Message(parser_e_expr_have_to_be_destructor_call);
                         Message(parser_e_expr_have_to_be_destructor_call);
                     end;
                     end;
                  end;
                  end;
@@ -969,18 +960,18 @@ implementation
           end
           end
         else
         else
           begin
           begin
-             if (p.resulttype.def^.deftype<>pointerdef) then
+             if (p.resulttype.def.deftype<>pointerdef) then
                Begin
                Begin
-                  Message1(type_e_pointer_type_expected,p.resulttype.def^.typename);
+                  Message1(type_e_pointer_type_expected,p.resulttype.def.typename);
                   new_dispose_statement:=cerrornode.create;
                   new_dispose_statement:=cerrornode.create;
                end
                end
              else
              else
                begin
                begin
-                  if (ppointerdef(p.resulttype.def)^.pointertype.def^.deftype=objectdef) and
-                     (oo_has_vmt in pobjectdef(ppointerdef(p.resulttype.def)^.pointertype.def)^.objectoptions) then
+                  if (tpointerdef(p.resulttype.def).pointertype.def.deftype=objectdef) and
+                     (oo_has_vmt in tobjectdef(tpointerdef(p.resulttype.def).pointertype.def).objectoptions) then
                     Message(parser_w_use_extended_syntax_for_objects);
                     Message(parser_w_use_extended_syntax_for_objects);
-                  if (ppointerdef(p.resulttype.def)^.pointertype.def^.deftype=orddef) and
-                     (porddef(ppointerdef(p.resulttype.def)^.pointertype.def)^.typ=uvoid) then
+                  if (tpointerdef(p.resulttype.def).pointertype.def.deftype=orddef) and
+                     (torddef(tpointerdef(p.resulttype.def).pointertype.def).typ=uvoid) then
                     begin
                     begin
                       if (m_tp in aktmodeswitches) or
                       if (m_tp in aktmodeswitches) or
                          (m_delphi in aktmodeswitches) then
                          (m_delphi in aktmodeswitches) then
@@ -1004,8 +995,8 @@ implementation
          p       : tnode;
          p       : tnode;
          code    : tnode;
          code    : tnode;
          filepos : tfileposinfo;
          filepos : tfileposinfo;
-         srsym   : psym;
-         srsymtable : psymtable;
+         srsym   : tsym;
+         srsymtable : tsymtable;
       begin
       begin
          filepos:=akttokenpos;
          filepos:=akttokenpos;
          case token of
          case token of
@@ -1022,17 +1013,17 @@ implementation
                 else
                 else
                   begin
                   begin
                      consume_sym(srsym,srsymtable);
                      consume_sym(srsym,srsymtable);
-                     if srsym^.typ<>labelsym then
+                     if srsym.typ<>labelsym then
                        begin
                        begin
                           Message(sym_e_id_is_no_label_id);
                           Message(sym_e_id_is_no_label_id);
                           code:=cerrornode.create;
                           code:=cerrornode.create;
                        end
                        end
                      else
                      else
                        begin
                        begin
-                         code:=cgotonode.create(plabelsym(srsym)^.lab);
-                         tgotonode(code).labsym:=plabelsym(srsym);
+                         code:=cgotonode.create(tlabelsym(srsym).lab);
+                         tgotonode(code).labsym:=tlabelsym(srsym);
                          { set flag that this label is used }
                          { set flag that this label is used }
-                         plabelsym(srsym)^.used:=true;
+                         tlabelsym(srsym).used:=true;
                        end;
                        end;
                   end;
                   end;
              end;
              end;
@@ -1065,7 +1056,7 @@ implementation
              code:=cnothingnode.create;
              code:=cnothingnode.create;
            _FAIL :
            _FAIL :
              begin
              begin
-                if (aktprocsym^.definition^.proctypeoption<>potype_constructor) then
+                if (aktprocsym.definition.proctypeoption<>potype_constructor) then
                   Message(parser_e_fail_only_in_constructor);
                   Message(parser_e_fail_only_in_constructor);
                 consume(_FAIL);
                 consume(_FAIL);
                 code:=cfailnode.create;
                 code:=cfailnode.create;
@@ -1163,8 +1154,8 @@ implementation
 
 
       begin
       begin
          { temporary space is set, while the BEGIN of the procedure }
          { temporary space is set, while the BEGIN of the procedure }
-         if symtablestack^.symtabletype=localsymtable then
-           procinfo^.firsttemp_offset := -symtablestack^.datasize
+         if symtablestack.symtabletype=localsymtable then
+           procinfo^.firsttemp_offset := -symtablestack.datasize
          else
          else
            procinfo^.firsttemp_offset := 0;
            procinfo^.firsttemp_offset := 0;
 
 
@@ -1175,7 +1166,7 @@ implementation
               if ret_in_acc(procinfo^.returntype.def) then
               if ret_in_acc(procinfo^.returntype.def) then
                 begin
                 begin
                    { in assembler code the result should be directly in %eax
                    { in assembler code the result should be directly in %eax
-                   procinfo^.retoffset:=procinfo^.firsttemp-procinfo^.retdef^.size;
+                   procinfo^.retoffset:=procinfo^.firsttemp-procinfo^.retdef.size;
                    procinfo^.firsttemp:=procinfo^.retoffset;                 }
                    procinfo^.firsttemp:=procinfo^.retoffset;                 }
 
 
 {$ifndef newcg}
 {$ifndef newcg}
@@ -1201,14 +1192,14 @@ implementation
            { at -8(%ebp) (JM)                                      }
            { at -8(%ebp) (JM)                                      }
            { why if se use %esp then self is still at the correct address PM }
            { why if se use %esp then self is still at the correct address PM }
            if {not(assigned(procinfo^._class)) and}
            if {not(assigned(procinfo^._class)) and}
-              (po_assembler in aktprocsym^.definition^.procoptions) and
-              (aktprocsym^.definition^.localst^.datasize=0) and
-              (aktprocsym^.definition^.parast^.datasize=0) and
-              not(ret_in_param(aktprocsym^.definition^.rettype.def)) then
+              (po_assembler in aktprocsym.definition.procoptions) and
+              (aktprocsym.definition.localst.datasize=0) and
+              (aktprocsym.definition.parast.datasize=0) and
+              not(ret_in_param(aktprocsym.definition.rettype.def)) then
              begin
              begin
                procinfo^.framepointer:=stack_pointer;
                procinfo^.framepointer:=stack_pointer;
                { set the right value for parameters }
                { set the right value for parameters }
-               dec(aktprocsym^.definition^.parast^.address_fixup,target_os.size_of_pointer);
+               dec(aktprocsym.definition.parast.address_fixup,target_os.size_of_pointer);
                dec(procinfo^.para_offset,target_os.size_of_pointer);
                dec(procinfo^.para_offset,target_os.size_of_pointer);
              end;
              end;
           { force the asm statement }
           { force the asm statement }
@@ -1224,7 +1215,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2001-04-04 22:43:52  peter
+  Revision 1.24  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.23  2001/04/04 22:43:52  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.22  2001/04/02 21:20:34  peter
   Revision 1.22  2001/04/02 21:20:34  peter

+ 107 - 108
compiler/psub.pas

@@ -26,9 +26,6 @@ unit psub;
 
 
 interface
 interface
 
 
-    uses
-       cobjects;
-
     procedure compile_proc_body(make_global,parent_has_class:boolean);
     procedure compile_proc_body(make_global,parent_has_class:boolean);
 
 
     { reads the declaration blocks }
     { reads the declaration blocks }
@@ -42,14 +39,14 @@ implementation
 
 
     uses
     uses
        { common }
        { common }
-       cutils,
+       cutils,cclasses,
        { global }
        { global }
        globtype,globals,tokens,verbose,
        globtype,globals,tokens,verbose,
        systems,
        systems,
        { aasm }
        { aasm }
        cpubase,aasm,
        cpubase,aasm,
        { symtable }
        { symtable }
-       symconst,symbase,symtype,symdef,symsym,symtable,types,
+       symconst,symbase,symdef,symsym,symtable,types,
        ppu,fmodule,
        ppu,fmodule,
        { pass 1 }
        { pass 1 }
        node,
        node,
@@ -87,16 +84,16 @@ implementation
 
 
     function block(islibrary : boolean) : tnode;
     function block(islibrary : boolean) : tnode;
       var
       var
-         funcretsym : pfuncretsym;
+         funcretsym : tfuncretsym;
          storepos : tfileposinfo;
          storepos : tfileposinfo;
       begin
       begin
          { do we have an assembler block without the po_assembler?
          { do we have an assembler block without the po_assembler?
            we should allow this for Delphi compatibility (PFV) }
            we should allow this for Delphi compatibility (PFV) }
          if (token=_ASM) and (m_delphi in aktmodeswitches) then
          if (token=_ASM) and (m_delphi in aktmodeswitches) then
-          include(aktprocsym^.definition^.procoptions,po_assembler);
+          include(aktprocsym.definition.procoptions,po_assembler);
 
 
          { Handle assembler block different }
          { Handle assembler block different }
-         if (po_assembler in aktprocsym^.definition^.procoptions) then
+         if (po_assembler in aktprocsym.definition.procoptions) then
           begin
           begin
             read_declarations(false);
             read_declarations(false);
             block:=assembler_block;
             block:=assembler_block;
@@ -108,26 +105,26 @@ implementation
               { if the current is a function aktprocsym is non nil }
               { if the current is a function aktprocsym is non nil }
               { and there is a local symtable set }
               { and there is a local symtable set }
               storepos:=akttokenpos;
               storepos:=akttokenpos;
-              akttokenpos:=aktprocsym^.fileinfo;
-              funcretsym:=new(pfuncretsym,init(aktprocsym^.name,procinfo));
+              akttokenpos:=aktprocsym.fileinfo;
+              funcretsym:=tfuncretsym.create(aktprocsym.name,procinfo);
               { insert in local symtable }
               { insert in local symtable }
-              symtablestack^.insert(funcretsym);
+              symtablestack.insert(funcretsym);
               akttokenpos:=storepos;
               akttokenpos:=storepos;
-              if ret_in_acc(procinfo^.returntype.def) or (procinfo^.returntype.def^.deftype=floatdef) then
-                procinfo^.return_offset:=-funcretsym^.address;
+              if ret_in_acc(procinfo^.returntype.def) or (procinfo^.returntype.def.deftype=floatdef) then
+                procinfo^.return_offset:=-funcretsym.address;
               procinfo^.funcretsym:=funcretsym;
               procinfo^.funcretsym:=funcretsym;
               { insert result also if support is on }
               { insert result also if support is on }
               if (m_result in aktmodeswitches) then
               if (m_result in aktmodeswitches) then
                begin
                begin
-                 procinfo^.resultfuncretsym:=new(pfuncretsym,init('RESULT',procinfo));
-                 symtablestack^.insert(procinfo^.resultfuncretsym);
+                 procinfo^.resultfuncretsym:=tfuncretsym.create('RESULT',procinfo);
+                 symtablestack.insert(procinfo^.resultfuncretsym);
                end;
                end;
            end;
            end;
          read_declarations(islibrary);
          read_declarations(islibrary);
 
 
          { temporary space is set, while the BEGIN of the procedure }
          { temporary space is set, while the BEGIN of the procedure }
-         if (symtablestack^.symtabletype=localsymtable) then
-           procinfo^.firsttemp_offset := -symtablestack^.datasize
+         if (symtablestack.symtabletype=localsymtable) then
+           procinfo^.firsttemp_offset := -symtablestack.datasize
          else
          else
            procinfo^.firsttemp_offset := 0;
            procinfo^.firsttemp_offset := 0;
 
 
@@ -137,13 +134,13 @@ implementation
          { because we don't know yet where the address is }
          { because we don't know yet where the address is }
          if not is_void(procinfo^.returntype.def) then
          if not is_void(procinfo^.returntype.def) then
            begin
            begin
-              if ret_in_acc(procinfo^.returntype.def) or (procinfo^.returntype.def^.deftype=floatdef) then
+              if ret_in_acc(procinfo^.returntype.def) or (procinfo^.returntype.def.deftype=floatdef) then
                 begin
                 begin
                    { the space has been set in the local symtable }
                    { the space has been set in the local symtable }
-                   procinfo^.return_offset:=-funcretsym^.address;
+                   procinfo^.return_offset:=-funcretsym.address;
                    if ((procinfo^.flags and pi_operator)<>0) and
                    if ((procinfo^.flags and pi_operator)<>0) and
-                      assigned(opsym) then
-                     opsym^.address:=-procinfo^.return_offset;
+                      assigned(otsym) then
+                     otsym.address:=-procinfo^.return_offset;
                    { eax is modified by a function }
                    { eax is modified by a function }
 {$ifndef newcg}
 {$ifndef newcg}
 {$ifdef i386}
 {$ifdef i386}
@@ -216,9 +213,9 @@ implementation
         Compile the body of a procedure
         Compile the body of a procedure
       }
       }
       var
       var
-         oldexitlabel,oldexit2label : pasmlabel;
-         oldfaillabel,oldquickexitlabel:Pasmlabel;
-         _class,hp:Pobjectdef;
+         oldexitlabel,oldexit2label : tasmlabel;
+         oldfaillabel,oldquickexitlabel:tasmlabel;
+         _class,hp:tobjectdef;
          { switches can change inside the procedure }
          { switches can change inside the procedure }
          entryswitches, exitswitches : tlocalswitches;
          entryswitches, exitswitches : tlocalswitches;
          oldaktmaxfpuregisters,localmaxfpuregisters : longint;
          oldaktmaxfpuregisters,localmaxfpuregisters : longint;
@@ -241,7 +238,7 @@ implementation
           Message(parser_e_too_much_lexlevel);
           Message(parser_e_too_much_lexlevel);
 
 
          { static is also important for local procedures !! }
          { static is also important for local procedures !! }
-         if (po_staticmethod in aktprocsym^.definition^.procoptions) then
+         if (po_staticmethod in aktprocsym.definition.procoptions) then
            allow_only_static:=true
            allow_only_static:=true
          else if (lexlevel=normal_function_level) then
          else if (lexlevel=normal_function_level) then
            allow_only_static:=false;
            allow_only_static:=false;
@@ -255,7 +252,7 @@ implementation
          getlabel(aktexitlabel);
          getlabel(aktexitlabel);
          getlabel(aktexit2label);
          getlabel(aktexit2label);
          { exit for fail in constructors }
          { exit for fail in constructors }
-         if (aktprocsym^.definition^.proctypeoption=potype_constructor) then
+         if (aktprocsym.definition.proctypeoption=potype_constructor) then
            begin
            begin
              getlabel(faillabel);
              getlabel(faillabel);
              getlabel(quickexitlabel);
              getlabel(quickexitlabel);
@@ -272,11 +269,11 @@ implementation
              hp:=nil;
              hp:=nil;
              repeat
              repeat
                _class:=procinfo^._class;
                _class:=procinfo^._class;
-               while _class^.childof<>hp do
-                 _class:=_class^.childof;
+               while _class.childof<>hp do
+                 _class:=_class.childof;
                hp:=_class;
                hp:=_class;
-               _class^.symtable^.next:=symtablestack;
-               symtablestack:=_class^.symtable;
+               _class.symtable.next:=symtablestack;
+               symtablestack:=_class.symtable;
              until hp=procinfo^._class;
              until hp=procinfo^._class;
            end;
            end;
 
 
@@ -285,14 +282,14 @@ implementation
            for checking of same names used in interface and implementation !! }
            for checking of same names used in interface and implementation !! }
          if lexlevel>=normal_function_level then
          if lexlevel>=normal_function_level then
            begin
            begin
-              aktprocsym^.definition^.parast^.next:=symtablestack;
-              symtablestack:=aktprocsym^.definition^.parast;
-              symtablestack^.symtablelevel:=lexlevel;
+              aktprocsym.definition.parast.next:=symtablestack;
+              symtablestack:=aktprocsym.definition.parast;
+              symtablestack.symtablelevel:=lexlevel;
            end;
            end;
          { insert localsymtable in symtablestack}
          { insert localsymtable in symtablestack}
-         aktprocsym^.definition^.localst^.next:=symtablestack;
-         symtablestack:=aktprocsym^.definition^.localst;
-         symtablestack^.symtablelevel:=lexlevel;
+         aktprocsym.definition.localst.next:=symtablestack;
+         symtablestack:=aktprocsym.definition.localst;
+         symtablestack.symtablelevel:=lexlevel;
          { constant symbols are inserted in this symboltable }
          { constant symbols are inserted in this symboltable }
          constsymtable:=symtablestack;
          constsymtable:=symtablestack;
 
 
@@ -347,10 +344,10 @@ implementation
 
 
          if assigned(code) then
          if assigned(code) then
            begin
            begin
-              aktprocsym^.definition^.code:=code;
+              aktprocsym.definition.code:=code;
 
 
               { the procedure is now defined }
               { the procedure is now defined }
-              aktprocsym^.definition^.forwarddef:=false;
+              aktprocsym.definition.forwarddef:=false;
            end;
            end;
 
 
 {$ifdef newcg}
 {$ifdef newcg}
@@ -386,9 +383,9 @@ implementation
 {$endif newcg}
 {$endif newcg}
              { now all the registers used are known }
              { now all the registers used are known }
 {$ifdef newcg}
 {$ifdef newcg}
-             aktprocsym^.definition^.usedregisters:=tg.usedinproc;
+             aktprocsym.definition.usedregisters:=tg.usedinproc;
 {$else newcg}
 {$else newcg}
-             aktprocsym^.definition^.usedregisters:=usedinproc;
+             aktprocsym.definition.usedregisters:=usedinproc;
 {$endif newcg}
 {$endif newcg}
              procinfo^.aktproccode.insertlist(procinfo^.aktentrycode);
              procinfo^.aktproccode.insertlist(procinfo^.aktentrycode);
              procinfo^.aktproccode.concatlist(procinfo^.aktexitcode);
              procinfo^.aktproccode.concatlist(procinfo^.aktexitcode);
@@ -415,19 +412,16 @@ implementation
              { add the procedure to the codesegment }
              { add the procedure to the codesegment }
              codeSegment.concatlist(procinfo^.aktproccode);
              codeSegment.concatlist(procinfo^.aktproccode);
            end;
            end;
-{$else NOPASS2}
-         if assigned(code) then
-          firstpass(code);
 {$endif NOPASS2}
 {$endif NOPASS2}
 
 
          { ... remove symbol tables, for the browser leave the static table }
          { ... remove symbol tables, for the browser leave the static table }
-      {    if (cs_browser in aktmoduleswitches) and (symtablestack^.symtabletype=staticsymtable) then
-          symtablestack^.next:=symtablestack^.next^.next
+      {    if (cs_browser in aktmoduleswitches) and (symtablestack.symtabletype=staticsymtable) then
+          symtablestack.next:=symtablestack.next^.next
          else }
          else }
          if lexlevel>=normal_function_level then
          if lexlevel>=normal_function_level then
-           symtablestack:=symtablestack^.next^.next
+           symtablestack:=symtablestack.next.next
          else
          else
-           symtablestack:=symtablestack^.next;
+           symtablestack:=symtablestack.next;
 
 
          { ... check for unused symbols      }
          { ... check for unused symbols      }
          { but only if there is no asm block }
          { but only if there is no asm block }
@@ -435,17 +429,17 @@ implementation
            begin
            begin
              if (Errorcount=0) then
              if (Errorcount=0) then
                begin
                begin
-                 pstoredsymtable(aktprocsym^.definition^.localst)^.check_forwards;
-                 pstoredsymtable(aktprocsym^.definition^.localst)^.checklabels;
+                 tstoredsymtable(aktprocsym.definition.localst).check_forwards;
+                 tstoredsymtable(aktprocsym.definition.localst).checklabels;
                end;
                end;
              if (procinfo^.flags and pi_uses_asm)=0 then
              if (procinfo^.flags and pi_uses_asm)=0 then
                begin
                begin
                   { not for unit init, becuase the var can be used in finalize,
                   { not for unit init, becuase the var can be used in finalize,
                     it will be done in proc_unit }
                     it will be done in proc_unit }
-                  if not(aktprocsym^.definition^.proctypeoption
+                  if not(aktprocsym.definition.proctypeoption
                      in [potype_proginit,potype_unitinit,potype_unitfinalize]) then
                      in [potype_proginit,potype_unitinit,potype_unitfinalize]) then
-                     pstoredsymtable(aktprocsym^.definition^.localst)^.allsymbolsused;
-                  pstoredsymtable(aktprocsym^.definition^.parast)^.allsymbolsused;
+                     tstoredsymtable(aktprocsym.definition.localst).allsymbolsused;
+                  tstoredsymtable(aktprocsym.definition.parast).allsymbolsused;
                end;
                end;
            end;
            end;
 
 
@@ -457,11 +451,11 @@ implementation
          { so no dispose here !!                              }
          { so no dispose here !!                              }
          if assigned(code) and
          if assigned(code) and
             not(cs_browser in aktmoduleswitches) and
             not(cs_browser in aktmoduleswitches) and
-            not(pocall_inline in aktprocsym^.definition^.proccalloptions) then
+            not(pocall_inline in aktprocsym.definition.proccalloptions) then
            begin
            begin
              if lexlevel>=normal_function_level then
              if lexlevel>=normal_function_level then
-               dispose(aktprocsym^.definition^.localst,done);
-             aktprocsym^.definition^.localst:=nil;
+               aktprocsym.definition.localst.free;
+             aktprocsym.definition.localst:=nil;
            end;
            end;
 
 
 {$ifdef newcg}
 {$ifdef newcg}
@@ -477,12 +471,12 @@ implementation
 {$endif newcg}
 {$endif newcg}
 
 
          { remove code tree, if not inline procedure }
          { remove code tree, if not inline procedure }
-         if assigned(code) and not(pocall_inline in aktprocsym^.definition^.proccalloptions) then
+         if assigned(code) and not(pocall_inline in aktprocsym.definition.proccalloptions) then
            code.free;
            code.free;
 
 
          { remove class member symbol tables }
          { remove class member symbol tables }
-         while symtablestack^.symtabletype=objectsymtable do
-           symtablestack:=symtablestack^.next;
+         while symtablestack.symtabletype=objectsymtable do
+           symtablestack:=symtablestack.next;
 
 
          aktmaxfpuregisters:=oldaktmaxfpuregisters;
          aktmaxfpuregisters:=oldaktmaxfpuregisters;
 
 
@@ -506,24 +500,24 @@ implementation
                         PROCEDURE/FUNCTION PARSING
                         PROCEDURE/FUNCTION PARSING
 ****************************************************************************}
 ****************************************************************************}
 
 
-      procedure checkvaluepara(p:pnamedindexobject);
+    procedure checkvaluepara(p:tnamedindexitem);
       var
       var
-        vs : pvarsym;
+        vs : tvarsym;
         s  : string;
         s  : string;
       begin
       begin
-        with pvarsym(p)^ do
+        with tvarsym(p) do
          begin
          begin
            if copy(name,1,3)='val' then
            if copy(name,1,3)='val' then
             begin
             begin
               s:=Copy(name,4,255);
               s:=Copy(name,4,255);
-              if not(po_assembler in aktprocsym^.definition^.procoptions) then
+              if not(po_assembler in aktprocsym.definition.procoptions) then
                begin
                begin
-                 vs:=new(Pvarsym,init(s,vartype));
-                 vs^.fileinfo:=fileinfo;
-                 vs^.varspez:=varspez;
-                 aktprocsym^.definition^.localst^.insert(vs);
-                 include(vs^.varoptions,vo_is_local_copy);
-                 vs^.varstate:=vs_assigned;
+                 vs:=tvarsym.create(s,vartype);
+                 vs.fileinfo:=fileinfo;
+                 vs.varspez:=varspez;
+                 aktprocsym.definition.localst.insert(vs);
+                 include(vs.varoptions,vo_is_local_copy);
+                 vs.varstate:=vs_assigned;
                  localvarsym:=vs;
                  localvarsym:=vs;
                  inc(refs); { the para was used to set the local copy ! }
                  inc(refs); { the para was used to set the local copy ! }
                  { warnings only on local copy ! }
                  { warnings only on local copy ! }
@@ -531,7 +525,7 @@ implementation
                end
                end
               else
               else
                begin
                begin
-                 aktprocsym^.definition^.parast^.rename(name,s);
+                 aktprocsym.definition.parast.rename(name,s);
                end;
                end;
             end;
             end;
          end;
          end;
@@ -545,12 +539,12 @@ implementation
       }
       }
       var
       var
         oldprefix     : string;
         oldprefix     : string;
-        oldprocsym       : Pprocsym;
+        oldprocsym       : tprocsym;
         oldprocinfo      : pprocinfo;
         oldprocinfo      : pprocinfo;
-        oldconstsymtable : Psymtable;
+        oldconstsymtable : tsymtable;
         oldfilepos       : tfileposinfo;
         oldfilepos       : tfileposinfo;
         pdflags         : word;
         pdflags         : word;
-        prevdef,stdef   : pprocdef;
+        prevdef,stdef   : tprocdef;
       begin
       begin
       { save old state }
       { save old state }
          oldprocsym:=aktprocsym;
          oldprocsym:=aktprocsym;
@@ -576,15 +570,15 @@ implementation
          parse_proc_dec;
          parse_proc_dec;
 
 
          procinfo^.sym:=aktprocsym;
          procinfo^.sym:=aktprocsym;
-         procinfo^.def:=aktprocsym^.definition;
+         procinfo^.def:=aktprocsym.definition;
 
 
       { set the default function options }
       { set the default function options }
          if parse_only then
          if parse_only then
           begin
           begin
-            aktprocsym^.definition^.forwarddef:=true;
+            aktprocsym.definition.forwarddef:=true;
             { set also the interface flag, for better error message when the
             { set also the interface flag, for better error message when the
               implementation doesn't much this header }
               implementation doesn't much this header }
-            aktprocsym^.definition^.interfacedef:=true;
+            aktprocsym.definition.interfacedef:=true;
             pdflags:=pd_interface;
             pdflags:=pd_interface;
           end
           end
          else
          else
@@ -595,7 +589,7 @@ implementation
             if (not current_module.is_unit) or (cs_create_smart in aktmoduleswitches) then
             if (not current_module.is_unit) or (cs_create_smart in aktmoduleswitches) then
              pdflags:=pdflags or pd_global;
              pdflags:=pdflags or pd_global;
             procinfo^.exported:=false;
             procinfo^.exported:=false;
-            aktprocsym^.definition^.forwarddef:=false;
+            aktprocsym.definition.forwarddef:=false;
           end;
           end;
 
 
       { parse the directives that may follow }
       { parse the directives that may follow }
@@ -605,7 +599,7 @@ implementation
 
 
       { set aktfilepos to the beginning of the function declaration }
       { set aktfilepos to the beginning of the function declaration }
          oldfilepos:=aktfilepos;
          oldfilepos:=aktfilepos;
-         aktfilepos:=aktprocsym^.definition^.fileinfo;
+         aktfilepos:=aktprocsym.definition.fileinfo;
 
 
       { search for forward declarations }
       { search for forward declarations }
          if not check_identical_proc(prevdef) then
          if not check_identical_proc(prevdef) then
@@ -614,22 +608,22 @@ implementation
              if assigned(procinfo^._class) and (not assigned(oldprocinfo^._class)) then
              if assigned(procinfo^._class) and (not assigned(oldprocinfo^._class)) then
               begin
               begin
                 Message1(parser_e_header_dont_match_any_member,
                 Message1(parser_e_header_dont_match_any_member,
-                         aktprocsym^.definition^.fullprocname);
-                aktprocsym^.write_parameter_lists(aktprocsym^.definition);
+                         aktprocsym.definition.fullprocname);
+                aktprocsym.write_parameter_lists(aktprocsym.definition);
               end
               end
              else
              else
               begin
               begin
                 { Give a better error if there is a forward def in the interface and only
                 { Give a better error if there is a forward def in the interface and only
                   a single implementation }
                   a single implementation }
-                if (not aktprocsym^.definition^.forwarddef) and
-                   assigned(aktprocsym^.definition^.nextoverloaded) and
-                   aktprocsym^.definition^.nextoverloaded^.forwarddef and
-                   aktprocsym^.definition^.nextoverloaded^.interfacedef and
-                   not(assigned(aktprocsym^.definition^.nextoverloaded^.nextoverloaded)) then
+                if (not aktprocsym.definition.forwarddef) and
+                   assigned(aktprocsym.definition.nextoverloaded) and
+                   aktprocsym.definition.nextoverloaded.forwarddef and
+                   aktprocsym.definition.nextoverloaded.interfacedef and
+                   not(assigned(aktprocsym.definition.nextoverloaded.nextoverloaded)) then
                  begin
                  begin
                    Message1(parser_e_header_dont_match_forward,
                    Message1(parser_e_header_dont_match_forward,
-                            aktprocsym^.definition^.fullprocname);
-                   aktprocsym^.write_parameter_lists(aktprocsym^.definition);
+                            aktprocsym.definition.fullprocname);
+                   aktprocsym.write_parameter_lists(aktprocsym.definition);
                  end
                  end
                 else
                 else
                  begin
                  begin
@@ -640,12 +634,12 @@ implementation
               end;
               end;
            end;
            end;
 
 
-         { set return type here, becuase the aktprocsym^.definition can be
+         { set return type here, becuase the aktprocsym.definition can be
            changed by check_identical_proc (PFV) }
            changed by check_identical_proc (PFV) }
-         procinfo^.returntype.def:=aktprocsym^.definition^.rettype.def;
+         procinfo^.returntype.def:=aktprocsym.definition.rettype.def;
 
 
 {$ifdef i386}
 {$ifdef i386}
-         if (po_interrupt in aktprocsym^.definition^.procoptions) then
+         if (po_interrupt in aktprocsym.definition.procoptions) then
            begin
            begin
              { we push Flags and CS as long
              { we push Flags and CS as long
                to cope with the IRETD
                to cope with the IRETD
@@ -661,13 +655,13 @@ implementation
             inc(procinfo^.para_offset,target_os.size_of_pointer);
             inc(procinfo^.para_offset,target_os.size_of_pointer);
           end;
           end;
          { allows to access the parameters of main functions in nested functions }
          { allows to access the parameters of main functions in nested functions }
-         aktprocsym^.definition^.parast^.address_fixup:=procinfo^.para_offset;
+         aktprocsym.definition.parast.address_fixup:=procinfo^.para_offset;
 
 
          { when it is a value para and it needs a local copy then rename
          { when it is a value para and it needs a local copy then rename
            the parameter and insert a copy in the localst. This is not done
            the parameter and insert a copy in the localst. This is not done
            for assembler procedures }
            for assembler procedures }
-         if (not parse_only) and (not aktprocsym^.definition^.forwarddef) then
-           aktprocsym^.definition^.parast^.foreach({$ifdef FPCPROCVAR}@{$endif}checkvaluepara);
+         if (not parse_only) and (not aktprocsym.definition.forwarddef) then
+           aktprocsym.definition.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}checkvaluepara);
 
 
       { restore file pos }
       { restore file pos }
          aktfilepos:=oldfilepos;
          aktfilepos:=oldfilepos;
@@ -676,20 +670,20 @@ implementation
          if (pdflags and pd_body)<>0 then
          if (pdflags and pd_body)<>0 then
            begin
            begin
              Message1(parser_p_procedure_start,
              Message1(parser_p_procedure_start,
-                      aktprocsym^.definition^.fullprocname);
-             aktprocsym^.definition^.aliasnames.insert(aktprocsym^.definition^.mangledname);
+                      aktprocsym.definition.fullprocname);
+             aktprocsym.definition.aliasnames.insert(aktprocsym.definition.mangledname);
             { set _FAIL as keyword if constructor }
             { set _FAIL as keyword if constructor }
-            if (aktprocsym^.definition^.proctypeoption=potype_constructor) then
+            if (aktprocsym.definition.proctypeoption=potype_constructor) then
               tokeninfo^[_FAIL].keyword:=m_all;
               tokeninfo^[_FAIL].keyword:=m_all;
-            if assigned(aktprocsym^.definition^._class) then
+            if assigned(aktprocsym.definition._class) then
               tokeninfo^[_SELF].keyword:=m_all;
               tokeninfo^[_SELF].keyword:=m_all;
 
 
              compile_proc_body(((pdflags and pd_global)<>0),assigned(oldprocinfo^._class));
              compile_proc_body(((pdflags and pd_global)<>0),assigned(oldprocinfo^._class));
 
 
             { reset _FAIL as normal }
             { reset _FAIL as normal }
-            if (aktprocsym^.definition^.proctypeoption=potype_constructor) then
+            if (aktprocsym.definition.proctypeoption=potype_constructor) then
               tokeninfo^[_FAIL].keyword:=m_none;
               tokeninfo^[_FAIL].keyword:=m_none;
-            if assigned(aktprocsym^.definition^._class) and (lexlevel=main_program_level) then
+            if assigned(aktprocsym.definition._class) and (lexlevel=main_program_level) then
               tokeninfo^[_SELF].keyword:=m_none;
               tokeninfo^[_SELF].keyword:=m_none;
              consume(_SEMICOLON);
              consume(_SEMICOLON);
            end;
            end;
@@ -699,19 +693,19 @@ implementation
          constsymtable:=oldconstsymtable;
          constsymtable:=oldconstsymtable;
          { from now on all refernece to mangledname means
          { from now on all refernece to mangledname means
            that the function is already used }
            that the function is already used }
-         aktprocsym^.definition^.count:=true;
+         aktprocsym.definition.count:=true;
          { restore the interface order to maintain CRC values PM }
          { restore the interface order to maintain CRC values PM }
-         if assigned(prevdef) and assigned(aktprocsym^.definition^.nextoverloaded) then
+         if assigned(prevdef) and assigned(aktprocsym.definition.nextoverloaded) then
            begin
            begin
-             stdef:=aktprocsym^.definition;
-             aktprocsym^.definition:=stdef^.nextoverloaded;
-             stdef^.nextoverloaded:=prevdef^.nextoverloaded;
-             prevdef^.nextoverloaded:=stdef;
+             stdef:=aktprocsym.definition;
+             aktprocsym.definition:=stdef.nextoverloaded;
+             stdef.nextoverloaded:=prevdef.nextoverloaded;
+             prevdef.nextoverloaded:=stdef;
            end;
            end;
          aktprocsym:=oldprocsym;
          aktprocsym:=oldprocsym;
          procprefix:=oldprefix;
          procprefix:=oldprefix;
          procinfo:=oldprocinfo;
          procinfo:=oldprocinfo;
-         opsym:=nil;
+         otsym:=nil;
       end;
       end;
 
 
 
 
@@ -724,11 +718,11 @@ implementation
         procedure Not_supported_for_inline(t : ttoken);
         procedure Not_supported_for_inline(t : ttoken);
         begin
         begin
            if assigned(aktprocsym) and
            if assigned(aktprocsym) and
-              (pocall_inline in aktprocsym^.definition^.proccalloptions) then
+              (pocall_inline in aktprocsym.definition.proccalloptions) then
              Begin
              Begin
                 Message1(parser_w_not_supported_for_inline,tokenstring(t));
                 Message1(parser_w_not_supported_for_inline,tokenstring(t));
                 Message(parser_w_inlining_disabled);
                 Message(parser_w_inlining_disabled);
-                exclude(aktprocsym^.definition^.proccalloptions,pocall_inline);
+                exclude(aktprocsym.definition.proccalloptions,pocall_inline);
              End;
              End;
         end;
         end;
 
 
@@ -813,7 +807,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  2001-04-02 21:20:34  peter
+  Revision 1.27  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.26  2001/04/02 21:20:34  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.25  2001/02/26 19:44:53  peter
   Revision 1.25  2001/02/26 19:44:53  peter

+ 88 - 83
compiler/psystem.pas

@@ -28,8 +28,8 @@ interface
 uses
 uses
   symbase;
   symbase;
 
 
-procedure insertinternsyms(p : psymtable);
-procedure insert_intern_types(p : psymtable);
+procedure insertinternsyms(p : tsymtable);
+procedure insert_intern_types(p : tsymtable);
 
 
 procedure readconstdefs;
 procedure readconstdefs;
 procedure createconstdefs;
 procedure createconstdefs;
@@ -42,65 +42,65 @@ uses
   symconst,symtype,symsym,symdef,symtable,
   symconst,symtype,symsym,symdef,symtable,
   ninl;
   ninl;
 
 
-procedure insertinternsyms(p : psymtable);
+procedure insertinternsyms(p : tsymtable);
 {
 {
   all intern procedures for the system unit
   all intern procedures for the system unit
 }
 }
 begin
 begin
-  p^.insert(new(psyssym,init('Concat',in_concat_x)));
-  p^.insert(new(psyssym,init('Write',in_write_x)));
-  p^.insert(new(psyssym,init('WriteLn',in_writeln_x)));
-  p^.insert(new(psyssym,init('Assigned',in_assigned_x)));
-  p^.insert(new(psyssym,init('Read',in_read_x)));
-  p^.insert(new(psyssym,init('ReadLn',in_readln_x)));
-  p^.insert(new(psyssym,init('Ofs',in_ofs_x)));
-  p^.insert(new(psyssym,init('SizeOf',in_sizeof_x)));
-  p^.insert(new(psyssym,init('TypeOf',in_typeof_x)));
-  p^.insert(new(psyssym,init('Low',in_low_x)));
-  p^.insert(new(psyssym,init('High',in_high_x)));
-  p^.insert(new(psyssym,init('Seg',in_seg_x)));
-  p^.insert(new(psyssym,init('Ord',in_ord_x)));
-  p^.insert(new(psyssym,init('Pred',in_pred_x)));
-  p^.insert(new(psyssym,init('Succ',in_succ_x)));
-  p^.insert(new(psyssym,init('Exclude',in_exclude_x_y)));
-  p^.insert(new(psyssym,init('Include',in_include_x_y)));
-  p^.insert(new(psyssym,init('Break',in_break)));
-  p^.insert(new(psyssym,init('Continue',in_continue)));
-  p^.insert(new(psyssym,init('Dec',in_dec_x)));
-  p^.insert(new(psyssym,init('Inc',in_inc_x)));
-  p^.insert(new(psyssym,init('Str',in_str_x_string)));
-  p^.insert(new(psyssym,init('Assert',in_assert_x_y)));
-  p^.insert(new(psyssym,init('Val',in_val_x)));
-  p^.insert(new(psyssym,init('Addr',in_addr_x)));
-  p^.insert(new(psyssym,init('TypeInfo',in_typeinfo_x)));
-  p^.insert(new(psyssym,init('SetLength',in_setlength_x)));
-  p^.insert(new(psyssym,init('Finalize',in_finalize_x)));
+  p.insert(tsyssym.create('Concat',in_concat_x));
+  p.insert(tsyssym.create('Write',in_write_x));
+  p.insert(tsyssym.create('WriteLn',in_writeln_x));
+  p.insert(tsyssym.create('Assigned',in_assigned_x));
+  p.insert(tsyssym.create('Read',in_read_x));
+  p.insert(tsyssym.create('ReadLn',in_readln_x));
+  p.insert(tsyssym.create('Ofs',in_ofs_x));
+  p.insert(tsyssym.create('SizeOf',in_sizeof_x));
+  p.insert(tsyssym.create('TypeOf',in_typeof_x));
+  p.insert(tsyssym.create('Low',in_low_x));
+  p.insert(tsyssym.create('High',in_high_x));
+  p.insert(tsyssym.create('Seg',in_seg_x));
+  p.insert(tsyssym.create('Ord',in_ord_x));
+  p.insert(tsyssym.create('Pred',in_pred_x));
+  p.insert(tsyssym.create('Succ',in_succ_x));
+  p.insert(tsyssym.create('Exclude',in_exclude_x_y));
+  p.insert(tsyssym.create('Include',in_include_x_y));
+  p.insert(tsyssym.create('Break',in_break));
+  p.insert(tsyssym.create('Continue',in_continue));
+  p.insert(tsyssym.create('Dec',in_dec_x));
+  p.insert(tsyssym.create('Inc',in_inc_x));
+  p.insert(tsyssym.create('Str',in_str_x_string));
+  p.insert(tsyssym.create('Assert',in_assert_x_y));
+  p.insert(tsyssym.create('Val',in_val_x));
+  p.insert(tsyssym.create('Addr',in_addr_x));
+  p.insert(tsyssym.create('TypeInfo',in_typeinfo_x));
+  p.insert(tsyssym.create('SetLength',in_setlength_x));
+  p.insert(tsyssym.create('Finalize',in_finalize_x));
 end;
 end;
 
 
 
 
-procedure insert_intern_types(p : psymtable);
+procedure insert_intern_types(p : tsymtable);
 {
 {
   all the types inserted into the system unit
   all the types inserted into the system unit
 }
 }
 
 
   procedure addtype(const s:string;const t:ttype);
   procedure addtype(const s:string;const t:ttype);
   begin
   begin
-    p^.insert(new(ptypesym,init(s,t)));
+    p.insert(ttypesym.create(s,t));
   end;
   end;
 
 
-  procedure adddef(const s:string;def:pdef);
+  procedure adddef(const s:string;def:tdef);
   var
   var
     t : ttype;
     t : ttype;
   begin
   begin
     t.setdef(def);
     t.setdef(def);
-    p^.insert(new(ptypesym,init(s,t)));
+    p.insert(ttypesym.create(s,t));
   end;
   end;
 
 
 var
 var
   { several defs to simulate more or less C++ objects for GDB }
   { several defs to simulate more or less C++ objects for GDB }
   vmttype,
   vmttype,
   vmtarraytype : ttype;
   vmtarraytype : ttype;
-  vmtsymtable  : psymtable;
+  vmtsymtable  : tsymtable;
 begin
 begin
 { Internal types }
 { Internal types }
   addtype('$formal',cformaltype);
   addtype('$formal',cformaltype);
@@ -130,19 +130,19 @@ begin
   addtype('$s80real',s80floattype);
   addtype('$s80real',s80floattype);
   { Add a type for virtual method tables in lowercase }
   { Add a type for virtual method tables in lowercase }
   { so it isn't reachable!                            }
   { so it isn't reachable!                            }
-  vmtsymtable:=new(pstoredsymtable,init(recordsymtable));
-  vmttype.setdef(new(precorddef,init(vmtsymtable)));
-  pvmttype.setdef(new(ppointerdef,init(vmttype)));
-  vmtsymtable^.insert(new(pvarsym,init('$parent',pvmttype)));
-  vmtsymtable^.insert(new(pvarsym,init('$length',s32bittype)));
-  vmtsymtable^.insert(new(pvarsym,init('$mlength',s32bittype)));
-  vmtarraytype.setdef(new(parraydef,init(0,1,s32bittype)));
-  parraydef(vmtarraytype.def)^.elementtype:=voidpointertype;
-  vmtsymtable^.insert(new(pvarsym,init('$__pfn',vmtarraytype)));
+  vmtsymtable:=trecordsymtable.create;
+  vmttype.setdef(trecorddef.create(vmtsymtable));
+  pvmttype.setdef(tpointerdef.create(vmttype));
+  vmtsymtable.insert(tvarsym.create('$parent',pvmttype));
+  vmtsymtable.insert(tvarsym.create('$length',s32bittype));
+  vmtsymtable.insert(tvarsym.create('$mlength',s32bittype));
+  vmtarraytype.setdef(tarraydef.create(0,1,s32bittype));
+  tarraydef(vmtarraytype.def).elementtype:=voidpointertype;
+  vmtsymtable.insert(tvarsym.create('$__pfn',vmtarraytype));
   addtype('$__vtbl_ptr_type',vmttype);
   addtype('$__vtbl_ptr_type',vmttype);
   addtype('$pvmt',pvmttype);
   addtype('$pvmt',pvmttype);
-  vmtarraytype.setdef(new(parraydef,init(0,1,s32bittype)));
-  parraydef(vmtarraytype.def)^.elementtype:=pvmttype;
+  vmtarraytype.setdef(tarraydef.create(0,1,s32bittype));
+  tarraydef(vmtarraytype.def).elementtype:=pvmttype;
   addtype('$vtblarray',vmtarraytype);
   addtype('$vtblarray',vmtarraytype);
 { Add functions that require compiler magic }
 { Add functions that require compiler magic }
   insertinternsyms(p);
   insertinternsyms(p);
@@ -152,7 +152,7 @@ begin
   addtype('Extended',s80floattype);
   addtype('Extended',s80floattype);
   addtype('Real',s64floattype);
   addtype('Real',s64floattype);
 {$ifdef i386}
 {$ifdef i386}
-  adddef('Comp',new(pfloatdef,init(s64comp)));
+  adddef('Comp',tfloatdef.create(s64comp));
 {$endif}
 {$endif}
   addtype('Pointer',voidpointertype);
   addtype('Pointer',voidpointertype);
   addtype('FarPointer',voidfarpointertype);
   addtype('FarPointer',voidfarpointertype);
@@ -162,15 +162,15 @@ begin
   addtype('WideString',cwidestringtype);
   addtype('WideString',cwidestringtype);
   addtype('Boolean',booltype);
   addtype('Boolean',booltype);
   addtype('ByteBool',booltype);
   addtype('ByteBool',booltype);
-  adddef('WordBool',new(porddef,init(bool16bit,0,1)));
-  adddef('LongBool',new(porddef,init(bool32bit,0,1)));
+  adddef('WordBool',torddef.create(bool16bit,0,1));
+  adddef('LongBool',torddef.create(bool32bit,0,1));
   addtype('Char',cchartype);
   addtype('Char',cchartype);
   addtype('WideChar',cwidechartype);
   addtype('WideChar',cwidechartype);
-  adddef('Text',new(pfiledef,inittext));
+  adddef('Text',tfiledef.createtext);
   addtype('Cardinal',u32bittype);
   addtype('Cardinal',u32bittype);
   addtype('QWord',cu64bittype);
   addtype('QWord',cu64bittype);
   addtype('Int64',cs64bittype);
   addtype('Int64',cs64bittype);
-  adddef('TypedFile',new(pfiledef,inittyped(voidtype)));
+  adddef('TypedFile',tfiledef.createtyped(voidtype));
   addtype('Variant',cvarianttype);
   addtype('Variant',cvarianttype);
 end;
 end;
 
 
@@ -219,45 +219,45 @@ begin
   { create definitions for constants }
   { create definitions for constants }
   oldregisterdef:=registerdef;
   oldregisterdef:=registerdef;
   registerdef:=false;
   registerdef:=false;
-  cformaltype.setdef(new(pformaldef,init));
-  voidtype.setdef(new(porddef,init(uvoid,0,0)));
-  u8bittype.setdef(new(porddef,init(u8bit,0,255)));
-  u16bittype.setdef(new(porddef,init(u16bit,0,65535)));
-  u32bittype.setdef(new(porddef,init(u32bit,0,longint($ffffffff))));
-  s32bittype.setdef(new(porddef,init(s32bit,longint($80000000),$7fffffff)));
-  cu64bittype.setdef(new(porddef,init(u64bit,0,0)));
-  cs64bittype.setdef(new(porddef,init(s64bit,0,0)));
-  booltype.setdef(new(porddef,init(bool8bit,0,1)));
-  cchartype.setdef(new(porddef,init(uchar,0,255)));
-  cwidechartype.setdef(new(porddef,init(uwidechar,0,65535)));
-  cshortstringtype.setdef(new(pstringdef,shortinit(255)));
+  cformaltype.setdef(tformaldef.create);
+  voidtype.setdef(torddef.create(uvoid,0,0));
+  u8bittype.setdef(torddef.create(u8bit,0,255));
+  u16bittype.setdef(torddef.create(u16bit,0,65535));
+  u32bittype.setdef(torddef.create(u32bit,0,longint($ffffffff)));
+  s32bittype.setdef(torddef.create(s32bit,longint($80000000),$7fffffff));
+  cu64bittype.setdef(torddef.create(u64bit,0,0));
+  cs64bittype.setdef(torddef.create(s64bit,0,0));
+  booltype.setdef(torddef.create(bool8bit,0,1));
+  cchartype.setdef(torddef.create(uchar,0,255));
+  cwidechartype.setdef(torddef.create(uwidechar,0,65535));
+  cshortstringtype.setdef(tstringdef.createshort(255));
   { should we give a length to the default long and ansi string definition ?? }
   { should we give a length to the default long and ansi string definition ?? }
-  clongstringtype.setdef(new(pstringdef,longinit(-1)));
-  cansistringtype.setdef(new(pstringdef,ansiinit(-1)));
-  cwidestringtype.setdef(new(pstringdef,wideinit(-1)));
+  clongstringtype.setdef(tstringdef.createlong(-1));
+  cansistringtype.setdef(tstringdef.createansi(-1));
+  cwidestringtype.setdef(tstringdef.createwide(-1));
   { length=0 for shortstring is open string (needed for readln(string) }
   { length=0 for shortstring is open string (needed for readln(string) }
-  openshortstringtype.setdef(new(pstringdef,shortinit(0)));
-  openchararraytype.setdef(new(parraydef,init(0,-1,s32bittype)));
-  parraydef(openchararraytype.def)^.elementtype:=cchartype;
+  openshortstringtype.setdef(tstringdef.createshort(0));
+  openchararraytype.setdef(tarraydef.create(0,-1,s32bittype));
+  tarraydef(openchararraytype.def).elementtype:=cchartype;
 {$ifdef i386}
 {$ifdef i386}
-  s32floattype.setdef(new(pfloatdef,init(s32real)));
-  s64floattype.setdef(new(pfloatdef,init(s64real)));
-  s80floattype.setdef(new(pfloatdef,init(s80real)));
+  s32floattype.setdef(tfloatdef.create(s32real));
+  s64floattype.setdef(tfloatdef.create(s64real));
+  s80floattype.setdef(tfloatdef.create(s80real));
 {$endif}
 {$endif}
 {$ifdef m68k}
 {$ifdef m68k}
-  s32floattype.setdef(new(pfloatdef,init(s32real)));
-  s64floattype.setdef(new(pfloatdef,init(s64real)));
+  s32floattype.setdef(tfloatdef.create(s32real));
+  s64floattype.setdef(tfloatdef.create(s64real));
   if (cs_fp_emulation in aktmoduleswitches) then
   if (cs_fp_emulation in aktmoduleswitches) then
-   s80floattype.setdef(new(pfloatdef,init(s32real)))
+   s80floattype.setdef(tfloatdef.create(s32real)))
   else
   else
-   s80floattype.setdef(new(pfloatdef,init(s80real)));
+   s80floattype.setdef(tfloatdef.create(s80real));
 {$endif}
 {$endif}
   { some other definitions }
   { some other definitions }
-  voidpointertype.setdef(new(ppointerdef,init(voidtype)));
-  charpointertype.setdef(new(ppointerdef,init(cchartype)));
-  voidfarpointertype.setdef(new(ppointerdef,initfar(voidtype)));
-  cfiletype.setdef(new(pfiledef,inituntyped));
-  cvarianttype.setdef(new(pvariantdef,init));
+  voidpointertype.setdef(tpointerdef.create(voidtype));
+  charpointertype.setdef(tpointerdef.create(cchartype));
+  voidfarpointertype.setdef(tpointerdef.createfar(voidtype));
+  cfiletype.setdef(tfiledef.createuntyped);
+  cvarianttype.setdef(tvariantdef.create);
   registerdef:=oldregisterdef;
   registerdef:=oldregisterdef;
 end;
 end;
 
 
@@ -265,7 +265,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2001-04-02 21:20:34  peter
+  Revision 1.15  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.14  2001/04/02 21:20:34  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.13  2001/03/25 12:40:00  florian
   Revision 1.13  2001/03/25 12:40:00  florian

+ 99 - 94
compiler/ptconst.pas

@@ -31,7 +31,7 @@ interface
     { this procedure reads typed constants }
     { this procedure reads typed constants }
     { sym is only needed for ansi strings  }
     { sym is only needed for ansi strings  }
     { the assembler label is in the middle (PM) }
     { the assembler label is in the middle (PM) }
-    procedure readtypedconst(const t:ttype;sym : ptypedconstsym;no_change_allowed : boolean);
+    procedure readtypedconst(const t:ttype;sym : ttypedconstsym;no_change_allowed : boolean);
 
 
 implementation
 implementation
 
 
@@ -60,7 +60,7 @@ implementation
   {$maxfpuregisters 0}
   {$maxfpuregisters 0}
 {$endif fpc}
 {$endif fpc}
     { this procedure reads typed constants }
     { this procedure reads typed constants }
-    procedure readtypedconst(const t:ttype;sym : ptypedconstsym;no_change_allowed : boolean);
+    procedure readtypedconst(const t:ttype;sym : ttypedconstsym;no_change_allowed : boolean);
 
 
       var
       var
 {$ifdef m68k}
 {$ifdef m68k}
@@ -71,21 +71,21 @@ implementation
          i,l,offset,
          i,l,offset,
          strlength : longint;
          strlength : longint;
          curconstsegment : TAAsmoutput;
          curconstsegment : TAAsmoutput;
-         ll        : pasmlabel;
+         ll        : tasmlabel;
          s         : string;
          s         : string;
          ca        : pchar;
          ca        : pchar;
          tmpguid   : tguid;
          tmpguid   : tguid;
          aktpos    : longint;
          aktpos    : longint;
-         obj       : pobjectdef;
-         srsym     : psym;
-         symt      : psymtable;
+         obj       : tobjectdef;
+         srsym     : tsym;
+         symt      : tsymtable;
          value     : bestreal;
          value     : bestreal;
          strval    : pchar;
          strval    : pchar;
 
 
-      procedure check_range(def:porddef);
+      procedure check_range(def:torddef);
         begin
         begin
-           if ((tordconstnode(p).value>def^.high) or
-               (tordconstnode(p).value<def^.low)) then
+           if ((tordconstnode(p).value>def.high) or
+               (tordconstnode(p).value<def.low)) then
              begin
              begin
                 if (cs_check_range in aktlocalswitches) then
                 if (cs_check_range in aktlocalswitches) then
                   Message(parser_e_range_check_error)
                   Message(parser_e_range_check_error)
@@ -100,11 +100,11 @@ implementation
            curconstsegment:=consts
            curconstsegment:=consts
          else
          else
            curconstsegment:=datasegment;
            curconstsegment:=datasegment;
-         case t.def^.deftype of
+         case t.def.deftype of
             orddef:
             orddef:
               begin
               begin
                  p:=comp_expr(true);
                  p:=comp_expr(true);
-                 case porddef(t.def)^.typ of
+                 case torddef(t.def).typ of
                     bool8bit :
                     bool8bit :
                       begin
                       begin
                          if is_constboolnode(p) then
                          if is_constboolnode(p) then
@@ -146,7 +146,7 @@ implementation
                          if is_constintnode(p) then
                          if is_constintnode(p) then
                            begin
                            begin
                               curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value));
                               curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value));
-                              check_range(porddef(t.def));
+                              check_range(torddef(t.def));
                            end
                            end
                          else
                          else
                            Message(cg_e_illegal_expression);
                            Message(cg_e_illegal_expression);
@@ -157,7 +157,7 @@ implementation
                          if is_constintnode(p) then
                          if is_constintnode(p) then
                            begin
                            begin
                              curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value));
                              curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value));
-                             check_range(porddef(t.def));
+                             check_range(torddef(t.def));
                            end
                            end
                          else
                          else
                            Message(cg_e_illegal_expression);
                            Message(cg_e_illegal_expression);
@@ -168,8 +168,8 @@ implementation
                          if is_constintnode(p) then
                          if is_constintnode(p) then
                            begin
                            begin
                               curconstSegment.concat(Tai_const.Create_32bit(tordconstnode(p).value));
                               curconstSegment.concat(Tai_const.Create_32bit(tordconstnode(p).value));
-                              if porddef(t.def)^.typ<>u32bit then
-                               check_range(porddef(t.def));
+                              if torddef(t.def).typ<>u32bit then
+                               check_range(torddef(t.def));
                            end
                            end
                          else
                          else
                            Message(cg_e_illegal_expression);
                            Message(cg_e_illegal_expression);
@@ -201,7 +201,7 @@ implementation
               else
               else
                 Message(cg_e_illegal_expression);
                 Message(cg_e_illegal_expression);
 
 
-              case pfloatdef(t.def)^.typ of
+              case tfloatdef(t.def).typ of
                  s32real :
                  s32real :
                    curconstSegment.concat(Tai_real_32bit.Create(value));
                    curconstSegment.concat(Tai_real_32bit.Create(value));
                  s64real :
                  s64real :
@@ -221,11 +221,11 @@ implementation
               case p.nodetype of
               case p.nodetype of
                  loadvmtn:
                  loadvmtn:
                    begin
                    begin
-                      if not(pobjectdef(pclassrefdef(p.resulttype.def)^.pointertype.def)^.is_related(
-                        pobjectdef(pclassrefdef(t.def)^.pointertype.def))) then
+                      if not(tobjectdef(tclassrefdef(p.resulttype.def).pointertype.def).is_related(
+                        tobjectdef(tclassrefdef(t.def).pointertype.def))) then
                         Message(cg_e_illegal_expression);
                         Message(cg_e_illegal_expression);
-                      curconstSegment.concat(Tai_const_symbol.Create(newasmsymbol(pobjectdef(
-                        pclassrefdef(p.resulttype.def)^.pointertype.def)^.vmt_mangledname)));
+                      curconstSegment.concat(Tai_const_symbol.Create(newasmsymbol(tobjectdef(
+                        tclassrefdef(p.resulttype.def).pointertype.def).vmt_mangledname)));
                    end;
                    end;
                  niln:
                  niln:
                    curconstSegment.concat(Tai_const.Create_32bit(0));
                    curconstSegment.concat(Tai_const.Create_32bit(0));
@@ -263,7 +263,7 @@ implementation
                 curconstSegment.concat(Tai_const.Create_32bit(0))
                 curconstSegment.concat(Tai_const.Create_32bit(0))
               { maybe pchar ? }
               { maybe pchar ? }
               else
               else
-                if is_char(ppointerdef(t.def)^.pointertype.def) and
+                if is_char(tpointerdef(t.def).pointertype.def) and
                    (p.nodetype<>addrn) then
                    (p.nodetype<>addrn) then
                   begin
                   begin
                     getdatalabel(ll);
                     getdatalabel(ll);
@@ -292,9 +292,9 @@ implementation
                     hp:=taddrnode(p).left;
                     hp:=taddrnode(p).left;
                     while assigned(hp) and (hp.nodetype in [subscriptn,vecn]) do
                     while assigned(hp) and (hp.nodetype in [subscriptn,vecn]) do
                       hp:=tbinarynode(hp).left;
                       hp:=tbinarynode(hp).left;
-                    if (is_equal(ppointerdef(p.resulttype.def)^.pointertype.def,ppointerdef(t.def)^.pointertype.def) or
-                       (is_void(ppointerdef(p.resulttype.def)^.pointertype.def)) or
-                       (is_void(ppointerdef(t.def)^.pointertype.def))) and
+                    if (is_equal(tpointerdef(p.resulttype.def).pointertype.def,tpointerdef(t.def).pointertype.def) or
+                       (is_void(tpointerdef(p.resulttype.def).pointertype.def)) or
+                       (is_void(tpointerdef(t.def).pointertype.def))) and
                        (hp.nodetype=loadn) then
                        (hp.nodetype=loadn) then
                       begin
                       begin
                         do_resulttypepass(taddrnode(p).left);
                         do_resulttypepass(taddrnode(p).left);
@@ -305,7 +305,7 @@ implementation
                              case hp.nodetype of
                              case hp.nodetype of
                                vecn :
                                vecn :
                                  begin
                                  begin
-                                   case tvecnode(hp).left.resulttype.def^.deftype of
+                                   case tvecnode(hp).left.resulttype.def.deftype of
                                      stringdef :
                                      stringdef :
                                        begin
                                        begin
                                           { this seems OK for shortstring and ansistrings PM }
                                           { this seems OK for shortstring and ansistrings PM }
@@ -315,8 +315,8 @@ implementation
                                        end;
                                        end;
                                      arraydef :
                                      arraydef :
                                        begin
                                        begin
-                                          len:=parraydef(tvecnode(hp).left.resulttype.def)^.elesize;
-                                          base:=parraydef(tvecnode(hp).left.resulttype.def)^.lowrange;
+                                          len:=tarraydef(tvecnode(hp).left.resulttype.def).elesize;
+                                          base:=tarraydef(tvecnode(hp).left.resulttype.def).lowrange;
                                        end
                                        end
                                      else
                                      else
                                        Message(cg_e_illegal_expression);
                                        Message(cg_e_illegal_expression);
@@ -327,15 +327,15 @@ implementation
                                      Message(cg_e_illegal_expression);
                                      Message(cg_e_illegal_expression);
                                  end;
                                  end;
                                subscriptn :
                                subscriptn :
-                                 inc(offset,tsubscriptnode(hp).vs^.address)
+                                 inc(offset,tsubscriptnode(hp).vs.address)
                                else
                                else
                                  Message(cg_e_illegal_expression);
                                  Message(cg_e_illegal_expression);
                              end;
                              end;
                              hp:=tbinarynode(hp).left;
                              hp:=tbinarynode(hp).left;
                           end;
                           end;
-                        if tloadnode(hp).symtableentry^.typ=constsym then
+                        if tloadnode(hp).symtableentry.typ=constsym then
                           Message(type_e_variable_id_expected);
                           Message(type_e_variable_id_expected);
-                        curconstSegment.concat(Tai_const_symbol.Createname_offset(tloadnode(hp).symtableentry^.mangledname,offset));
+                        curconstSegment.concat(Tai_const_symbol.Createname_offset(tloadnode(hp).symtableentry.mangledname,offset));
                       end
                       end
                     else
                     else
                       Message(cg_e_illegal_expression);
                       Message(cg_e_illegal_expression);
@@ -348,7 +348,7 @@ implementation
                     if (tinlinenode(p).left.nodetype=typen) then
                     if (tinlinenode(p).left.nodetype=typen) then
                       begin
                       begin
                         curconstSegment.concat(Tai_const_symbol.createname(
                         curconstSegment.concat(Tai_const_symbol.createname(
-                          pobjectdef(tinlinenode(p).left.resulttype.def)^.vmt_mangledname));
+                          tobjectdef(tinlinenode(p).left.resulttype.def).vmt_mangledname));
                       end
                       end
                     else
                     else
                       Message(cg_e_illegal_expression);
                       Message(cg_e_illegal_expression);
@@ -368,12 +368,12 @@ implementation
                    else
                    else
                      begin
                      begin
 {$ifdef i386}
 {$ifdef i386}
-                        for l:=0 to t.def^.size-1 do
+                        for l:=0 to t.def.size-1 do
                           curconstSegment.concat(Tai_const.Create_8bit(tsetconstnode(p).value_set^[l]));
                           curconstSegment.concat(Tai_const.Create_8bit(tsetconstnode(p).value_set^[l]));
 {$endif}
 {$endif}
 {$ifdef m68k}
 {$ifdef m68k}
                         j:=0;
                         j:=0;
-                        for l:=0 to ((def^.size-1) div 4) do
+                        for l:=0 to ((def.size-1) div 4) do
                         { HORRIBLE HACK because of endian       }
                         { HORRIBLE HACK because of endian       }
                         { now use intel endian for constant sets }
                         { now use intel endian for constant sets }
                          begin
                          begin
@@ -398,14 +398,14 @@ implementation
                   if is_equal(p.resulttype.def,t.def) or
                   if is_equal(p.resulttype.def,t.def) or
                      is_subequal(p.resulttype.def,t.def) then
                      is_subequal(p.resulttype.def,t.def) then
                    begin
                    begin
-                     case p.resulttype.def^.size of
+                     case p.resulttype.def.size of
                        1 : curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value));
                        1 : curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value));
                        2 : curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value));
                        2 : curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value));
                        4 : curconstSegment.concat(Tai_const.Create_32bit(tordconstnode(p).value));
                        4 : curconstSegment.concat(Tai_const.Create_32bit(tordconstnode(p).value));
                      end;
                      end;
                    end
                    end
                   else
                   else
-                   Message2(type_e_incompatible_types,t.def^.typename,p.resulttype.def^.typename);
+                   Message2(type_e_incompatible_types,t.def.typename,p.resulttype.def.typename);
                 end
                 end
               else
               else
                 Message(cg_e_illegal_expression);
                 Message(cg_e_illegal_expression);
@@ -427,8 +427,8 @@ implementation
                 end
                 end
               else if is_constresourcestringnode(p) then
               else if is_constresourcestringnode(p) then
                 begin
                 begin
-                  strval:=pchar(tpointerord(pconstsym(tloadnode(p).symtableentry)^.value));
-                  strlength:=pconstsym(tloadnode(p).symtableentry)^.len;
+                  strval:=pchar(tpointerord(tconstsym(tloadnode(p).symtableentry).value));
+                  strlength:=tconstsym(tloadnode(p).symtableentry).len;
                 end
                 end
               else
               else
                 begin
                 begin
@@ -437,13 +437,13 @@ implementation
                 end;
                 end;
               if strlength>=0 then
               if strlength>=0 then
                begin
                begin
-                 case pstringdef(t.def)^.string_typ of
+                 case tstringdef(t.def).string_typ of
                    st_shortstring:
                    st_shortstring:
                      begin
                      begin
-                       if strlength>=t.def^.size then
+                       if strlength>=t.def.size then
                         begin
                         begin
-                          message2(parser_w_string_too_long,strpas(strval),tostr(t.def^.size-1));
-                          strlength:=t.def^.size-1;
+                          message2(parser_w_string_too_long,strpas(strval),tostr(t.def.size-1));
+                          strlength:=t.def.size-1;
                         end;
                         end;
                        curconstSegment.concat(Tai_const.Create_8bit(strlength));
                        curconstSegment.concat(Tai_const.Create_8bit(strlength));
                        { this can also handle longer strings }
                        { this can also handle longer strings }
@@ -452,15 +452,15 @@ implementation
                        ca[strlength]:=#0;
                        ca[strlength]:=#0;
                        curconstSegment.concat(Tai_string.Create_length_pchar(ca,strlength));
                        curconstSegment.concat(Tai_string.Create_length_pchar(ca,strlength));
                        { fillup with spaces if size is shorter }
                        { fillup with spaces if size is shorter }
-                       if t.def^.size>strlength then
+                       if t.def.size>strlength then
                         begin
                         begin
-                          getmem(ca,t.def^.size-strlength);
-                          { def^.size contains also the leading length, so we }
+                          getmem(ca,t.def.size-strlength);
+                          { def.size contains also the leading length, so we }
                           { we have to subtract one                       }
                           { we have to subtract one                       }
-                          fillchar(ca[0],t.def^.size-strlength-1,' ');
-                          ca[t.def^.size-strlength-1]:=#0;
+                          fillchar(ca[0],t.def.size-strlength-1,' ');
+                          ca[t.def.size-strlength-1]:=#0;
                           { this can also handle longer strings }
                           { this can also handle longer strings }
-                          curconstSegment.concat(Tai_string.Create_length_pchar(ca,t.def^.size-strlength-1));
+                          curconstSegment.concat(Tai_string.Create_length_pchar(ca,t.def.size-strlength-1));
                         end;
                         end;
                      end;
                      end;
 {$ifdef UseLongString}
 {$ifdef UseLongString}
@@ -513,17 +513,17 @@ implementation
               if token=_LKLAMMER then
               if token=_LKLAMMER then
                 begin
                 begin
                     consume(_LKLAMMER);
                     consume(_LKLAMMER);
-                    for l:=parraydef(t.def)^.lowrange to parraydef(t.def)^.highrange-1 do
+                    for l:=tarraydef(t.def).lowrange to tarraydef(t.def).highrange-1 do
                       begin
                       begin
-                         readtypedconst(parraydef(t.def)^.elementtype,nil,no_change_allowed);
+                         readtypedconst(tarraydef(t.def).elementtype,nil,no_change_allowed);
                          consume(_COMMA);
                          consume(_COMMA);
                       end;
                       end;
-                    readtypedconst(parraydef(t.def)^.elementtype,nil,no_change_allowed);
+                    readtypedconst(tarraydef(t.def).elementtype,nil,no_change_allowed);
                     consume(_RKLAMMER);
                     consume(_RKLAMMER);
                  end
                  end
               else
               else
               { if array of char then we allow also a string }
               { if array of char then we allow also a string }
-               if is_char(parraydef(t.def)^.elementtype.def) then
+               if is_char(tarraydef(t.def).elementtype.def) then
                 begin
                 begin
                    p:=comp_expr(true);
                    p:=comp_expr(true);
                    if p.nodetype=stringconstn then
                    if p.nodetype=stringconstn then
@@ -546,11 +546,11 @@ implementation
                        Message(cg_e_illegal_expression);
                        Message(cg_e_illegal_expression);
                        len:=0;
                        len:=0;
                      end;
                      end;
-                   if len>(Parraydef(t.def)^.highrange-Parraydef(t.def)^.lowrange+1) then
+                   if len>(tarraydef(t.def).highrange-tarraydef(t.def).lowrange+1) then
                      Message(parser_e_string_larger_array);
                      Message(parser_e_string_larger_array);
-                   for i:=Parraydef(t.def)^.lowrange to Parraydef(t.def)^.highrange do
+                   for i:=tarraydef(t.def).lowrange to tarraydef(t.def).highrange do
                      begin
                      begin
-                        if i+1-Parraydef(t.def)^.lowrange<=len then
+                        if i+1-tarraydef(t.def).lowrange<=len then
                           begin
                           begin
                              curconstSegment.concat(Tai_const.Create_8bit(byte(ca^)));
                              curconstSegment.concat(Tai_const.Create_8bit(byte(ca^)));
                              inc(ca);
                              inc(ca);
@@ -582,7 +582,7 @@ implementation
                   if token=_KLAMMERAFFE then
                   if token=_KLAMMERAFFE then
                     consume(_KLAMMERAFFE);
                     consume(_KLAMMERAFFE);
               getprocvar:=true;
               getprocvar:=true;
-              getprocvardef:=pprocvardef(t.def);
+              getprocvardef:=tprocvardef(t.def);
               p:=comp_expr(true);
               p:=comp_expr(true);
               getprocvar:=false;
               getprocvar:=false;
               if codegenerror then
               if codegenerror then
@@ -593,9 +593,9 @@ implementation
               { convert calln to loadn }
               { convert calln to loadn }
               if p.nodetype=calln then
               if p.nodetype=calln then
                begin
                begin
-                 hp:=cloadnode.create(pprocsym(tcallnode(p).symtableprocentry),tcallnode(p).symtableproc);
-                 if (tcallnode(p).symtableprocentry^.owner^.symtabletype=objectsymtable) and
-                    is_class(pdef(tcallnode(p).symtableprocentry^.owner^.defowner)) then
+                 hp:=cloadnode.create(tprocsym(tcallnode(p).symtableprocentry),tcallnode(p).symtableproc);
+                 if (tcallnode(p).symtableprocentry.owner.symtabletype=objectsymtable) and
+                    is_class(tdef(tcallnode(p).symtableprocentry.owner.defowner)) then
                   tloadnode(hp).set_mp(tcallnode(p).methodpointer.getcopy);
                   tloadnode(hp).set_mp(tcallnode(p).methodpointer.getcopy);
                  p.free;
                  p.free;
                  do_resulttypepass(hp);
                  do_resulttypepass(hp);
@@ -609,10 +609,10 @@ implementation
               else if (p.nodetype=addrn) and assigned(taddrnode(p).left) and
               else if (p.nodetype=addrn) and assigned(taddrnode(p).left) and
                 (taddrnode(p).left.nodetype=calln) then
                 (taddrnode(p).left.nodetype=calln) then
                 begin
                 begin
-                   hp:=cloadnode.create(pprocsym(tcallnode(taddrnode(p).left).symtableprocentry),
+                   hp:=cloadnode.create(tprocsym(tcallnode(taddrnode(p).left).symtableprocentry),
                      tcallnode(taddrnode(p).left).symtableproc);
                      tcallnode(taddrnode(p).left).symtableproc);
-                   if (tcallnode(taddrnode(p).left).symtableprocentry^.owner^.symtabletype=objectsymtable) and
-                      is_class(pdef(tcallnode(taddrnode(p).left).symtableprocentry^.owner^.defowner)) then
+                   if (tcallnode(taddrnode(p).left).symtableprocentry.owner.symtabletype=objectsymtable) and
+                      is_class(tdef(tcallnode(taddrnode(p).left).symtableprocentry.owner.defowner)) then
                     tloadnode(hp).set_mp(tcallnode(taddrnode(p).left).methodpointer.getcopy);
                     tloadnode(hp).set_mp(tcallnode(taddrnode(p).left).methodpointer.getcopy);
                    p.free;
                    p.free;
                    do_resulttypepass(hp);
                    do_resulttypepass(hp);
@@ -649,10 +649,10 @@ implementation
                end;
                end;
               { we now need to have a loadn with a procsym }
               { we now need to have a loadn with a procsym }
               if (p.nodetype=loadn) and
               if (p.nodetype=loadn) and
-                 (tloadnode(p).symtableentry^.typ=procsym) then
+                 (tloadnode(p).symtableentry.typ=procsym) then
                begin
                begin
                  curconstSegment.concat(Tai_const_symbol.createname(
                  curconstSegment.concat(Tai_const_symbol.createname(
-                   pprocsym(tloadnode(p).symtableentry)^.definition^.mangledname));
+                   tprocsym(tloadnode(p).symtableentry).definition.mangledname));
                end
                end
               else
               else
                Message(cg_e_illegal_expression);
                Message(cg_e_illegal_expression);
@@ -662,7 +662,7 @@ implementation
          recorddef:
          recorddef:
            begin
            begin
               { KAZ }
               { KAZ }
-              if (precorddef(t.def)=rec_tguid) and
+              if (trecorddef(t.def)=rec_tguid) and
                  ((token=_CSTRING) or (token=_CCHAR) or (token=_ID)) then
                  ((token=_CSTRING) or (token=_CCHAR) or (token=_ID)) then
                 begin
                 begin
                   p:=comp_expr(true);
                   p:=comp_expr(true);
@@ -698,7 +698,7 @@ implementation
                         s:=pattern;
                         s:=pattern;
                         consume(_ID);
                         consume(_ID);
                         consume(_COLON);
                         consume(_COLON);
-                        srsym:=psym(precorddef(t.def)^.symtable^.search(s));
+                        srsym:=tsym(trecorddef(t.def).symtable.search(s));
                         if srsym=nil then
                         if srsym=nil then
                           begin
                           begin
                              Message1(sym_e_id_not_found,s);
                              Message1(sym_e_id_not_found,s);
@@ -707,26 +707,26 @@ implementation
                         else
                         else
                           begin
                           begin
                              { check position }
                              { check position }
-                             if pvarsym(srsym)^.address<aktpos then
+                             if tvarsym(srsym).address<aktpos then
                                Message(parser_e_invalid_record_const);
                                Message(parser_e_invalid_record_const);
 
 
                              { if needed fill }
                              { if needed fill }
-                             if pvarsym(srsym)^.address>aktpos then
-                               for i:=1 to pvarsym(srsym)^.address-aktpos do
+                             if tvarsym(srsym).address>aktpos then
+                               for i:=1 to tvarsym(srsym).address-aktpos do
                                  curconstSegment.concat(Tai_const.Create_8bit(0));
                                  curconstSegment.concat(Tai_const.Create_8bit(0));
 
 
                              { new position }
                              { new position }
-                             aktpos:=pvarsym(srsym)^.address+pvarsym(srsym)^.vartype.def^.size;
+                             aktpos:=tvarsym(srsym).address+tvarsym(srsym).vartype.def.size;
 
 
                              { read the data }
                              { read the data }
-                             readtypedconst(pvarsym(srsym)^.vartype,nil,no_change_allowed);
+                             readtypedconst(tvarsym(srsym).vartype,nil,no_change_allowed);
 
 
                              if token=_SEMICOLON then
                              if token=_SEMICOLON then
                                consume(_SEMICOLON)
                                consume(_SEMICOLON)
                              else break;
                              else break;
                           end;
                           end;
                    end;
                    end;
-                 for i:=1 to t.def^.size-aktpos do
+                 for i:=1 to t.def.size-aktpos do
                    curconstSegment.concat(Tai_const.Create_8bit(0));
                    curconstSegment.concat(Tai_const.Create_8bit(0));
                  consume(_RKLAMMER);
                  consume(_RKLAMMER);
               end;
               end;
@@ -749,7 +749,7 @@ implementation
                   p.free;
                   p.free;
                 end
                 end
               { for objects we allow it only if it doesn't contain a vmt }
               { for objects we allow it only if it doesn't contain a vmt }
-              else if (oo_has_vmt in pobjectdef(t.def)^.objectoptions) and
+              else if (oo_has_vmt in tobjectdef(t.def).objectoptions) and
                       not(m_tp in aktmodeswitches) then
                       not(m_tp in aktmodeswitches) then
                  Message(parser_e_type_const_not_possible)
                  Message(parser_e_type_const_not_possible)
               else
               else
@@ -762,15 +762,15 @@ implementation
                         consume(_ID);
                         consume(_ID);
                         consume(_COLON);
                         consume(_COLON);
                         srsym:=nil;
                         srsym:=nil;
-                        obj:=pobjectdef(t.def);
-                        symt:=obj^.symtable;
+                        obj:=tobjectdef(t.def);
+                        symt:=obj.symtable;
                         while (srsym=nil) and assigned(symt) do
                         while (srsym=nil) and assigned(symt) do
                           begin
                           begin
-                             srsym:=psym(symt^.search(s));
+                             srsym:=tsym(symt.search(s));
                              if assigned(obj) then
                              if assigned(obj) then
-                               obj:=obj^.childof;
+                               obj:=obj.childof;
                              if assigned(obj) then
                              if assigned(obj) then
-                               symt:=obj^.symtable
+                               symt:=obj.symtable
                              else
                              else
                                symt:=nil;
                                symt:=nil;
                           end;
                           end;
@@ -783,31 +783,31 @@ implementation
                         else
                         else
                           begin
                           begin
                              { check position }
                              { check position }
-                             if pvarsym(srsym)^.address<aktpos then
+                             if tvarsym(srsym).address<aktpos then
                                Message(parser_e_invalid_record_const);
                                Message(parser_e_invalid_record_const);
 
 
                              { check in VMT needs to be added for TP mode }
                              { check in VMT needs to be added for TP mode }
                              if (m_tp in aktmodeswitches) and
                              if (m_tp in aktmodeswitches) and
-                                (oo_has_vmt in pobjectdef(t.def)^.objectoptions) and
-                                (pobjectdef(t.def)^.vmt_offset<pvarsym(srsym)^.address) then
+                                (oo_has_vmt in tobjectdef(t.def).objectoptions) and
+                                (tobjectdef(t.def).vmt_offset<tvarsym(srsym).address) then
                                begin
                                begin
-                                 for i:=1 to pobjectdef(t.def)^.vmt_offset-aktpos do
+                                 for i:=1 to tobjectdef(t.def).vmt_offset-aktpos do
                                    curconstsegment.concat(tai_const.create_8bit(0));
                                    curconstsegment.concat(tai_const.create_8bit(0));
-                                 curconstsegment.concat(tai_const_symbol.createname(pobjectdef(t.def)^.vmt_mangledname));
+                                 curconstsegment.concat(tai_const_symbol.createname(tobjectdef(t.def).vmt_mangledname));
                                  { this is more general }
                                  { this is more general }
-                                 aktpos:=pobjectdef(t.def)^.vmt_offset + target_os.size_of_pointer;
+                                 aktpos:=tobjectdef(t.def).vmt_offset + target_os.size_of_pointer;
                                end;
                                end;
 
 
                              { if needed fill }
                              { if needed fill }
-                             if pvarsym(srsym)^.address>aktpos then
-                               for i:=1 to pvarsym(srsym)^.address-aktpos do
+                             if tvarsym(srsym).address>aktpos then
+                               for i:=1 to tvarsym(srsym).address-aktpos do
                                  curconstSegment.concat(Tai_const.Create_8bit(0));
                                  curconstSegment.concat(Tai_const.Create_8bit(0));
 
 
                              { new position }
                              { new position }
-                             aktpos:=pvarsym(srsym)^.address+pvarsym(srsym)^.vartype.def^.size;
+                             aktpos:=tvarsym(srsym).address+tvarsym(srsym).vartype.def.size;
 
 
                              { read the data }
                              { read the data }
-                             readtypedconst(pvarsym(srsym)^.vartype,nil,no_change_allowed);
+                             readtypedconst(tvarsym(srsym).vartype,nil,no_change_allowed);
 
 
                              if token=_SEMICOLON then
                              if token=_SEMICOLON then
                                consume(_SEMICOLON)
                                consume(_SEMICOLON)
@@ -815,16 +815,16 @@ implementation
                           end;
                           end;
                      end;
                      end;
                    if (m_tp in aktmodeswitches) and
                    if (m_tp in aktmodeswitches) and
-                      (oo_has_vmt in pobjectdef(t.def)^.objectoptions) and
-                      (pobjectdef(t.def)^.vmt_offset>=aktpos) then
+                      (oo_has_vmt in tobjectdef(t.def).objectoptions) and
+                      (tobjectdef(t.def).vmt_offset>=aktpos) then
                      begin
                      begin
-                       for i:=1 to pobjectdef(t.def)^.vmt_offset-aktpos do
+                       for i:=1 to tobjectdef(t.def).vmt_offset-aktpos do
                          curconstsegment.concat(tai_const.create_8bit(0));
                          curconstsegment.concat(tai_const.create_8bit(0));
-                       curconstsegment.concat(tai_const_symbol.createname(pobjectdef(t.def)^.vmt_mangledname));
+                       curconstsegment.concat(tai_const_symbol.createname(tobjectdef(t.def).vmt_mangledname));
                        { this is more general }
                        { this is more general }
-                       aktpos:=pobjectdef(t.def)^.vmt_offset + target_os.size_of_pointer;
+                       aktpos:=tobjectdef(t.def).vmt_offset + target_os.size_of_pointer;
                      end;
                      end;
-                   for i:=1 to t.def^.size-aktpos do
+                   for i:=1 to t.def.size-aktpos do
                      curconstSegment.concat(Tai_const.Create_8bit(0));
                      curconstSegment.concat(Tai_const.Create_8bit(0));
                    consume(_RKLAMMER);
                    consume(_RKLAMMER);
                 end;
                 end;
@@ -847,7 +847,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  2001-04-04 22:43:53  peter
+  Revision 1.21  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.20  2001/04/04 22:43:53  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.19  2001/04/02 21:20:34  peter
   Revision 1.19  2001/04/02 21:20:34  peter

+ 66 - 61
compiler/ptype.pas

@@ -40,13 +40,13 @@ interface
        curobjectname : stringid;
        curobjectname : stringid;
 
 
     { reads a string, file type or a type id and returns a name and }
     { reads a string, file type or a type id and returns a name and }
-    { pdef }
+    { tdef }
     procedure single_type(var tt:ttype;var s : string;isforwarddef:boolean);
     procedure single_type(var tt:ttype;var s : string;isforwarddef:boolean);
 
 
     procedure read_type(var tt:ttype;const name : stringid);
     procedure read_type(var tt:ttype;const name : stringid);
 
 
     { reads a type definition }
     { reads a type definition }
-    { to a appropriating pdef, s gets the name of   }
+    { to a appropriating tdef, s gets the name of   }
     { the type to allow name mangling          }
     { the type to allow name mangling          }
     procedure id_type(var tt : ttype;var s : string;isforwarddef:boolean);
     procedure id_type(var tt : ttype;var s : string;isforwarddef:boolean);
 
 
@@ -71,13 +71,13 @@ implementation
 
 
     procedure id_type(var tt : ttype;var s : string;isforwarddef:boolean);
     procedure id_type(var tt : ttype;var s : string;isforwarddef:boolean);
     { reads a type definition }
     { reads a type definition }
-    { to a appropriating pdef, s gets the name of   }
+    { to a appropriating tdef, s gets the name of   }
     { the type to allow name mangling          }
     { the type to allow name mangling          }
       var
       var
         is_unit_specific : boolean;
         is_unit_specific : boolean;
         pos : tfileposinfo;
         pos : tfileposinfo;
-        srsym : psym;
-        srsymtable : psymtable;
+        srsym : tsym;
+        srsymtable : tsymtable;
       begin
       begin
          s:=pattern;
          s:=pattern;
          pos:=akttokenpos;
          pos:=akttokenpos;
@@ -100,13 +100,13 @@ implementation
          searchsym(s,srsym,srsymtable);
          searchsym(s,srsym,srsymtable);
          consume(_ID);
          consume(_ID);
          if assigned(srsym) and
          if assigned(srsym) and
-            (srsym^.typ=unitsym) then
+            (srsym.typ=unitsym) then
            begin
            begin
               is_unit_specific:=true;
               is_unit_specific:=true;
               consume(_POINT);
               consume(_POINT);
-              if srsym^.owner^.unitid=0 then
+              if srsym.owner.unitid=0 then
                begin
                begin
-                 srsym:=searchsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
+                 srsym:=searchsymonlyin(tunitsym(srsym).unitsymtable,pattern);
                  pos:=akttokenpos;
                  pos:=akttokenpos;
                  s:=pattern;
                  s:=pattern;
                end
                end
@@ -118,7 +118,7 @@ implementation
          if isforwarddef and
          if isforwarddef and
             not(is_unit_specific) then
             not(is_unit_specific) then
           begin
           begin
-            tt.setdef(new(pforwarddef,init(s,pos)));
+            tt.setdef(tforwarddef.create(s,pos));
             exit;
             exit;
           end;
           end;
          { unknown sym ? }
          { unknown sym ? }
@@ -129,7 +129,7 @@ implementation
             exit;
             exit;
           end;
           end;
          { type sym ? }
          { type sym ? }
-         if (srsym^.typ<>typesym) then
+         if (srsym.typ<>typesym) then
           begin
           begin
             Message(type_e_type_id_expected);
             Message(type_e_type_id_expected);
             tt:=generrortype;
             tt:=generrortype;
@@ -138,7 +138,7 @@ implementation
          { Types are first defined with an error def before assigning
          { Types are first defined with an error def before assigning
            the real type so check if it's an errordef. if so then
            the real type so check if it's an errordef. if so then
            give an error }
            give an error }
-         if (ptypesym(srsym)^.restype.def^.deftype=errordef) then
+         if (ttypesym(srsym).restype.def.deftype=errordef) then
           begin
           begin
             Message(sym_e_error_in_type_def);
             Message(sym_e_error_in_type_def);
             tt:=generrortype;
             tt:=generrortype;
@@ -149,9 +149,9 @@ implementation
            loaded at that time. A symbol reference to an other unit
            loaded at that time. A symbol reference to an other unit
            is still possible, because it's already loaded (PFV)
            is still possible, because it's already loaded (PFV)
            can't use in [] here, becuase unitid can be > 255 }
            can't use in [] here, becuase unitid can be > 255 }
-         if (ptypesym(srsym)^.owner^.unitid=0) or
-            (ptypesym(srsym)^.owner^.unitid=1) then
-          tt.setdef(ptypesym(srsym)^.restype.def)
+         if (ttypesym(srsym).owner.unitid=0) or
+            (ttypesym(srsym).owner.unitid=1) then
+          tt.setdef(ttypesym(srsym).restype.def)
          else
          else
           tt.setsym(srsym);
           tt.setsym(srsym);
       end;
       end;
@@ -159,7 +159,7 @@ implementation
 
 
     procedure single_type(var tt:ttype;var s : string;isforwarddef:boolean);
     procedure single_type(var tt:ttype;var s : string;isforwarddef:boolean);
     { reads a string, file type or a type id and returns a name and }
     { reads a string, file type or a type id and returns a name and }
-    { pdef                                                        }
+    { tdef                                                        }
        var
        var
           hs : string;
           hs : string;
           t2 : ttype;
           t2 : ttype;
@@ -177,7 +177,7 @@ implementation
                      begin
                      begin
                         consume(_OF);
                         consume(_OF);
                         single_type(t2,hs,false);
                         single_type(t2,hs,false);
-                        tt.setdef(new(pfiledef,inittyped(t2)));
+                        tt.setdef(tfiledef.createtyped(t2));
                         s:='FILE$OF$'+hs;
                         s:='FILE$OF$'+hs;
                      end
                      end
                    else
                    else
@@ -194,18 +194,18 @@ implementation
       end;
       end;
 
 
     { reads a record declaration }
     { reads a record declaration }
-    function record_dec : pdef;
+    function record_dec : tdef;
 
 
       var
       var
-         symtable : psymtable;
+         symtable : tsymtable;
          storetypecanbeforward : boolean;
          storetypecanbeforward : boolean;
 
 
       begin
       begin
          { create recdef }
          { create recdef }
-         symtable:=new(pstoredsymtable,init(recordsymtable));
-         record_dec:=new(precorddef,init(symtable));
+         symtable:=trecordsymtable.create;
+         record_dec:=trecorddef.create(symtable);
          { update symtable stack }
          { update symtable stack }
-         symtable^.next:=symtablestack;
+         symtable.next:=symtablestack;
          symtablestack:=symtable;
          symtablestack:=symtable;
          { parse record }
          { parse record }
          consume(_RECORD);
          consume(_RECORD);
@@ -217,9 +217,9 @@ implementation
          consume(_END);
          consume(_END);
          typecanbeforward:=storetypecanbeforward;
          typecanbeforward:=storetypecanbeforward;
          { may be scale record size to a size of n*4 ? }
          { may be scale record size to a size of n*4 ? }
-         symtablestack^.datasize:=align(symtablestack^.datasize,symtablestack^.dataalignment);
+         symtablestack.datasize:=align(symtablestack.datasize,symtablestack.dataalignment);
          { restore symtable stack }
          { restore symtable stack }
-         symtablestack:=symtable^.next;
+         symtablestack:=symtable.next;
       end;
       end;
 
 
 
 
@@ -228,8 +228,8 @@ implementation
       var
       var
         pt : tnode;
         pt : tnode;
         tt2 : ttype;
         tt2 : ttype;
-        aktenumdef : penumdef;
-        ap : parraydef;
+        aktenumdef : tenumdef;
+        ap : tarraydef;
         s : stringid;
         s : stringid;
         l,v : TConstExprInt;
         l,v : TConstExprInt;
         oldaktpackrecords : tpackrecords;
         oldaktpackrecords : tpackrecords;
@@ -276,18 +276,18 @@ implementation
                        else
                        else
                         begin
                         begin
                         { All checks passed, create the new def }
                         { All checks passed, create the new def }
-                          case pt1.resulttype.def^.deftype of
+                          case pt1.resulttype.def.deftype of
                             enumdef :
                             enumdef :
-                              tt.setdef(new(penumdef,init_subrange(penumdef(pt1.resulttype.def),tordconstnode(pt1).value,tordconstnode(pt2).value)));
+                              tt.setdef(tenumdef.create_subrange(tenumdef(pt1.resulttype.def),tordconstnode(pt1).value,tordconstnode(pt2).value));
                             orddef :
                             orddef :
                               begin
                               begin
                                 if is_char(pt1.resulttype.def) then
                                 if is_char(pt1.resulttype.def) then
-                                  tt.setdef(new(porddef,init(uchar,tordconstnode(pt1).value,tordconstnode(pt2).value)))
+                                  tt.setdef(torddef.create(uchar,tordconstnode(pt1).value,tordconstnode(pt2).value))
                                 else
                                 else
                                   if is_boolean(pt1.resulttype.def) then
                                   if is_boolean(pt1.resulttype.def) then
-                                    tt.setdef(new(porddef,init(bool8bit,tordconstnode(pt1).value,tordconstnode(pt2).value)))
+                                    tt.setdef(torddef.create(bool8bit,tordconstnode(pt1).value,tordconstnode(pt2).value))
                                   else
                                   else
-                                    tt.setdef(new(porddef,init(uauto,tordconstnode(pt1).value,tordconstnode(pt2).value)));
+                                    tt.setdef(torddef.create(uauto,tordconstnode(pt1).value,tordconstnode(pt2).value));
                               end;
                               end;
                           end;
                           end;
                         end;
                         end;
@@ -317,27 +317,27 @@ implementation
 
 
           procedure setdefdecl(const t:ttype);
           procedure setdefdecl(const t:ttype);
           begin
           begin
-            case t.def^.deftype of
+            case t.def.deftype of
               enumdef :
               enumdef :
                 begin
                 begin
-                  lowval:=penumdef(t.def)^.min;
-                  highval:=penumdef(t.def)^.max;
+                  lowval:=tenumdef(t.def).min;
+                  highval:=tenumdef(t.def).max;
                   arraytype:=t;
                   arraytype:=t;
                 end;
                 end;
               orddef :
               orddef :
                 begin
                 begin
-                  if porddef(t.def)^.typ in [uchar,
+                  if torddef(t.def).typ in [uchar,
                     u8bit,u16bit,
                     u8bit,u16bit,
                     s8bit,s16bit,s32bit,
                     s8bit,s16bit,s32bit,
                     bool8bit,bool16bit,bool32bit,
                     bool8bit,bool16bit,bool32bit,
                     uwidechar] then
                     uwidechar] then
                     begin
                     begin
-                       lowval:=porddef(t.def)^.low;
-                       highval:=porddef(t.def)^.high;
+                       lowval:=torddef(t.def).low;
+                       highval:=torddef(t.def).high;
                        arraytype:=t;
                        arraytype:=t;
                     end
                     end
                   else
                   else
-                    Message1(parser_e_type_cant_be_used_in_array_index,t.def^.gettypename);
+                    Message1(parser_e_type_cant_be_used_in_array_index,t.def.gettypename);
                 end;
                 end;
               else
               else
                 Message(sym_e_error_in_type_def);
                 Message(sym_e_error_in_type_def);
@@ -398,13 +398,13 @@ implementation
                 { create arraydef }
                 { create arraydef }
                   if not assigned(tt.def) then
                   if not assigned(tt.def) then
                    begin
                    begin
-                     ap:=new(parraydef,init(lowval,highval,arraytype));
+                     ap:=tarraydef.create(lowval,highval,arraytype);
                      tt.setdef(ap);
                      tt.setdef(ap);
                    end
                    end
                   else
                   else
                    begin
                    begin
-                     ap^.elementtype.setdef(new(parraydef,init(lowval,highval,arraytype)));
-                     ap:=parraydef(ap^.elementtype.def);
+                     ap.elementtype.setdef(tarraydef.create(lowval,highval,arraytype));
+                     ap:=tarraydef(ap.elementtype.def);
                    end;
                    end;
 
 
                   if token=_COMMA then
                   if token=_COMMA then
@@ -416,15 +416,15 @@ implementation
              end
              end
            else
            else
              begin
              begin
-                ap:=new(parraydef,init(0,-1,s32bittype));
-                ap^.IsDynamicArray:=true;
+                ap:=tarraydef.create(0,-1,s32bittype);
+                ap.IsDynamicArray:=true;
                 tt.setdef(ap);
                 tt.setdef(ap);
              end;
              end;
            consume(_OF);
            consume(_OF);
            read_type(tt2,'');
            read_type(tt2,'');
            { if no error, set element type }
            { if no error, set element type }
            if assigned(ap) then
            if assigned(ap) then
-             ap^.elementtype:=tt2;
+             ap.elementtype:=tt2;
         end;
         end;
 
 
       begin
       begin
@@ -439,7 +439,7 @@ implementation
                 consume(_LKLAMMER);
                 consume(_LKLAMMER);
                 { allow negativ value_str }
                 { allow negativ value_str }
                 l:=-1;
                 l:=-1;
-                aktenumdef:=new(penumdef,init);
+                aktenumdef:=tenumdef.create;
                 repeat
                 repeat
                   s:=orgpattern;
                   s:=orgpattern;
                   defpos:=akttokenpos;
                   defpos:=akttokenpos;
@@ -471,7 +471,7 @@ implementation
                     inc(l);
                     inc(l);
                   storepos:=akttokenpos;
                   storepos:=akttokenpos;
                   akttokenpos:=defpos;
                   akttokenpos:=defpos;
-                  constsymtable^.insert(new(penumsym,init(s,aktenumdef,l)));
+                  constsymtable.insert(tenumsym.create(s,aktenumdef,l));
                   akttokenpos:=storepos;
                   akttokenpos:=storepos;
                 until not try_to_consume(_COMMA);
                 until not try_to_consume(_COMMA);
                 tt.setdef(aktenumdef);
                 tt.setdef(aktenumdef);
@@ -488,23 +488,23 @@ implementation
                 read_type(tt2,'');
                 read_type(tt2,'');
                 if assigned(tt2.def) then
                 if assigned(tt2.def) then
                  begin
                  begin
-                   case tt2.def^.deftype of
+                   case tt2.def.deftype of
                      { don't forget that min can be negativ  PM }
                      { don't forget that min can be negativ  PM }
                      enumdef :
                      enumdef :
-                       if penumdef(tt2.def)^.min>=0 then
-                        tt.setdef(new(psetdef,init(tt2,penumdef(tt2.def)^.max)))
+                       if tenumdef(tt2.def).min>=0 then
+                        tt.setdef(tsetdef.create(tt2,tenumdef(tt2.def).max))
                        else
                        else
                         Message(sym_e_ill_type_decl_set);
                         Message(sym_e_ill_type_decl_set);
                      orddef :
                      orddef :
                        begin
                        begin
-                         case porddef(tt2.def)^.typ of
+                         case torddef(tt2.def).typ of
                            uchar :
                            uchar :
-                             tt.setdef(new(psetdef,init(tt2,255)));
+                             tt.setdef(tsetdef.create(tt2,255));
                            u8bit,u16bit,u32bit,
                            u8bit,u16bit,u32bit,
                            s8bit,s16bit,s32bit :
                            s8bit,s16bit,s32bit :
                              begin
                              begin
-                               if (porddef(tt2.def)^.low>=0) then
-                                tt.setdef(new(psetdef,init(tt2,porddef(tt2.def)^.high)))
+                               if (torddef(tt2.def).low>=0) then
+                                tt.setdef(tsetdef.create(tt2,torddef(tt2.def).high))
                                else
                                else
                                 Message(sym_e_ill_type_decl_set);
                                 Message(sym_e_ill_type_decl_set);
                              end;
                              end;
@@ -523,7 +523,7 @@ implementation
               begin
               begin
                 consume(_CARET);
                 consume(_CARET);
                 single_type(tt2,hs,typecanbeforward);
                 single_type(tt2,hs,typecanbeforward);
-                tt.setdef(new(ppointerdef,init(tt2)));
+                tt.setdef(tpointerdef.create(tt2));
               end;
               end;
             _RECORD:
             _RECORD:
               begin
               begin
@@ -555,29 +555,29 @@ implementation
             _PROCEDURE:
             _PROCEDURE:
               begin
               begin
                 consume(_PROCEDURE);
                 consume(_PROCEDURE);
-                tt.setdef(new(pprocvardef,init));
+                tt.setdef(tprocvardef.create);
                 if token=_LKLAMMER then
                 if token=_LKLAMMER then
-                 parameter_dec(pprocvardef(tt.def));
+                 parameter_dec(tprocvardef(tt.def));
                 if token=_OF then
                 if token=_OF then
                   begin
                   begin
                     consume(_OF);
                     consume(_OF);
                     consume(_OBJECT);
                     consume(_OBJECT);
-                    include(pprocvardef(tt.def)^.procoptions,po_methodpointer);
+                    include(tprocvardef(tt.def).procoptions,po_methodpointer);
                   end;
                   end;
               end;
               end;
             _FUNCTION:
             _FUNCTION:
               begin
               begin
                 consume(_FUNCTION);
                 consume(_FUNCTION);
-                tt.def:=new(pprocvardef,init);
+                tt.def:=tprocvardef.create;
                 if token=_LKLAMMER then
                 if token=_LKLAMMER then
-                 parameter_dec(pprocvardef(tt.def));
+                 parameter_dec(tprocvardef(tt.def));
                 consume(_COLON);
                 consume(_COLON);
-                single_type(pprocvardef(tt.def)^.rettype,hs,false);
+                single_type(tprocvardef(tt.def).rettype,hs,false);
                 if token=_OF then
                 if token=_OF then
                   begin
                   begin
                     consume(_OF);
                     consume(_OF);
                     consume(_OBJECT);
                     consume(_OBJECT);
-                    include(pprocvardef(tt.def)^.procoptions,po_methodpointer);
+                    include(tprocvardef(tt.def).procoptions,po_methodpointer);
                   end;
                   end;
               end;
               end;
             else
             else
@@ -590,7 +590,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.22  2001-04-04 22:43:53  peter
+  Revision 1.23  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.22  2001/04/04 22:43:53  peter
     * remove unnecessary calls to firstpass
     * remove unnecessary calls to firstpass
 
 
   Revision 1.21  2001/04/02 21:20:34  peter
   Revision 1.21  2001/04/02 21:20:34  peter

+ 162 - 162
compiler/rautils.pas

@@ -27,7 +27,7 @@ Unit RAUtils;
 Interface
 Interface
 
 
 Uses
 Uses
-  cutils,cobjects,
+  cutils,cclasses,
   globtype,aasm,cpubase,symconst,symdef;
   globtype,aasm,cpubase,symconst,symdef;
 
 
 Const
 Const
@@ -43,25 +43,23 @@ Const
 
 
 Type
 Type
   { Each local label has this structure associated with it }
   { Each local label has this structure associated with it }
-  PLocalLabel = ^TLocalLabel;
-  TLocalLabel = object(TNamedIndexObject)
+  TLocalLabel = class(TNamedIndexItem)
     Emitted : boolean;
     Emitted : boolean;
-    constructor Init(const n:string);
-    function  Getpasmlabel:pasmlabel;
+    constructor Create(const n:string);
+    function  Gettasmlabel:tasmlabel;
   private
   private
-    lab : pasmlabel;
+    lab : tasmlabel;
   end;
   end;
 
 
-  PLocalLabelList = ^TLocalLabelList;
-  TLocalLabelList = Object(TDictionary)
+  TLocalLabelList = class(TDictionary)
     procedure CheckEmitted;
     procedure CheckEmitted;
   end;
   end;
 
 
 var
 var
-  LocalLabelList : PLocalLabelList;
+  LocalLabelList : TLocalLabelList;
 
 
-function CreateLocalLabel(const s: string; var hl: pasmlabel; emit:boolean):boolean;
-Function SearchLabel(const s: string; var hl: pasmlabel;emit:boolean): boolean;
+function CreateLocalLabel(const s: string; var hl: tasmlabel; emit:boolean):boolean;
+Function SearchLabel(const s: string; var hl: tasmlabel;emit:boolean): boolean;
 
 
 
 
 {---------------------------------------------------------------------
 {---------------------------------------------------------------------
@@ -76,7 +74,7 @@ type
     case typ:TOprType of
     case typ:TOprType of
       OPR_NONE   : ();
       OPR_NONE   : ();
       OPR_CONSTANT  : (val:longint);
       OPR_CONSTANT  : (val:longint);
-      OPR_SYMBOL    : (symbol:PAsmSymbol;symofs:longint);
+      OPR_SYMBOL    : (symbol:tasmsymbol;symofs:longint);
       OPR_REFERENCE : (ref:treference);
       OPR_REFERENCE : (ref:treference);
       OPR_REGISTER  : (reg:tregister);
       OPR_REGISTER  : (reg:tregister);
 {$ifdef m68k}
 {$ifdef m68k}
@@ -86,14 +84,13 @@ type
 {$endif m68k}
 {$endif m68k}
   end;
   end;
 
 
-  POperand = ^TOperand;
-  TOperand = object
+  TOperand = class
     size   : topsize;
     size   : topsize;
     hastype,          { if the operand has typecasted variable }
     hastype,          { if the operand has typecasted variable }
     hasvar : boolean; { if the operand is loaded with a variable }
     hasvar : boolean; { if the operand is loaded with a variable }
     opr    : TOprRec;
     opr    : TOprRec;
-    constructor init;
-    destructor  done;virtual;
+    constructor create;
+    destructor  destroy;override;
     Procedure BuildOperand;virtual;
     Procedure BuildOperand;virtual;
     Procedure SetSize(_size:longint;force:boolean);
     Procedure SetSize(_size:longint;force:boolean);
     Procedure SetCorrectSize(opcode:tasmop);virtual;
     Procedure SetCorrectSize(opcode:tasmop);virtual;
@@ -105,20 +102,19 @@ type
     Procedure InitRef;
     Procedure InitRef;
   end;
   end;
 
 
-  PInstruction = ^TInstruction;
-  TInstruction = object
+  TInstruction = class
     opcode    : tasmop;
     opcode    : tasmop;
     opsize    : topsize;
     opsize    : topsize;
     condition : tasmcond;
     condition : tasmcond;
     ops       : byte;
     ops       : byte;
     labeled   : boolean;
     labeled   : boolean;
-    operands  : array[1..maxoperands] of POperand;
-    constructor init;
-    destructor  done;virtual;
+    operands  : array[1..maxoperands] of toperand;
+    constructor create;
+    destructor  destroy;override;
     Procedure InitOperands;virtual;
     Procedure InitOperands;virtual;
     Procedure BuildOpcode;virtual;
     Procedure BuildOpcode;virtual;
     procedure ConcatInstruction(p:TAAsmoutput);virtual;
     procedure ConcatInstruction(p:TAAsmoutput);virtual;
-    Procedure SwapOperands;
+    Procedure Swatoperands;
   end;
   end;
 
 
 
 
@@ -149,12 +145,12 @@ type
   {  ( and ) parenthesis                                                }
   {  ( and ) parenthesis                                                }
   {**********************************************************************}
   {**********************************************************************}
 
 
-  TExprParse = Object
+  TExprParse = class
     public
     public
-     Constructor Init;
-     Destructor Done;
+     Constructor create;
+     Destructor Destroy;override;
      Function Evaluate(Expr:  String): longint;
      Function Evaluate(Expr:  String): longint;
-     Function Priority(_Operator: Char): longint; virtual;
+     Function Priority(_Operator: Char): longint;
     private
     private
      RPNStack   : Array[1..RPNMax] of longint;        { Stack For RPN calculator }
      RPNStack   : Array[1..RPNMax] of longint;        { Stack For RPN calculator }
      RPNTop     : longint;
      RPNTop     : longint;
@@ -198,7 +194,7 @@ Function SearchIConstant(const s:string; var l:longint): boolean;
 
 
   Procedure ConcatPasString(p : TAAsmoutput;s:string);
   Procedure ConcatPasString(p : TAAsmoutput;s:string);
   Procedure ConcatDirect(p : TAAsmoutput;s:string);
   Procedure ConcatDirect(p : TAAsmoutput;s:string);
-  Procedure ConcatLabel(p: TAAsmoutput;var l : pasmlabel);
+  Procedure ConcatLabel(p: TAAsmoutput;var l : tasmlabel);
   Procedure ConcatConstant(p : TAAsmoutput;value: longint; maxvalue: longint);
   Procedure ConcatConstant(p : TAAsmoutput;value: longint; maxvalue: longint);
   Procedure ConcatConstSymbol(p : TAAsmoutput;const sym:string;l:longint);
   Procedure ConcatConstSymbol(p : TAAsmoutput;const sym:string;l:longint);
   Procedure ConcatRealConstant(p : TAAsmoutput;value: bestreal; real_typ : tfloattype);
   Procedure ConcatRealConstant(p : TAAsmoutput;value: bestreal; real_typ : tfloattype);
@@ -230,7 +226,7 @@ uses
                               TExprParse
                               TExprParse
 *************************************************************************}
 *************************************************************************}
 
 
-Constructor TExprParse.Init;
+Constructor TExprParse.create;
 Begin
 Begin
 end;
 end;
 
 
@@ -491,7 +487,7 @@ begin
 end;
 end;
 
 
 
 
-Destructor TExprParse.Done;
+Destructor TExprParse.Destroy;
 Begin
 Begin
 end;
 end;
 
 
@@ -500,9 +496,9 @@ Function CalculateExpression(const expression: string): longint;
 var
 var
   expr: TExprParse;
   expr: TExprParse;
 Begin
 Begin
-  expr.Init;
+  expr:=TExprParse.create;
   CalculateExpression:=expr.Evaluate(expression);
   CalculateExpression:=expr.Evaluate(expression);
-  expr.Done;
+  expr.Free;
 end;
 end;
 
 
 
 
@@ -694,7 +690,7 @@ end;
                                    TOperand
                                    TOperand
 ****************************************************************************}
 ****************************************************************************}
 
 
-constructor TOperand.init;
+constructor TOperand.Create;
 begin
 begin
   size:=S_NO;
   size:=S_NO;
   hastype:=false;
   hastype:=false;
@@ -703,7 +699,7 @@ begin
 end;
 end;
 
 
 
 
-destructor TOperand.done;
+destructor TOperand.destroy;
 begin
 begin
 end;
 end;
 
 
@@ -790,23 +786,23 @@ Function TOperand.SetupVar(const hs:string;GetOffset : boolean): Boolean;
 { for the NON-constant identifier passed to the routine.    }
 { for the NON-constant identifier passed to the routine.    }
 { if not found returns FALSE.                               }
 { if not found returns FALSE.                               }
 var
 var
-  sym : psym;
-  srsymtable : psymtable;
-  harrdef : parraydef;
+  sym : tsym;
+  srsymtable : tsymtable;
+  harrdef : tarraydef;
 Begin
 Begin
   SetupVar:=false;
   SetupVar:=false;
 { are we in a routine ? }
 { are we in a routine ? }
   searchsym(hs,sym,srsymtable);
   searchsym(hs,sym,srsymtable);
   if sym=nil then
   if sym=nil then
    exit;
    exit;
-  case sym^.typ of
+  case sym.typ of
     varsym :
     varsym :
       begin
       begin
         { we always assume in asm statements that     }
         { we always assume in asm statements that     }
         { that the variable is valid.                 }
         { that the variable is valid.                 }
-        pvarsym(sym)^.varstate:=vs_used;
-        inc(pvarsym(sym)^.refs);
-        case pvarsym(sym)^.owner^.symtabletype of
+        tvarsym(sym).varstate:=vs_used;
+        inc(tvarsym(sym).refs);
+        case tvarsym(sym).owner.symtabletype of
           objectsymtable :
           objectsymtable :
             begin
             begin
               { this is not allowed, because we don't know if the self
               { this is not allowed, because we don't know if the self
@@ -816,32 +812,31 @@ Begin
               if (m_tp in aktmodeswitches) then
               if (m_tp in aktmodeswitches) then
                 begin
                 begin
                   opr.typ:=OPR_CONSTANT;
                   opr.typ:=OPR_CONSTANT;
-                  opr.val:=pvarsym(sym)^.address;
+                  opr.val:=tvarsym(sym).address;
                 end
                 end
               { I do not agree here people using method vars should ensure
               { I do not agree here people using method vars should ensure
                 that %esi is valid there }
                 that %esi is valid there }
               else
               else
                 begin
                 begin
                   opr.ref.base:=self_pointer;
                   opr.ref.base:=self_pointer;
-                  opr.ref.offset:=pvarsym(sym)^.address;
+                  opr.ref.offset:=tvarsym(sym).address;
                 end;
                 end;
               hasvar:=true;
               hasvar:=true;
               SetupVar:=true;
               SetupVar:=true;
               Exit;
               Exit;
             end;
             end;
-          unitsymtable,
           globalsymtable,
           globalsymtable,
           staticsymtable :
           staticsymtable :
-            opr.ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname);
+            opr.ref.symbol:=newasmsymbol(tvarsym(sym).mangledname);
           parasymtable :
           parasymtable :
             begin
             begin
               { if we only want the offset we don't have to care
               { if we only want the offset we don't have to care
                 the base will be zeroed after ! }
                 the base will be zeroed after ! }
-              if (lexlevel=pvarsym(sym)^.owner^.symtablelevel) or
+              if (lexlevel=tvarsym(sym).owner.symtablelevel) or
               { this below is wrong because there are two parast
               { this below is wrong because there are two parast
                 for global functions one of interface the second of
                 for global functions one of interface the second of
                 implementation
                 implementation
-              if (pvarsym(sym)^.owner=procinfo^.def^.parast) or }
+              if (tvarsym(sym).owner=procinfo^.def.parast) or }
                 GetOffset then
                 GetOffset then
                 begin
                 begin
                   opr.ref.base:=procinfo^.framepointer;
                   opr.ref.base:=procinfo^.framepointer;
@@ -850,18 +845,18 @@ Begin
                 begin
                 begin
                   if (procinfo^.framepointer=stack_pointer) and
                   if (procinfo^.framepointer=stack_pointer) and
                      assigned(procinfo^.parent) and
                      assigned(procinfo^.parent) and
-                     (lexlevel=pvarsym(sym)^.owner^.symtablelevel+1) and
+                     (lexlevel=tvarsym(sym).owner.symtablelevel+1) and
                      { same problem as above !!
                      { same problem as above !!
-                     (procinfo^.parent^.sym^.definition^.parast=pvarsym(sym)^.owner) and }
+                     (procinfo^.parent^.sym.definition.parast=tvarsym(sym).owner) and }
                      (lexlevel>normal_function_level) then
                      (lexlevel>normal_function_level) then
                     opr.ref.base:=procinfo^.parent^.framepointer
                     opr.ref.base:=procinfo^.parent^.framepointer
                   else
                   else
                     message1(asmr_e_local_para_unreachable,hs);
                     message1(asmr_e_local_para_unreachable,hs);
                 end;
                 end;
-              opr.ref.offset:=pvarsym(sym)^.address;
-              if (lexlevel=pvarsym(sym)^.owner^.symtablelevel) then
+              opr.ref.offset:=tvarsym(sym).address;
+              if (lexlevel=tvarsym(sym).owner.symtablelevel) then
                 begin
                 begin
-                  opr.ref.offsetfixup:=aktprocsym^.definition^.parast^.address_fixup;
+                  opr.ref.offsetfixup:=aktprocsym.definition.parast.address_fixup;
                   opr.ref.options:=ref_parafixup;
                   opr.ref.options:=ref_parafixup;
                 end
                 end
               else
               else
@@ -869,38 +864,38 @@ Begin
                   opr.ref.offsetfixup:=0;
                   opr.ref.offsetfixup:=0;
                   opr.ref.options:=ref_none;
                   opr.ref.options:=ref_none;
                 end;
                 end;
-              if (pvarsym(sym)^.varspez=vs_var) or
-                 ((pvarsym(sym)^.varspez=vs_const) and
-                 push_addr_param(pvarsym(sym)^.vartype.def)) then
+              if (tvarsym(sym).varspez=vs_var) or
+                 ((tvarsym(sym).varspez=vs_const) and
+                 push_addr_param(tvarsym(sym).vartype.def)) then
                 SetSize(target_os.size_of_pointer,false);
                 SetSize(target_os.size_of_pointer,false);
             end;
             end;
           localsymtable :
           localsymtable :
             begin
             begin
-              if (vo_is_external in pvarsym(sym)^.varoptions) then
-                opr.ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname)
+              if (vo_is_external in tvarsym(sym).varoptions) then
+                opr.ref.symbol:=newasmsymbol(tvarsym(sym).mangledname)
               else
               else
                 begin
                 begin
                   { if we only want the offset we don't have to care
                   { if we only want the offset we don't have to care
                     the base will be zeroed after ! }
                     the base will be zeroed after ! }
-                  if (lexlevel=pvarsym(sym)^.owner^.symtablelevel) or
-                  {if (pvarsym(sym)^.owner=procinfo^.def^.localst) or}
+                  if (lexlevel=tvarsym(sym).owner.symtablelevel) or
+                  {if (tvarsym(sym).owner=procinfo^.def.localst) or}
                     GetOffset then
                     GetOffset then
                     opr.ref.base:=procinfo^.framepointer
                     opr.ref.base:=procinfo^.framepointer
                   else
                   else
                     begin
                     begin
                       if (procinfo^.framepointer=stack_pointer) and
                       if (procinfo^.framepointer=stack_pointer) and
                          assigned(procinfo^.parent) and
                          assigned(procinfo^.parent) and
-                         (lexlevel=pvarsym(sym)^.owner^.symtablelevel+1) and
-                         {(procinfo^.parent^.sym^.definition^.localst=pvarsym(sym)^.owner) and}
+                         (lexlevel=tvarsym(sym).owner.symtablelevel+1) and
+                         {(procinfo^.parent^.sym.definition.localst=tvarsym(sym).owner) and}
                          (lexlevel>normal_function_level) then
                          (lexlevel>normal_function_level) then
                         opr.ref.base:=procinfo^.parent^.framepointer
                         opr.ref.base:=procinfo^.parent^.framepointer
                       else
                       else
                         message1(asmr_e_local_para_unreachable,hs);
                         message1(asmr_e_local_para_unreachable,hs);
                     end;
                     end;
-                  opr.ref.offset:=-(pvarsym(sym)^.address);
-                  if (lexlevel=pvarsym(sym)^.owner^.symtablelevel) then
+                  opr.ref.offset:=-(tvarsym(sym).address);
+                  if (lexlevel=tvarsym(sym).owner.symtablelevel) then
                     begin
                     begin
-                      opr.ref.offsetfixup:=aktprocsym^.definition^.localst^.address_fixup;
+                      opr.ref.offsetfixup:=aktprocsym.definition.localst.address_fixup;
                       opr.ref.options:=ref_localfixup;
                       opr.ref.options:=ref_localfixup;
                     end
                     end
                   else
                   else
@@ -909,27 +904,27 @@ Begin
                       opr.ref.options:=ref_none;
                       opr.ref.options:=ref_none;
                     end;
                     end;
                 end;
                 end;
-              if (pvarsym(sym)^.varspez in [vs_var,vs_out]) or
-                 ((pvarsym(sym)^.varspez=vs_const) and
-                  push_addr_param(pvarsym(sym)^.vartype.def)) then
+              if (tvarsym(sym).varspez in [vs_var,vs_out]) or
+                 ((tvarsym(sym).varspez=vs_const) and
+                  push_addr_param(tvarsym(sym).vartype.def)) then
                 SetSize(target_os.size_of_pointer,false);
                 SetSize(target_os.size_of_pointer,false);
             end;
             end;
         end;
         end;
-        case pvarsym(sym)^.vartype.def^.deftype of
+        case tvarsym(sym).vartype.def.deftype of
           orddef,
           orddef,
           enumdef,
           enumdef,
           pointerdef,
           pointerdef,
           floatdef :
           floatdef :
-            SetSize(pvarsym(sym)^.getsize,false);
+            SetSize(tvarsym(sym).getsize,false);
           arraydef :
           arraydef :
             begin
             begin
               { for arrays try to get the element size, take care of
               { for arrays try to get the element size, take care of
                 multiple indexes }
                 multiple indexes }
-              harrdef:=Parraydef(PVarsym(sym)^.vartype.def);
-              while assigned(harrdef^.elementtype.def) and
-                    (harrdef^.elementtype.def^.deftype=arraydef) do
-               harrdef:=parraydef(harrdef^.elementtype.def);
-              SetSize(harrdef^.elesize,false);
+              harrdef:=tarraydef(tvarsym(sym).vartype.def);
+              while assigned(harrdef.elementtype.def) and
+                    (harrdef.elementtype.def.deftype=arraydef) do
+               harrdef:=tarraydef(harrdef.elementtype.def);
+              SetSize(harrdef.elesize,false);
             end;
             end;
         end;
         end;
         hasvar:=true;
         hasvar:=true;
@@ -938,22 +933,22 @@ Begin
       end;
       end;
     typedconstsym :
     typedconstsym :
       begin
       begin
-        opr.ref.symbol:=newasmsymbol(ptypedconstsym(sym)^.mangledname);
-        case ptypedconstsym(sym)^.typedconsttype.def^.deftype of
+        opr.ref.symbol:=newasmsymbol(ttypedconstsym(sym).mangledname);
+        case ttypedconstsym(sym).typedconsttype.def.deftype of
           orddef,
           orddef,
           enumdef,
           enumdef,
           pointerdef,
           pointerdef,
           floatdef :
           floatdef :
-            SetSize(ptypedconstsym(sym)^.getsize,false);
+            SetSize(ttypedconstsym(sym).getsize,false);
           arraydef :
           arraydef :
             begin
             begin
               { for arrays try to get the element size, take care of
               { for arrays try to get the element size, take care of
                 multiple indexes }
                 multiple indexes }
-              harrdef:=Parraydef(PTypedConstSym(sym)^.typedconsttype.def);
-              while assigned(harrdef^.elementtype.def) and
-                    (harrdef^.elementtype.def^.deftype=arraydef) do
-               harrdef:=parraydef(harrdef^.elementtype.def);
-              SetSize(harrdef^.elesize,false);
+              harrdef:=tarraydef(ttypedconstsym(sym).typedconsttype.def);
+              while assigned(harrdef.elementtype.def) and
+                    (harrdef.elementtype.def.deftype=arraydef) do
+               harrdef:=tarraydef(harrdef.elementtype.def);
+              SetSize(harrdef.elesize,false);
             end;
             end;
         end;
         end;
         hasvar:=true;
         hasvar:=true;
@@ -962,17 +957,17 @@ Begin
       end;
       end;
     constsym :
     constsym :
       begin
       begin
-        if pconstsym(sym)^.consttyp in [constint,constchar,constbool] then
+        if tconstsym(sym).consttyp in [constint,constchar,constbool] then
          begin
          begin
            opr.typ:=OPR_CONSTANT;
            opr.typ:=OPR_CONSTANT;
-           opr.val:=pconstsym(sym)^.value;
+           opr.val:=tconstsym(sym).value;
            SetupVar:=true;
            SetupVar:=true;
            Exit;
            Exit;
          end;
          end;
       end;
       end;
     typesym :
     typesym :
       begin
       begin
-        if ptypesym(sym)^.restype.def^.deftype in [recorddef,objectdef] then
+        if ttypesym(sym).restype.def.deftype in [recorddef,objectdef] then
          begin
          begin
            opr.typ:=OPR_CONSTANT;
            opr.typ:=OPR_CONSTANT;
            opr.val:=0;
            opr.val:=0;
@@ -982,10 +977,10 @@ Begin
       end;
       end;
     procsym :
     procsym :
       begin
       begin
-        if assigned(pprocsym(sym)^.definition^.nextoverloaded) then
+        if assigned(tprocsym(sym).definition.nextoverloaded) then
           Message(asmr_w_calling_overload_func);
           Message(asmr_w_calling_overload_func);
         opr.typ:=OPR_SYMBOL;
         opr.typ:=OPR_SYMBOL;
-        opr.symbol:=newasmsymbol(pprocsym(sym)^.definition^.mangledname);
+        opr.symbol:=newasmsymbol(tprocsym(sym).definition.mangledname);
         hasvar:=true;
         hasvar:=true;
         SetupVar:=TRUE;
         SetupVar:=TRUE;
         Exit;
         Exit;
@@ -1002,7 +997,7 @@ end;
 { looks for internal names of variables and routines }
 { looks for internal names of variables and routines }
 Function TOperand.SetupDirectVar(const hs:string): Boolean;
 Function TOperand.SetupDirectVar(const hs:string): Boolean;
 var
 var
-  p : pasmsymbol;
+  p : tasmsymbol;
 begin
 begin
   SetupDirectVar:=false;
   SetupDirectVar:=false;
   p:=getasmsymbol(hs);
   p:=getasmsymbol(hs);
@@ -1046,7 +1041,7 @@ end;
                                  TInstruction
                                  TInstruction
 ****************************************************************************}
 ****************************************************************************}
 
 
-constructor TInstruction.init;
+constructor TInstruction.create;
 Begin
 Begin
   Opcode:=A_NONE;
   Opcode:=A_NONE;
   Opsize:=S_NO;
   Opsize:=S_NO;
@@ -1057,12 +1052,12 @@ Begin
 end;
 end;
 
 
 
 
-destructor TInstruction.done;
+destructor TInstruction.destroy;
 var
 var
   i : longint;
   i : longint;
 Begin
 Begin
   for i:=1 to 3 do
   for i:=1 to 3 do
-   Dispose(Operands[i],Done);
+   Operands[i].free;
 end;
 end;
 
 
 
 
@@ -1071,13 +1066,13 @@ var
   i : longint;
   i : longint;
 begin
 begin
   for i:=1 to 3 do
   for i:=1 to 3 do
-   New(Operands[i],init);
+   Operands[i].create;
 end;
 end;
 
 
 
 
-Procedure TInstruction.SwapOperands;
+Procedure TInstruction.Swatoperands;
 Var
 Var
-  p : POperand;
+  p : toperand;
 Begin
 Begin
   case Ops of
   case Ops of
    2 :
    2 :
@@ -1112,23 +1107,23 @@ end;
                                  TLocalLabel
                                  TLocalLabel
 ***************************************************************************}
 ***************************************************************************}
 
 
-constructor TLocalLabel.Init(const n:string);
+constructor TLocalLabel.create(const n:string);
 begin
 begin
-  inherited InitName(n);
+  inherited CreateName(n);
   lab:=nil;
   lab:=nil;
   emitted:=false;
   emitted:=false;
 end;
 end;
 
 
 
 
-function TLocalLabel.Getpasmlabel:pasmlabel;
+function TLocalLabel.Gettasmlabel:tasmlabel;
 begin
 begin
   if not assigned(lab) then
   if not assigned(lab) then
    begin
    begin
      getlabel(lab);
      getlabel(lab);
      { this label is forced to be used so it's always written }
      { this label is forced to be used so it's always written }
-     inc(lab^.refs);
+     inc(lab.refs);
    end;
    end;
-  Getpasmlabel:=lab;
+  Gettasmlabel:=lab;
 end;
 end;
 
 
 
 
@@ -1136,41 +1131,41 @@ end;
                              TLocalLabelList
                              TLocalLabelList
 ***************************************************************************}
 ***************************************************************************}
 
 
-procedure LocalLabelEmitted(p:PNamedIndexObject);
+procedure LocalLabelEmitted(p:tnamedindexitem);
 begin
 begin
-  if not PLocalLabel(p)^.emitted  then
-   Message1(asmr_e_unknown_label_identifier,p^.name);
+  if not TLocalLabel(p).emitted  then
+   Message1(asmr_e_unknown_label_identifier,p.name);
 end;
 end;
 
 
 procedure TLocalLabelList.CheckEmitted;
 procedure TLocalLabelList.CheckEmitted;
 begin
 begin
-  ForEach({$ifdef FPCPROCVAR}@{$endif}LocalLabelEmitted)
+  ForEach_Static({$ifdef FPCPROCVAR}@{$endif}LocalLabelEmitted)
 end;
 end;
 
 
 
 
-function CreateLocalLabel(const s: string; var hl: pasmlabel; emit:boolean):boolean;
+function CreateLocalLabel(const s: string; var hl: tasmlabel; emit:boolean):boolean;
 var
 var
-  lab : PLocalLabel;
+  lab : TLocalLabel;
 Begin
 Begin
   CreateLocalLabel:=true;
   CreateLocalLabel:=true;
 { Check if it already is defined }
 { Check if it already is defined }
-  lab:=PLocalLabel(LocalLabelList^.Search(s));
+  lab:=TLocalLabel(LocalLabellist.Search(s));
   if not assigned(lab) then
   if not assigned(lab) then
    begin
    begin
-     new(lab,init(s));
-     LocalLabelList^.Insert(lab);
+     lab:=TLocalLabel.Create(s);
+     LocalLabellist.Insert(lab);
    end;
    end;
 { set emitted flag and check for dup syms }
 { set emitted flag and check for dup syms }
   if emit then
   if emit then
    begin
    begin
-     if lab^.Emitted then
+     if lab.Emitted then
       begin
       begin
-        Message1(asmr_e_dup_local_sym,lab^.Name);
+        Message1(asmr_e_dup_local_sym,lab.Name);
         CreateLocalLabel:=false;
         CreateLocalLabel:=false;
       end;
       end;
-     lab^.Emitted:=true;
+     lab.Emitted:=true;
    end;
    end;
-  hl:=lab^.Getpasmlabel;
+  hl:=lab.Gettasmlabel;
 end;
 end;
 
 
 
 
@@ -1180,30 +1175,30 @@ end;
 
 
 Function SearchType(const hs:string): Boolean;
 Function SearchType(const hs:string): Boolean;
 var
 var
-  srsym : psym;
-  srsymtable : psymtable;
+  srsym : tsym;
+  srsymtable : tsymtable;
 begin
 begin
   searchsym(hs,srsym,srsymtable);
   searchsym(hs,srsym,srsymtable);
   SearchType:=assigned(srsym) and
   SearchType:=assigned(srsym) and
-             (srsym^.typ=typesym);
+             (srsym.typ=typesym);
 end;
 end;
 
 
 
 
 
 
 Function SearchRecordType(const s:string): boolean;
 Function SearchRecordType(const s:string): boolean;
 var
 var
-  srsym : psym;
-  srsymtable : psymtable;
+  srsym : tsym;
+  srsymtable : tsymtable;
 Begin
 Begin
   SearchRecordType:=false;
   SearchRecordType:=false;
 { Check the constants in symtable }
 { Check the constants in symtable }
   searchsym(s,srsym,srsymtable);
   searchsym(s,srsym,srsymtable);
   if srsym <> nil then
   if srsym <> nil then
    Begin
    Begin
-     case srsym^.typ of
+     case srsym.typ of
        typesym :
        typesym :
          begin
          begin
-           if ptypesym(srsym)^.restype.def^.deftype in [recorddef,objectdef] then
+           if ttypesym(srsym).restype.def.deftype in [recorddef,objectdef] then
             begin
             begin
               SearchRecordType:=true;
               SearchRecordType:=true;
               exit;
               exit;
@@ -1224,8 +1219,8 @@ Function SearchIConstant(const s:string; var l:longint): boolean;
 {  respectively.                                                       }
 {  respectively.                                                       }
 {**********************************************************************}
 {**********************************************************************}
 var
 var
-  srsym : psym;
-  srsymtable : psymtable;
+  srsym : tsym;
+  srsymtable : tsymtable;
 Begin
 Begin
   SearchIConstant:=false;
   SearchIConstant:=false;
 { check for TRUE or FALSE reserved words first }
 { check for TRUE or FALSE reserved words first }
@@ -1245,19 +1240,19 @@ Begin
   searchsym(s,srsym,srsymtable);
   searchsym(s,srsym,srsymtable);
   if srsym <> nil then
   if srsym <> nil then
    Begin
    Begin
-     case srsym^.typ of
+     case srsym.typ of
        constsym :
        constsym :
          begin
          begin
-           if (pconstsym(srsym)^.consttyp in [constord,constint,constchar,constbool]) then
+           if (tconstsym(srsym).consttyp in [constord,constint,constchar,constbool]) then
             Begin
             Begin
-              l:=pconstsym(srsym)^.value;
+              l:=tconstsym(srsym).value;
               SearchIConstant:=TRUE;
               SearchIConstant:=TRUE;
               exit;
               exit;
             end;
             end;
          end;
          end;
        enumsym:
        enumsym:
          Begin
          Begin
-           l:=penumsym(srsym)^.value;
+           l:=tenumsym(srsym).value;
            SearchIConstant:=TRUE;
            SearchIConstant:=TRUE;
            exit;
            exit;
          end;
          end;
@@ -1272,10 +1267,10 @@ Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):bool
 { returns FALSE if not found.                                  }
 { returns FALSE if not found.                                  }
 { used when base is a variable or a typed constant name.       }
 { used when base is a variable or a typed constant name.       }
 var
 var
-  st   : psymtable;
-  harrdef : parraydef;
-  sym  : psym;
-  srsymtable : psymtable;
+  st   : tsymtable;
+  harrdef : tarraydef;
+  sym  : tsym;
+  srsymtable : tsymtable;
   i    : longint;
   i    : longint;
   base : string;
   base : string;
 Begin
 Begin
@@ -1288,38 +1283,38 @@ Begin
   base:=Copy(s,1,i-1);
   base:=Copy(s,1,i-1);
   delete(s,1,i);
   delete(s,1,i);
   if base='SELF' then
   if base='SELF' then
-   st:=procinfo^._class^.symtable
+   st:=procinfo^._class.symtable
   else
   else
    begin
    begin
      searchsym(base,sym,srsymtable);
      searchsym(base,sym,srsymtable);
      st:=nil;
      st:=nil;
      { we can start with a var,type,typedconst }
      { we can start with a var,type,typedconst }
-     case sym^.typ of
+     case sym.typ of
        varsym :
        varsym :
          begin
          begin
-           case pvarsym(sym)^.vartype.def^.deftype of
+           case tvarsym(sym).vartype.def.deftype of
              recorddef :
              recorddef :
-               st:=precorddef(pvarsym(sym)^.vartype.def)^.symtable;
+               st:=trecorddef(tvarsym(sym).vartype.def).symtable;
              objectdef :
              objectdef :
-               st:=pobjectdef(pvarsym(sym)^.vartype.def)^.symtable;
+               st:=tobjectdef(tvarsym(sym).vartype.def).symtable;
            end;
            end;
          end;
          end;
        typesym :
        typesym :
          begin
          begin
-           case ptypesym(sym)^.restype.def^.deftype of
+           case ttypesym(sym).restype.def.deftype of
              recorddef :
              recorddef :
-               st:=precorddef(ptypesym(sym)^.restype.def)^.symtable;
+               st:=trecorddef(ttypesym(sym).restype.def).symtable;
              objectdef :
              objectdef :
-               st:=pobjectdef(ptypesym(sym)^.restype.def)^.symtable;
+               st:=tobjectdef(ttypesym(sym).restype.def).symtable;
            end;
            end;
          end;
          end;
        typedconstsym :
        typedconstsym :
          begin
          begin
-           case ptypedconstsym(sym)^.typedconsttype.def^.deftype of
+           case ttypedconstsym(sym).typedconsttype.def.deftype of
              recorddef :
              recorddef :
-               st:=precorddef(ptypedconstsym(sym)^.typedconsttype.def)^.symtable;
+               st:=trecorddef(ttypedconstsym(sym).typedconsttype.def).symtable;
              objectdef :
              objectdef :
-               st:=pobjectdef(ptypedconstsym(sym)^.typedconsttype.def)^.symtable;
+               st:=tobjectdef(ttypedconstsym(sym).typedconsttype.def).symtable;
            end;
            end;
          end;
          end;
      end;
      end;
@@ -1333,36 +1328,36 @@ Begin
       i:=255;
       i:=255;
      base:=Copy(s,1,i-1);
      base:=Copy(s,1,i-1);
      delete(s,1,i);
      delete(s,1,i);
-     if st^.symtabletype=objectsymtable then
-       sym:=search_class_member(pobjectdef(st^.defowner),base)
+     if st.symtabletype=objectsymtable then
+       sym:=search_class_member(tobjectdef(st.defowner),base)
      else
      else
-       sym:=psym(st^.search(base));
+       sym:=tsym(st.search(base));
      if not assigned(sym) then
      if not assigned(sym) then
       begin
       begin
         GetRecordOffsetSize:=false;
         GetRecordOffsetSize:=false;
         exit;
         exit;
       end;
       end;
      st:=nil;
      st:=nil;
-     case sym^.typ of
+     case sym.typ of
        varsym :
        varsym :
          begin
          begin
-           inc(Offset,pvarsym(sym)^.address);
-           Size:=PVarsym(sym)^.getsize;
-           case pvarsym(sym)^.vartype.def^.deftype of
+           inc(Offset,tvarsym(sym).address);
+           Size:=tvarsym(sym).getsize;
+           case tvarsym(sym).vartype.def.deftype of
              arraydef :
              arraydef :
                begin
                begin
                  { for arrays try to get the element size, take care of
                  { for arrays try to get the element size, take care of
                    multiple indexes }
                    multiple indexes }
-                 harrdef:=Parraydef(PVarsym(sym)^.vartype.def);
-                 while assigned(harrdef^.elementtype.def) and
-                       (harrdef^.elementtype.def^.deftype=arraydef) do
-                  harrdef:=parraydef(harrdef^.elementtype.def);
-                 size:=harrdef^.elesize;
+                 harrdef:=tarraydef(tvarsym(sym).vartype.def);
+                 while assigned(harrdef.elementtype.def) and
+                       (harrdef.elementtype.def.deftype=arraydef) do
+                  harrdef:=tarraydef(harrdef.elementtype.def);
+                 size:=harrdef.elesize;
                end;
                end;
              recorddef :
              recorddef :
-               st:=precorddef(pvarsym(sym)^.vartype.def)^.symtable;
+               st:=trecorddef(tvarsym(sym).vartype.def).symtable;
              objectdef :
              objectdef :
-               st:=pobjectdef(pvarsym(sym)^.vartype.def)^.symtable;
+               st:=tobjectdef(tvarsym(sym).vartype.def).symtable;
            end;
            end;
          end;
          end;
      end;
      end;
@@ -1371,10 +1366,10 @@ Begin
 end;
 end;
 
 
 
 
-Function SearchLabel(const s: string; var hl: pasmlabel;emit:boolean): boolean;
+Function SearchLabel(const s: string; var hl: tasmlabel;emit:boolean): boolean;
 var
 var
-  sym : psym;
-  srsymtable : psymtable;
+  sym : tsym;
+  srsymtable : tsymtable;
   hs  : string;
   hs  : string;
 Begin
 Begin
   hl:=nil;
   hl:=nil;
@@ -1384,14 +1379,14 @@ Begin
   searchsym(hs,sym,srsymtable);
   searchsym(hs,sym,srsymtable);
   if sym=nil then
   if sym=nil then
    exit;
    exit;
-  case sym^.typ of
+  case sym.typ of
     labelsym :
     labelsym :
       begin
       begin
-        hl:=plabelsym(sym)^.lab;
+        hl:=tlabelsym(sym).lab;
         if emit then
         if emit then
-         plabelsym(sym)^.defined:=true
+         tlabelsym(sym).defined:=true
         else
         else
-         plabelsym(sym)^.used:=true;
+         tlabelsym(sym).used:=true;
         SearchLabel:=true;
         SearchLabel:=true;
         exit;
         exit;
       end;
       end;
@@ -1501,7 +1496,7 @@ end;
        end;
        end;
     end;
     end;
 
 
-   Procedure ConcatLabel(p: TAAsmoutput;var l : pasmlabel);
+   Procedure ConcatLabel(p: TAAsmoutput;var l : tasmlabel);
   {*********************************************************************}
   {*********************************************************************}
   { PROCEDURE ConcatLabel                                               }
   { PROCEDURE ConcatLabel                                               }
   {  Description: This routine either emits a label or a labeled        }
   {  Description: This routine either emits a label or a labeled        }
@@ -1564,7 +1559,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2001-04-02 21:20:34  peter
+  Revision 1.18  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.17  2001/04/02 21:20:34  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.16  2001/03/11 22:58:50  peter
   Revision 1.16  2001/03/11 22:58:50  peter

+ 89 - 85
compiler/regvars.pas

@@ -37,7 +37,7 @@ interface
     procedure cleanup_regvars(asml: TAAsmoutput);
     procedure cleanup_regvars(asml: TAAsmoutput);
 {$ifdef i386}
 {$ifdef i386}
     procedure store_regvar(asml: TAAsmoutput; reg: tregister);
     procedure store_regvar(asml: TAAsmoutput; reg: tregister);
-    procedure load_regvar(asml: TAAsmoutput; vsym: pvarsym);
+    procedure load_regvar(asml: TAAsmoutput; vsym: tvarsym);
     procedure load_regvar_reg(asml: TAAsmoutput; reg: tregister);
     procedure load_regvar_reg(asml: TAAsmoutput; reg: tregister);
     procedure load_all_regvars(asml: TAAsmoutput);
     procedure load_all_regvars(asml: TAAsmoutput);
 {$endif i386}
 {$endif i386}
@@ -46,21 +46,20 @@ implementation
 
 
     uses
     uses
       globtype,systems,comphook,
       globtype,systems,comphook,
-      cutils,cobjects,verbose,globals,
+      cutils,cclasses,verbose,globals,
       symconst,symbase,symtype,symdef,types,
       symconst,symbase,symtype,symdef,types,
       hcodegen,cpuasm,tgcpu;
       hcodegen,cpuasm,tgcpu;
 
 
-
     var
     var
       parasym : boolean;
       parasym : boolean;
 
 
-    procedure searchregvars(p : pnamedindexobject);
+    procedure searchregvars(p : tnamedindexitem);
       var
       var
          i,j,k : longint;
          i,j,k : longint;
       begin
       begin
-         if (psym(p)^.typ=varsym) and (vo_regable in pvarsym(p)^.varoptions) then
+         if (tsym(p).typ=varsym) and (vo_regable in tvarsym(p).varoptions) then
            begin
            begin
-              j:=pvarsym(p)^.refs;
+              j:=tvarsym(p).refs;
               { parameter get a less value }
               { parameter get a less value }
               if parasym then
               if parasym then
                 begin
                 begin
@@ -72,7 +71,7 @@ implementation
               { walk through all momentary register variables }
               { walk through all momentary register variables }
               for i:=1 to maxvarregs do
               for i:=1 to maxvarregs do
                 begin
                 begin
-                  with pregvarinfo(aktprocsym^.definition^.regvarinfo)^ do
+                  with pregvarinfo(aktprocsym.definition.regvarinfo)^ do
                    if ((regvars[i]=nil) or (j>regvars_refs[i])) and (j>0) then
                    if ((regvars[i]=nil) or (j>regvars_refs[i])) and (j>0) then
                      begin
                      begin
                         for k:=maxvarregs-1 downto i do
                         for k:=maxvarregs-1 downto i do
@@ -82,8 +81,8 @@ implementation
                              regvars_refs[k+1]:=regvars_refs[k];
                              regvars_refs[k+1]:=regvars_refs[k];
                           end;
                           end;
                         { calc the new refs
                         { calc the new refs
-                        pvarsym(p)^.refs:=j; }
-                        regvars[i]:=pvarsym(p);
+                        tvarsym(p).refs:=j; }
+                        regvars[i]:=tvarsym(p);
                         regvars_para[i]:=parasym;
                         regvars_para[i]:=parasym;
                         regvars_refs[i]:=j;
                         regvars_refs[i]:=j;
                         break;
                         break;
@@ -93,13 +92,13 @@ implementation
       end;
       end;
 
 
 
 
-    procedure searchfpuregvars(p : pnamedindexobject);
+    procedure searchfpuregvars(p : tnamedindexitem);
       var
       var
          i,j,k : longint;
          i,j,k : longint;
       begin
       begin
-         if (psym(p)^.typ=varsym) and (vo_fpuregable in pvarsym(p)^.varoptions) then
+         if (tsym(p).typ=varsym) and (vo_fpuregable in tvarsym(p).varoptions) then
            begin
            begin
-              j:=pvarsym(p)^.refs;
+              j:=tvarsym(p).refs;
               { parameter get a less value }
               { parameter get a less value }
               if parasym then
               if parasym then
                 begin
                 begin
@@ -111,7 +110,7 @@ implementation
               { walk through all momentary register variables }
               { walk through all momentary register variables }
               for i:=1 to maxfpuvarregs do
               for i:=1 to maxfpuvarregs do
                 begin
                 begin
-                  with pregvarinfo(aktprocsym^.definition^.regvarinfo)^ do
+                  with pregvarinfo(aktprocsym.definition.regvarinfo)^ do
                    if ((fpuregvars[i]=nil) or (j>fpuregvars_refs[i])) and (j>0) then
                    if ((fpuregvars[i]=nil) or (j>fpuregvars_refs[i])) and (j>0) then
                      begin
                      begin
                         for k:=maxfpuvarregs-1 downto i do
                         for k:=maxfpuvarregs-1 downto i do
@@ -121,8 +120,8 @@ implementation
                              fpuregvars_refs[k+1]:=fpuregvars_refs[k];
                              fpuregvars_refs[k+1]:=fpuregvars_refs[k];
                           end;
                           end;
                         { calc the new refs
                         { calc the new refs
-                        pvarsym(p)^.refs:=j; }
-                        fpuregvars[i]:=pvarsym(p);
+                        tvarsym(p).refs:=j; }
+                        fpuregvars[i]:=tvarsym(p);
                         fpuregvars_para[i]:=parasym;
                         fpuregvars_para[i]:=parasym;
                         fpuregvars_refs[i]:=j;
                         fpuregvars_refs[i]:=j;
                         break;
                         break;
@@ -162,14 +161,14 @@ implementation
         begin
         begin
           new(regvarinfo);
           new(regvarinfo);
           fillchar(regvarinfo^,sizeof(regvarinfo^),0);
           fillchar(regvarinfo^,sizeof(regvarinfo^),0);
-          aktprocsym^.definition^.regvarinfo := regvarinfo;
+          aktprocsym.definition.regvarinfo := regvarinfo;
           if (p.registers32<4) then
           if (p.registers32<4) then
             begin
             begin
               parasym:=false;
               parasym:=false;
-              symtablestack^.foreach({$ifdef FPCPROCVAR}@{$endif}searchregvars);
+              symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars);
               { copy parameter into a register ? }
               { copy parameter into a register ? }
               parasym:=true;
               parasym:=true;
-              symtablestack^.next^.foreach({$ifdef FPCPROCVAR}@{$endif}searchregvars);
+              symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars);
               { hold needed registers free }
               { hold needed registers free }
               for i:=maxvarregs downto maxvarregs-p.registers32+1 do
               for i:=maxvarregs downto maxvarregs-p.registers32+1 do
                 begin
                 begin
@@ -180,7 +179,7 @@ implementation
               for i:=1 to maxvarregs-p.registers32 do
               for i:=1 to maxvarregs-p.registers32 do
                 begin
                 begin
                   if assigned(regvarinfo^.regvars[i]) and
                   if assigned(regvarinfo^.regvars[i]) and
-                    (reg_pushes[varregs[i]] < regvarinfo^.regvars[i]^.refs) then
+                    (reg_pushes[varregs[i]] < regvarinfo^.regvars[i].refs) then
                     begin
                     begin
                       { register is no longer available for }
                       { register is no longer available for }
                       { expressions                          }
                       { expressions                          }
@@ -192,34 +191,34 @@ implementation
 
 
                       { possibly no 32 bit register are needed }
                       { possibly no 32 bit register are needed }
                       { call by reference/const ? }
                       { call by reference/const ? }
-                      if (regvarinfo^.regvars[i]^.varspez in [vs_var,vs_out]) or
-                         ((regvarinfo^.regvars[i]^.varspez=vs_const) and
-                           push_addr_param(regvarinfo^.regvars[i]^.vartype.def)) then
+                      if (regvarinfo^.regvars[i].varspez in [vs_var,vs_out]) or
+                         ((regvarinfo^.regvars[i].varspez=vs_const) and
+                           push_addr_param(regvarinfo^.regvars[i].vartype.def)) then
                         begin
                         begin
-                           regvarinfo^.regvars[i]^.reg:=varregs[i];
+                           regvarinfo^.regvars[i].reg:=varregs[i];
                         end
                         end
                       else
                       else
-                       if (regvarinfo^.regvars[i]^.vartype.def^.deftype in [orddef,enumdef]) and
-                          (porddef(regvarinfo^.regvars[i]^.vartype.def)^.size=1) then
+                       if (regvarinfo^.regvars[i].vartype.def.deftype in [orddef,enumdef]) and
+                          (torddef(regvarinfo^.regvars[i].vartype.def).size=1) then
                         begin
                         begin
 {$ifdef i386}
 {$ifdef i386}
-                          regvarinfo^.regvars[i]^.reg:=reg32toreg8(varregs[i]);
+                          regvarinfo^.regvars[i].reg:=reg32toreg8(varregs[i]);
 {$endif}
 {$endif}
                         end
                         end
                       else
                       else
-                       if (regvarinfo^.regvars[i]^.vartype.def^.deftype in [orddef,enumdef]) and
-                          (porddef(regvarinfo^.regvars[i]^.vartype.def)^.size=2) then
+                       if (regvarinfo^.regvars[i].vartype.def.deftype in [orddef,enumdef]) and
+                          (torddef(regvarinfo^.regvars[i].vartype.def).size=2) then
                          begin
                          begin
 {$ifdef i386}
 {$ifdef i386}
-                           regvarinfo^.regvars[i]^.reg:=reg32toreg16(varregs[i]);
+                           regvarinfo^.regvars[i].reg:=reg32toreg16(varregs[i]);
 {$endif}
 {$endif}
                          end
                          end
                       else
                       else
                         begin
                         begin
-                          regvarinfo^.regvars[i]^.reg:=varregs[i];
+                          regvarinfo^.regvars[i].reg:=varregs[i];
                         end;
                         end;
                       if regvarinfo^.regvars_para[i] then
                       if regvarinfo^.regvars_para[i] then
-                        unused:=unused - [regvarinfo^.regvars[i]^.reg];
+                        unused:=unused - [regvarinfo^.regvars[i].reg];
                       { procedure uses this register }
                       { procedure uses this register }
 {$ifdef i386}
 {$ifdef i386}
                       usedinproc:=usedinproc or ($80 shr byte(varregs[i]));
                       usedinproc:=usedinproc or ($80 shr byte(varregs[i]));
@@ -238,11 +237,11 @@ implementation
             if ((p.registersfpu+1)<maxfpuvarregs) then
             if ((p.registersfpu+1)<maxfpuvarregs) then
               begin
               begin
                 parasym:=false;
                 parasym:=false;
-                symtablestack^.foreach({$ifdef FPCPROCVAR}@{$endif}searchfpuregvars);
+                symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchfpuregvars);
 {$ifdef dummy}
 {$ifdef dummy}
                 { copy parameter into a register ? }
                 { copy parameter into a register ? }
                 parasym:=true;
                 parasym:=true;
-                symtablestack^.next^.foreach({$ifdef FPCPROCVAR}@{$endif}searchregvars);
+                symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars);
 {$endif dummy}
 {$endif dummy}
                 { hold needed registers free }
                 { hold needed registers free }
 
 
@@ -273,10 +272,10 @@ implementation
                      begin
                      begin
 {$ifdef i386}
 {$ifdef i386}
                        { reserve place on the FPU stack }
                        { reserve place on the FPU stack }
-                       regvarinfo^.fpuregvars[i]^.reg:=correct_fpuregister(R_ST0,i-1);
+                       regvarinfo^.fpuregvars[i].reg:=correct_fpuregister(R_ST0,i-1);
 {$endif i386}
 {$endif i386}
 {$ifdef m68k}
 {$ifdef m68k}
-                       regvarinfo^.fpuregvars[i]^.reg:=fpuvarregs[i];
+                       regvarinfo^.fpuregvars[i].reg:=fpuvarregs[i];
 {$endif m68k}
 {$endif m68k}
                      end;
                      end;
                   end;
                   end;
@@ -291,25 +290,25 @@ implementation
       i: longint;
       i: longint;
       hr: preference;
       hr: preference;
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
-      vsym: pvarsym;
+      vsym: tvarsym;
     begin
     begin
-      regvarinfo := pregvarinfo(aktprocsym^.definition^.regvarinfo);
+      regvarinfo := pregvarinfo(aktprocsym.definition.regvarinfo);
       if not assigned(regvarinfo) then
       if not assigned(regvarinfo) then
         exit;
         exit;
       for i := 1 to maxvarregs do
       for i := 1 to maxvarregs do
         if assigned(regvarinfo^.regvars[i]) and
         if assigned(regvarinfo^.regvars[i]) and
-           (reg32(regvarinfo^.regvars[i]^.reg) = reg) then
+           (reg32(regvarinfo^.regvars[i].reg) = reg) then
           begin
           begin
             if regvar_loaded[reg32(reg)] then
             if regvar_loaded[reg32(reg)] then
               begin
               begin
-                vsym := pvarsym(regvarinfo^.regvars[i]);
+                vsym := tvarsym(regvarinfo^.regvars[i]);
                 new(hr);
                 new(hr);
                 reset_reference(hr^);
                 reset_reference(hr^);
-                if vsym^.owner^.symtabletype in [inlinelocalsymtable,localsymtable] then
-                  hr^.offset:=-vsym^.address+vsym^.owner^.address_fixup
-                else hr^.offset:=vsym^.address+vsym^.owner^.address_fixup;
+                if vsym.owner.symtabletype in [inlinelocalsymtable,localsymtable] then
+                  hr^.offset:=-vsym.address+vsym.owner.address_fixup
+                else hr^.offset:=vsym.address+vsym.owner.address_fixup;
                 hr^.base:=procinfo^.framepointer;
                 hr^.base:=procinfo^.framepointer;
-                asml.concat(Taicpu.op_reg_ref(A_MOV,regsize(vsym^.reg),vsym^.reg,hr));
+                asml.concat(Taicpu.op_reg_ref(A_MOV,regsize(vsym.reg),vsym.reg,hr));
                 asml.concat(Tairegalloc.dealloc(reg32(reg)));
                 asml.concat(Tairegalloc.dealloc(reg32(reg)));
                 regvar_loaded[reg32(reg)] := false;
                 regvar_loaded[reg32(reg)] := false;
               end;
               end;
@@ -317,20 +316,20 @@ implementation
           end;
           end;
     end;
     end;
 
 
-    procedure load_regvar(asml: TAAsmoutput; vsym: pvarsym);
+    procedure load_regvar(asml: TAAsmoutput; vsym: tvarsym);
     var
     var
       hr: preference;
       hr: preference;
       opsize: topsize;
       opsize: topsize;
       opcode: tasmop;
       opcode: tasmop;
     begin
     begin
-      if not regvar_loaded[reg32(vsym^.reg)] then
+      if not regvar_loaded[reg32(vsym.reg)] then
         begin
         begin
-          asml.concat(Tairegalloc.alloc(reg32(vsym^.reg)));
+          asml.concat(Tairegalloc.alloc(reg32(vsym.reg)));
           { zero the regvars because the upper 48bits must be clear }
           { zero the regvars because the upper 48bits must be clear }
           { for 8bits vars when using them with btrl                }
           { for 8bits vars when using them with btrl                }
           { don't care about sign extension, since the upper 24/16  }
           { don't care about sign extension, since the upper 24/16  }
           { bits won't be adapted when doing maths anyway (JM)      }
           { bits won't be adapted when doing maths anyway (JM)      }
-          case regsize(vsym^.reg) of
+          case regsize(vsym.reg) of
             S_L:
             S_L:
               begin
               begin
                 opsize := S_L;
                 opsize := S_L;
@@ -347,15 +346,15 @@ implementation
                 opcode := A_MOVZX;
                 opcode := A_MOVZX;
               end;
               end;
           end;
           end;
-          asml.concat(Tairegalloc.alloc(reg32(vsym^.reg)));
+          asml.concat(Tairegalloc.alloc(reg32(vsym.reg)));
           new(hr);
           new(hr);
           reset_reference(hr^);
           reset_reference(hr^);
-          if vsym^.owner^.symtabletype in [inlinelocalsymtable,localsymtable] then
-            hr^.offset:=-vsym^.address+vsym^.owner^.address_fixup
-          else hr^.offset:=vsym^.address+vsym^.owner^.address_fixup;
+          if vsym.owner.symtabletype in [inlinelocalsymtable,localsymtable] then
+            hr^.offset:=-vsym.address+vsym.owner.address_fixup
+          else hr^.offset:=vsym.address+vsym.owner.address_fixup;
           hr^.base:=procinfo^.framepointer;
           hr^.base:=procinfo^.framepointer;
-          asml.concat(Taicpu.op_ref_reg(opcode,opsize,hr,reg32(vsym^.reg)));
-          regvar_loaded[reg32(vsym^.reg)] := true;
+          asml.concat(Taicpu.op_ref_reg(opcode,opsize,hr,reg32(vsym.reg)));
+          regvar_loaded[reg32(vsym.reg)] := true;
         end;
         end;
     end;
     end;
 
 
@@ -364,14 +363,14 @@ implementation
       i: longint;
       i: longint;
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
     begin
     begin
-      regvarinfo := pregvarinfo(aktprocsym^.definition^.regvarinfo);
+      regvarinfo := pregvarinfo(aktprocsym.definition.regvarinfo);
       if not assigned(regvarinfo) then
       if not assigned(regvarinfo) then
         exit;
         exit;
       reg := reg32(reg);
       reg := reg32(reg);
       for i := 1 to maxvarregs do
       for i := 1 to maxvarregs do
         if assigned(regvarinfo^.regvars[i]) and
         if assigned(regvarinfo^.regvars[i]) and
-           (reg32(regvarinfo^.regvars[i]^.reg) = reg) then
-          load_regvar(asml,pvarsym(regvarinfo^.regvars[i]))
+           (reg32(regvarinfo^.regvars[i].reg) = reg) then
+          load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
     end;
     end;
 
 
     procedure load_all_regvars(asml: TAAsmoutput);
     procedure load_all_regvars(asml: TAAsmoutput);
@@ -379,13 +378,13 @@ implementation
       i: longint;
       i: longint;
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
     begin
     begin
-      regvarinfo := pregvarinfo(aktprocsym^.definition^.regvarinfo);
+      regvarinfo := pregvarinfo(aktprocsym.definition.regvarinfo);
       if not assigned(regvarinfo) then
       if not assigned(regvarinfo) then
         exit;
         exit;
       for i := 1 to maxvarregs do
       for i := 1 to maxvarregs do
         if assigned(regvarinfo^.regvars[i]) and
         if assigned(regvarinfo^.regvars[i]) and
-           (reg32(regvarinfo^.regvars[i]^.reg) in [R_EAX,R_EBX,R_ECX,R_EDX]) then
-          load_regvar(asml,pvarsym(regvarinfo^.regvars[i]))
+           (reg32(regvarinfo^.regvars[i].reg) in [R_EAX,R_EBX,R_ECX,R_EDX]) then
+          load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
     end;
     end;
 
 
 {$endif i386}
 {$endif i386}
@@ -394,13 +393,13 @@ implementation
     procedure load_regvars(asml: TAAsmoutput; p: tnode);
     procedure load_regvars(asml: TAAsmoutput; p: tnode);
     var
     var
       i: longint;
       i: longint;
-      {hr      : preference;}
+      {hr      : treference;}
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
     begin
     begin
       if (cs_regalloc in aktglobalswitches) and
       if (cs_regalloc in aktglobalswitches) and
          ((procinfo^.flags and (pi_uses_asm or pi_uses_exceptions))=0) then
          ((procinfo^.flags and (pi_uses_asm or pi_uses_exceptions))=0) then
         begin
         begin
-          regvarinfo := pregvarinfo(aktprocsym^.definition^.regvarinfo);
+          regvarinfo := pregvarinfo(aktprocsym.definition.regvarinfo);
           { can happen when inlining assembler procedures (JM) }
           { can happen when inlining assembler procedures (JM) }
           if not assigned(regvarinfo) then
           if not assigned(regvarinfo) then
             exit;
             exit;
@@ -416,10 +415,10 @@ implementation
                   { when loading parameter to reg  }
                   { when loading parameter to reg  }
                   new(hr);
                   new(hr);
                   reset_reference(hr^);
                   reset_reference(hr^);
-                  hr^.offset:=pvarsym(regvarinfo^.regvars[i])^.address+procinfo^.para_offset;
+                  hr^.offset:=tvarsym(regvarinfo^.regvars[i])^.address+procinfo^.para_offset;
                   hr^.base:=procinfo^.framepointer;
                   hr^.base:=procinfo^.framepointer;
-                  asml.concat(Taicpu,op_ref_reg(A_MOVE,regsize(regvarinfo^.regvars[i]^.reg),
-                    hr,regvarinfo^.regvars[i]^.reg)));
+                  asml.concat(Taicpu,op_ref_reg(A_MOVE,regsize(regvarinfo^.regvars[i].reg),
+                    hr,regvarinfo^.regvars[i].reg)));
                 end
                 end
             end;
             end;
 {$endif m68k}
 {$endif m68k}
@@ -428,12 +427,12 @@ implementation
              if assigned(regvarinfo^.regvars[i]) then
              if assigned(regvarinfo^.regvars[i]) then
                begin
                begin
                 if cs_asm_source in aktglobalswitches then
                 if cs_asm_source in aktglobalswitches then
-                 asml.insert(Tai_asm_comment.Create(strpnew(regvarinfo^.regvars[i]^.name+
-                  ' with weight '+tostr(regvarinfo^.regvars[i]^.refs)+' assigned to register '+
-                  reg2str(regvarinfo^.regvars[i]^.reg))));
+                 asml.insert(Tai_asm_comment.Create(strpnew(regvarinfo^.regvars[i].name+
+                  ' with weight '+tostr(regvarinfo^.regvars[i].refs)+' assigned to register '+
+                  reg2str(regvarinfo^.regvars[i].reg))));
                 if (status.verbosity and v_debug)=v_debug then
                 if (status.verbosity and v_debug)=v_debug then
-                 Message3(cg_d_register_weight,reg2str(regvarinfo^.regvars[i]^.reg),
-                  tostr(regvarinfo^.regvars[i]^.refs),regvarinfo^.regvars[i]^.name);
+                 Message3(cg_d_register_weight,reg2str(regvarinfo^.regvars[i].reg),
+                  tostr(regvarinfo^.regvars[i].refs),regvarinfo^.regvars[i].name);
                end;
                end;
             end;
             end;
           for i:=1 to maxfpuvarregs do
           for i:=1 to maxfpuvarregs do
@@ -442,7 +441,7 @@ implementation
                 begin
                 begin
 {$ifdef i386}
 {$ifdef i386}
                   { reserve place on the FPU stack }
                   { reserve place on the FPU stack }
-                  regvarinfo^.fpuregvars[i]^.reg:=correct_fpuregister(R_ST0,i-1);
+                  regvarinfo^.fpuregvars[i].reg:=correct_fpuregister(R_ST0,i-1);
                   asml.concat(Taicpu.op_none(A_FLDZ,S_NO));
                   asml.concat(Taicpu.op_none(A_FLDZ,S_NO));
 {$endif i386}
 {$endif i386}
 {$ifdef dummy}
 {$ifdef dummy}
@@ -455,15 +454,15 @@ implementation
                       { when loading parameter to reg  }
                       { when loading parameter to reg  }
                       new(hr);
                       new(hr);
                       reset_reference(hr^);
                       reset_reference(hr^);
-                      hr^.offset:=pvarsym(regvarinfo^.regvars[i])^.address+procinfo^.para_offset;
+                      hr^.offset:=tvarsym(regvarinfo^.regvars[i])^.address+procinfo^.para_offset;
                       hr^.base:=procinfo^.framepointer;
                       hr^.base:=procinfo^.framepointer;
 {$ifdef i386}
 {$ifdef i386}
-                      asml.concat(Taicpu,op_ref_reg(A_MOV,regsize(regvarinfo^.regvars[i]^.reg),
-                        hr,regvarinfo^.regvars[i]^.reg)));
+                      asml.concat(Taicpu,op_ref_reg(A_MOV,regsize(regvarinfo^.regvars[i].reg),
+                        hr,regvarinfo^.regvars[i].reg)));
 {$endif i386}
 {$endif i386}
 {$ifdef m68k}
 {$ifdef m68k}
-                      asml.concat(Taicpu,op_ref_reg(A_MOVE,regsize(regvarinfo^.regvars[i]^.reg),
-                        hr,regvarinfo^.regvars[i]^.reg)));
+                      asml.concat(Taicpu,op_ref_reg(A_MOVE,regsize(regvarinfo^.regvars[i].reg),
+                        hr,regvarinfo^.regvars[i].reg)));
 {$endif m68k}
 {$endif m68k}
                     end;
                     end;
 {$endif dummy}
 {$endif dummy}
@@ -478,12 +477,12 @@ implementation
                if assigned(regvarinfo^.fpuregvars[i]) then
                if assigned(regvarinfo^.fpuregvars[i]) then
                  begin
                  begin
                     if cs_asm_source in aktglobalswitches then
                     if cs_asm_source in aktglobalswitches then
-                      asml.insert(Tai_asm_comment.Create(strpnew(regvarinfo^.fpuregvars[i]^.name+
-                        ' with weight '+tostr(regvarinfo^.fpuregvars[i]^.refs)+' assigned to register '+
-                        reg2str(regvarinfo^.fpuregvars[i]^.reg))));
+                      asml.insert(Tai_asm_comment.Create(strpnew(regvarinfo^.fpuregvars[i].name+
+                        ' with weight '+tostr(regvarinfo^.fpuregvars[i].refs)+' assigned to register '+
+                        reg2str(regvarinfo^.fpuregvars[i].reg))));
                     if (status.verbosity and v_debug)=v_debug then
                     if (status.verbosity and v_debug)=v_debug then
-                      Message3(cg_d_register_weight,reg2str(regvarinfo^.fpuregvars[i]^.reg),
-                        tostr(regvarinfo^.fpuregvars[i]^.refs),regvarinfo^.fpuregvars[i]^.name);
+                      Message3(cg_d_register_weight,reg2str(regvarinfo^.fpuregvars[i].reg),
+                        tostr(regvarinfo^.fpuregvars[i].refs),regvarinfo^.fpuregvars[i].name);
                  end;
                  end;
             end;
             end;
           if cs_asm_source in aktglobalswitches then
           if cs_asm_source in aktglobalswitches then
@@ -498,11 +497,11 @@ implementation
     begin
     begin
 {$ifdef i386}
 {$ifdef i386}
       { can happen when inlining assembler procedures (JM) }
       { can happen when inlining assembler procedures (JM) }
-      if not assigned(aktprocsym^.definition^.regvarinfo) then
+      if not assigned(aktprocsym.definition.regvarinfo) then
         exit;
         exit;
       if (cs_regalloc in aktglobalswitches) and
       if (cs_regalloc in aktglobalswitches) and
          ((procinfo^.flags and (pi_uses_asm or pi_uses_exceptions))=0) then
          ((procinfo^.flags and (pi_uses_asm or pi_uses_exceptions))=0) then
-        with pregvarinfo(aktprocsym^.definition^.regvarinfo)^ do
+        with pregvarinfo(aktprocsym.definition.regvarinfo)^ do
           begin
           begin
             for i:=1 to maxfpuvarregs do
             for i:=1 to maxfpuvarregs do
               if assigned(fpuregvars[i]) then
               if assigned(fpuregvars[i]) then
@@ -510,8 +509,8 @@ implementation
                 asml.concat(Taicpu.op_reg(A_FSTP,S_NO,R_ST0));
                 asml.concat(Taicpu.op_reg(A_FSTP,S_NO,R_ST0));
             for i := 1 to maxvarregs do
             for i := 1 to maxvarregs do
               if assigned(regvars[i]) and
               if assigned(regvars[i]) and
-                 (regvar_loaded[reg32(regvars[i]^.reg)]) then
-                asml.concat(Tairegalloc.dealloc(reg32(regvars[i]^.reg)));
+                 (regvar_loaded[reg32(regvars[i].reg)]) then
+                asml.concat(Tairegalloc.dealloc(reg32(regvars[i].reg)));
           end;
           end;
 {$endif i386}
 {$endif i386}
     end;
     end;
@@ -520,7 +519,12 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2000-12-25 00:07:28  peter
+  Revision 1.16  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.15  2000/12/25 00:07:28  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 49 - 44
compiler/scandir.inc

@@ -177,7 +177,7 @@ const
     function read_factor : string;
     function read_factor : string;
       var
       var
          hs : string;
          hs : string;
-         mac : pmacro;
+         mac : tmacro;
          len : byte;
          len : byte;
       begin
       begin
          if preproc_token=_ID then
          if preproc_token=_ID then
@@ -193,22 +193,22 @@ const
                 end
                 end
               else
               else
                 begin
                 begin
-                   mac:=pmacro(current_scanner^.macros^.search(hs));
+                   mac:=tmacro(current_scanner^.macros.search(hs));
                    hs:=preprocpat;
                    hs:=preprocpat;
                    preproc_consume(_ID);
                    preproc_consume(_ID);
                    if assigned(mac) then
                    if assigned(mac) then
                      begin
                      begin
-                        if mac^.defined and assigned(mac^.buftext) then
+                        if mac.defined and assigned(mac.buftext) then
                           begin
                           begin
-                             if mac^.buflen>255 then
+                             if mac.buflen>255 then
                                begin
                                begin
                                   len:=255;
                                   len:=255;
                                   Message(scan_w_macro_cut_after_255_chars);
                                   Message(scan_w_macro_cut_after_255_chars);
                                end
                                end
                              else
                              else
-                               len:=mac^.buflen;
+                               len:=mac.buflen;
                              hs[0]:=char(len);
                              hs[0]:=char(len);
-                             move(mac^.buftext^,hs[1],len);
+                             move(mac.buftext^,hs[1],len);
                           end
                           end
                         else
                         else
                           read_factor:='';
                           read_factor:='';
@@ -340,7 +340,7 @@ const
     procedure dir_conditional(t:tdirectivetoken);
     procedure dir_conditional(t:tdirectivetoken);
       var
       var
         hs    : string;
         hs    : string;
-        mac   : pmacro;
+        mac   : tmacro;
         found : boolean;
         found : boolean;
         state : char;
         state : char;
         oldaktfilepos : tfileposinfo;
         oldaktfilepos : tfileposinfo;
@@ -359,10 +359,10 @@ const
    _DIR_IFDEF : begin
    _DIR_IFDEF : begin
                   current_scanner^.skipspace;
                   current_scanner^.skipspace;
                   hs:=current_scanner^.readid;
                   hs:=current_scanner^.readid;
-                  mac:=pmacro(current_scanner^.macros^.search(hs));
+                  mac:=tmacro(current_scanner^.macros.search(hs));
                   if assigned(mac) then
                   if assigned(mac) then
-                    mac^.is_used:=true;
-                  current_scanner^.addpreprocstack(pp_ifdef,assigned(mac) and mac^.defined,hs,scan_c_ifdef_found);
+                    mac.is_used:=true;
+                  current_scanner^.addpreprocstack(pp_ifdef,assigned(mac) and mac.defined,hs,scan_c_ifdef_found);
                 end;
                 end;
    _DIR_IFOPT : begin
    _DIR_IFOPT : begin
                   current_scanner^.skipspace;
                   current_scanner^.skipspace;
@@ -387,14 +387,14 @@ const
   _DIR_IFNDEF : begin
   _DIR_IFNDEF : begin
                   current_scanner^.skipspace;
                   current_scanner^.skipspace;
                   hs:=current_scanner^.readid;
                   hs:=current_scanner^.readid;
-                  mac:=pmacro(current_scanner^.macros^.search(hs));
+                  mac:=tmacro(current_scanner^.macros.search(hs));
                   if assigned(mac) then
                   if assigned(mac) then
-                    mac^.is_used:=true;
-                  current_scanner^.addpreprocstack(pp_ifndef,not(assigned(mac) and mac^.defined),hs,scan_c_ifndef_found);
+                    mac.is_used:=true;
+                  current_scanner^.addpreprocstack(pp_ifndef,not(assigned(mac) and mac.defined),hs,scan_c_ifndef_found);
                 end;
                 end;
            end;
            end;
          { accept the text ? }
          { accept the text ? }
-           if (current_scanner^.preprocstack=nil) or current_scanner^.preprocstack^.accept then
+           if (current_scanner^.preprocstack=nil) or current_scanner^.preprocstack.accept then
             break
             break
            else
            else
             begin
             begin
@@ -416,32 +416,32 @@ const
       var
       var
         hs  : string;
         hs  : string;
         bracketcount : longint;
         bracketcount : longint;
-        mac : pmacro;
+        mac : tmacro;
         macropos : longint;
         macropos : longint;
         macrobuffer : pmacrobuffer;
         macrobuffer : pmacrobuffer;
       begin
       begin
         current_scanner^.skipspace;
         current_scanner^.skipspace;
         hs:=current_scanner^.readid;
         hs:=current_scanner^.readid;
-        mac:=pmacro(current_scanner^.macros^.search(hs));
+        mac:=tmacro(current_scanner^.macros.search(hs));
         if not assigned(mac) then
         if not assigned(mac) then
           begin
           begin
-            mac:=new(pmacro,init(hs));
-            mac^.defined:=true;
-            Message1(parser_m_macro_defined,mac^.name);
-            current_scanner^.macros^.insert(mac);
+            mac:=tmacro.create(hs);
+            mac.defined:=true;
+            Message1(parser_m_macro_defined,mac.name);
+            current_scanner^.macros.insert(mac);
           end
           end
         else
         else
           begin
           begin
-            Message1(parser_m_macro_defined,mac^.name);
-            mac^.defined:=true;
+            Message1(parser_m_macro_defined,mac.name);
+            mac.defined:=true;
           { delete old definition }
           { delete old definition }
-            if assigned(mac^.buftext) then
+            if assigned(mac.buftext) then
              begin
              begin
-               freemem(mac^.buftext,mac^.buflen);
-               mac^.buftext:=nil;
+               freemem(mac.buftext,mac.buflen);
+               mac.buftext:=nil;
              end;
              end;
           end;
           end;
-        mac^.is_used:=true;
+        mac.is_used:=true;
         if (cs_support_macro in aktmoduleswitches) then
         if (cs_support_macro in aktmoduleswitches) then
           begin
           begin
           { key words are never substituted }
           { key words are never substituted }
@@ -479,13 +479,13 @@ const
                           Message(scan_f_macro_buffer_overflow);
                           Message(scan_f_macro_buffer_overflow);
                        until false;
                        until false;
                        { free buffer of macro ?}
                        { free buffer of macro ?}
-                       if assigned(mac^.buftext) then
-                         freemem(mac^.buftext,mac^.buflen);
+                       if assigned(mac.buftext) then
+                         freemem(mac.buftext,mac.buflen);
                        { get new mem }
                        { get new mem }
-                       getmem(mac^.buftext,macropos);
-                       mac^.buflen:=macropos;
+                       getmem(mac.buftext,macropos);
+                       mac.buflen:=macropos;
                        { copy the text }
                        { copy the text }
-                       move(macrobuffer^,mac^.buftext^,macropos);
+                       move(macrobuffer^,mac.buftext^,macropos);
                        dispose(macrobuffer);
                        dispose(macrobuffer);
                     end;
                     end;
                end;
                end;
@@ -508,30 +508,30 @@ const
     procedure dir_undef(t:tdirectivetoken);
     procedure dir_undef(t:tdirectivetoken);
       var
       var
         hs  : string;
         hs  : string;
-        mac : pmacro;
+        mac : tmacro;
       begin
       begin
         current_scanner^.skipspace;
         current_scanner^.skipspace;
         hs:=current_scanner^.readid;
         hs:=current_scanner^.readid;
-        mac:=pmacro(current_scanner^.macros^.search(hs));
+        mac:=tmacro(current_scanner^.macros.search(hs));
         if not assigned(mac) then
         if not assigned(mac) then
           begin
           begin
-             mac:=new(pmacro,init(hs));
-             Message1(parser_m_macro_undefined,mac^.name);
-             mac^.defined:=false;
-             current_scanner^.macros^.insert(mac);
+             mac:=tmacro.create(hs);
+             Message1(parser_m_macro_undefined,mac.name);
+             mac.defined:=false;
+             current_scanner^.macros.insert(mac);
           end
           end
         else
         else
           begin
           begin
-             Message1(parser_m_macro_undefined,mac^.name);
-             mac^.defined:=false;
+             Message1(parser_m_macro_undefined,mac.name);
+             mac.defined:=false;
              { delete old definition }
              { delete old definition }
-             if assigned(mac^.buftext) then
+             if assigned(mac.buftext) then
                begin
                begin
-                  freemem(mac^.buftext,mac^.buflen);
-                  mac^.buftext:=nil;
+                  freemem(mac.buftext,mac.buflen);
+                  mac.buftext:=nil;
                end;
                end;
           end;
           end;
-        mac^.is_used:=true;
+        mac.is_used:=true;
       end;
       end;
 
 
 
 
@@ -1394,7 +1394,12 @@ const
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2001-03-13 18:45:07  peter
+  Revision 1.20  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.19  2001/03/13 18:45:07  peter
     * fixed some memory leaks
     * fixed some memory leaks
 
 
   Revision 1.18  2001/02/20 21:41:18  peter
   Revision 1.18  2001/02/20 21:41:18  peter

+ 72 - 69
compiler/scanner.pas

@@ -27,7 +27,7 @@ unit scanner;
 interface
 interface
 
 
     uses
     uses
-       cobjects,cclasses,
+       cclasses,
        globtype,globals,version,tokens,
        globtype,globals,version,tokens,
        verbose,comphook,
        verbose,comphook,
        finput,
        finput,
@@ -45,27 +45,25 @@ interface
        pmacrobuffer = ^tmacrobuffer;
        pmacrobuffer = ^tmacrobuffer;
        tmacrobuffer = array[0..maxmacrolen-1] of char;
        tmacrobuffer = array[0..maxmacrolen-1] of char;
 
 
-       pmacro = ^tmacro;
-       tmacro = object(tnamedindexobject)
+       tmacro = class(TNamedIndexItem)
           defined,
           defined,
           defined_at_startup,
           defined_at_startup,
           is_used : boolean;
           is_used : boolean;
           buftext : pchar;
           buftext : pchar;
           buflen  : longint;
           buflen  : longint;
-          constructor init(const n : string);
-          destructor  done;virtual;
+          constructor Create(const n : string);
+          destructor  destroy;override;
        end;
        end;
 
 
        preproctyp = (pp_ifdef,pp_ifndef,pp_if,pp_ifopt,pp_else);
        preproctyp = (pp_ifdef,pp_ifndef,pp_if,pp_ifopt,pp_else);
-       ppreprocstack = ^tpreprocstack;
-       tpreprocstack = object
+
+       tpreprocstack = class
           typ     : preproctyp;
           typ     : preproctyp;
           accept  : boolean;
           accept  : boolean;
-          next    : ppreprocstack;
+          next    : tpreprocstack;
           name    : stringid;
           name    : stringid;
           line_nb : longint;
           line_nb : longint;
-          constructor init(atyp:preproctyp;a:boolean;n:ppreprocstack);
-          destructor done;
+          constructor Create(atyp:preproctyp;a:boolean;n:tpreprocstack);
        end;
        end;
 
 
        pscannerfile = ^tscannerfile;
        pscannerfile = ^tscannerfile;
@@ -87,9 +85,9 @@ interface
           yylexcount     : longint;
           yylexcount     : longint;
           lastasmgetchar : char;
           lastasmgetchar : char;
           ignoredirectives : tstringlist; { ignore directives, used to give warnings only once }
           ignoredirectives : tstringlist; { ignore directives, used to give warnings only once }
-          preprocstack   : ppreprocstack;
+          preprocstack   : tpreprocstack;
           invalid        : boolean; { flag if sourcefiles have been destroyed ! }
           invalid        : boolean; { flag if sourcefiles have been destroyed ! }
-          macros         : pdictionary;
+          macros         : Tdictionary;
           in_asm_string  : boolean;
           in_asm_string  : boolean;
 
 
           constructor init(const fn:string);
           constructor init(const fn:string);
@@ -136,7 +134,7 @@ interface
        end;
        end;
 
 
 {$ifdef PREPROCWRITE}
 {$ifdef PREPROCWRITE}
-       ppreprocfile=^tpreprocfile;
+       tpreprocfile=^tpreprocfile;
        tpreprocfile=object
        tpreprocfile=object
          f   : text;
          f   : text;
          buf : pointer;
          buf : pointer;
@@ -163,7 +161,7 @@ interface
         current_scanner : pscannerfile;
         current_scanner : pscannerfile;
         aktcommentstyle : tcommentstyle; { needed to use read_comment from directives }
         aktcommentstyle : tcommentstyle; { needed to use read_comment from directives }
 {$ifdef PREPROCWRITE}
 {$ifdef PREPROCWRITE}
-        preprocfile     : ppreprocfile; { used with only preprocessing }
+        preprocfile     : tpreprocfile; { used with only preprocessing }
 {$endif PREPROCWRITE}
 {$endif PREPROCWRITE}
 
 
 
 
@@ -218,9 +216,9 @@ implementation
                                  TMacro
                                  TMacro
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tmacro.init(const n : string);
+    constructor tmacro.create(const n : string);
       begin
       begin
-         inherited initname(n);
+         inherited createname(n);
          defined:=true;
          defined:=true;
          defined_at_startup:=false;
          defined_at_startup:=false;
          is_used:=false;
          is_used:=false;
@@ -229,11 +227,11 @@ implementation
       end;
       end;
 
 
 
 
-    destructor tmacro.done;
+    destructor tmacro.destroy;
       begin
       begin
          if assigned(buftext) then
          if assigned(buftext) then
            freemem(buftext,buflen);
            freemem(buftext,buflen);
-         inherited done;
+         inherited destroy;
       end;
       end;
 
 
 
 
@@ -293,7 +291,7 @@ implementation
                               TPreProcStack
                               TPreProcStack
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor tpreprocstack.init(atyp : preproctyp;a:boolean;n:ppreprocstack);
+    constructor tpreprocstack.create(atyp : preproctyp;a:boolean;n:tpreprocstack);
       begin
       begin
         accept:=a;
         accept:=a;
         typ:=atyp;
         typ:=atyp;
@@ -301,11 +299,6 @@ implementation
       end;
       end;
 
 
 
 
-    destructor tpreprocstack.done;
-      begin
-      end;
-
-
 {****************************************************************************
 {****************************************************************************
                                 TSCANNERFILE
                                 TSCANNERFILE
  ****************************************************************************}
  ****************************************************************************}
@@ -333,7 +326,7 @@ implementation
         ignoredirectives:=TStringList.Create;
         ignoredirectives:=TStringList.Create;
         invalid:=false;
         invalid:=false;
         in_asm_string:=false;
         in_asm_string:=false;
-        new(macros,init);
+        macros:=tdictionary.create;
       { load block }
       { load block }
         if not openinputfile then
         if not openinputfile then
          Message1(scan_f_cannot_open_input,fn);
          Message1(scan_f_cannot_open_input,fn);
@@ -352,7 +345,12 @@ implementation
         if not invalid then
         if not invalid then
           begin
           begin
              if status.errorcount=0 then
              if status.errorcount=0 then
-              checkpreprocstack;
+              checkpreprocstack
+             else
+              begin
+                while assigned(preprocstack) do
+                 poppreprocstack;
+              end;
            { close file, but only if we are the first compile }
            { close file, but only if we are the first compile }
            { probably not necessary anymore with invalid flag PM }
            { probably not necessary anymore with invalid flag PM }
              if not current_module.in_second_compile then
              if not current_module.in_second_compile then
@@ -362,47 +360,47 @@ implementation
               end;
               end;
           end;
           end;
          ignoredirectives.free;
          ignoredirectives.free;
-         dispose(macros,done);
+         macros.free;
        end;
        end;
 
 
 
 
     procedure tscannerfile.def_macro(const s : string);
     procedure tscannerfile.def_macro(const s : string);
       var
       var
-        mac : pmacro;
+        mac : tmacro;
       begin
       begin
-         mac:=pmacro(macros^.search(s));
+         mac:=tmacro(macros.search(s));
          if mac=nil then
          if mac=nil then
            begin
            begin
-             mac:=new(pmacro,init(s));
-             Message1(parser_m_macro_defined,mac^.name);
-             macros^.insert(mac);
+             mac:=tmacro.create(s);
+             Message1(parser_m_macro_defined,mac.name);
+             macros.insert(mac);
            end;
            end;
-         mac^.defined:=true;
-         mac^.defined_at_startup:=true;
+         mac.defined:=true;
+         mac.defined_at_startup:=true;
       end;
       end;
 
 
 
 
     procedure tscannerfile.set_macro(const s : string;value : string);
     procedure tscannerfile.set_macro(const s : string;value : string);
       var
       var
-        mac : pmacro;
+        mac : tmacro;
       begin
       begin
-         mac:=pmacro(macros^.search(s));
+         mac:=tmacro(macros.search(s));
          if mac=nil then
          if mac=nil then
            begin
            begin
-             mac:=new(pmacro,init(s));
-             macros^.insert(mac);
+             mac:=tmacro.create(s);
+             macros.insert(mac);
            end
            end
          else
          else
            begin
            begin
-              if assigned(mac^.buftext) then
-                freemem(mac^.buftext,mac^.buflen);
+              if assigned(mac.buftext) then
+                freemem(mac.buftext,mac.buflen);
            end;
            end;
-         Message2(parser_m_macro_set_to,mac^.name,value);
-         mac^.buflen:=length(value);
-         getmem(mac^.buftext,mac^.buflen);
-         move(value[1],mac^.buftext^,mac^.buflen);
-         mac^.defined:=true;
-         mac^.defined_at_startup:=true;
+         Message2(parser_m_macro_set_to,mac.name,value);
+         mac.buflen:=length(value);
+         getmem(mac.buftext,mac.buflen);
+         move(value[1],mac.buftext^,mac.buflen);
+         mac.defined:=true;
+         mac.defined_at_startup:=true;
       end;
       end;
 
 
 
 
@@ -700,7 +698,7 @@ implementation
       { check for missing ifdefs }
       { check for missing ifdefs }
         while assigned(preprocstack) do
         while assigned(preprocstack) do
          begin
          begin
-           Message3(scan_e_endif_expected,preprocstring[preprocstack^.typ],preprocstack^.name,tostr(preprocstack^.line_nb));
+           Message3(scan_e_endif_expected,preprocstring[preprocstack.typ],preprocstack.name,tostr(preprocstack.line_nb));
            poppreprocstack;
            poppreprocstack;
          end;
          end;
       end;
       end;
@@ -708,13 +706,13 @@ implementation
 
 
     procedure tscannerfile.poppreprocstack;
     procedure tscannerfile.poppreprocstack;
       var
       var
-        hp : ppreprocstack;
+        hp : tpreprocstack;
       begin
       begin
         if assigned(preprocstack) then
         if assigned(preprocstack) then
          begin
          begin
-           Message1(scan_c_endif_found,preprocstack^.name);
-           hp:=preprocstack^.next;
-           dispose(preprocstack,done);
+           Message1(scan_c_endif_found,preprocstack.name);
+           hp:=preprocstack.next;
+           preprocstack.free;
            preprocstack:=hp;
            preprocstack:=hp;
          end
          end
         else
         else
@@ -724,13 +722,13 @@ implementation
 
 
     procedure tscannerfile.addpreprocstack(atyp : preproctyp;a:boolean;const s:string;w:longint);
     procedure tscannerfile.addpreprocstack(atyp : preproctyp;a:boolean;const s:string;w:longint);
       begin
       begin
-        preprocstack:=new(ppreprocstack,init(atyp,((preprocstack=nil) or preprocstack^.accept) and a,preprocstack));
-        preprocstack^.name:=s;
-        preprocstack^.line_nb:=line_no;
-        if preprocstack^.accept then
-         Message2(w,preprocstack^.name,'accepted')
+        preprocstack:=tpreprocstack.create(atyp,((preprocstack=nil) or preprocstack.accept) and a,preprocstack);
+        preprocstack.name:=s;
+        preprocstack.line_nb:=line_no;
+        if preprocstack.accept then
+         Message2(w,preprocstack.name,'accepted')
         else
         else
-         Message2(w,preprocstack^.name,'rejected');
+         Message2(w,preprocstack.name,'rejected');
       end;
       end;
 
 
 
 
@@ -738,14 +736,14 @@ implementation
       begin
       begin
         if assigned(preprocstack) then
         if assigned(preprocstack) then
          begin
          begin
-           preprocstack^.typ:=pp_else;
-           preprocstack^.line_nb:=line_no;
-           if not(assigned(preprocstack^.next)) or (preprocstack^.next^.accept) then
-            preprocstack^.accept:=not preprocstack^.accept;
-           if preprocstack^.accept then
-            Message2(scan_c_else_found,preprocstack^.name,'accepted')
+           preprocstack.typ:=pp_else;
+           preprocstack.line_nb:=line_no;
+           if not(assigned(preprocstack.next)) or (preprocstack.next.accept) then
+            preprocstack.accept:=not preprocstack.accept;
+           if preprocstack.accept then
+            Message2(scan_c_else_found,preprocstack.name,'accepted')
            else
            else
-            Message2(scan_c_else_found,preprocstack^.name,'rejected');
+            Message2(scan_c_else_found,preprocstack.name,'rejected');
          end
          end
         else
         else
          Message(scan_e_endif_without_if);
          Message(scan_e_endif_without_if);
@@ -1240,7 +1238,7 @@ implementation
         code    : integer;
         code    : integer;
         low,high,mid : longint;
         low,high,mid : longint;
         m       : longint;
         m       : longint;
-        mac     : pmacro;
+        mac     : tmacro;
         asciinr : string[6];
         asciinr : string[6];
         iswidestring : boolean;
         iswidestring : boolean;
       label
       label
@@ -1322,10 +1320,10 @@ implementation
             { this takes some time ... }
             { this takes some time ... }
               if (cs_support_macro in aktmoduleswitches) then
               if (cs_support_macro in aktmoduleswitches) then
                begin
                begin
-                 mac:=pmacro(macros^.search(pattern));
-                 if assigned(mac) and (assigned(mac^.buftext)) then
+                 mac:=tmacro(macros.search(pattern));
+                 if assigned(mac) and (assigned(mac.buftext)) then
                   begin
                   begin
-                    insertmacro(pattern,mac^.buftext,mac^.buflen);
+                    insertmacro(pattern,mac.buftext,mac.buflen);
                   { handle empty macros }
                   { handle empty macros }
                     if c=#0 then
                     if c=#0 then
                      begin
                      begin
@@ -1946,7 +1944,12 @@ exit_label:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2000-12-25 00:07:28  peter
+  Revision 1.14  2001-04-13 01:22:13  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.13  2000/12/25 00:07:28  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 19 - 17
compiler/script.pas

@@ -30,31 +30,28 @@ uses
   cclasses;
   cclasses;
 
 
 type
 type
-  PScript=^TScript;
-  TScript=object
+  TScript=class
     fn   : string[80];
     fn   : string[80];
     data : TStringList;
     data : TStringList;
     executable : boolean;
     executable : boolean;
-    constructor Init(const s:string);
-    constructor InitExec(const s:string);
-    destructor Done;
+    constructor Create(const s:string);
+    constructor CreateExec(const s:string);
+    destructor Destroy;override;
     procedure AddStart(const s:string);
     procedure AddStart(const s:string);
     procedure Add(const s:string);
     procedure Add(const s:string);
     Function  Empty:boolean;
     Function  Empty:boolean;
     procedure WriteToDisk;virtual;
     procedure WriteToDisk;virtual;
   end;
   end;
 
 
-  PAsmScript = ^TAsmScript;
-  TAsmScript = Object (TScript)
-    Constructor Init (Const ScriptName : String);
+  TAsmScript = class (TScript)
+    Constructor Create(Const ScriptName : String);
     Procedure AddAsmCommand (Const Command, Options,FileName : String);
     Procedure AddAsmCommand (Const Command, Options,FileName : String);
     Procedure AddLinkCommand (Const Command, Options, FileName : String);
     Procedure AddLinkCommand (Const Command, Options, FileName : String);
     Procedure AddDeleteCommand (Const FileName : String);
     Procedure AddDeleteCommand (Const FileName : String);
-    Procedure WriteToDisk;virtual;
+    Procedure WriteToDisk;override;
   end;
   end;
 
 
-  PLinkRes = ^TLinkRes;
-  TLinkRes = Object (TScript)
+  TLinkRes = Class (TScript)
     procedure Add(const s:string);
     procedure Add(const s:string);
     procedure AddFileName(const s:string);
     procedure AddFileName(const s:string);
   end;
   end;
@@ -81,7 +78,7 @@ uses
                                   TScript
                                   TScript
 ****************************************************************************}
 ****************************************************************************}
 
 
-constructor TScript.Init(const s:string);
+constructor TScript.Create(const s:string);
 begin
 begin
   fn:=FixFileName(s);
   fn:=FixFileName(s);
   executable:=false;
   executable:=false;
@@ -89,7 +86,7 @@ begin
 end;
 end;
 
 
 
 
-constructor TScript.InitExec(const s:string);
+constructor TScript.CreateExec(const s:string);
 begin
 begin
   fn:=FixFileName(s)+source_os.scriptext;
   fn:=FixFileName(s)+source_os.scriptext;
   executable:=true;
   executable:=true;
@@ -97,7 +94,7 @@ begin
 end;
 end;
 
 
 
 
-destructor TScript.Done;
+destructor TScript.Destroy;
 begin
 begin
   data.Free;
   data.Free;
 end;
 end;
@@ -141,9 +138,9 @@ end;
                                   Asm Response
                                   Asm Response
 ****************************************************************************}
 ****************************************************************************}
 
 
-Constructor TAsmScript.Init (Const ScriptName : String);
+Constructor TAsmScript.Create (Const ScriptName : String);
 begin
 begin
-  Inherited InitExec(ScriptName);
+  Inherited CreateExec(ScriptName);
 end;
 end;
 
 
 
 
@@ -241,7 +238,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2001-02-05 20:47:00  peter
+  Revision 1.8  2001-04-13 01:22:14  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.7  2001/02/05 20:47:00  peter
     * support linux unit for ver1_0 compilers
     * support linux unit for ver1_0 compilers
 
 
   Revision 1.6  2001/01/21 20:32:45  marco
   Revision 1.6  2001/01/21 20:32:45  marco

+ 102 - 69
compiler/symbase.pas

@@ -27,7 +27,7 @@ interface
 
 
     uses
     uses
        { common }
        { common }
-       cutils,cobjects,
+       cutils,cclasses,
        { global }
        { global }
        globtype,globals,
        globtype,globals,
        { symtable }
        { symtable }
@@ -42,28 +42,32 @@ interface
        hasharraysize    = 256;
        hasharraysize    = 256;
        indexgrowsize    = 64;
        indexgrowsize    = 64;
 
 
+{$ifdef GDB}
+       memsizeinc = 2048; { for long stabstrings }
+{$endif GDB}
+
+
 {************************************************
 {************************************************
             Needed forward pointers
             Needed forward pointers
 ************************************************}
 ************************************************}
 
 
     type
     type
-       psymtable = ^tsymtable;
+       tsymtable = class;
 
 
 {************************************************
 {************************************************
                TSymtableEntry
                TSymtableEntry
 ************************************************}
 ************************************************}
 
 
-      psymtableentry = ^tsymtableentry;
-      tsymtableentry = object(tnamedindexobject)
-         owner : psymtable;
+      tsymtableentry = class(TNamedIndexItem)
+         owner : tsymtable;
       end;
       end;
 
 
 
 
 {************************************************
 {************************************************
                  TDefEntry
                  TDefEntry
 ************************************************}
 ************************************************}
-      pdefentry = ^tdefentry;
-      tdefentry = object(tsymtableentry)
+
+      tdefentry = class(tsymtableentry)
          deftype : tdeftype;
          deftype : tdeftype;
       end;
       end;
 
 
@@ -73,8 +77,7 @@ interface
 ************************************************}
 ************************************************}
 
 
       { this object is the base for all symbol objects }
       { this object is the base for all symbol objects }
-      psymentry = ^tsymentry;
-      tsymentry = object(tsymtableentry)
+      tsymentry = class(tsymtableentry)
          typ : tsymtyp;
          typ : tsymtyp;
       end;
       end;
 
 
@@ -83,38 +86,41 @@ interface
                  TSymtable
                  TSymtable
 ************************************************}
 ************************************************}
 
 
-       tsearchhasharray = array[0..hasharraysize-1] of psymentry;
+       tsearchhasharray = array[0..hasharraysize-1] of tsymentry;
        psearchhasharray = ^tsearchhasharray;
        psearchhasharray = ^tsearchhasharray;
 
 
-       tsymtable = object
+       tsymtable = class
+       public
+          name      : pstring;
+          realname  : pstring;
           symtabletype : tsymtabletype;
           symtabletype : tsymtabletype;
           { each symtable gets a number }
           { each symtable gets a number }
           unitid    : word{integer give range check errors PM};
           unitid    : word{integer give range check errors PM};
-          name      : pstring;
           datasize  : longint;
           datasize  : longint;
           dataalignment : longint;
           dataalignment : longint;
           symindex,
           symindex,
-          defindex  : pindexarray;
-          symsearch : pdictionary;
-          next      : psymtable;
-          defowner  : pdefentry; { for records and objects }
+          defindex  : TIndexArray;
+          symsearch : Tdictionary;
+          next      : tsymtable;
+          defowner  : tdefentry; { for records and objects }
           { only used for parameter symtable to determine the offset relative }
           { only used for parameter symtable to determine the offset relative }
           { to the frame pointer and for local inline }
           { to the frame pointer and for local inline }
           address_fixup : longint;
           address_fixup : longint;
           { this saves all definition to allow a proper clean up }
           { this saves all definition to allow a proper clean up }
           { separate lexlevel from symtable type }
           { separate lexlevel from symtable type }
           symtablelevel : byte;
           symtablelevel : byte;
-          constructor init(t : tsymtabletype);
-          destructor  done;virtual;
+          constructor Create(const s:string);
+          destructor  destroy;override;
           procedure clear;virtual;
           procedure clear;virtual;
-          function  rename(const olds,news : stringid):psymentry;
+          function  rename(const olds,news : stringid):tsymentry;
           procedure foreach(proc2call : tnamedindexcallback);
           procedure foreach(proc2call : tnamedindexcallback);
-          procedure insert(sym : psymentry);virtual;
-          function  search(const s : stringid) : psymentry;
-          function  speedsearch(const s : stringid;speedvalue : longint) : psymentry;virtual;
-          procedure registerdef(p : pdefentry);
-          function  getdefnr(l : longint) : pdefentry;
-          function  getsymnr(l : longint) : psymentry;
+          procedure foreach_static(proc2call : tnamedindexstaticcallback);
+          procedure insert(sym : tsymentry);virtual;
+          function  search(const s : stringid) : tsymentry;
+          function  speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;virtual;
+          procedure registerdef(p : tdefentry);
+          function  getdefnr(l : longint) : tdefentry;
+          function  getsymnr(l : longint) : tsymentry;
 {$ifdef GDB}
 {$ifdef GDB}
           function getnewtypecount : word; virtual;
           function getnewtypecount : word; virtual;
 {$endif GDB}
 {$endif GDB}
@@ -124,24 +130,23 @@ interface
                     TDeref
                     TDeref
 ************************************************}
 ************************************************}
 
 
-      pderef = ^tderef;
-      tderef = object
+      tderef = class
         dereftype : tdereftype;
         dereftype : tdereftype;
         index     : word;
         index     : word;
-        next      : pderef;
-        constructor init(typ:tdereftype;i:word);
-        destructor  done;
+        next      : tderef;
+        constructor create(typ:tdereftype;i:word);
+        destructor  destroy;override;
       end;
       end;
 
 
 
 
     var
     var
        registerdef : boolean;      { true, when defs should be registered }
        registerdef : boolean;      { true, when defs should be registered }
 
 
-       defaultsymtablestack : psymtable;  { symtablestack after default units have been loaded }
-       symtablestack     : psymtable;     { linked list of symtables }
-       aktrecordsymtable : psymtable;     { current record read from ppu symtable }
-       aktstaticsymtable : psymtable;     { current static for local ppu symtable }
-       aktlocalsymtable  : psymtable;     { current proc local for local ppu symtable }
+       defaultsymtablestack : tsymtable;  { symtablestack after default units have been loaded }
+       symtablestack     : tsymtable;     { linked list of symtables }
+       aktrecordsymtable : tsymtable;     { current record read from ppu symtable }
+       aktstaticsymtable : tsymtable;     { current static for local ppu symtable }
+       aktlocalsymtable  : tsymtable;     { current proc local for local ppu symtable }
 
 
 
 
 implementation
 implementation
@@ -153,42 +158,65 @@ implementation
                                 TSYMTABLE
                                 TSYMTABLE
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tsymtable.init(t : tsymtabletype);
+    constructor tsymtable.Create(const s:string);
       begin
       begin
-         symtabletype:=t;
+         if s<>'' then
+          begin
+            name:=stringdup(upper(s));
+            realname:=stringdup(s);
+          end
+         else
+          begin
+            name:=nil;
+            realname:=nil;
+          end;
+         symtabletype:=abstractsymtable;
+         symtablelevel:=0;
          defowner:=nil;
          defowner:=nil;
-         new(symindex,init(indexgrowsize));
-         new(defindex,init(indexgrowsize));
-         new(symsearch,init);
-         symsearch^.noclear:=true;
+         next:=nil;
+         symindex:=tindexarray.create(indexgrowsize);
+         defindex:=TIndexArray.create(indexgrowsize);
+         symsearch:=tdictionary.create;
+         symsearch.noclear:=true;
+         unitid:=0;
+         address_fixup:=0;
+         datasize:=0;
+         dataalignment:=1;
       end;
       end;
 
 
 
 
-    destructor tsymtable.done;
+    destructor tsymtable.destroy;
       begin
       begin
         stringdispose(name);
         stringdispose(name);
-        dispose(symindex,done);
-        dispose(defindex,done);
+        stringdispose(realname);
+        symindex.destroy;
+        defindex.destroy;
         { symsearch can already be disposed or set to nil for withsymtable }
         { symsearch can already be disposed or set to nil for withsymtable }
         if assigned(symsearch) then
         if assigned(symsearch) then
          begin
          begin
-           dispose(symsearch,done);
+           symsearch.destroy;
            symsearch:=nil;
            symsearch:=nil;
          end;
          end;
       end;
       end;
 
 
 
 
-    procedure tsymtable.registerdef(p : pdefentry);
+    procedure tsymtable.registerdef(p : tdefentry);
       begin
       begin
-         defindex^.insert(p);
+         defindex.insert(p);
          { set def owner and indexnb }
          { set def owner and indexnb }
-         p^.owner:=@self;
+         p.owner:=self;
       end;
       end;
 
 
 
 
     procedure tsymtable.foreach(proc2call : tnamedindexcallback);
     procedure tsymtable.foreach(proc2call : tnamedindexcallback);
       begin
       begin
-        symindex^.foreach(proc2call);
+        symindex.foreach(proc2call);
+      end;
+
+
+    procedure tsymtable.foreach_static(proc2call : tnamedindexstaticcallback);
+      begin
+        symindex.foreach_static(proc2call);
       end;
       end;
 
 
 
 
@@ -198,54 +226,54 @@ implementation
 
 
     procedure tsymtable.clear;
     procedure tsymtable.clear;
       begin
       begin
-         symindex^.clear;
-         defindex^.clear;
+         symindex.clear;
+         defindex.clear;
       end;
       end;
 
 
 
 
-    procedure tsymtable.insert(sym:psymentry);
+    procedure tsymtable.insert(sym:tsymentry);
       begin
       begin
-         sym^.owner:=@self;
+         sym.owner:=self;
          { insert in index and search hash }
          { insert in index and search hash }
-         symindex^.insert(sym);
-         symsearch^.insert(sym);
+         symindex.insert(sym);
+         symsearch.insert(sym);
       end;
       end;
 
 
 
 
-    function tsymtable.search(const s : stringid) : psymentry;
+    function tsymtable.search(const s : stringid) : tsymentry;
       begin
       begin
         search:=speedsearch(s,getspeedvalue(s));
         search:=speedsearch(s,getspeedvalue(s));
       end;
       end;
 
 
 
 
-    function tsymtable.speedsearch(const s : stringid;speedvalue : longint) : psymentry;
+    function tsymtable.speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;
       begin
       begin
-        speedsearch:=psymentry(symsearch^.speedsearch(s,speedvalue));
+        speedsearch:=tsymentry(symsearch.speedsearch(s,speedvalue));
       end;
       end;
 
 
 
 
-    function tsymtable.rename(const olds,news : stringid):psymentry;
+    function tsymtable.rename(const olds,news : stringid):tsymentry;
       begin
       begin
-        rename:=psymentry(symsearch^.rename(olds,news));
+        rename:=tsymentry(symsearch.rename(olds,news));
       end;
       end;
 
 
 
 
-    function tsymtable.getsymnr(l : longint) : psymentry;
+    function tsymtable.getsymnr(l : longint) : tsymentry;
       var
       var
-        hp : psymentry;
+        hp : tsymentry;
       begin
       begin
-        hp:=psymentry(symindex^.search(l));
+        hp:=tsymentry(symindex.search(l));
         if hp=nil then
         if hp=nil then
          internalerror(10999);
          internalerror(10999);
         getsymnr:=hp;
         getsymnr:=hp;
       end;
       end;
 
 
 
 
-    function tsymtable.getdefnr(l : longint) : pdefentry;
+    function tsymtable.getdefnr(l : longint) : tdefentry;
       var
       var
-        hp : pdefentry;
+        hp : tdefentry;
       begin
       begin
-        hp:=pdefentry(defindex^.search(l));
+        hp:=tdefentry(defindex.search(l));
         if hp=nil then
         if hp=nil then
          internalerror(10998);
          internalerror(10998);
         getdefnr:=hp;
         getdefnr:=hp;
@@ -264,7 +292,7 @@ implementation
                                TDeref
                                TDeref
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tderef.init(typ:tdereftype;i:word);
+    constructor tderef.create(typ:tdereftype;i:word);
       begin
       begin
         dereftype:=typ;
         dereftype:=typ;
         index:=i;
         index:=i;
@@ -272,7 +300,7 @@ implementation
       end;
       end;
 
 
 
 
-    destructor tderef.done;
+    destructor tderef.destroy;
       begin
       begin
       end;
       end;
 
 
@@ -283,7 +311,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2000-10-31 22:02:51  peter
+  Revision 1.2  2001-04-13 01:22:15  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.1  2000/10/31 22:02:51  peter
     * symtable splitted, no real code changes
     * symtable splitted, no real code changes
 
 
 }
 }

+ 14 - 10
compiler/symconst.pas

@@ -372,15 +372,14 @@ type
   tvaroptions=set of tvaroption;
   tvaroptions=set of tvaroption;
 
 
   { types of the symtables }
   { types of the symtables }
-  tsymtabletype = (invalidsymtable,withsymtable,staticsymtable,
-                   globalsymtable,unitsymtable,
-                   objectsymtable,recordsymtable,
-                   macrosymtable,localsymtable,
-                   parasymtable,inlineparasymtable,
-                   inlinelocalsymtable,stt_exceptsymtable,
-                   { only used for PPU reading of static part
-                     of a unit }
-                   staticppusymtable);
+  tsymtabletype = (abstractsymtable,
+    globalsymtable,staticsymtable,
+    objectsymtable,recordsymtable,
+    localsymtable,parasymtable,
+    withsymtable,stt_exceptsymtable,
+    { used for inline detection }
+    inlineparasymtable,inlinelocalsymtable
+  );
 
 
 
 
   { definition contains the informations about a type }
   { definition contains the informations about a type }
@@ -452,7 +451,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2001-04-02 21:20:34  peter
+  Revision 1.16  2001-04-13 01:22:15  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.15  2001/04/02 21:20:34  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.14  2001/03/22 00:10:58  florian
   Revision 1.14  2001/03/22 00:10:58  florian

File diff suppressed because it is too large
+ 303 - 285
compiler/symdef.pas


+ 34 - 31
compiler/symppu.pas

@@ -23,7 +23,6 @@ unit symppu;
 interface
 interface
 
 
     uses
     uses
-       cobjects,
        globtype,globals,
        globtype,globals,
        symbase,
        symbase,
        ppu;
        ppu;
@@ -40,7 +39,7 @@ interface
     procedure writesmallset(var s);
     procedure writesmallset(var s);
     procedure writeguid(var g: tguid);
     procedure writeguid(var g: tguid);
     procedure writeposinfo(const p:tfileposinfo);
     procedure writeposinfo(const p:tfileposinfo);
-    procedure writederef(p : psymtableentry);
+    procedure writederef(p : tsymtableentry);
 
 
     function readbyte:byte;
     function readbyte:byte;
     function readword:word;
     function readword:word;
@@ -51,7 +50,7 @@ interface
     procedure readsmallset(var s);
     procedure readsmallset(var s);
     procedure readguid(var g: tguid);
     procedure readguid(var g: tguid);
     procedure readposinfo(var p:tfileposinfo);
     procedure readposinfo(var p:tfileposinfo);
-    function readderef : psymtableentry;
+    function readderef : tsymtableentry;
 
 
     procedure closecurrentppu;
     procedure closecurrentppu;
 
 
@@ -127,77 +126,76 @@ implementation
         current_ppu^.putdata(g,sizeof(g));
         current_ppu^.putdata(g,sizeof(g));
       end;
       end;
 
 
-    procedure writederef(p : psymtableentry);
+    procedure writederef(p : tsymtableentry);
       begin
       begin
         if p=nil then
         if p=nil then
          current_ppu^.putbyte(ord(derefnil))
          current_ppu^.putbyte(ord(derefnil))
         else
         else
          begin
          begin
            { Static symtable ? }
            { Static symtable ? }
-           if p^.owner^.symtabletype=staticsymtable then
+           if p.owner.symtabletype=staticsymtable then
             begin
             begin
               current_ppu^.putbyte(ord(derefaktstaticindex));
               current_ppu^.putbyte(ord(derefaktstaticindex));
-              current_ppu^.putword(p^.indexnr);
+              current_ppu^.putword(p.indexnr);
             end
             end
            { Local record/object symtable ? }
            { Local record/object symtable ? }
-           else if (p^.owner=aktrecordsymtable) then
+           else if (p.owner=aktrecordsymtable) then
             begin
             begin
               current_ppu^.putbyte(ord(derefaktrecordindex));
               current_ppu^.putbyte(ord(derefaktrecordindex));
-              current_ppu^.putword(p^.indexnr);
+              current_ppu^.putword(p.indexnr);
             end
             end
            { Local local/para symtable ? }
            { Local local/para symtable ? }
-           else if (p^.owner=aktlocalsymtable) then
+           else if (p.owner=aktlocalsymtable) then
             begin
             begin
               current_ppu^.putbyte(ord(derefaktlocal));
               current_ppu^.putbyte(ord(derefaktlocal));
-              current_ppu^.putword(p^.indexnr);
+              current_ppu^.putword(p.indexnr);
             end
             end
            else
            else
             begin
             begin
               current_ppu^.putbyte(ord(derefindex));
               current_ppu^.putbyte(ord(derefindex));
-              current_ppu^.putword(p^.indexnr);
+              current_ppu^.putword(p.indexnr);
            { Current unit symtable ? }
            { Current unit symtable ? }
               repeat
               repeat
                 if not assigned(p) then
                 if not assigned(p) then
                  internalerror(556655);
                  internalerror(556655);
-                case p^.owner^.symtabletype of
+                case p.owner.symtabletype of
                  { when writing the pseudo PPU file
                  { when writing the pseudo PPU file
                    to get CRC values the globalsymtable is not yet
                    to get CRC values the globalsymtable is not yet
                    a unitsymtable PM }
                    a unitsymtable PM }
-                  globalsymtable,
-                  unitsymtable :
+                  globalsymtable :
                     begin
                     begin
                       { check if the unit is available in the uses
                       { check if the unit is available in the uses
                         clause, else it's an error }
                         clause, else it's an error }
-                      if p^.owner^.unitid=$ffff then
+                      if p.owner.unitid=$ffff then
                        internalerror(55665566);
                        internalerror(55665566);
                       current_ppu^.putbyte(ord(derefunit));
                       current_ppu^.putbyte(ord(derefunit));
-                      current_ppu^.putword(p^.owner^.unitid);
+                      current_ppu^.putword(p.owner.unitid);
                       break;
                       break;
                     end;
                     end;
                   staticsymtable :
                   staticsymtable :
                     begin
                     begin
                       current_ppu^.putbyte(ord(derefaktstaticindex));
                       current_ppu^.putbyte(ord(derefaktstaticindex));
-                      current_ppu^.putword(p^.indexnr);
+                      current_ppu^.putword(p.indexnr);
                       break;
                       break;
                     end;
                     end;
                   localsymtable :
                   localsymtable :
                     begin
                     begin
-                      p:=p^.owner^.defowner;
+                      p:=p.owner.defowner;
                       current_ppu^.putbyte(ord(dereflocal));
                       current_ppu^.putbyte(ord(dereflocal));
-                      current_ppu^.putword(p^.indexnr);
+                      current_ppu^.putword(p.indexnr);
                     end;
                     end;
                   parasymtable :
                   parasymtable :
                     begin
                     begin
-                      p:=p^.owner^.defowner;
+                      p:=p.owner.defowner;
                       current_ppu^.putbyte(ord(derefpara));
                       current_ppu^.putbyte(ord(derefpara));
-                      current_ppu^.putword(p^.indexnr);
+                      current_ppu^.putword(p.indexnr);
                     end;
                     end;
                   objectsymtable,
                   objectsymtable,
                   recordsymtable :
                   recordsymtable :
                     begin
                     begin
-                      p:=p^.owner^.defowner;
+                      p:=p.owner.defowner;
                       current_ppu^.putbyte(ord(derefrecord));
                       current_ppu^.putbyte(ord(derefrecord));
-                      current_ppu^.putword(p^.indexnr);
+                      current_ppu^.putword(p.indexnr);
                     end;
                     end;
                   else
                   else
                     internalerror(556656);
                     internalerror(556656);
@@ -297,9 +295,9 @@ implementation
       end;
       end;
 
 
 
 
-    function readderef : psymtableentry;
+    function readderef : tsymtableentry;
       var
       var
-        hp,p : pderef;
+        hp,p : tderef;
         b : tdereftype;
         b : tdereftype;
       begin
       begin
         p:=nil;
         p:=nil;
@@ -314,8 +312,8 @@ implementation
             derefaktlocal,
             derefaktlocal,
             derefaktstaticindex :
             derefaktstaticindex :
               begin
               begin
-                new(p,init(b,current_ppu^.getword));
-                p^.next:=hp;
+                p:=tderef.create(b,current_ppu^.getword);
+                p.next:=hp;
                 break;
                 break;
               end;
               end;
             derefindex,
             derefindex,
@@ -323,18 +321,23 @@ implementation
             derefpara,
             derefpara,
             derefrecord :
             derefrecord :
               begin
               begin
-                new(p,init(b,current_ppu^.getword));
-                p^.next:=hp;
+                p:=tderef.create(b,current_ppu^.getword);
+                p.next:=hp;
               end;
               end;
           end;
           end;
         until false;
         until false;
-        readderef:=psymtableentry(p);
+        readderef:=tsymtableentry(p);
       end;
       end;
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2000-12-25 00:07:29  peter
+  Revision 1.5  2001-04-13 01:22:16  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.4  2000/12/25 00:07:29  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

File diff suppressed because it is too large
+ 242 - 281
compiler/symsym.pas


File diff suppressed because it is too large
+ 600 - 877
compiler/symtable.pas


+ 97 - 95
compiler/symtype.pas

@@ -26,7 +26,7 @@ interface
 
 
     uses
     uses
       { common }
       { common }
-      cutils,cobjects,
+      cutils,
       { global }
       { global }
       globtype,globals,
       globtype,globals,
       { symtable }
       { symtable }
@@ -40,21 +40,20 @@ interface
                 Required Forwards
                 Required Forwards
 ************************************************}
 ************************************************}
 
 
-      psym = ^tsym;
+      tsym = class;
 
 
 {************************************************
 {************************************************
                      TRef
                      TRef
 ************************************************}
 ************************************************}
 
 
-      pref = ^tref;
-      tref = object
-        nextref     : pref;
+      tref = class
+        nextref     : tref;
         posinfo     : tfileposinfo;
         posinfo     : tfileposinfo;
         moduleindex : longint;
         moduleindex : longint;
         is_written  : boolean;
         is_written  : boolean;
-        constructor init(ref:pref;pos:pfileposinfo);
+        constructor create(ref:tref;pos:pfileposinfo);
         procedure   freechain;
         procedure   freechain;
-        destructor  done; virtual;
+        destructor  destroy;override;
       end;
       end;
 
 
 {************************************************
 {************************************************
@@ -63,16 +62,15 @@ interface
 
 
       tgetsymtable = (gs_none,gs_record,gs_local,gs_para);
       tgetsymtable = (gs_none,gs_record,gs_local,gs_para);
 
 
-      pdef = ^tdef;
-      tdef = object(tdefentry)
-         typesym    : psym;  { which type the definition was generated this def }
-         constructor init;
+      tdef = class(tdefentry)
+         typesym    : tsym;  { which type the definition was generated this def }
+         constructor create;
          procedure deref;virtual;
          procedure deref;virtual;
          function  typename:string;
          function  typename:string;
          function  gettypename:string;virtual;
          function  gettypename:string;virtual;
          function  size:longint;virtual;abstract;
          function  size:longint;virtual;abstract;
          function  alignment:longint;virtual;abstract;
          function  alignment:longint;virtual;abstract;
-         function  getsymtable(t:tgetsymtable):psymtable;virtual;
+         function  getsymtable(t:tgetsymtable):tsymtable;virtual;
          function  is_publishable:boolean;virtual;abstract;
          function  is_publishable:boolean;virtual;abstract;
          function  needs_inittable:boolean;virtual;abstract;
          function  needs_inittable:boolean;virtual;abstract;
          function  get_rtti_label : string;virtual;abstract;
          function  get_rtti_label : string;virtual;abstract;
@@ -83,16 +81,16 @@ interface
 ************************************************}
 ************************************************}
 
 
       { this object is the base for all symbol objects }
       { this object is the base for all symbol objects }
-      tsym = object(tsymentry)
+      tsym = class(tsymentry)
          _realname  : pstring;
          _realname  : pstring;
          fileinfo   : tfileposinfo;
          fileinfo   : tfileposinfo;
          symoptions : tsymoptions;
          symoptions : tsymoptions;
-         constructor init(const n : string);
-         destructor done;virtual;
+         constructor create(const n : string);
+         destructor destroy;override;
          function  realname:string;
          function  realname:string;
          procedure prederef;virtual; { needed for ttypesym to be deref'd first }
          procedure prederef;virtual; { needed for ttypesym to be deref'd first }
          procedure deref;virtual;
          procedure deref;virtual;
-         function  gettypedef:pdef;virtual;
+         function  gettypedef:tdef;virtual;
          function  mangledname : string;virtual;abstract;
          function  mangledname : string;virtual;abstract;
       end;
       end;
 
 
@@ -101,11 +99,11 @@ interface
 ************************************************}
 ************************************************}
 
 
       ttype = object
       ttype = object
-        def : pdef;
-        sym : psym;
+        def : tdef;
+        sym : tsym;
         procedure reset;
         procedure reset;
-        procedure setdef(p:pdef);
-        procedure setsym(p:psym);
+        procedure setdef(p:tdef);
+        procedure setsym(p:tsym);
         procedure load;
         procedure load;
         procedure write;
         procedure write;
         procedure resolve;
         procedure resolve;
@@ -117,31 +115,30 @@ interface
 
 
       psymlistitem = ^tsymlistitem;
       psymlistitem = ^tsymlistitem;
       tsymlistitem = record
       tsymlistitem = record
-        sym  : psym;
+        sym  : tsym;
         next : psymlistitem;
         next : psymlistitem;
       end;
       end;
 
 
-      psymlist = ^tsymlist;
-      tsymlist = object
-        def      : pdef;
+      tsymlist = class
+        def      : tdef;
         firstsym,
         firstsym,
         lastsym  : psymlistitem;
         lastsym  : psymlistitem;
-        constructor init;
+        constructor create;
         constructor load;
         constructor load;
-        destructor  done;
+        destructor  destroy;override;
         function  empty:boolean;
         function  empty:boolean;
-        procedure setdef(p:pdef);
-        procedure addsym(p:psym);
+        procedure setdef(p:tdef);
+        procedure addsym(p:tsym);
         procedure clear;
         procedure clear;
-        function  getcopy:psymlist;
+        function  getcopy:tsymlist;
         procedure resolve;
         procedure resolve;
         procedure write;
         procedure write;
       end;
       end;
 
 
 
 
     { resolving }
     { resolving }
-    procedure resolvesym(var sym:psym);
-    procedure resolvedef(var def:pdef);
+    procedure resolvesym(var sym:tsym);
+    procedure resolvedef(var def:tdef);
 
 
 
 
 implementation
 implementation
@@ -155,9 +152,9 @@ implementation
                                 Tdef
                                 Tdef
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tdef.init;
+    constructor tdef.create;
       begin
       begin
-         inherited init;
+         inherited create;
          deftype:=abstractdef;
          deftype:=abstractdef;
          owner := nil;
          owner := nil;
          typesym := nil;
          typesym := nil;
@@ -168,9 +165,9 @@ implementation
       begin
       begin
         if assigned(typesym) and
         if assigned(typesym) and
            not(deftype=procvardef) and
            not(deftype=procvardef) and
-           assigned(typesym^._realname) and
-           (typesym^._realname^[1]<>'$') then
-         typename:=typesym^._realname^
+           assigned(typesym._realname) and
+           (typesym._realname^[1]<>'$') then
+         typename:=typesym._realname^
         else
         else
          typename:=gettypename;
          typename:=gettypename;
       end;
       end;
@@ -188,7 +185,7 @@ implementation
       end;
       end;
 
 
 
 
-    function tdef.getsymtable(t:tgetsymtable):psymtable;
+    function tdef.getsymtable(t:tgetsymtable):tsymtable;
       begin
       begin
         getsymtable:=nil;
         getsymtable:=nil;
       end;
       end;
@@ -198,21 +195,21 @@ implementation
                           TSYM (base for all symtypes)
                           TSYM (base for all symtypes)
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tsym.init(const n : string);
+    constructor tsym.create(const n : string);
       begin
       begin
          if n[1]='$' then
          if n[1]='$' then
-          inherited initname(copy(n,2,255))
+          inherited createname(copy(n,2,255))
          else
          else
-          inherited initname(upper(n));
+          inherited createname(upper(n));
          _realname:=stringdup(n);
          _realname:=stringdup(n);
          typ:=abstractsym;
          typ:=abstractsym;
       end;
       end;
 
 
 
 
-    destructor tsym.done;
+    destructor tsym.destroy;
       begin
       begin
         stringdispose(_realname);
         stringdispose(_realname);
-        inherited done;
+        inherited destroy;
       end;
       end;
 
 
 
 
@@ -234,7 +231,7 @@ implementation
       end;
       end;
 
 
 
 
-    function tsym.gettypedef:pdef;
+    function tsym.gettypedef:tdef;
       begin
       begin
         gettypedef:=nil;
         gettypedef:=nil;
       end;
       end;
@@ -244,7 +241,7 @@ implementation
                                TRef
                                TRef
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tref.init(ref :pref;pos : pfileposinfo);
+    constructor tref.create(ref :tref;pos : pfileposinfo);
       begin
       begin
         nextref:=nil;
         nextref:=nil;
         if pos<>nil then
         if pos<>nil then
@@ -252,25 +249,25 @@ implementation
         if assigned(current_module) then
         if assigned(current_module) then
           moduleindex:=current_module.unit_index;
           moduleindex:=current_module.unit_index;
         if assigned(ref) then
         if assigned(ref) then
-          ref^.nextref:=@self;
+          ref.nextref:=self;
         is_written:=false;
         is_written:=false;
       end;
       end;
 
 
     procedure tref.freechain;
     procedure tref.freechain;
       var
       var
-        p,q : pref;
+        p,q : tref;
       begin
       begin
         p:=nextref;
         p:=nextref;
         nextref:=nil;
         nextref:=nil;
         while assigned(p) do
         while assigned(p) do
           begin
           begin
-            q:=p^.nextref;
-            dispose(p,done);
+            q:=p.nextref;
+            p.free;
             p:=q;
             p:=q;
           end;
           end;
       end;
       end;
 
 
-    destructor tref.done;
+    destructor tref.destroy;
       begin
       begin
          nextref:=nil;
          nextref:=nil;
       end;
       end;
@@ -287,17 +284,17 @@ implementation
       end;
       end;
 
 
 
 
-    procedure ttype.setdef(p:pdef);
+    procedure ttype.setdef(p:tdef);
       begin
       begin
         def:=p;
         def:=p;
         sym:=nil;
         sym:=nil;
       end;
       end;
 
 
 
 
-    procedure ttype.setsym(p:psym);
+    procedure ttype.setsym(p:tsym);
       begin
       begin
         sym:=p;
         sym:=p;
-        def:=p^.gettypedef;
+        def:=p.gettypedef;
         if not assigned(def) then
         if not assigned(def) then
          internalerror(1234005);
          internalerror(1234005);
       end;
       end;
@@ -305,8 +302,8 @@ implementation
 
 
     procedure ttype.load;
     procedure ttype.load;
       begin
       begin
-        def:=pdef(readderef);
-        sym:=psym(readderef);
+        def:=tdef(readderef);
+        sym:=tsym(readderef);
       end;
       end;
 
 
 
 
@@ -315,8 +312,8 @@ implementation
         { Don't write symbol references for the current unit
         { Don't write symbol references for the current unit
           and for the system unit }
           and for the system unit }
         if assigned(sym) and
         if assigned(sym) and
-           (sym^.owner^.unitid<>0) and
-           (sym^.owner^.unitid<>1) then
+           (sym.owner.unitid<>0) and
+           (sym.owner.unitid<>1) then
          begin
          begin
            writederef(nil);
            writederef(nil);
            writederef(sym);
            writederef(sym);
@@ -344,7 +341,7 @@ implementation
                                  TSymList
                                  TSymList
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor tsymlist.init;
+    constructor tsymlist.create;
       begin
       begin
         def:=nil; { needed for procedures }
         def:=nil; { needed for procedures }
         firstsym:=nil;
         firstsym:=nil;
@@ -354,13 +351,13 @@ implementation
 
 
     constructor tsymlist.load;
     constructor tsymlist.load;
       var
       var
-        sym : psym;
+        sym : tsym;
       begin
       begin
-        def:=pdef(readderef);
+        def:=tdef(readderef);
         firstsym:=nil;
         firstsym:=nil;
         lastsym:=nil;
         lastsym:=nil;
         repeat
         repeat
-          sym:=psym(readderef);
+          sym:=tsym(readderef);
           if sym=nil then
           if sym=nil then
            break;
            break;
           addsym(sym);
           addsym(sym);
@@ -368,7 +365,7 @@ implementation
       end;
       end;
 
 
 
 
-    destructor tsymlist.done;
+    destructor tsymlist.destroy;
       begin
       begin
         clear;
         clear;
       end;
       end;
@@ -396,13 +393,13 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tsymlist.setdef(p:pdef);
+    procedure tsymlist.setdef(p:tdef);
       begin
       begin
         def:=p;
         def:=p;
       end;
       end;
 
 
 
 
-    procedure tsymlist.addsym(p:psym);
+    procedure tsymlist.addsym(p:tsym);
       var
       var
         hp : psymlistitem;
         hp : psymlistitem;
       begin
       begin
@@ -419,17 +416,17 @@ implementation
       end;
       end;
 
 
 
 
-    function tsymlist.getcopy:psymlist;
+    function tsymlist.getcopy:tsymlist;
       var
       var
-        hp  : psymlist;
+        hp  : tsymlist;
         hp2 : psymlistitem;
         hp2 : psymlistitem;
       begin
       begin
-        new(hp,init);
-        hp^.def:=def;
+        hp:=tsymlist.create;
+        hp.def:=def;
         hp2:=firstsym;
         hp2:=firstsym;
         while assigned(hp2) do
         while assigned(hp2) do
          begin
          begin
-           hp^.addsym(hp2^.sym);
+           hp.addsym(hp2^.sym);
            hp2:=hp2^.next;
            hp2:=hp2^.next;
          end;
          end;
         getcopy:=hp;
         getcopy:=hp;
@@ -469,95 +466,95 @@ implementation
                         Symbol / Definition Resolving
                         Symbol / Definition Resolving
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure resolvederef(var p:pderef;var st:psymtable;var idx:word);
+    procedure resolvederef(var p:tderef;var st:tsymtable;var idx:word);
       var
       var
-        hp : pderef;
-        pd : pdef;
+        hp : tderef;
+        pd : tdef;
       begin
       begin
         st:=nil;
         st:=nil;
         idx:=0;
         idx:=0;
         while assigned(p) do
         while assigned(p) do
          begin
          begin
-           case p^.dereftype of
+           case p.dereftype of
              derefaktrecordindex :
              derefaktrecordindex :
                begin
                begin
                  st:=aktrecordsymtable;
                  st:=aktrecordsymtable;
-                 idx:=p^.index;
+                 idx:=p.index;
                end;
                end;
              derefaktstaticindex :
              derefaktstaticindex :
                begin
                begin
                  st:=aktstaticsymtable;
                  st:=aktstaticsymtable;
-                 idx:=p^.index;
+                 idx:=p.index;
                end;
                end;
              derefaktlocal :
              derefaktlocal :
                begin
                begin
                  st:=aktlocalsymtable;
                  st:=aktlocalsymtable;
-                 idx:=p^.index;
+                 idx:=p.index;
                end;
                end;
              derefunit :
              derefunit :
                begin
                begin
 {$ifdef NEWMAP}
 {$ifdef NEWMAP}
-                 st:=psymtable(current_module.map^[p^.index]^.globalsymtable);
+                 st:=tsymtable(current_module.map^[p.index]^.globalsymtable);
 {$else NEWMAP}
 {$else NEWMAP}
-                 st:=psymtable(current_module.map^[p^.index]);
+                 st:=tsymtable(current_module.map^[p.index]);
 {$endif NEWMAP}
 {$endif NEWMAP}
                end;
                end;
              derefrecord :
              derefrecord :
                begin
                begin
-                 pd:=pdef(st^.getdefnr(p^.index));
-                 st:=pd^.getsymtable(gs_record);
+                 pd:=tdef(st.getdefnr(p.index));
+                 st:=pd.getsymtable(gs_record);
                  if not assigned(st) then
                  if not assigned(st) then
                   internalerror(556658);
                   internalerror(556658);
                end;
                end;
              dereflocal :
              dereflocal :
                begin
                begin
-                 pd:=pdef(st^.getdefnr(p^.index));
-                 st:=pd^.getsymtable(gs_local);
+                 pd:=tdef(st.getdefnr(p.index));
+                 st:=pd.getsymtable(gs_local);
                  if not assigned(st) then
                  if not assigned(st) then
                   internalerror(556658);
                   internalerror(556658);
                end;
                end;
              derefpara :
              derefpara :
                begin
                begin
-                 pd:=pdef(st^.getdefnr(p^.index));
-                 st:=pd^.getsymtable(gs_para);
+                 pd:=tdef(st.getdefnr(p.index));
+                 st:=pd.getsymtable(gs_para);
                  if not assigned(st) then
                  if not assigned(st) then
                   internalerror(556658);
                   internalerror(556658);
                end;
                end;
              derefindex :
              derefindex :
                begin
                begin
-                 idx:=p^.index;
+                 idx:=p.index;
                end;
                end;
              else
              else
                internalerror(556658);
                internalerror(556658);
            end;
            end;
            hp:=p;
            hp:=p;
-           p:=p^.next;
-           dispose(hp,done);
+           p:=p.next;
+           hp.free;
          end;
          end;
       end;
       end;
 
 
 
 
-    procedure resolvedef(var def:pdef);
+    procedure resolvedef(var def:tdef);
       var
       var
-        st   : psymtable;
+        st   : tsymtable;
         idx  : word;
         idx  : word;
       begin
       begin
-        resolvederef(pderef(def),st,idx);
+        resolvederef(tderef(def),st,idx);
         if assigned(st) then
         if assigned(st) then
-         def:=pdef(st^.getdefnr(idx))
+         def:=tdef(st.getdefnr(idx))
         else
         else
          def:=nil;
          def:=nil;
       end;
       end;
 
 
 
 
-    procedure resolvesym(var sym:psym);
+    procedure resolvesym(var sym:tsym);
       var
       var
-        st   : psymtable;
+        st   : tsymtable;
         idx  : word;
         idx  : word;
       begin
       begin
-        resolvederef(pderef(sym),st,idx);
+        resolvederef(tderef(sym),st,idx);
         if assigned(st) then
         if assigned(st) then
-         sym:=psym(st^.getsymnr(idx))
+         sym:=tsym(st.getsymnr(idx))
         else
         else
          sym:=nil;
          sym:=nil;
       end;
       end;
@@ -565,7 +562,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2001-04-02 21:20:35  peter
+  Revision 1.6  2001-04-13 01:22:17  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.5  2001/04/02 21:20:35  peter
     * resulttype rewrite
     * resulttype rewrite
 
 
   Revision 1.4  2000/12/25 00:07:30  peter
   Revision 1.4  2000/12/25 00:07:30  peter

+ 12 - 7
compiler/targets/t_fbsd.pas

@@ -82,7 +82,7 @@ begin
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   { do nothing with the procedure, only set the mangledname }
   { do nothing with the procedure, only set the mangledname }
   if name<>'' then
   if name<>'' then
-    aktprocsym^.definition^.setmangledname(name)
+    aktprocsym.definition.setmangledname(name)
   else
   else
     message(parser_e_empty_import_name);
     message(parser_e_empty_import_name);
 end;
 end;
@@ -93,8 +93,8 @@ begin
   { insert sharedlibrary }
   { insert sharedlibrary }
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   { reset the mangledname and turn off the dll_var option }
   { reset the mangledname and turn off the dll_var option }
-  aktvarsym^.setmangledname(name);
-  exclude(aktvarsym^.varoptions,vo_is_dll_var);
+  aktvarsym.setmangledname(name);
+  exclude(aktvarsym.varoptions,vo_is_dll_var);
 end;
 end;
 
 
 
 
@@ -169,7 +169,7 @@ begin
         { place jump in codesegment }
         { place jump in codesegment }
         codeSegment.concat(Tai_align.Create_op(4,$90));
         codeSegment.concat(Tai_align.Create_op(4,$90));
         codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
         codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
-        codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym^.mangledname)));
+        codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym.mangledname)));
         codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
         codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}
       end
       end
@@ -265,7 +265,7 @@ begin
    end;
    end;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes.Init(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
@@ -355,7 +355,7 @@ begin
    end;
    end;
 { Write and Close response }
 { Write and Close response }
   linkres.writetodisk;
   linkres.writetodisk;
-  linkres.done;
+  linkres.Free;
 
 
   WriteResponseFile:=True;
   WriteResponseFile:=True;
 end;
 end;
@@ -444,7 +444,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-02-26 19:43:11  peter
+  Revision 1.2  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.1  2001/02/26 19:43:11  peter
     * moved target units to subdir
     * moved target units to subdir
 
 
   Revision 1.7  2001/02/20 21:41:17  peter
   Revision 1.7  2001/02/20 21:41:17  peter

+ 8 - 3
compiler/targets/t_go32v1.pas

@@ -82,7 +82,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes.Init(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
@@ -147,7 +147,7 @@ begin
 
 
 { Write and Close response }
 { Write and Close response }
   linkres.writetodisk;
   linkres.writetodisk;
-  linkres.done;
+  LinkRes.Free;
 
 
   WriteResponseFile:=True;
   WriteResponseFile:=True;
 end;
 end;
@@ -189,7 +189,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-02-26 19:43:11  peter
+  Revision 1.2  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.1  2001/02/26 19:43:11  peter
     * moved target units to subdir
     * moved target units to subdir
 
 
   Revision 1.5  2000/12/25 00:07:30  peter
   Revision 1.5  2000/12/25 00:07:30  peter

+ 10 - 5
compiler/targets/t_go32v2.pas

@@ -85,7 +85,7 @@ begin
   WriteResponseFile:=False;
   WriteResponseFile:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes.Init(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
@@ -150,7 +150,7 @@ begin
 
 
 { Write and Close response }
 { Write and Close response }
   linkres.writetodisk;
   linkres.writetodisk;
-  linkres.done;
+  LinkRes.Free;
 
 
   WriteResponseFile:=True;
   WriteResponseFile:=True;
 end;
 end;
@@ -165,7 +165,7 @@ begin
   WriteScript:=False;
   WriteScript:=False;
 
 
   { Open link.res file }
   { Open link.res file }
-  ScriptRes.Init(outputexedir+Info.ResName);
+  ScriptRes:=TLinkRes.Create(outputexedir+Info.ResName);
   ScriptRes.Add('OUTPUT_FORMAT("coff-go32-exe")');
   ScriptRes.Add('OUTPUT_FORMAT("coff-go32-exe")');
   ScriptRes.Add('ENTRY(start)');
   ScriptRes.Add('ENTRY(start)');
 
 
@@ -271,7 +271,7 @@ begin
 
 
 { Write and Close response }
 { Write and Close response }
   ScriptRes.WriteToDisk;
   ScriptRes.WriteToDisk;
-  ScriptRes.done;
+  ScriptRes.Free;
 
 
   WriteScript:=True;
   WriteScript:=True;
 end;
 end;
@@ -419,7 +419,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-02-26 19:43:11  peter
+  Revision 1.2  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.1  2001/02/26 19:43:11  peter
     * moved target units to subdir
     * moved target units to subdir
 
 
   Revision 1.7  2001/01/27 21:29:35  florian
   Revision 1.7  2001/01/27 21:29:35  florian

+ 12 - 7
compiler/targets/t_linux.pas

@@ -81,7 +81,7 @@ begin
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   { do nothing with the procedure, only set the mangledname }
   { do nothing with the procedure, only set the mangledname }
   if name<>'' then
   if name<>'' then
-    aktprocsym^.definition^.setmangledname(name)
+    aktprocsym.definition.setmangledname(name)
   else
   else
     message(parser_e_empty_import_name);
     message(parser_e_empty_import_name);
 end;
 end;
@@ -92,8 +92,8 @@ begin
   { insert sharedlibrary }
   { insert sharedlibrary }
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   { reset the mangledname and turn off the dll_var option }
   { reset the mangledname and turn off the dll_var option }
-  aktvarsym^.setmangledname(name);
-  exclude(aktvarsym^.varoptions,vo_is_dll_var);
+  aktvarsym.setmangledname(name);
+  exclude(aktvarsym.varoptions,vo_is_dll_var);
 end;
 end;
 
 
 
 
@@ -168,7 +168,7 @@ begin
         { place jump in codesegment }
         { place jump in codesegment }
         codesegment.concat(Tai_align.Create_op(4,$90));
         codesegment.concat(Tai_align.Create_op(4,$90));
         codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
         codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
-        codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym^.mangledname)));
+        codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym.mangledname)));
         codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
         codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}
       end
       end
@@ -262,7 +262,7 @@ begin
    end;
    end;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes.Init(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
 
 
   { Write path to search libraries }
   { Write path to search libraries }
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
   HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
@@ -355,7 +355,7 @@ begin
    end;
    end;
 { Write and Close response }
 { Write and Close response }
   linkres.writetodisk;
   linkres.writetodisk;
-  linkres.done;
+  linkres.Free;
 
 
   WriteResponseFile:=True;
   WriteResponseFile:=True;
 end;
 end;
@@ -445,7 +445,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2001-03-22 10:08:12  michael
+  Revision 1.3  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.2  2001/03/22 10:08:12  michael
   + .ctor patch merged from fixbranch
   + .ctor patch merged from fixbranch
 
 
   Revision 1.1  2001/02/26 19:43:11  peter
   Revision 1.1  2001/02/26 19:43:11  peter

+ 13 - 8
compiler/targets/t_nwm.pas

@@ -134,7 +134,7 @@ begin
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   { do nothing with the procedure, only set the mangledname }
   { do nothing with the procedure, only set the mangledname }
   if name<>'' then
   if name<>'' then
-    aktprocsym^.definition^.setmangledname(name)
+    aktprocsym.definition.setmangledname(name)
   else
   else
     message(parser_e_empty_import_name);
     message(parser_e_empty_import_name);
 end;
 end;
@@ -145,8 +145,8 @@ begin
   { insert sharedlibrary }
   { insert sharedlibrary }
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   current_module.linkothersharedlibs.add(SplitName(module),link_allways);
   { reset the mangledname and turn off the dll_var option }
   { reset the mangledname and turn off the dll_var option }
-  aktvarsym^.setmangledname(name);
-  exclude(aktvarsym^.varoptions,vo_is_dll_var);
+  aktvarsym.setmangledname(name);
+  exclude(aktvarsym.varoptions,vo_is_dll_var);
 end;
 end;
 
 
 
 
@@ -177,7 +177,7 @@ begin
   { use pascal name is none specified }
   { use pascal name is none specified }
   if (hp.options and eo_name)=0 then
   if (hp.options and eo_name)=0 then
     begin
     begin
-       hp.name:=stringdup(hp.sym^.name);
+       hp.name:=stringdup(hp.sym.name);
        hp.options:=hp.options or eo_name;
        hp.options:=hp.options or eo_name;
     end;
     end;
   { now place in correct order }
   { now place in correct order }
@@ -227,7 +227,7 @@ begin
         { place jump in codesegment }
         { place jump in codesegment }
         codeSegment.concat(Tai_align.Create_op(4,$90));
         codeSegment.concat(Tai_align.Create_op(4,$90));
         codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
         codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,0));
-        codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym^.mangledname)));
+        codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,newasmsymbol(hp2.sym.mangledname)));
         codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
         codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}
       end
       end
@@ -277,7 +277,7 @@ begin
   NlmNam := ProgNam + target_os.exeext;
   NlmNam := ProgNam + target_os.exeext;
 
 
   { Open link.res file }
   { Open link.res file }
-  LinkRes.Init(outputexedir+Info.ResName);
+  LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
 
 
   if Description <> '' then
   if Description <> '' then
     LinkRes.Add('DESCRIPTION "' + Description + '"');
     LinkRes.Add('DESCRIPTION "' + Description + '"');
@@ -375,7 +375,7 @@ begin
 
 
 { Write and Close response }
 { Write and Close response }
   linkres.writetodisk;
   linkres.writetodisk;
-  linkres.done;
+  LinkRes.Free;
 
 
   WriteResponseFile:=True;
   WriteResponseFile:=True;
 end;
 end;
@@ -421,7 +421,12 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-02-26 19:43:11  peter
+  Revision 1.2  2001-04-13 01:22:21  peter
+    * symtable change to classes
+    * range check generation and errors fixed, make cycle DEBUG=1 works
+    * memory leaks fixed
+
+  Revision 1.1  2001/02/26 19:43:11  peter
     * moved target units to subdir
     * moved target units to subdir
 
 
   Revision 1.6  2001/02/20 21:41:16  peter
   Revision 1.6  2001/02/20 21:41:16  peter

Some files were not shown because too many files changed in this diff