瀏覽代碼

* some stuff of Pavel implement (win32 dll creation)
* bug with ansistring function results fixed

florian 27 年之前
父節點
當前提交
3bb3dc34ff
共有 2 個文件被更改,包括 79 次插入58 次删除
  1. 69 56
      compiler/cg386cal.pas
  2. 10 2
      compiler/files.pas

+ 69 - 56
compiler/cg386cal.pas

@@ -674,7 +674,7 @@ implementation
       var
       var
          unusedregisters : tregisterset;
          unusedregisters : tregisterset;
          pushed : tpushed;
          pushed : tpushed;
-         funcretref : treference;
+         hr,funcretref : treference;
          hregister : tregister;
          hregister : tregister;
          oldpushedparasize : longint;
          oldpushedparasize : longint;
          { true if ESI must be loaded again after the subroutine }
          { true if ESI must be loaded again after the subroutine }
@@ -1270,7 +1270,7 @@ implementation
            end;
            end;
          if (p^.resulttype<>pdef(voiddef)) and p^.return_value_used then
          if (p^.resulttype<>pdef(voiddef)) and p^.return_value_used then
            begin
            begin
-                 { a contructor could be a function with boolean result }
+              { a contructor could be a function with boolean result }
               if (p^.right=nil) and
               if (p^.right=nil) and
                  ((p^.procdefinition^.options and poconstructor)<>0) and
                  ((p^.procdefinition^.options and poconstructor)<>0) 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 }
@@ -1319,69 +1319,78 @@ implementation
                                     p^.location.register:=hregister;
                                     p^.location.register:=hregister;
                                  end;
                                  end;
                             end;
                             end;
-                          uchar,u8bit,bool8bit,s8bit :
-                                  begin
+                          uchar,u8bit,bool8bit,s8bit:
+                            begin
 {$ifdef test_dest_loc}
 {$ifdef test_dest_loc}
-                                     if dest_loc_known and (dest_loc_tree=p) then
-                                       mov_reg_to_dest(p,S_B,R_AL)
-                                     else
+                                 if dest_loc_known and (dest_loc_tree=p) then
+                                   mov_reg_to_dest(p,S_B,R_AL)
+                                 else
 {$endif test_dest_loc}
 {$endif test_dest_loc}
-                                       begin
-                                          hregister:=getexplicitregister32(R_EAX);
-                                          emit_reg_reg(A_MOV,S_B,R_AL,reg32toreg8(hregister));
-                                          p^.location.register:=reg32toreg8(hregister);
-                                       end;
-                                  end;
-                                s16bit,u16bit,bool16bit :
-                                  begin
+                                   begin
+                                      hregister:=getexplicitregister32(R_EAX);
+                                      emit_reg_reg(A_MOV,S_B,R_AL,reg32toreg8(hregister));
+                                      p^.location.register:=reg32toreg8(hregister);
+                                   end;
+                              end;
+                          s16bit,u16bit,bool16bit :
+                            begin
 {$ifdef test_dest_loc}
 {$ifdef test_dest_loc}
-                                     if dest_loc_known and (dest_loc_tree=p) then
-                                       mov_reg_to_dest(p,S_W,R_AX)
-                                     else
+                               if dest_loc_known and (dest_loc_tree=p) then
+                                 mov_reg_to_dest(p,S_W,R_AX)
+                               else
 {$endif test_dest_loc}
 {$endif test_dest_loc}
-                                       begin
-                                          hregister:=getexplicitregister32(R_EAX);
-                                          emit_reg_reg(A_MOV,S_W,R_AX,reg32toreg16(hregister));
-                                          p^.location.register:=reg32toreg16(hregister);
-                                       end;
-                                  end;
-                             else internalerror(7);
-                              end
+                                 begin
+                                    hregister:=getexplicitregister32(R_EAX);
+                                    emit_reg_reg(A_MOV,S_W,R_AX,reg32toreg16(hregister));
+                                    p^.location.register:=reg32toreg16(hregister);
+                                 end;
+                            end;
+                        else internalerror(7);
+                     end
 
 
-                          end
-                       else if (p^.resulttype^.deftype=floatdef) then
-                           case pfloatdef(p^.resulttype)^.typ of
-                                 f32bit : begin
-                                             p^.location.loc:=LOC_REGISTER;
+                end
+              else if (p^.resulttype^.deftype=floatdef) then
+                case pfloatdef(p^.resulttype)^.typ of
+                  f32bit:
+                    begin
+                       p^.location.loc:=LOC_REGISTER;
 {$ifdef test_dest_loc}
 {$ifdef test_dest_loc}
