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.

8 lines
23 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.

<!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="viewport" content="width=device-width,initial-scale=1.0"/><meta name="generator" content="doc-ock-html v1.0.0-1-g1fc9bf0"/></head><body><nav id="top"><a href="../index.html">Up</a> &mdash; <span class="package">package <a href="../index.html">InferIR</a></span></nav><header><h1><span class="keyword">Module</span> <span class="module-path">InferIR__Exp</span></h1></header><p>The Smallfoot Intermediate Language: Expressions</p><div class="spec module" id="module-F"><a href="#module-F" class="anchor"></a><div class="def module"><code><span class="keyword">module </span>F = Format</code></div><div class="doc"></div></div><div class="spec type" id="type-closure"><a href="#type-closure" class="anchor"></a><div class="def type"><code><span class="keyword">type </span>closure</code><code></code><code><span class="keyword"> = </span></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 : (<a href="index.html#type-t">t</a><span class="keyword"> * </span><a href="../InferIR/Pvar/index.html#type-t">InferIR.Pvar.t</a><span class="keyword"> * </span><a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a>) list;</code></td></tr></table><code>}</code><code></code></div><div class="doc"></div></div><div class="spec type" id="type-sizeof_data"><a href="#type-sizeof_data" class="anchor"></a><div class="def type"><code><span class="keyword">type </span>sizeof_data</code><code></code><code><span class="keyword"> = </span></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 : int option;</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 : <a href="index.html#type-t">t</a> option;</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><code></code></div><div class="doc"><p>This records information about a <code class="code">sizeof(typ)</code> expression.</p><p><code class="code">nbytes</code> represents the result of the evaluation of <code class="code">sizeof(typ)</code> if it is statically known.</p><p>If <code class="code">typ</code> is of the form <code class="code">Tarray elt (Some static_length)</code>, then <code class="code">dynamic_length</code> is the number
of elements of type <code class="code">elt</code> in the array. The <code class="code">dynamic_length</code>, tracked by symbolic execution, may
differ from the <code class="code">static_length</code> obtained from the type definition, e.g. when an array is
over-allocated.</p><p>If <code class="code">typ</code> is a struct type, the <code class="code">dynamic_length</code> is that of the final extensible array, if any.</p></div></div><div class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><div class="def type"><code><span class="keyword">type </span>t</code><code></code><code><span class="keyword"> = </span></code><table class="variant"><tr id="type-t.Var" class="anchored"><td class="def constructor"><a href="#type-t.Var" class="anchor"></a><code><span class="keyword">| </span></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><span class="keyword">| </span></code><code><span class="constructor">UnOp</span><span class="keyword"> of </span><a href="../InferIR/Unop/index.html#type-t">InferIR.Unop.t</a><span class="keyword"> * </span><a href="index.html#type-t">t</a><span class="keyword"> * </span><a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> option</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><span class="keyword">| </span></code><code><span class="constructor">BinOp</span><span class="keyword"> of </span><a href="../InferIR/Binop/index.html#type-t">InferIR.Binop.t</a><span class="keyword"> * </span><a href="index.html#type-t">t</a><span class="keyword"> * </span><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><span class="keyword">| </span></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><span class="keyword">| </span></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><span class="keyword">| </span></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><span class="keyword">| </span></code><code><span class="constructor">Cast</span><span class="keyword"> of </span><a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a><span class="keyword"> * </span><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><span class="keyword">| </span></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><span class="keyword">| </span></code><code><span class="constructor">Lfield</span><span class="keyword"> of </span><a href="index.html#type-t">t</a><span class="keyword"> * </span><a href="../InferIR/Typ/Fieldname/index.html#type-t">InferIR.Typ.Fieldname.t</a><span class="keyword"> * </span><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><span class="keyword">| </span></code><code><span class="constructor">Lindex</span><span class="keyword"> of </span><a href="index.html#type-t">t</a><span class="keyword"> * </span><a href="index.html#type-t">t</a></code></td><td class="doc"><p>(** An array index offset: <code class="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><span class="keyword">| </span></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><code></code></div><div class="doc"><p>Program expressions.</p></div></div><div class="spec include"><div class="doc"></div><details open="open"><summary><span class="def"><code><span class="keyword">include </span><span class="keyword">sig</span> ... <span class="keyword">end</span></code></span></summary><div class="spec val" id="val-compare_closure"><a href="#val-compare_closure" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>compare_closure : <a href="index.html#type-closure">closure</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-closure">closure</a> <span class="keyword">&#8209;&gt;</span> int</code></div><div class="doc"></div></div><div class="spec val" id="val-compare_sizeof_data"><a href="#val-compare_sizeof_data" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>compare_sizeof_data : <a href="index.html#type-sizeof_data">sizeof_data</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-sizeof_data">sizeof_data</a> <span class="keyword">&#8209;&gt;</span> int</code></div><div class="doc"></div></div><div class="spec val" id="val-compare"><a href="#val-compare" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>compare : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> int</code></div><div class="doc"></div></div></details></div><div class="spec val" id="val-equal"><a href="#val-equal" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>equal : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Equality for expressions.</p></div></div><div class="spec module" id="module-Set"><a href="#module-Set" class="anchor"></a><div class="def module"><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<span class="keyword"> = </span><a href="index.html#type-t">t</a></code></div><div class="doc"><p>Set of expressions.</p></div></div><div class="spec module" id="module-Map"><a href="#module-Map" class="anchor"></a><div class="def module"><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<span class="keyword"> = </span><a href="index.html#type-t">t</a></code></div><div class="doc"><p>Map with expression keys.</p></div></div><div class="spec module" id="module-Hash"><a href="#module-Hash" class="anchor"></a><div class="def module"><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<span class="keyword"> = </span><a href="index.html#type-t">t</a></code></div><div class="doc"><p>Hashtable with expression keys.</p></div></div><div class="spec val" id="val-is_null_literal"><a href="#val-is_null_literal" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_null_literal : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"></div></div><div class="spec val" id="val-is_this"><a href="#val-is_this" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_this : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>return true if <code class="code">exp</code> is the special this/self expression</p></div></div><div class="spec val" id="val-is_zero"><a href="#val-is_zero" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_zero : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"></div></div><h3>Utility Functions for Expressions</h3><div class="spec val" id="val-texp_to_typ"><a href="#val-texp_to_typ" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>texp_to_typ : <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> option <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a></code></div><div class="doc"><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></div></div><div class="spec val" id="val-root_of_lexp"><a href="#val-root_of_lexp" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>root_of_lexp : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Return the root of <code class="code">lexp</code>.</p></div></div><div class="spec val" id="val-get_undefined"><a href="#val-get_undefined" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_undefined : bool <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Get an expression &quot;undefined&quot;, the boolean indicates
whether the undefined value goest into the footprint</p></div></div><div class="spec val" id="val-pointer_arith"><a href="#val-pointer_arith" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>pointer_arith : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Checks whether an expression denotes a location using pointer arithmetic.
Currently, catches array - indexing expressions such as a<code class="code">i</code> only.</p></div></div><div class="spec val" id="val-has_local_addr"><a href="#val-has_local_addr" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>has_local_addr : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>returns true if the expression operates on address of local variable</p></div></div><div class="spec val" id="val-zero"><a href="#val-zero" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>zero : <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Integer constant 0</p></div></div><div class="spec val" id="val-null"><a href="#val-null" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>null : <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Null constant</p></div></div><div class="spec val" id="val-one"><a href="#val-one" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>one : <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Integer constant 1</p></div></div><div class="spec val" id="val-minus_one"><a href="#val-minus_one" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>minus_one : <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Integer constant -1</p></div></div><div class="spec val" id="val-int"><a href="#val-int" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>int : <a href="../InferIR/IntLit/index.html#type-t">InferIR.IntLit.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create integer constant</p></div></div><div class="spec val" id="val-float"><a href="#val-float" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>float : float <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create float constant</p></div></div><div class="spec val" id="val-bool"><a href="#val-bool" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>bool : bool <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create integer constant corresponding to the boolean value</p></div></div><div class="spec val" id="val-eq"><a href="#val-eq" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>eq : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create expression <code class="code">e1 == e2</code></p></div></div><div class="spec val" id="val-ne"><a href="#val-ne" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>ne : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create expression <code class="code">e1 != e2</code></p></div></div><div class="spec val" id="val-le"><a href="#val-le" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>le : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create expression <code class="code">e1 &lt;= e2</code></p></div></div><div class="spec val" id="val-lt"><a href="#val-lt" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>lt : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>Create expression <code class="code">e1 &lt; e2</code></p></div></div><div class="spec val" id="val-free_vars"><a href="#val-free_vars" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>free_vars : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</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</code></div><div class="doc"><p>all the idents appearing in the expression</p></div></div><div class="spec val" id="val-gen_free_vars"><a href="#val-gen_free_vars" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>gen_free_vars : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> (unit, <a href="../InferIR/Ident/index.html#type-t">InferIR.Ident.t</a>) <a href="../../InferStdlib/InferStdlib/index.html#module-IStd">InferStdlib.IStd</a>.Sequence.Generator.t</code></div><div class="doc"></div></div><div class="spec val" id="val-ident_mem"><a href="#val-ident_mem" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>ident_mem : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Ident/index.html#type-t">InferIR.Ident.t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>true if the identifier appears in the expression</p></div></div><div class="spec val" id="val-program_vars"><a href="#val-program_vars" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>program_vars : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</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</code></div><div class="doc"><p>all the program variables appearing in the expression</p></div></div><div class="spec val" id="val-fold_captured"><a href="#val-fold_captured" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>fold_captured : f:(<span class="type-var">'a</span> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <span class="type-var">'a</span>) <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <span class="type-var">'a</span> <span class="keyword">&#8209;&gt;</span> <span class="type-var">'a</span></code></div><div class="doc"><p>Fold over the expressions captured by this expression.</p></div></div><div class="spec val" id="val-pp_printenv"><a href="#val-pp_printenv" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>pp_printenv : <a href="../../InferStdlib/InferStdlib/Pp/index.html#type-env">InferStdlib.Pp.env</a> <span class="keyword">&#8209;&gt;</span> (<a href="../../InferStdlib/InferStdlib/Pp/index.html#type-env">InferStdlib.Pp.env</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#module-F">F</a>.formatter <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> <span class="keyword">&#8209;&gt;</span> unit) <span class="keyword">&#8209;&gt;</span> <a href="index.html#module-F">F</a>.formatter <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> unit</code></div><div class="doc"></div></div><div class="spec val" id="val-pp"><a href="#val-pp" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>pp : <a href="index.html#module-F">F</a>.formatter <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> unit</code></div><div class="doc"></div></div><div class="spec val" id="val-to_string"><a href="#val-to_string" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>to_string : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> string</code></div><div class="doc"></div></div><div class="spec val" id="val-is_objc_block_closure"><a href="#val-is_objc_block_closure" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_objc_block_closure : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"></div></div><div class="spec val" id="val-zero_of_type"><a href="#val-zero_of_type" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>zero_of_type : <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a> option</code></div><div class="doc"><p>Returns the zero value of a type, for int, float and ptr types</p></div></div><div class="spec val" id="val-zero_of_type_exn"><a href="#val-zero_of_type_exn" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>zero_of_type_exn : <a href="../InferIR/Typ/index.html#type-t">InferIR.Typ.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"></div></div></body></html>