Concepts bodies are now evaluated on demand

This commit is contained in:
2020-02-27 10:48:45 +01:00
parent 7cd94e888f
commit ef31a4807d
25 changed files with 468 additions and 172 deletions
+15 -2
View File
@@ -5,7 +5,7 @@ from evaluators.BaseEvaluator import OneReturnValueEvaluator
class ConceptEvaluator(OneReturnValueEvaluator):
"""
The concept evaluatuor is the main class that know what to do with a concept
The concept evaluator is the main class that know what to do with a concept
It verifies the PRE
If ok, can execute or not the BODY
Then checks the POST conditions
@@ -15,6 +15,19 @@ class ConceptEvaluator(OneReturnValueEvaluator):
def __init__(self, return_body=False):
super().__init__(self.NAME, [BuiltinConcepts.EVALUATION], 50)
self.return_body = return_body
self.evaluate_body = False
self.is_initialized = False
def init_evaluator(self, context, return_values):
if BuiltinConcepts.CONCEPT_EVAL_REQUESTED in context.extra_info:
self.evaluate_body = True
for r in return_values:
if r.status and context.sheerka.isinstance(r.body, BuiltinConcepts.CONCEPT_VALUE_REQUESTED):
self.evaluate_body = True
break
self.is_initialized = True
def matches(self, context, return_value):
return return_value.status and \
@@ -36,7 +49,7 @@ class ConceptEvaluator(OneReturnValueEvaluator):
return sheerka.ret(self.name, True, value, parents=[return_value])
evaluated = sheerka.evaluate_concept(context, concept)
evaluated = sheerka.evaluate_concept(context, concept, self.evaluate_body)
if evaluated.key != concept.key:
# evaluated.key != concept.key means that we have transformed the concept