Procházet zdrojové kódy

* fix for real and string consts inside inlined procs

pierre před 27 roky
rodič
revize
acc260ed78
3 změnil soubory, kde provedl 34 přidání a 11 odebrání
  1. 5 2
      compiler/cg386con.pas
  2. 13 3
      compiler/cgi386.pas
  3. 16 6
      compiler/hcodegen.pas

+ 5 - 2
compiler/cg386con.pas

@@ -205,14 +205,17 @@ implementation
          if assigned(lastlabel) then
            p^.location.reference.symbol:=stringdup(constlabel2str(lastlabel,conststring))
          else
-           p^.location.reference.symbol:=stringdup(constlabelnb2str(p^.labnumber,conststring));
+           p^.location.reference.symbol:=stringdup(constlabelnb2str(p^.labstrnumber,conststring));
          p^.location.loc := LOC_MEM;
       end;
 
 end.
 {
   $Log$
-  Revision 1.1  1998-05-23 01:21:02  peter
+  Revision 1.2  1998-06-05 16:13:31  pierre
+    * fix for real and string consts inside inlined procs
+
+  Revision 1.1  1998/05/23 01:21:02  peter
     + aktasmmode, aktoptprocessor, aktoutputformat
     + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
     + $LIBNAME to set the library name where the unit will be put in

+ 13 - 3
compiler/cgi386.pas

@@ -4690,6 +4690,7 @@ do_jmp:
            oldprocsym : pprocsym;
            para_size : longint;
            oldprocinfo : tprocinfo;
+           old_make_const_global : boolean;
            { just dummies for genentrycode }
            nostackframe,make_global : boolean;
            proc_names : tstringcontainer;
@@ -4711,6 +4712,8 @@ do_jmp:
               { set it to the same lexical level }
           st^.symtablelevel:=
             oldprocsym^.definition^.localst^.symtablelevel;
+          old_make_const_global:=make_const_global;
+          make_const_global:=true;
           if st^.datasize>0 then
             st^.call_offset:=gettempofsizepersistant(st^.datasize);
 {$ifdef extdebug}
@@ -4750,6 +4753,7 @@ do_jmp:
           aktexitlabel:=oldexitlabel;
           aktexit2label:=oldexit2label;
           quickexitlabel:=oldquickexitlabel;
+          make_const_global:=old_make_const_global;
           procinfo:=oldprocinfo;
        end;
 
@@ -4926,7 +4930,7 @@ do_jmp:
                    }
                    if assigned(aktprocsym) then
                      begin
-                       if (aktprocsym^.definition^.options and
+                        if (aktprocsym^.definition^.options and
                         poconstructor+podestructor{+poinline}+pointerrupt=0) and
                         ((procinfo.flags and pi_do_call)=0) and (lexlevel>1) then
                        begin
@@ -5042,6 +5046,9 @@ do_jmp:
                           end;
                      end;
                 end;
+              if assigned(aktprocsym) and
+                 ((aktprocsym^.definition^.options and poinline)<>0) then
+                make_const_global:=true;
               do_secondpass(p);
 
 {$ifdef StoreFPULevel}
@@ -5055,7 +5062,7 @@ do_jmp:
               c_usableregs:=4;
            end;
          procinfo.aktproccode^.concatlist(exprasmlist);
-
+         make_const_global:=false;
          current_module^.current_inputfile:=oldis;
          current_module^.current_inputfile^.line_no:=oldnr;
       end;
@@ -5063,7 +5070,10 @@ do_jmp:
 end.
 {
   $Log$
-  Revision 1.34  1998-06-05 14:37:27  pierre
+  Revision 1.35  1998-06-05 16:13:32  pierre
+    * fix for real and string consts inside inlined procs
+
+  Revision 1.34  1998/06/05 14:37:27  pierre
     * fixes for inline for operators
     * inline procedure more correctly restricted
 

+ 16 - 6
compiler/hcodegen.pas

@@ -53,7 +53,8 @@ unit hcodegen;
           { return type }
           sym : pprocsym;
           { the definition of the proc itself }
-          def : pdef;
+          { why was this a pdef only ?? PM    }
+          def : pprocdef;
           { frame pointer offset }
           framepointer_offset : longint;
           { self pointer offset }
@@ -144,7 +145,10 @@ unit hcodegen;
     function constlabelnb2str(pnb : longint;ctype:tconsttype):string;
     procedure concat_constlabel(p:plabel;ctype:tconsttype);
 
-
+    { to be able to force to have a global label for const }
+    const
+       make_const_global : boolean = false;
+       
 implementation
 
      uses
@@ -356,7 +360,8 @@ implementation
       { we must use the number directly !!! (PM) }
     function constlabel2str(l : plabel;ctype:tconsttype):string;
       begin
-        if (cs_smartlink in aktswitches) {or (aktoutputformat in [as_tasm])} then
+        if (cs_smartlink in aktswitches) or
+           make_const_global {or (aktoutputformat in [as_tasm])} then
          constlabel2str:='_$'+current_module^.modulename^+'$'+consttypestr[ctype]+'_const_'+tostr(l^.nb)
         else
          constlabel2str:=lab2str(l);
@@ -364,7 +369,8 @@ implementation
 
     function constlabelnb2str(pnb : longint;ctype:tconsttype):string;
       begin
-        if (cs_smartlink in aktswitches) {or (aktoutputformat in [as_tasm])} then
+        if (cs_smartlink in aktswitches) or
+           make_const_global {or (aktoutputformat in [as_tasm])} then
          constlabelnb2str:='_$'+current_module^.modulename^+'$'+consttypestr[ctype]+'_const_'+tostr(pnb)
         else
          constlabelnb2str:=target_asm.labelprefix+tostr(pnb);
@@ -375,7 +381,8 @@ implementation
       var
         s : string;
       begin
-        if (cs_smartlink in aktswitches) {or (aktoutputformat in [as_tasm])} then
+        if (cs_smartlink in aktswitches) or
+           make_const_global {or (aktoutputformat in [as_tasm])} then
          begin
            s:='_$'+current_module^.modulename^+'$'+consttypestr[ctype]+'_const_'+tostr(p^.nb);
            if (cs_smartlink in aktswitches) then
@@ -394,7 +401,10 @@ end.
 
 {
   $Log$
-  Revision 1.8  1998-06-04 23:51:40  peter
+  Revision 1.9  1998-06-05 16:13:34  pierre
+    * fix for real and string consts inside inlined procs
+
+  Revision 1.8  1998/06/04 23:51:40  peter
     * m68k compiles
     + .def file creation moved to gendef.pas so it could also be used
       for win32