Fixed EvalEvaluator when there is nothing to evaluate

This commit is contained in:
2019-12-27 14:43:36 +01:00
parent 21da87393f
commit 81b2355633
5 changed files with 97 additions and 15 deletions
+16 -11
View File
@@ -12,8 +12,6 @@ class EvalEvaluator(AllReturnValuesEvaluator):
def __init__(self):
super().__init__(self.NAME, [BuiltinConcepts.AFTER_EVALUATION], 80)
self.successful_return_value = None
self.to_eval = []
self.eval_requested = None
def matches(self, context, return_values):
@@ -21,18 +19,25 @@ class EvalEvaluator(AllReturnValuesEvaluator):
for ret in return_values:
if ret.status and sheerka.isinstance(ret.body, BuiltinConcepts.CONCEPT_EVAL_REQUESTED):
self.eval_requested = ret
elif ret.status and isinstance(ret.body, Concept) and ret.body.body:
self.to_eval.append(ret)
return True
return self.eval_requested is not None and len(self.to_eval) > 0
return False
def eval(self, context, return_value):
def eval(self, context, return_values):
sheerka = context.sheerka
result = []
context.log(self.verbose_log, f"{len(self.to_eval)} return value(s) to eval", who=self)
for ret_val in self.to_eval:
context.log(self.verbose_log, f"{ret_val}", who=self)
result.append(sheerka.ret(self.name, True, ret_val.body.body, parents=[ret_val, self.eval_requested]))
for ret_val in return_values:
if ret_val.status and isinstance(ret_val.body, Concept) and ret_val.body.body:
context.log(self.verbose_log, f"Evaluating {ret_val}", who=self)
result.append(sheerka.ret(self.name, True, ret_val.body.body, parents=[ret_val, self.eval_requested]))
return result
if len(result) > 0:
return result
else:
# suppress the successful BuiltinConcepts.CONCEPT_EVAL_REQUESTED
return sheerka.ret(
self.name,
False,
sheerka.new(BuiltinConcepts.CONCEPT_EVAL_REQUESTED),
parents=[self.eval_requested])