Browse Source

* getposition added to retrieve the the current tai item

peter 22 years ago
parent
commit
47b691057b
2 changed files with 62 additions and 20 deletions
  1. 52 19
      compiler/nbas.pas
  2. 10 1
      compiler/ncgbas.pas

+ 52 - 19
compiler/nbas.pas

@@ -51,7 +51,10 @@ interface
 
 
        tasmnode = class(tnode)
        tasmnode = class(tnode)
           p_asm : taasmoutput;
           p_asm : taasmoutput;
+          currenttai : tai;
+          getposition : boolean;
           constructor create(p : taasmoutput);virtual;
           constructor create(p : taasmoutput);virtual;
+          constructor create_get_position;
           destructor destroy;override;
           destructor destroy;override;
           constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
@@ -480,12 +483,23 @@ implementation
 *****************************************************************************}
 *****************************************************************************}
 
 
     constructor tasmnode.create(p : taasmoutput);
     constructor tasmnode.create(p : taasmoutput);
+      begin
+        inherited create(asmn);
+        p_asm:=p;
+        getposition:=false;
+        currenttai:=nil;
+      end;
+
 
 
+    constructor tasmnode.create_get_position;
       begin
       begin
-         inherited create(asmn);
-         p_asm:=p;
+        inherited create(asmn);
+        p_asm:=nil;
+        getposition:=true;
+        currenttai:=nil;
       end;
       end;
 
 
+
     destructor tasmnode.destroy;
     destructor tasmnode.destroy;
       begin
       begin
         if assigned(p_asm) then
         if assigned(p_asm) then
@@ -499,13 +513,20 @@ implementation
         hp : tai;
         hp : tai;
       begin
       begin
         inherited ppuload(t,ppufile);
         inherited ppuload(t,ppufile);
-        p_asm:=taasmoutput.create;
-        repeat
-          hp:=ppuloadai(ppufile);
-          if hp=nil then
-           break;
-          p_asm.concat(hp);
-        until false;
+        getposition:=boolean(ppufile.getbyte);
+        if not getposition then
+          begin
+            p_asm:=taasmoutput.create;
+            repeat
+              hp:=ppuloadai(ppufile);
+              if hp=nil then
+                break;
+              p_asm.concat(hp);
+            until false;
+          end
+        else
+          p_asm:=nil;
+        currenttai:=nil;
       end;
       end;
 
 
 
 
@@ -514,14 +535,18 @@ implementation
         hp : tai;
         hp : tai;
       begin
       begin
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
-        hp:=tai(p_asm.first);
-        while assigned(hp) do
-         begin
-           ppuwriteai(ppufile,hp);
-           hp:=tai(hp.next);
-         end;
-        { end is marked by a nil }
-        ppuwriteai(ppufile,nil);
+        ppufile.putbyte(byte(getposition));
+        if not getposition then
+          begin
+            hp:=tai(p_asm.first);
+            while assigned(hp) do
+             begin
+               ppuwriteai(ppufile,hp);
+               hp:=tai(hp.next);
+             end;
+            { end is marked by a nil }
+            ppuwriteai(ppufile,nil);
+          end;
       end;
       end;
 
 
 
 
@@ -550,16 +575,21 @@ implementation
             n.p_asm.concatlistcopy(p_asm);
             n.p_asm.concatlistcopy(p_asm);
           end
           end
         else n.p_asm := nil;
         else n.p_asm := nil;
+        n.getposition:=getposition;
+        n.currenttai:=currenttai;
         getcopy := n;
         getcopy := n;
       end;
       end;
 
 
+
     function tasmnode.det_resulttype:tnode;
     function tasmnode.det_resulttype:tnode;
       begin
       begin
          result:=nil;
          result:=nil;
          resulttype:=voidtype;
          resulttype:=voidtype;
-         include(current_procinfo.flags,pi_uses_asm);
+         if not getposition then
+           include(current_procinfo.flags,pi_uses_asm);
       end;
       end;
 
 
+
     function tasmnode.pass_1 : tnode;
     function tasmnode.pass_1 : tnode;
       begin
       begin
          result:=nil;
          result:=nil;
@@ -823,7 +853,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.54  2003-06-08 18:27:15  jonas
+  Revision 1.55  2003-06-09 12:20:47  peter
+    * getposition added to retrieve the the current tai item
+
+  Revision 1.54  2003/06/08 18:27:15  jonas
     + ability to change the location of a ttempref node with changelocation()
     + ability to change the location of a ttempref node with changelocation()
       method. Useful to use instead of copying the contents from one temp to
       method. Useful to use instead of copying the contents from one temp to
       another
       another

+ 10 - 1
compiler/ncgbas.pas

@@ -135,6 +135,12 @@ interface
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
 
 
+         if getposition then
+           begin
+             currenttai:=tai(exprasmlist.last);
+             exit;
+           end;
+
          if inlining_procedure then
          if inlining_procedure then
            begin
            begin
              objectlibrary.CreateUsedAsmSymbolList;
              objectlibrary.CreateUsedAsmSymbolList;
@@ -310,7 +316,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.34  2003-05-17 13:30:08  jonas
+  Revision 1.35  2003-06-09 12:20:47  peter
+    * getposition added to retrieve the the current tai item
+
+  Revision 1.34  2003/05/17 13:30:08  jonas
     * changed tt_persistant to tt_persistent :)
     * changed tt_persistant to tt_persistent :)
     * tempcreatenode now doesn't accept a boolean anymore for persistent
     * tempcreatenode now doesn't accept a boolean anymore for persistent
       temps, but a ttemptype, so you can also create ansistring temps etc
       temps, but a ttemptype, so you can also create ansistring temps etc