27 lines
642 B
Python
27 lines
642 B
Python
# Copyright (c) PARRRATE T&V 2021. All rights reserved.
|
|
|
|
from bu4.evaluation.constructs.evalue import EValue
|
|
from bu4.evaluation.constructs.etraceable import ETraceable
|
|
from bu4.evaluation.sync import sync
|
|
from bu4.tracing.probe import Probe
|
|
|
|
__all__ = ('trace', 'probe_index_reset',)
|
|
|
|
_probe_index = 0
|
|
|
|
|
|
def trace(lambda_: EValue):
|
|
global _probe_index
|
|
size = 0
|
|
while True:
|
|
if not isinstance(lambda_, ETraceable):
|
|
return size, lambda_
|
|
lambda_ = sync(lambda_.call(Probe(_probe_index)))
|
|
_probe_index += 1
|
|
size += 1
|
|
|
|
|
|
def probe_index_reset():
|
|
global _probe_index
|
|
_probe_index = 0
|