Преглед на файлове

* added support for very big/small currency constants for non x86 CPUs.

git-svn-id: trunk@5937 -
yury преди 18 години
родител
ревизия
bcd86ef782
променени са 5 файла, в които са добавени 18 реда и са изтрити 2 реда
  1. 8 0
      compiler/ncon.pas
  2. 1 0
      compiler/nmat.pas
  3. 7 0
      compiler/pexpr.pas
  4. 1 1
      compiler/ppu.pas
  5. 1 1
      compiler/ptconst.pas

+ 8 - 0
compiler/ncon.pas

@@ -54,6 +54,7 @@ interface
           typedef : tdef;
           typedefderef : tderef;
           value_real : bestreal;
+          value_currency : currency;
           lab_real : tasmlabel;
           constructor create(v : bestreal;def:tdef);virtual;
           constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
@@ -472,14 +473,19 @@ implementation
          inherited create(realconstn);
          typedef:=def;
          value_real:=v;
+         value_currency:=v;
          lab_real:=nil;
       end;
 
     constructor trealconstnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
+      var
+        i : int64;
       begin
         inherited ppuload(t,ppufile);
         ppufile.getderef(typedefderef);
         value_real:=ppufile.getreal;
+        i:=ppufile.getint64;
+        value_currency:=PCurrency(@i)^;
         lab_real:=tasmlabel(ppufile.getasmsymbol);
       end;
 
@@ -489,6 +495,7 @@ implementation
         inherited ppuwrite(ppufile);
         ppufile.putderef(typedefderef);
         ppufile.putreal(value_real);
+        ppufile.putint64(PInt64(@value_currency)^);
         ppufile.putasmsymbol(lab_real);
       end;
 
@@ -513,6 +520,7 @@ implementation
       begin
          n:=trealconstnode(inherited dogetcopy);
          n.value_real:=value_real;
+         n.value_currency:=value_currency;
          n.lab_real:=lab_real;
          dogetcopy:=n;
       end;

+ 1 - 0
compiler/nmat.pas

@@ -605,6 +605,7 @@ implementation
         if is_constrealnode(left) then
           begin
              trealconstnode(left).value_real:=-trealconstnode(left).value_real;
+             trealconstnode(left).value_currency:=-trealconstnode(left).value_currency;
              result:=left;
              left:=nil;
              exit;

+ 7 - 0
compiler/pexpr.pas

@@ -2198,6 +2198,7 @@ implementation
          pd         : tprocdef;
          hclassdef     : tobjectdef;
          d          : bestreal;
+         cur        : currency;
          hs,hsorg   : string;
          hdef       : tdef;
          filepos    : tfileposinfo;
@@ -2446,6 +2447,11 @@ implementation
                else
 {$endif FPC_REAL2REAL_FIXED}
                  p1:=crealconstnode.create(d,pbestrealtype^);
+{$ifdef FPC_HAS_STR_CURRENCY}
+               val(pattern,cur,code);
+               if code=0 then
+                 trealconstnode(p1).value_currency:=cur;
+{$endif FPC_HAS_STR_CURRENCY}
              end;
 
            _STRING :
@@ -2595,6 +2601,7 @@ implementation
                         else if tbinarynode(p1).left.nodetype=realconstn then
                           begin
                             trealconstnode(tbinarynode(p1).left).value_real:=-trealconstnode(tbinarynode(p1).left).value_real;
+                            trealconstnode(tbinarynode(p1).left).value_currency:=-trealconstnode(tbinarynode(p1).left).value_currency;
                             p1:=cunaryminusnode.create(p1);
                           end
                         else

+ 1 - 1
compiler/ppu.pas

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

+ 1 - 1
compiler/ptconst.pas

@@ -131,7 +131,7 @@ implementation
                      intvalue := tordconstnode(n).value
                    { allow bootstrapping }
                    else if is_constrealnode(n) then
-                     intvalue:=round(trealconstnode(n).value_real*10000)
+                     intvalue:=PInt64(@trealconstnode(n).value_currency)^
                    else
                      begin
                        intvalue:=0;