浏览代码

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

J. Gareth "Curious Kit" Moreton 4 月之前
父节点
当前提交
b2a010de7f
共有 1 个文件被更改,包括 13 次插入0 次删除
  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.