-                                             if dest_loc_known and (dest_loc_tree=p) then
-                                               mov_reg_to_dest(p,S_L,R_EAX)
-                                             else
-{$endif test_dest_loc}
-                                               begin
-                                                  hregister:=getexplicitregister32(R_EAX);
-                                                  emit_reg_reg(A_MOV,S_L,R_EAX,hregister);
-                                                  p^.location.register:=hregister;
-                                               end;
-                                          end;
-                                 else
-                                     p^.location.loc:=LOC_FPU;
-                           end
+                       if dest_loc_known and (dest_loc_tree=p) then
+                         mov_reg_to_dest(p,S_L,R_EAX)
                        else
                        else
-                          begin
-                              p^.location.loc:=LOC_REGISTER;
+{$endif test_dest_loc}
+                         begin
+                            hregister:=getexplicitregister32(R_EAX);
+                            emit_reg_reg(A_MOV,S_L,R_EAX,hregister);
+                            p^.location.register:=hregister;
+                         end;
+                    end;
+                  else
+                    p^.location.loc:=LOC_FPU;
+                end
+              else
+                begin
+                   p^.location.loc:=LOC_REGISTER;
 {$ifdef test_dest_loc}
 {$ifdef test_dest_loc}
-                              if dest_loc_known and (dest_loc_tree=p) then
-                                mov_reg_to_dest(p,S_L,R_EAX)
-                              else
+                   if dest_loc_known and (dest_loc_tree=p) then
+                     mov_reg_to_dest(p,S_L,R_EAX)
+                   else
 {$endif test_dest_loc}
 {$endif test_dest_loc}
-                                begin
-                                    hregister:=getexplicitregister32(R_EAX);
-                                    emit_reg_reg(A_MOV,S_L,R_EAX,hregister);
-                                    p^.location.register:=hregister;
-                                end;
-                          end;
+                    begin
+                       hregister:=getexplicitregister32(R_EAX);
+                       emit_reg_reg(A_MOV,S_L,R_EAX,hregister);
+                       p^.location.register:=hregister;
+                       if is_ansistring(p^.resulttype) or
+                         is_widestring(p^.resulttype) then
+                         begin
+                            gettempofsizereference(4,hr);
+                            temptoremove^.concat(new(ptemptodestroy,init(hr,p^.resulttype)));
+                            exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,p^.location.register,
+                              newreference(hr))));
+                         end;
+                    end;
                 end;
                 end;
+             end;
            end;
            end;
 
 
          { perhaps i/o check ? }
          { perhaps i/o check ? }
@@ -1543,7 +1552,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.42  1998-11-13 15:40:13  pierre
+  Revision 1.43  1998-11-15 16:32:33  florian
+    * some stuff of Pavel implement (win32 dll creation)
+    * bug with ansistring function results fixed
+
+  Revision 1.42  1998/11/13 15:40:13  pierre
     + added -Se in Makefile cvstest target
     + added -Se in Makefile cvstest target
     + lexlevel cleanup
     + lexlevel cleanup
       normal_function_level main_program_level and unit_init_level defined
       normal_function_level main_program_level and unit_init_level defined

+ 10 - 2
compiler/files.pas

@@ -614,7 +614,11 @@ unit files;
          if AllowOutput and (OutputFile<>'') then
          if AllowOutput and (OutputFile<>'') then
           n:=OutputFile;
           n:=OutputFile;
          staticlibfilename:=stringdup(p+target_os.libprefix+n+target_os.staticlibext);
          staticlibfilename:=stringdup(p+target_os.libprefix+n+target_os.staticlibext);
-         sharedlibfilename:=stringdup(p+target_os.libprefix+n+target_os.sharedlibext);
+
+         if target_info.target=target_i386_WIN32 then
+           sharedlibfilename:=stringdup(p+n+target_os.sharedlibext)
+         else
+           sharedlibfilename:=stringdup(p+target_os.libprefix+n+target_os.sharedlibext);
          { output dir of exe can be specified separatly }
          { output dir of exe can be specified separatly }
          if AllowOutput and (OutputExeDir<>'') then
          if AllowOutput and (OutputExeDir<>'') then
           p:=OutputExeDir
           p:=OutputExeDir
@@ -1032,7 +1036,11 @@ unit files;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.71  1998-11-06 09:45:40  pierre
+  Revision 1.72  1998-11-15 16:32:35  florian
+    * some stuff of Pavel implement (win32 dll creation)
+    * bug with ansistring function results fixed
+
+  Revision 1.71  1998/11/06 09:45:40  pierre
     * bug on errors (file used after dispose !) fixed
     * bug on errors (file used after dispose !) fixed
 
 
   Revision 1.70  1998/11/03 11:33:14  peter
   Revision 1.70  1998/11/03 11:33:14  peter