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.

11 lines
19 KiB

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>InferIR__Pvar (InferIR.InferIR__Pvar)</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__Pvar</span></h1></header><p>Program variables.</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-translation_unit"><a href="#type-translation_unit" class="anchor"></a><div class="def type"><code><span class="keyword">type </span>translation_unit</code><code><span class="keyword"> = </span><a href="../../InferBase/InferBase/SourceFile/index.html#type-t">InferBase.SourceFile.t</a> option</code><code></code></div><div class="doc"></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_translation_unit"><a href="#val-compare_translation_unit" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>compare_translation_unit : <a href="index.html#type-translation_unit">translation_unit</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-translation_unit">translation_unit</a> <span class="keyword">&#8209;&gt;</span> int</code></div><div class="doc"></div></div></details></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></code></div><div class="doc"><p>Type for program variables. There are 4 kinds of variables:
1) local variables, used for local variables and formal parameters
2) callee program variables, used to handle recursion (<code class="code">x | callee</code> is distinguished from <code class="code">x</code>)
3) global variables
4) seed variables, used to store the initial value of formal parameters</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"><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-compare_modulo_this"><a href="#val-compare_modulo_this" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>compare_modulo_this : <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"><p>Comparison considering all pvars named 'this' to be equal</p></div></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 pvar's</p></div></div><div class="spec val" id="val-get_declaring_function"><a href="#val-get_declaring_function" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_declaring_function : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> option</code></div><div class="doc"><p>if not a global, return function declaring var</p></div></div><div class="spec val" id="val-d"><a href="#val-d" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>d : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> unit</code></div><div class="doc"><p>Dump a program variable.</p></div></div><div class="spec val" id="val-get_name"><a href="#val-get_name" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_name : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Mangled/index.html#type-t">InferIR.Mangled.t</a></code></div><div class="doc"><p>Get the name component of a program variable.</p></div></div><div class="spec val" id="val-get_ret_pvar"><a href="#val-get_ret_pvar" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_ret_pvar : <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p><code class="code">get_ret_pvar proc_name</code> retuns the return pvar associated with the procedure name</p></div></div><div class="spec val" id="val-get_simplified_name"><a href="#val-get_simplified_name" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_simplified_name : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> string</code></div><div class="doc"><p>Get a simplified version of the name component of a program variable.</p></div></div><div class="spec val" id="val-is_abduced"><a href="#val-is_abduced" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_abduced : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is an abduced return var or param passed by ref</p></div></div><div class="spec val" id="val-is_callee"><a href="#val-is_callee" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_callee : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is a callee var</p></div></div><div class="spec val" id="val-is_global"><a href="#val-is_global" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_global : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is a global var or a static local var</p></div></div><div class="spec val" id="val-is_static_local"><a href="#val-is_static_local" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_static_local : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is a static variable declared inside a function</p></div></div><div class="spec val" id="val-is_local"><a href="#val-is_local" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_local : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is a (non-static) local var</p></div></div><div class="spec val" id="val-is_seed"><a href="#val-is_seed" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_seed : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is a seed var</p></div></div><div class="spec val" id="val-is_return"><a href="#val-is_return" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_return : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if the pvar is a return var</p></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>Check if a pvar is the special &quot;this&quot; var</p></div></div><div class="spec val" id="val-is_self"><a href="#val-is_self" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_self : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Check if a pvar is the special &quot;self&quot; var</p></div></div><div class="spec val" id="val-is_frontend_tmp"><a href="#val-is_frontend_tmp" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_frontend_tmp : <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">pvar</code> is a temporary variable generated by the frontend</p></div></div><div class="spec val" id="val-is_ssa_frontend_tmp"><a href="#val-is_ssa_frontend_tmp" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_ssa_frontend_tmp : <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">pvar</code> is a temporary variable generated by the frontend and is only assigned
once on a non-looping control-flow path</p></div></div><div class="spec val" id="val-is_cpp_temporary"><a href="#val-is_cpp_temporary" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_cpp_temporary : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>return true if this pvar represents a C++ temporary object (see http://en.cppreference.com/w/cpp/language/lifetime)</p></div></div><div class="spec val" id="val-mk"><a href="#val-mk" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>mk : <a href="../InferIR/Mangled/index.html#type-t">InferIR.Mangled.t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p><code class="code">mk name proc_name suffix</code> creates a program var with the given function name and suffix</p></div></div><div class="spec val" id="val-mk_abduced_ref_param"><a href="#val-mk_abduced_ref_param" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>mk_abduced_ref_param : <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> <span class="keyword">&#8209;&gt;</span> int <span class="keyword">&#8209;&gt;</span> <a href="../../InferBase/InferBase/Location/index.html#type-t">InferBase.Location.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>create an abduced variable for a parameter passed by reference</p></div></div><div class="spec val" id="val-mk_abduced_ret"><a href="#val-mk_abduced_ret" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>mk_abduced_ret : <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> <span class="keyword">&#8209;&gt;</span> <a href="../../InferBase/InferBase/Location/index.html#type-t">InferBase.Location.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>create an abduced return variable for a call to <code class="code">proc_name</code> at <code class="code">loc</code></p></div></div><div class="spec val" id="val-mk_callee"><a href="#val-mk_callee" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>mk_callee : <a href="../InferIR/Mangled/index.html#type-t">InferIR.Mangled.t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p><code class="code">mk_callee name proc_name</code> creates a program var
for a callee function with the given function name</p></div></div><div class="spec val" id="val-mk_global"><a href="#val-mk_global" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>mk_global : ?&#8288;is_constexpr:bool <span class="keyword">&#8209;&gt;</span> ?&#8288;is_pod:bool <span class="keyword">&#8209;&gt;</span> ?&#8288;is_static_local:bool <span class="keyword">&#8209;&gt;</span> ?&#8288;is_static_global:bool <span class="keyword">&#8209;&gt;</span> ?&#8288;translation_unit:<a href="../../InferBase/InferBase/SourceFile/index.html#type-t">InferBase.SourceFile.t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Mangled/index.html#type-t">InferIR.Mangled.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>create a global variable with the given name</p></div></div><div class="spec val" id="val-mk_tmp"><a href="#val-mk_tmp" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>mk_tmp : string <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-t">t</a></code></div><div class="doc"><p>create a fresh temporary variable local to procedure <code class="code">pname</code>. for use in the frontends only!</p></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="../../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="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> unit</code></div><div class="doc"><p>Pretty print a program variable.</p></div></div><div class="spec val" id="val-pp_value"><a href="#val-pp_value" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>pp_value : <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"><p>Pretty print a pvar which denotes a value, not an address</p></div></div><div class="spec val" id="val-pp_translation_unit"><a href="#val-pp_translation_unit" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>pp_translation_unit : <a href="index.html#module-F">F</a>.formatter <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-translation_unit">translation_unit</a> <span class="keyword">&#8209;&gt;</span> unit</code></div><div class="doc"></div></div><div class="spec val" id="val-to_callee"><a href="#val-to_callee" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>to_callee : <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.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>Turn an ordinary program variable into a callee program variable</p></div></div><div class="spec val" id="val-to_seed"><a href="#val-to_seed" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>to_seed : <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>Turn a pvar into a seed pvar (which stores the initial value of a stack var)</p></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"><p>Convert a pvar to string.</p></div></div><div class="spec val" id="val-get_translation_unit"><a href="#val-get_translation_unit" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_translation_unit : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="index.html#type-translation_unit">translation_unit</a></code></div><div class="doc"><p>Get the translation unit corresponding to a global. Raises Invalid_arg if not a global.</p></div></div><div class="spec val" id="val-is_compile_constant"><a href="#val-is_compile_constant" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_compile_constant : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Is the variable's value a compile-time constant? Always (potentially incorrectly) returns
<code class="code">false</code> for non-globals.</p></div></div><div class="spec val" id="val-is_pod"><a href="#val-is_pod" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>is_pod : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> bool</code></div><div class="doc"><p>Is the variable's type a &quot;Plain Old Data&quot; type (C++)? Always (potentially incorrectly) returns
<code class="code">true</code> for non-globals.</p></div></div><div class="spec val" id="val-get_initializer_pname"><a href="#val-get_initializer_pname" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_initializer_pname : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Typ/Procname/index.html#type-t">InferIR.Typ.Procname.t</a> option</code></div><div class="doc"><p>Get the procname of the initializer function for the given global variable</p></div></div><div class="spec val" id="val-get_name_of_local_with_procname"><a href="#val-get_name_of_local_with_procname" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>get_name_of_local_with_procname : <a href="index.html#type-t">t</a> <span class="keyword">&#8209;&gt;</span> <a href="../InferIR/Mangled/index.html#type-t">InferIR.Mangled.t</a></code></div><div class="doc"><p><code class="code">get_name_of_local_with_procname var</code> Return a name that is composed of the name of
var and the name of the procname in case of locals</p></div></div><div class="spec val" id="val-materialized_cpp_temporary"><a href="#val-materialized_cpp_temporary" class="anchor"></a><div class="def val"><code><span class="keyword">val </span>materialized_cpp_temporary : string</code></div><div class="doc"></div></div></body></html>