curry.backends package

Defines the IBackend object, which mediates interations between the Python API and backends.

This contains definitions common to all backends and the interfaces each should implement.

class curry.backends.IBackend(backend=None)[source]

Bases: object

The interface to a Curry implementation.

This interface mediates all interactions bewteen the Sprite API (e.g., the Interpreter class) and a backend implementation. This stateless object is shared among all interpreters using the same backend.

after_evaluation(interp)[source]

Called when the values of an evaluation are exhausted. The C++ backend applies and logs the compiled objects that finished during the evaluation.

abstract property backend_name

E.g., ‘py’ or ‘cxx’.

before_evaluation(interp)[source]

Called when an evaluation is about to start. The C++ backend applies the compiled objects that finished in the background.

abstract property compile

Converts ICurry to an instance of IR.

compile_pending(moduleobj)[source]

Compiles the functions of a loaded module whose compilation the backend deferred, once every symbol of the module is registered. The Python backend compiles a step function on its first call; an expression module (compile.compile_expression) leaves the registry of the interpreter after this call, so its functions are compiled here. A backend that compiles whole modules ahead of time has nothing to do.

abstract property create_evaluation_rts

Creates a new runtime state representing an evaluation.

abstract property extend_plan_skeleton
abstractmethod find_or_create_internal_module(moduleobj)[source]
abstract property fundamental_symbols
gc_counters()[source]

The counters of the garbage collector of this backend, summed over its collections in this process, as a dict keyed by the names in stats.GC_COUNTERS (the seconds of the phases of a collection, the nodes marked by age, the configurations pushed, the queues and configurations destroyed, the writes into old nodes). A backend without a collector of its own answers an empty dict, which Interpreter.stats reports as zeros.

gc_seconds()[source]

The seconds the garbage collector of this backend has spent in its collections in this process. A backend without a collector of its own answers zero.

abstractmethod get_interpreter_state(interp)[source]

Gets the runtime-specific state attached to an interpreter.

getimpl(symbol)[source]

The implementation code of the step function of symbol (a CurryNodeInfo) as text; see curry.inspect.getimpl(). Raises ValueError when the backend has no code for the symbol.

abstractmethod init_interpreter_state(interp)[source]

Initializes an interpreter with the runtime-specific state.

abstract property load_module

Load the contents of a Curry module.

abstractmethod lookup_builtin_module(modulename)[source]

Looks up the implementation for a built-in module.

abstract property make_node
abstract property materialize
module_loaded(interp, moduleobj, currypath)[source]

Called when the import of a module ends, after the imports of the module were imported and its symbols were loaded. currypath is the search path of the imports of the module: the path of a program given as a file, or the path of the interpreter for a module given by name (interpreter.import_.ImportEx). The C++ backend queues the background compile of a module it interprets (see backends.cxx.tiered).

module_unlinked(interp, moduleobj)[source]

Called when a module leaves the interpreter (Handle.unlink: a reset, or the hard reset of reload), after its name left interp.modules. The module object may stay alive in the hands of the user. The C++ backend hands the tables of the module to the kept store of the runtime, so a module of the same name made later runs its own code (issue #114; see Module::retire in cyrt/module.hpp).

num_collections()[source]

The number of collections the garbage collector of this backend has run in this process. A backend without a collector of its own answers zero.

abstract property object_file_extension
scheduler_counters_enabled()[source]

True when the runtime of this backend counts the serial steps, the lifetimes of configurations, and the shared work of an evaluation (Interpreter.stats reports them). Only the C++ runtime built with make COUNTERS=1 does.

tiered_counts()[source]

The functions swapped to compiled code and the background compiles that failed in this process (Interpreter.stats reports them). A backend without tiered execution answers zeros.

abstract property write_module

Write the contents of a Curry module to a stream.

class curry.backends.Node[source]

Bases: object

Subpackages