# Copyright (c) PARRRATE T&V 2021. All rights reserved. from bu4.combinatory.lic import EIC from bu4.combinatory.lkc import EKC from bu4.combinatory.lsc import ESC, ESC1, ESC2 from bu4.evaluation.constructs.edelayed import EDelayed from bu4.evaluation.constructs.eilambda import EILambda from bu4.evaluation.constructs.elambda import ELambda from bu4.evaluation.constructs.evalue import EValue from bu4.evaluation.sync import sync from bu4.tracing.probe import ProbeA __all__ = ('trace', 'probe_index_reset',) _probe_index = 0 def trace(lambda_: EValue): global _probe_index size = 0 while True: if not isinstance(lambda_, (ELambda, EILambda, EIC, EKC, ESC, ESC1, ESC2, EDelayed)): return size, lambda_ lambda_ = sync(lambda_.call(ProbeA(_probe_index))) _probe_index += 1 size += 1 def probe_index_reset(): global _probe_index _probe_index = 0