You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There're three <codeclass="code">find</code> functions in the library, that accepts
49
+
an object of type <codeclass="code">finder</code>:
50
+
<p>
51
+
<ul>
52
+
<li><codeclass="code"><spanclass="constructor">Bil</span>.finder</code> searches in the <codeclass="code">stmt list</code> aka <codeclass="code">bil</code></li>
53
+
<li><codeclass="code"><spanclass="constructor">Stmt</span>.finder</code> searches in <codeclass="code">stmt</code></li>
54
+
<li><codeclass="code"><spanclass="constructor">Exp</span>.finder</code> searches in <codeclass="code">exp</code>.</li>
55
+
</ul>
56
+
57
+
In addition, you can use this object directly, using one of
<codeclass="code">iter visitor bil</code> apply a visitor for each node of a BIL
160
-
forest.<br>
165
+
forest. See also <ahref="Bap.Std.Exp.html#VALiter"><codeclass="code"><spanclass="constructor">Exp</span>.iter</code></a> and <ahref="Bap.Std.Stmt.html#VALiter"><codeclass="code"><spanclass="constructor">Stmt</span>.iter</code></a>.<br>
161
166
</div>
162
167
163
-
<pre><spanid="VALfold"><spanclass="keyword">val</span>fold</span> : <codeclass="type">'a #<ahref="Bap.Std.Bil.visitor-c.html">visitor</a> ->init:'a ->stmt list ->'a</code></pre><divclass="info ">
164
-
<codeclass="code">fold visitor ~init bil</code>folds visitor over BIL, passing init
165
-
value through the tree nodes.<br>
168
+
<pre><spanid="VALmap"><spanclass="keyword">val</span>map</span> : <codeclass="type">#<ahref="Bap.Std.Bil.mapper-c.html">mapper</a> -> stmt list ->stmt list</code></pre><divclass="info ">
169
+
<codeclass="code">map mapper bil</code>map or transform BIL program. See also
<codeclass="code">map mapper bil</code> map or transform BIL program.<br>
173
+
<pre><spanid="VALfind"><spanclass="keyword">val</span> find</span> : <codeclass="type">'a #<ahref="Bap.Std.Bil.finder-c.html">finder</a> -> stmt list -> 'a option</code></pre><divclass="info ">
174
+
<codeclass="code">find finder bil</code> search in <codeclass="code">bil</code> using provided <codeclass="code">finder</code>. See
175
+
also <ahref="Bap.Std.Exp.html#VALfind"><codeclass="code"><spanclass="constructor">Exp</span>.find</code></a> and <ahref="Bap.Std.Stmt.html#VALfind"><codeclass="code"><spanclass="constructor">Stmt</span>.find</code></a>.<br>
<codeclass="code">exists finder bil</code> returns true if <codeclass="code">finder</code> finds
180
+
something. See also <ahref="Bap.Std.Exp.html#VALexists"><codeclass="code"><spanclass="constructor">Exp</span>.exists</code></a> and <ahref="Bap.Std.Stmt.html#VALexists"><codeclass="code"><spanclass="constructor">Stmt</span>.exists</code></a>.<br>
170
181
</div>
171
182
172
183
<pre><spanid="VALis_referenced"><spanclass="keyword">val</span> is_referenced</span> : <codeclass="type"><ahref="Bap.Std.html#TYPEvar">var</a> -> stmt list -> bool</code></pre><divclass="info ">
173
-
<codeclass="code">is_referenced x p</code> is <codeclass="code"><spanclass="keyword">true</span></code> if <codeclass="code">x</code> is referenced in some expression or
174
-
statement in program <codeclass="code">p</code>:
175
-
BUG: currently occurrences on the left hand side of the
176
-
assignment operator is considered a reference too.<br>
184
+
<codeclass="code">is_referenced x p</code> is <codeclass="code"><spanclass="keyword">true</span></code> if <codeclass="code">x</code> is referenced in some
185
+
expression or statement in program <codeclass="code">p</code>, before it is
<codeclass="code">is_assigned x p</code> is <codeclass="code"><spanclass="keyword">true</span></code> if there exists such <codeclass="code"><spanclass="constructor">Move</span></code>
181
-
statement, that <codeclass="code">x</code> occures on the left side of it. If<codeclass="code">strict</code>
182
-
is true, then only unconditional assignments. By default,
183
-
<codeclass="code">strict</code> is <codeclass="code"><spanclass="keyword">false</span></code><br>
191
+
statement, that <codeclass="code">x</code> occures on the left side of it. If
192
+
<codeclass="code">strict</code>is true, then only unconditional assignments are
193
+
accounted. By default, <codeclass="code">strict</code> is <codeclass="code"><spanclass="keyword">false</span></code><br>
184
194
</div>
185
195
186
196
<pre><spanid="VALprune_unreferenced"><spanclass="keyword">val</span> prune_unreferenced</span> : <codeclass="type">stmt list -> stmt list</code></pre><divclass="info ">
187
197
<codeclass="code">prune_unreferenced p</code> remove all assignments to variables that
188
-
are not used in the program <codeclass="code">p</code><br>
198
+
are not used in the program <codeclass="code">p</code>. This is a local optimization.
199
+
The variable is unreferenced if it is not referenced in its lexical
200
+
scope, or if it is referenced after the assignment. Only
201
+
temporary variables are pruned, as their scope is local.<br>
189
202
</div>
190
203
191
204
<pre><spanid="VALnormalize_negatives"><spanclass="keyword">val</span> normalize_negatives</span> : <codeclass="type">stmt list -> stmt list</code></pre><divclass="info ">
0 commit comments