Jelajahi Sumber

* fixed saving/loading of nested procvar types to/from ppu files (symtable
level of parast has to be saved/loaded)

git-svn-id: branches/nestedprocvars@15673 -

Jonas Maebe 15 tahun lalu
induk
melakukan
677958fc79

+ 2 - 0
.gitattributes

@@ -9256,6 +9256,7 @@ tests/test/tmaclocalprocparam3b.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam3c.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam3d.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam3e.pp svneol=native#text/plain
+tests/test/tmaclocalprocparam3f.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4a.pp svneol=native#text/plain
 tests/test/tmaclocalprocparam4b.pp svneol=native#text/plain
@@ -9554,6 +9555,7 @@ tests/test/uimpluni1.pp svneol=native#text/plain
 tests/test/uimpluni2.pp svneol=native#text/plain
 tests/test/uinline4a.pp svneol=native#text/plain
 tests/test/uinline4b.pp svneol=native#text/plain
+tests/test/umaclocalprocparam3f.pp svneol=native#text/plain
 tests/test/umacpas1.pp svneol=native#text/plain
 tests/test/umainnam.pp svneol=native#text/plain
 tests/test/units/classes/tmakeobjinst.pp svneol=native#text/plain

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion = 119;
+  CurrentPPUVersion = 120;
 
 { buffer sizes }
   maxentrysize = 1024;

+ 5 - 1
compiler/symdef.pas

@@ -3721,7 +3721,7 @@ implementation
       begin
          inherited ppuload(procvardef,ppufile);
          { load para symtable }
-         parast:=tparasymtable.create(self,unknown_level);
+         parast:=tparasymtable.create(self,ppufile.getbyte);
          tparasymtable(parast).ppuload(ppufile);
       end;
 
@@ -3762,6 +3762,10 @@ implementation
       begin
         inherited ppuwrite(ppufile);
 
+        { Save the para symtable level (necessary to distinguish nested
+          procvars) }
+        ppufile.putbyte(parast.symtablelevel);
+
         { Write this entry }
         ppufile.writeentry(ibprocvardef);
 

+ 62 - 0
tests/test/tmaclocalprocparam3f.pp

@@ -0,0 +1,62 @@
+{ %recompile }
+
+{$modeswitch nestedprocvars}
+program tmaclocalprocparam3;
+
+uses
+  umaclocalprocparam3f;
+
+var
+  tempp: tnestedprocvar2;
+
+  procedure finalglobal;
+    begin
+      writeln('final');
+    end;
+
+  procedure p1( pp: tnestedprocvar2; p: tnestedprocvar);
+  begin
+    tempp:=pp;
+    tempp(p);
+  end;
+
+  procedure p2( pp: tnestedprocvar2; p: tnestedprocvar);
+  var
+    localpp: tnestedprocvar2;
+  begin
+    localpp:=pp;
+    p1( localpp, p)
+  end;
+
+  procedure n(pp: tnestedprocvar);
+  begin
+    writeln( 'calling through n');
+    pp();
+  end;
+
+  procedure q;
+  var qi: longint;
+
+    procedure r(pp: tnestedprocvar);
+    begin
+      if qi = 1 then
+        writeln( 'success for r')
+      else
+        begin
+        writeln( 'fail');
+        halt( 1)
+      end;
+      pp();
+    end;
+
+  begin
+    qi:= 1;
+    p1( @r, @finalglobal);
+    p2( @r, @finalglobal);
+    p1( @n, @finalglobal);
+    p2( @n, @finalglobal);
+  end;
+
+begin
+	q
+end.

+ 13 - 0
tests/test/umaclocalprocparam3f.pp

@@ -0,0 +1,13 @@
+{$modeswitch nestedprocvars}
+
+unit umaclocalprocparam3f;
+
+interface
+
+type
+  tnestedprocvar = procedure is nested;
+  tnestedprocvar2 = procedure(pp: tnestedprocvar) is nested;
+
+implementation
+
+end.