curry.backends.py.eval.rts_freevars module

Implements RuntimeState methods related to free variables. This module is not intended to be imported except by rts.py.

curry.backends.py.eval.rts_freevars.clone_generator(rts, bound, unbound)[source]
curry.backends.py.eval.rts_freevars.freshvar(rts, target=None)[source]

Places a fresh free variable at the specified location.

curry.backends.py.eval.rts_freevars.freshvar_args(rts)[source]

Generates arguments for a fresh free variable using the next available ID.

curry.backends.py.eval.rts_freevars.get_freevar(rts, arg=None, config=None)[source]
curry.backends.py.eval.rts_freevars.get_generator(rts, arg=None, config=None)[source]

Returns the generator for the given free variable. The first argument must be a choice or free variable node, or ID.

A variable of a decided class without a generator of its own is bound through the class (Def 2.74 of the note on the Fair Scheme): it gets a clone of the generator of a member that has one, paired leaf by leaf (_constrain_equal_rec of rts_constraints.py, which searches the class; the variable may be the root, which the union by size can leave without a generator; issue #127).

curry.backends.py.eval.rts_freevars.has_generator(rts, arg=None, config=None)[source]
curry.backends.py.eval.rts_freevars.instantiate(rts, var, typedef, config=None)[source]

Instantiates a needed free variable, at the specified location.

Returns:

The expression the free variable was replaced with.

curry.backends.py.eval.rts_freevars.is_narrowed(rts, arg=None, config=None)[source]

Indicates whether the given free varaible was narrowed in this configuration. The argument must be a free variable node or ID.

curry.backends.py.eval.rts_freevars.is_nondet(rts, arg=None, config=None)[source]

Returns True if the argument is a choice or variable.

curry.backends.py.eval.rts_freevars.is_void(rts, arg=None, config=None)[source]

Indicates whether a free variable is missing any information that would allow a computation needing it to proceed. Used to implement Prelude.ensureNotFree.

curry.backends.py.eval.rts_freevars.register_freevar(rts, var)[source]

Update the vtable for variable var. The variable is added to the table so that it can be found later, if needed.

curry.backends.py.eval.rts_freevars.register_freevars(rts, root)[source]

Registers every free variable of the expression at root in the vtable. A goal built outside this evaluation can hold variables that no table of this state knows: a curry.free marker shared with an earlier goal, whose node the step of Prelude.unknown forwarded to a free variable; the result of the single rewrite step of a compiled expression; a raw Free node of curry.raw_expr; a value of an earlier evaluation. The item of a generator node is built during the evaluation, so its step walks the item as well (prelude/string.py). The walk is iterative with a visited set, because a goal can be cyclic. It follows forward nodes and descends into every node successor: data, partial applications, set guards, constraints, choices, and the generators of free variables. The C++ runtime has the same method.