Added first version of DebugManager. Implemented draft of the rule engine

This commit is contained in:
2020-11-20 13:41:45 +01:00
parent cd066881b4
commit 315f8ea09b
156 changed files with 8388 additions and 2852 deletions
+25 -5
View File
@@ -1,5 +1,5 @@
from core.builtin_concepts import BuiltinConcepts
from core.concept import Concept
from core.concept import Concept, NotInit
from evaluators.BaseEvaluator import OneReturnValueEvaluator
@@ -25,11 +25,31 @@ class PostExecutionEvaluator(OneReturnValueEvaluator):
return isinstance(value, Concept) and context.sheerka.isa(value, context.sheerka.new(BuiltinConcepts.AUTO_EVAL))
def eval(self, context, return_value):
# only support the rule for the COMMANDS
#body = return_value.body.body
body = context.sheerka.objvalue(return_value)
# only support the rule for the COMMANDS ??
return context.sheerka.ret(
self.name,
True,
body if body != BuiltinConcepts.NOT_INITIALIZED else return_value.body,
self.custom_obj_value(context, return_value.body),
parents=[return_value])
@staticmethod
def custom_obj_value(context, obj):
"""
get concept inner value.
You cannot use sheerka.objvalue() as it does not handle container
And...
Do not try to make it manage it, it won't work ;-)
:param context:
:param obj:
:return:
"""
if context.sheerka.is_container(obj):
return obj
if isinstance(obj, Concept):
if isinstance(obj.body, Concept):
return PostExecutionEvaluator.custom_obj_value(context, obj.body)
else:
return obj.body if obj.body != NotInit else obj
return obj