PyEnv.DataStack
In Python, everything is an object, and the interpreter maintains a stack of references to such objects. Pushing and popping on the stack are always references to objets that leave in a heap. There is no need to model this heap, but the data stack is quite important.
type cell =
| Const of FFI.Constant.t
constant from co_consts
| Name of {
}
reference to a name, from co_names
.
| VarName of string
reference to a local name, fromco_varnames
| Temp of T.Ident.t
SSA variable
*)| Code of {
fun_or_class : bool;
code_name : string;
code : FFI.Code.t;
}
code
Python object with its name. It can be a function, class, closure, ...
| List of PyBuiltin.builder * cell list
Light encoding of raw Python tuples/lists.
*)| Map of (T.Exp.t * cell) list
Light encoding of raw Python maps/dicts.
*)| BuiltinBuildClass
see Python's LOAD_BUILD_CLASS
| Import of {
import_path : Ident.t;
from_list : string list;
}
imported module path, with optional names of symbols from that module
*)| ImportFrom of {
import_path : Ident.t;
imported_name : string;
}
imported symbol from a module. Must have been loaded via Import
first
| ImportCall of {
id : Ident.t;
loc : T.Location.t;
}
Static call to export definition
*)| MethodCall of {
receiver : T.Exp.t;
name : T.QualifiedProcName.t;
}
Virtual call, usually of a method of a class. Could be an access to a closure that is called straight away
*)| StaticCall of {
call_name : T.QualifiedProcName.t;
receiver : T.Exp.t option;
}
call to static method in class. Because we turn some method calls into static ones, we have to keep the receiver around, just in case.
*)| Super
special name to refer to the parent class, like in super().__init__()
| Path of Ident.t
Qualified path for sequence of imports, attribute accesses, ...
*)| WithContext of T.Ident.t
value to be used for calling __enter__ and __exit__ with the `with context` statement
*)| NoException
Special NONE symbol pushed by the exception infra to express that no exception has been raised
*)val pp_cell : Stdlib.Format.formatter -> cell -> unit
val as_code : cell -> FFI.Code.t option
val as_name : cell -> string option
val is_path : cell -> bool
val is_no_exception : cell -> bool
type t = cell list