Преглед изворни кода

* store/restore taddnode.resultrealdef to/from the ppufiles, and also
copy/compare it when copying/comparing taddnodes (necessary for inlined
procedures, mantis #13596)

git-svn-id: trunk@13054 -

Jonas Maebe пре 16 година
родитељ
комит
79c70c52a7
5 измењених фајлова са 123 додато и 2 уклоњено
  1. 2 0
      .gitattributes
  2. 54 1
      compiler/nadd.pas
  3. 1 1
      compiler/ppu.pas
  4. 14 0
      tests/webtbs/tw13596.pp
  5. 52 0
      tests/webtbs/tw13596a.pp

+ 2 - 0
.gitattributes

@@ -8833,6 +8833,8 @@ tests/webtbs/tw13552.pp svneol=native#text/plain
 tests/webtbs/tw13553.pp svneol=native#text/plain
 tests/webtbs/tw13563.pp svneol=native#text/plain
 tests/webtbs/tw13583.pp svneol=native#text/plain
+tests/webtbs/tw13596.pp svneol=native#text/plain
+tests/webtbs/tw13596a.pp svneol=native#text/plain
 tests/webtbs/tw1364.pp svneol=native#text/plain
 tests/webtbs/tw1365.pp svneol=native#text/plain
 tests/webtbs/tw1374.pp svneol=native#text/plain

+ 54 - 1
compiler/nadd.pas

@@ -33,15 +33,22 @@ interface
     type
        taddnode = class(tbinopnode)
        private
+          resultrealdefderef: tderef;
           function pass_typecheck_internal:tnode;
        public
           resultrealdef : tdef;
           constructor create(tt : tnodetype;l,r : tnode);override;
+          constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
+          procedure ppuwrite(ppufile:tcompilerppufile);override;
+          procedure buildderefimpl;override;
+          procedure derefimpl;override;
           function pass_1 : tnode;override;
           function pass_typecheck:tnode;override;
           function simplify : tnode;override;
+          function dogetcopy : tnode;override;
+          function docompare(p: tnode): boolean; override;
     {$ifdef state_tracking}
-      function track_state_pass(exec_known:boolean):boolean;override;
+          function track_state_pass(exec_known:boolean):boolean;override;
     {$endif}
          protected
           { override the following if you want to implement }
@@ -138,6 +145,34 @@ implementation
       end;
 
 
+    constructor taddnode.ppuload(t: tnodetype; ppufile: tcompilerppufile);
+      begin
+        inherited ppuload(t, ppufile);
+        ppufile.getderef(resultrealdefderef);
+      end;
+
+
+    procedure taddnode.ppuwrite(ppufile: tcompilerppufile);
+      begin
+        inherited ppuwrite(ppufile);
+         ppufile.putderef(resultrealdefderef);
+      end;
+
+
+    procedure taddnode.buildderefimpl;
+      begin
+        inherited buildderefimpl;
+        resultrealdefderef.build(resultrealdef);
+      end;
+
+
+    procedure taddnode.derefimpl;
+      begin
+        inherited derefimpl;
+        resultrealdef:=tdef(resultrealdefderef.resolve);
+      end;
+
+
     function taddnode.simplify : tnode;
       var
         t, hp   : tnode;
@@ -708,6 +743,24 @@ implementation
       end;
 
 
+    function taddnode.dogetcopy: tnode;
+      var
+        n: taddnode;
+      begin
+        n:=taddnode(inherited dogetcopy);
+        n.resultrealdef:=resultrealdef;
+        result:=n;
+      end;
+
+
+    function taddnode.docompare(p: tnode): boolean;
+      begin
+        result:=
+          inherited docompare(p) and
+          equal_defs(taddnode(p).resultrealdef,resultrealdef);
+      end;
+
+
     function taddnode.pass_typecheck:tnode;
       begin
         { This function is small to keep the stack small for recursive of

+ 1 - 1
compiler/ppu.pas

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

+ 14 - 0
tests/webtbs/tw13596.pp

@@ -0,0 +1,14 @@
+{ %norun }
+{ %recompile }
+
+{$inline on}
+
+program BothScreens3D;
+
+uses
+  tw13596a;
+
+begin
+  gluPerspective(70, 256.0 / 192.0, 0.1, 100);
+end.
+

+ 52 - 0
tests/webtbs/tw13596a.pp

@@ -0,0 +1,52 @@
+{$inline on}
+
+unit tw13596a;
+
+interface
+
+const
+  LUT_SIZE = 512;
+  LUT_MASK = 511;
+
+procedure gluPerspective(fovy, aspect, zNear, zFar: single); inline;
+procedure gluPerspectivef32(fovy: longint; aspect, zNear, zFar: longint); inline;
+function mulf32(a, b: longint): longint; inline;
+function floattof32(n: single): longint; inline;        
+
+implementation
+
+function floattof32(n: single): longint; inline;        
+begin
+  floattof32 := trunc((n) * (1 shl 12)); 
+end;
+
+function mulf32(a, b: longint): longint; inline;
+var
+  rslt: int64;
+begin
+        rslt := int64(a) * int64(b);
+        mulf32 := longint(rslt shr 12);
+end;
+
+procedure gluPerspectivef32(fovy: longint; aspect, zNear, zFar: longint); inline;
+var
+  xmin, xmax, ymin, ymax: longint;
+  TAN_bin: array [0..511] of smallint;
+begin
+
+  ymax := mulf32(zNear, TAN_bin[(fovy shr 1) and LUT_MASK]);
+        ymin := -ymax;
+        xmin := mulf32(ymin, aspect);
+        xmax := mulf32(ymax, aspect);
+        
+//        glFrustumf32(xmin, xmax, ymin, ymax, zNear, zFar);
+
+end;
+
+procedure gluPerspective(fovy, aspect, zNear, zFar: single); inline;
+begin
+ gluPerspectivef32(trunc(fovy * LUT_SIZE / 360.0), floattof32(aspect), floattof32(zNear), floattof32(zFar));
+end;
+
+
+end.