curry.backends.generic.eval.evaluator module

class curry.backends.generic.eval.evaluator.EvaluationTotals[source]

Bases: object

Sums the rewrite steps and the forks of the evaluations of one interpreter. The runtime state of an evaluation counts its own steps (steps_total) and forks (forks_total). A running evaluation is held by a weak reference, so the totals include its counts so far. An evaluation that ended is added once, when its value generator is exhausted or closed. Interpreter.stats reports the totals.

The scheduler counters of an instrumented C++ runtime (make COUNTERS=1) are summed the same way: rts.scheduler_counters() gives a dict of numbers, lists, and dicts, or None when the runtime has none.

add(rts)[source]

Adds the counts of a runtime state that takes no more steps.

property forks

The forks taken, running evaluations included.

property scheduler

The scheduler counters summed, running evaluations included; None when the runtime has no counters or no evaluation reported any.

property steps

The rewrite steps taken, running evaluations included.

track(rts, values)[source]

Yields the values of values, the value generator of the evaluation under rts, and adds the counts of rts when the generator ends or is closed.

class curry.backends.generic.eval.evaluator.Evaluator(interp, goal)[source]

Bases: object

Manages the evaluation of a Curry expression.

evaluate()[source]

Evaluate the goal.

set_global_step_limit(limit=None, reset=True)[source]

Sets the step limit after which E_TERMINATE is raised. By default there is no limit. This can be used to apply no more than a set number of steps, which is useful for debugging and perhaps in other situations.

Parameters:
  • limit – The new global step limit. Pass None to indicate no limit.

  • reset – Indicates whether to reset the global step count to zero.

curry.backends.generic.eval.evaluator.evaluate(interp, goal, steplimit=None)[source]
curry.backends.generic.eval.evaluator.merge_counters(total, part)[source]

Adds the counters of part to total and returns total: numbers add (a largest value, see MAX_KEYS, takes the maximum), lists add element by element, dicts merge key by key. total may be None, which stands for nothing counted yet.

curry.backends.generic.eval.evaluator.single_step(interp, expr)[source]

Takes one rewrite step at the root of expr, outside an evaluation, and returns expr. The runtime state of either backend counts the step as the step loop would (RuntimeState.single_step), and the totals of the interpreter take it up like the steps of an evaluation. A free variable the step creates (let x free in a compiled expression) outlives the state: the state counts it, so that set_goal of a later evaluation registers it (InterpreterState.external_freevars).