curry.backends.generic.eval.evaluator module
- class curry.backends.generic.eval.evaluator.EvaluationTotals[source]
Bases:
objectSums 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.statsreports 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.- 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.
- class curry.backends.generic.eval.evaluator.Evaluator(interp, goal)[source]
Bases:
objectManages the evaluation of a Curry expression.
- 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.merge_counters(total, part)[source]
Adds the counters of
parttototaland returnstotal: numbers add (a largest value, see MAX_KEYS, takes the maximum), lists add element by element, dicts merge key by key.totalmay 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 returnsexpr. 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 freein a compiled expression) outlives the state: the state counts it, so thatset_goalof a later evaluation registers it (InterpreterState.external_freevars).