Explorar o código

* Added new "SetAndPassThrough" support function to set an integer variable in a condition

J. Gareth "Curious Kit" Moreton hai 4 meses
pai
achega
b2a010de7f
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      compiler/aoptutils.pas

+ 13 - 0
compiler/aoptutils.pas

@@ -44,6 +44,10 @@ unit aoptutils;
     { Set Store and Result to Condition (useful as an inline assignment in a conditional block) }
     function SetAndTest(const Condition: Boolean; out Store: Boolean): Boolean; inline;
 
+    { Set result and store to value (useful as an inline assignment in a conditional block).
+      This is the equivalent of the C code "if ((store=value)==...)" }
+    function SetAndPassThrough(const value: integer; out store: integer): integer; inline;
+
   implementation
 
     uses
@@ -102,4 +106,13 @@ unit aoptutils;
         Result := Store;
       end;
 
+
+    { Set result and store to value (useful as an inline assignment in a conditional block).
+      This is the equivalent of the C code "if ((store=value)==...)" }
+    function SetAndPassThrough(const value: integer; out store: integer): integer;
+      begin
+        store := value;
+        result := value;
+      end;
+
 end.