Browse Source

* properly delete all generated .j files in case -a is not used
(previously, only the .j file for the unit itself was deleted,
and the ones for classes/interfaces remained behind)

git-svn-id: branches/jvmbackend@19750 -

Jonas Maebe 13 years ago
parent
commit
0418766417
1 changed files with 46 additions and 6 deletions
  1. 46 6
      compiler/agjasmin.pas

+ 46 - 6
compiler/agjasmin.pas

@@ -70,6 +70,7 @@ interface
         function MakeCmdLine: TCmdStr;override;
         function MakeCmdLine: TCmdStr;override;
         procedure WriteTree(p:TAsmList);override;
         procedure WriteTree(p:TAsmList);override;
         procedure WriteAsmList;override;
         procedure WriteAsmList;override;
+        procedure RemoveAsm; override;
         destructor destroy; override;
         destructor destroy; override;
        protected
        protected
         InstrWriter: TJasminInstrWriter;
         InstrWriter: TJasminInstrWriter;
@@ -646,6 +647,7 @@ implementation
        jasminjarname = 'jasmin.jar';
        jasminjarname = 'jasmin.jar';
      var
      var
        filenames: tcmdstr;
        filenames: tcmdstr;
+       asmfile: tcmdstrlistitem;
        jasminjarfound: boolean;
        jasminjarfound: boolean;
      begin
      begin
        if jasminjar='' then
        if jasminjar='' then
@@ -664,15 +666,30 @@ implementation
              Message1(exec_t_using_assembler,jasminjar);
              Message1(exec_t_using_assembler,jasminjar);
          end;
          end;
        result:=target_asm.asmcmd;
        result:=target_asm.asmcmd;
-       filenames:=maybequoted(ScriptFixFileName(AsmFileName));
-       while not asmfiles.empty do
-         filenames:=filenames+' '+asmfiles.GetFirst;
+       filenames:=ScriptFixFileName(AsmFileName);
+       if cs_asm_extern in current_settings.globalswitches then
+         filenames:=maybequoted(filenames);
+       asmfile:=tcmdstrlistitem(asmfiles.First);
+       while assigned(asmfile) do
+         begin
+           if cs_asm_extern in current_settings.globalswitches then
+             filenames:=filenames+' '+maybequoted(ScriptFixFileName(asmfile.str))
+           else
+            filenames:=filenames+' '+ScriptFixFileName(asmfile.str);
+           asmfile:=tcmdstrlistitem(asmfile.next);
+        end;
        Replace(result,'$ASM',filenames);
        Replace(result,'$ASM',filenames);
        if (path<>'') then
        if (path<>'') then
-         Replace(result,'$OBJDIR',maybequoted(ScriptFixFileName(path)))
+         if cs_asm_extern in current_settings.globalswitches then
+           Replace(result,'$OBJDIR',maybequoted(ScriptFixFileName(path)))
+         else
+           Replace(result,'$OBJDIR',ScriptFixFileName(path))
        else
        else
          Replace(result,'$OBJDIR','.');
          Replace(result,'$OBJDIR','.');
-       Replace(result,'$JASMINJAR',maybequoted(ScriptFixFileName(jasminjar)));
+       if cs_asm_extern in current_settings.globalswitches then
+         Replace(result,'$JASMINJAR',maybequoted(ScriptFixFileName(jasminjar)))
+       else
+         Replace(result,'$JASMINJAR',ScriptFixFileName(jasminjar))
      end;
      end;
 
 
 
 
@@ -681,7 +698,7 @@ implementation
         if AsmSize<>AsmStartSize then
         if AsmSize<>AsmStartSize then
           begin
           begin
             AsmClose;
             AsmClose;
-            asmfiles.Concat(maybequoted(ScriptFixFileName(AsmFileName)));
+            asmfiles.Concat(AsmFileName);
           end
           end
         else
         else
           AsmClear;
           AsmClear;
@@ -1082,6 +1099,29 @@ implementation
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
     end;
     end;
 
 
+
+    procedure TJasminAssembler.RemoveAsm;
+      var
+        g : file;
+      begin
+        inherited;
+        if cs_asm_leave in current_settings.globalswitches then
+         exit;
+        while not asmfiles.empty do
+          begin
+            if cs_asm_extern in current_settings.globalswitches then
+             AsmRes.AddDeleteCommand(asmfiles.GetFirst)
+            else
+             begin
+               assign(g,asmfiles.GetFirst);
+               {$I-}
+                erase(g);
+               {$I+}
+               if ioresult<>0 then;
+             end;
+          end;
+      end;
+
 {****************************************************************************}
 {****************************************************************************}
 {                         Jasmin Instruction Writer                          }
 {                         Jasmin Instruction Writer                          }
 {****************************************************************************}
 {****************************************************************************}