You must now use 'eval' to get the body of a concept

This commit is contained in:
2019-12-24 16:58:09 +01:00
parent 5c90b07e1a
commit 44e4b75cf8
37 changed files with 1003 additions and 383 deletions
+4 -3
View File
@@ -17,8 +17,9 @@ class ConceptEvaluator(OneReturnValueEvaluator):
BuiltinConcepts.AFTER_EVALUATION
]
def __init__(self):
def __init__(self, return_body=False):
super().__init__(self.NAME, [BuiltinConcepts.EVALUATION], 50)
self.return_body = return_body
def matches(self, context, return_value):
return return_value.status and \
@@ -35,7 +36,7 @@ class ConceptEvaluator(OneReturnValueEvaluator):
# If we evaluate Concept("foo", body="a").set_prop("a", "'property_a'")
# The body should be 'property_a', and not a concept called a in our universe
if context.obj and concept.name in context.obj.props:
return sheerka.ret(self.name, False, sheerka.new(BuiltinConcepts.NOT_FOR_ME), parents=[return_value])
return sheerka.ret(self.name, True, context.obj.props[concept.name].value, parents=[return_value])
evaluated = sheerka.evaluate_concept(context, concept, self.verbose_log)
@@ -48,7 +49,7 @@ class ConceptEvaluator(OneReturnValueEvaluator):
evaluated,
parents=[return_value])
if ConceptParts.BODY not in evaluated.cached_asts:
if not self.return_body or ConceptParts.BODY not in evaluated.cached_asts:
return sheerka.ret(self.name, True, evaluated, parents=[return_value])
else:
return sheerka.ret(self.name, True, evaluated.body, parents=[return_value])