Refactord Concept class to regroup all builtins properties into a ConceptMetadata class

This commit is contained in:
2019-11-30 18:16:20 +01:00
parent 5e539a4b28
commit 75c8793d53
13 changed files with 186 additions and 147 deletions
+5 -5
View File
@@ -29,8 +29,8 @@ class ConceptEvaluator(OneReturnValueEvaluator):
# pre condition should already be validated by the parser.
# It's a mandatory condition for the concept before it can be recognized
if len(concept.codes) == 0:
sheerka.add_codes_to_concept(context, concept)
if len(concept.cached_asts) == 0:
sheerka.initialize_concept_asts(context, concept)
# TODO; check pre
# if pre is not true, return Concept with a false value
@@ -38,7 +38,7 @@ class ConceptEvaluator(OneReturnValueEvaluator):
# Evaluate the properties
for prop in concept.props:
sub_context = context.push(self.name, f"Evaluating property '{prop}'", concept)
res = self.evaluate_parsing(sheerka, sub_context, concept.codes[prop])
res = self.evaluate_parsing(sheerka, sub_context, concept.cached_asts[prop])
if res.status:
concept.set_prop(prop, res.value)
else:
@@ -49,11 +49,11 @@ class ConceptEvaluator(OneReturnValueEvaluator):
parents=[return_value])
# Returns the concept when no body
if ConceptParts.BODY not in concept.codes:
if ConceptParts.BODY not in concept.cached_asts:
return sheerka.ret(self.name, True, concept, parents=[return_value])
# Evaluate the body otherwise
body = concept.codes[ConceptParts.BODY]
body = concept.cached_asts[ConceptParts.BODY]
if body is None:
raise NotImplementedError("Seems weird !")