You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
22 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>InferIR__Exp (InferIR.InferIR__Exp)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc %%VERSION%%"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">InferIR</a> &#x00BB; InferIR__Exp</nav><h1>Module <code>InferIR__Exp</code></h1><p>The Smallfoot Intermediate Language: Expressions</p><p>NOTE: For doing substitutionson expressions, there are some functions in <code>Sil</code>.</p><nav class="toc"><ul><li><a href="#utility-functions-for-expressions">Utility Functions for Expressions</a></li></ul></nav></header><div class="spec module" id="module-F"><a href="#module-F" class="anchor"></a><code><span class="keyword">module</span> F = Stdlib.Format</code></div><dl><dt class="spec type" id="type-closure"><a href="#type-closure" class="anchor"></a><code><span class="keyword">type</span> closure</code><code> = </code><code>{</code><table class="record"><tr id="type-closure.name" class="anchored"><td class="def field"><a href="#type-closure.name" class="anchor"></a><code>name : <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a>;</code></td></tr><tr id="type-closure.captured_vars" class="anchored"><td class="def field"><a href="#type-closure.captured_vars" class="anchor"></a><code>captured_vars : <span><span>(<a href="index.html#type-t">t</a> * <a href="../InferIR/Pvar/index.html#type-t">InferIR.Pvar.t</a> * <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a>)</span> list</span>;</code></td></tr></table><code>}</code></dt><dt class="spec type" id="type-sizeof_data"><a href="#type-sizeof_data" class="anchor"></a><code><span class="keyword">and</span> sizeof_data</code><code> = </code><code>{</code><table class="record"><tr id="type-sizeof_data.typ" class="anchored"><td class="def field"><a href="#type-sizeof_data.typ" class="anchor"></a><code>typ : <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a>;</code></td></tr><tr id="type-sizeof_data.nbytes" class="anchored"><td class="def field"><a href="#type-sizeof_data.nbytes" class="anchor"></a><code>nbytes : <span>int option</span>;</code></td></tr><tr id="type-sizeof_data.dynamic_length" class="anchored"><td class="def field"><a href="#type-sizeof_data.dynamic_length" class="anchor"></a><code>dynamic_length : <span><a href="index.html#type-t">t</a> option</span>;</code></td></tr><tr id="type-sizeof_data.subtype" class="anchored"><td class="def field"><a href="#type-sizeof_data.subtype" class="anchor"></a><code>subtype : <a href="../InferIR/Subtype/index.html#type-t">InferIR.Subtype.t</a>;</code></td></tr></table><code>}</code></dt><dd><p>This records information about a <code>sizeof(typ)</code> expression.</p><p><code>nbytes</code> represents the result of the evaluation of <code>sizeof(typ)</code> if it is statically known.</p><p>If <code>typ</code> is of the form <code>Tarray elt (Some static_length)</code>, then <code>dynamic_length</code> is the number of elements of type <code>elt</code> in the array. The <code>dynamic_length</code>, tracked by symbolic execution, may differ from the <code>static_length</code> obtained from the type definition, e.g. when an array is over-allocated.</p><p>If <code>typ</code> is a struct type, the <code>dynamic_length</code> is that of the final extensible array, if any.</p></dd></dl><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">and</span> t</code><code> = </code><table class="variant"><tr id="type-t.Var" class="anchored"><td class="def constructor"><a href="#type-t.Var" class="anchor"></a><code>| </code><code><span class="constructor">Var</span> <span class="keyword">of</span> <a href="../InferIR/Ident/index.html#type-t">InferIR.Ident.t</a></code></td><td class="doc"><p>Pure variable: it is not an lvalue</p></td></tr><tr id="type-t.UnOp" class="anchored"><td class="def constructor"><a href="#type-t.UnOp" class="anchor"></a><code>| </code><code><span class="constructor">UnOp</span> <span class="keyword">of</span> <a href="../InferIR/Unop/index.html#type-t">InferIR.Unop.t</a> * <a href="index.html#type-t">t</a> * <span><a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> option</span></code></td><td class="doc"><p>Unary operator with type of the result if known</p></td></tr><tr id="type-t.BinOp" class="anchored"><td class="def constructor"><a href="#type-t.BinOp" class="anchor"></a><code>| </code><code><span class="constructor">BinOp</span> <span class="keyword">of</span> <a href="../InferIR/Binop/index.html#type-t">InferIR.Binop.t</a> * <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a></code></td><td class="doc"><p>Binary operator</p></td></tr><tr id="type-t.Exn" class="anchored"><td class="def constructor"><a href="#type-t.Exn" class="anchor"></a><code>| </code><code><span class="constructor">Exn</span> <span class="keyword">of</span> <a href="index.html#type-t">t</a></code></td><td class="doc"><p>Exception</p></td></tr><tr id="type-t.Closure" class="anchored"><td class="def constructor"><a href="#type-t.Closure" class="anchor"></a><code>| </code><code><span class="constructor">Closure</span> <span class="keyword">of</span> <a href="index.html#type-closure">closure</a></code></td><td class="doc"><p>Anonymous function</p></td></tr><tr id="type-t.Const" class="anchored"><td class="def constructor"><a href="#type-t.Const" class="anchor"></a><code>| </code><code><span class="constructor">Const</span> <span class="keyword">of</span> <a href="../InferIR/Const/index.html#type-t">InferIR.Const.t</a></code></td><td class="doc"><p>Constants</p></td></tr><tr id="type-t.Cast" class="anchored"><td class="def constructor"><a href="#type-t.Cast" class="anchor"></a><code>| </code><code><span class="constructor">Cast</span> <span class="keyword">of</span> <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> * <a href="index.html#type-t">t</a></code></td><td class="doc"><p>Type cast</p></td></tr><tr id="type-t.Lvar" class="anchored"><td class="def constructor"><a href="#type-t.Lvar" class="anchor"></a><code>| </code><code><span class="constructor">Lvar</span> <span class="keyword">of</span> <a href="../InferIR/Pvar/index.html#type-t">InferIR.Pvar.t</a></code></td><td class="doc"><p>The address of a program variable</p></td></tr><tr id="type-t.Lfield" class="anchored"><td class="def constructor"><a href="#type-t.Lfield" class="anchor"></a><code>| </code><code><span class="constructor">Lfield</span> <span class="keyword">of</span> <a href="index.html#type-t">t</a> * <a href="../InferIR/Typ/Fieldname/index.html#type-t">InferIR.Typ.Fieldname.t</a> * <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a></code></td><td class="doc"><p>A field offset, the type is the surrounding struct type</p></td></tr><tr id="type-t.Lindex" class="anchored"><td class="def constructor"><a href="#type-t.Lindex" class="anchor"></a><code>| </code><code><span class="constructor">Lindex</span> <span class="keyword">of</span> <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a></code></td><td class="doc"><p>An array index offset: <code>exp1[exp2]</code></p></td></tr><tr id="type-t.Sizeof" class="anchored"><td class="def constructor"><a href="#type-t.Sizeof" class="anchor"></a><code>| </code><code><span class="constructor">Sizeof</span> <span class="keyword">of</span> <a href="index.html#type-sizeof_data">sizeof_data</a></code></td></tr></table></dt><dd><p>Program expressions.</p></dd></dl><div><div class="spec include"><div class="doc"><dl><dt class="spec value" id="val-compare_closure"><a href="#val-compare_closure" class="anchor"></a><code><span class="keyword">val</span> compare_closure : <a href="index.html#type-closure">closure</a> <span>&#45;&gt;</span> <a href="index.html#type-closure">closure</a> <span>&#45;&gt;</span> int</code></dt><dt class="spec value" id="val-compare_sizeof_data"><a href="#val-compare_sizeof_data" class="anchor"></a><code><span class="keyword">val</span> compare_sizeof_data : <a href="index.html#type-sizeof_data">sizeof_data</a> <span>&#45;&gt;</span> <a href="index.html#type-sizeof_data">sizeof_data</a> <span>&#45;&gt;</span> int</code></dt><dt class="spec value" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span class="keyword">val</span> compare : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt></dl></div></div></div><dl><dt class="spec value" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span class="keyword">val</span> equal : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>Equality for expressions.</p></dd></dl><dl><dt class="spec module" id="module-Set"><a href="#module-Set" class="anchor"></a><code><span class="keyword">module</span> Set : <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Caml.Set.S <span class="keyword">with</span> <span class="keyword">type</span> <a href="index.html#module-Set">Set</a>.elt = <a href="index.html#type-t">t</a></code></dt><dd><p>Set of expressions.</p></dd></dl><dl><dt class="spec module" id="module-Map"><a href="#module-Map" class="anchor"></a><code><span class="keyword">module</span> Map : <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Caml.Map.S <span class="keyword">with</span> <span class="keyword">type</span> <a href="index.html#module-Map">Map</a>.key = <a href="index.html#type-t">t</a></code></dt><dd><p>Map with expression keys.</p></dd></dl><dl><dt class="spec module" id="module-Hash"><a href="#module-Hash" class="anchor"></a><code><span class="keyword">module</span> Hash : <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Caml.Hashtbl.S <span class="keyword">with</span> <span class="keyword">type</span> <a href="index.html#module-Hash">Hash</a>.key = <a href="index.html#type-t">t</a></code></dt><dd><p>Hashtable with expression keys.</p></dd></dl><dl><dt class="spec value" id="val-is_null_literal"><a href="#val-is_null_literal" class="anchor"></a><code><span class="keyword">val</span> is_null_literal : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dt class="spec value" id="val-is_this"><a href="#val-is_this" class="anchor"></a><code><span class="keyword">val</span> is_this : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>return true if <code>exp</code> is the special this/self expression</p></dd></dl><dl><dt class="spec value" id="val-is_zero"><a href="#val-is_zero" class="anchor"></a><code><span class="keyword">val</span> is_zero : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dt class="spec value" id="val-is_const"><a href="#val-is_const" class="anchor"></a><code><span class="keyword">val</span> is_const : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt></dl><section><header><h3 id="utility-functions-for-expressions"><a href="#utility-functions-for-expressions" class="anchor"></a>Utility Functions for Expressions</h3></header><dl><dt class="spec value" id="val-texp_to_typ"><a href="#val-texp_to_typ" class="anchor"></a><code><span class="keyword">val</span> texp_to_typ : <span><a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> option</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a></code></dt><dd><p>Turn an expression representing a type into the type it represents If not a sizeof, return the default type if given, otherwise raise an exception</p></dd></dl><dl><dt class="spec value" id="val-root_of_lexp"><a href="#val-root_of_lexp" class="anchor"></a><code><span class="keyword">val</span> root_of_lexp : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Return the root of <code>lexp</code>.</p></dd></dl><dl><dt class="spec value" id="val-get_undefined"><a href="#val-get_undefined" class="anchor"></a><code><span class="keyword">val</span> get_undefined : bool <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Get an expression &quot;undefined&quot;, the boolean indicates whether the undefined value goest into the footprint</p></dd></dl><dl><dt class="spec value" id="val-pointer_arith"><a href="#val-pointer_arith" class="anchor"></a><code><span class="keyword">val</span> pointer_arith : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>Checks whether an expression denotes a location using pointer arithmetic. Currently, catches array - indexing expressions such as a<code>i</code> only.</p></dd></dl><dl><dt class="spec value" id="val-has_local_addr"><a href="#val-has_local_addr" class="anchor"></a><code><span class="keyword">val</span> has_local_addr : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>returns true if the expression operates on address of local variable</p></dd></dl><dl><dt class="spec value" id="val-zero"><a href="#val-zero" class="anchor"></a><code><span class="keyword">val</span> zero : <a href="index.html#type-t">t</a></code></dt><dd><p>Integer constant 0</p></dd></dl><dl><dt class="spec value" id="val-null"><a href="#val-null" class="anchor"></a><code><span class="keyword">val</span> null : <a href="index.html#type-t">t</a></code></dt><dd><p>Null constant</p></dd></dl><dl><dt class="spec value" id="val-one"><a href="#val-one" class="anchor"></a><code><span class="keyword">val</span> one : <a href="index.html#type-t">t</a></code></dt><dd><p>Integer constant 1</p></dd></dl><dl><dt class="spec value" id="val-minus_one"><a href="#val-minus_one" class="anchor"></a><code><span class="keyword">val</span> minus_one : <a href="index.html#type-t">t</a></code></dt><dd><p>Integer constant -1</p></dd></dl><dl><dt class="spec value" id="val-int"><a href="#val-int" class="anchor"></a><code><span class="keyword">val</span> int : <a href="../InferIR/IntLit/index.html#type-t">InferIR.IntLit.t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create integer constant</p></dd></dl><dl><dt class="spec value" id="val-float"><a href="#val-float" class="anchor"></a><code><span class="keyword">val</span> float : float <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create float constant</p></dd></dl><dl><dt class="spec value" id="val-bool"><a href="#val-bool" class="anchor"></a><code><span class="keyword">val</span> bool : bool <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create integer constant corresponding to the boolean value</p></dd></dl><dl><dt class="spec value" id="val-eq"><a href="#val-eq" class="anchor"></a><code><span class="keyword">val</span> eq : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create expression <code>e1 == e2</code></p></dd></dl><dl><dt class="spec value" id="val-ne"><a href="#val-ne" class="anchor"></a><code><span class="keyword">val</span> ne : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create expression <code>e1 != e2</code></p></dd></dl><dl><dt class="spec value" id="val-le"><a href="#val-le" class="anchor"></a><code><span class="keyword">val</span> le : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create expression <code>e1 &lt;= e2</code></p></dd></dl><dl><dt class="spec value" id="val-lt"><a href="#val-lt" class="anchor"></a><code><span class="keyword">val</span> lt : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create expression <code>e1 &lt; e2</code></p></dd></dl><dl><dt class="spec value" id="val-and_nary"><a href="#val-and_nary" class="anchor"></a><code><span class="keyword">val</span> and_nary : <span><a href="index.html#type-t">t</a> list</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Create expression <code>e1 &amp;&amp; e2 &amp;&amp; e3 &amp;&amp; ...</code></p></dd></dl><dl><dt class="spec value" id="val-free_vars"><a href="#val-free_vars" class="anchor"></a><code><span class="keyword">val</span> free_vars : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span><a href="../InferIR/Ident/index.html#type-t">InferIR.Ident.t</a> <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Sequence.t</span></code></dt><dd><p>all the idents appearing in the expression</p></dd></dl><dl><dt class="spec value" id="val-gen_free_vars"><a href="#val-gen_free_vars" class="anchor"></a><code><span class="keyword">val</span> gen_free_vars : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span><span>(unit, <a href="../InferIR/Ident/index.html#type-t">InferIR.Ident.t</a>)</span> <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Sequence.Generator.t</span></code></dt><dt class="spec value" id="val-ident_mem"><a href="#val-ident_mem" class="anchor"></a><code><span class="keyword">val</span> ident_mem : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="../InferIR/Ident/index.html#type-t">InferIR.Ident.t</a> <span>&#45;&gt;</span> bool</code></dt><dd><p>true if the identifier appears in the expression</p></dd></dl><dl><dt class="spec value" id="val-program_vars"><a href="#val-program_vars" class="anchor"></a><code><span class="keyword">val</span> program_vars : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span><a href="../InferIR/Pvar/index.html#type-t">InferIR.Pvar.t</a> <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Sequence.t</span></code></dt><dd><p>all the program variables appearing in the expression</p></dd></dl><dl><dt class="spec value" id="val-rename_pvars"><a href="#val-rename_pvars" class="anchor"></a><code><span class="keyword">val</span> rename_pvars : <span>f:<span>(string <span>&#45;&gt;</span> string)</span></span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dd><p>Rename all Pvars according to the function <code>f</code>. WARNING: You want to rename pvars before you combine expressions from different symbolic states, which you RARELY want to.</p></dd></dl><dl><dt class="spec value" id="val-fold_captured"><a href="#val-fold_captured" class="anchor"></a><code><span class="keyword">val</span> fold_captured : <span>f:<span>(<span class="type-var">'a</span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span class="type-var">'a</span>)</span></span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dd><p>Fold over the expressions captured by this expression.</p></dd></dl><dl><dt class="spec value" id="val-pp_printenv"><a href="#val-pp_printenv" class="anchor"></a><code><span class="keyword">val</span> pp_printenv : <span>print_types:bool</span> <span>&#45;&gt;</span> <a href="../../InferStdlib/InferStdlib/Pp/index.html#type-env">InferStdlib.Pp.env</a> <span>&#45;&gt;</span> <a href="index.html#module-F">F</a>.formatter <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val</span> pp : <a href="index.html#module-F">F</a>.formatter <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt><dt class="spec value" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span class="keyword">val</span> to_string : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> string</code></dt><dt class="spec value" id="val-is_objc_block_closure"><a href="#val-is_objc_block_closure" class="anchor"></a><code><span class="keyword">val</span> is_objc_block_closure : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt><dt class="spec value" id="val-zero_of_type"><a href="#val-zero_of_type" class="anchor"></a><code><span class="keyword">val</span> zero_of_type : <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> <span>&#45;&gt;</span> <span><a href="index.html#type-t">t</a> option</span></code></dt><dd><p>Returns the zero value of a type, for int, float and ptr types</p></dd></dl><dl><dt class="spec value" id="val-zero_of_type_exn"><a href="#val-zero_of_type_exn" class="anchor"></a><code><span class="keyword">val</span> zero_of_type_exn : <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-ignore_cast"><a href="#val-ignore_cast" class="anchor"></a><code><span class="keyword">val</span> ignore_cast : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt><dt class="spec value" id="val-ignore_integer_cast"><a href="#val-ignore_integer_cast" class="anchor"></a><code><span class="keyword">val</span> ignore_integer_cast : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a></code></dt></dl></section></div></body></html>