本文整理汇总了Python中myclips.functions.Function.Function.doExecute方法的典型用法代码示例。如果您正苦于以下问题:Python Function.doExecute方法的具体用法?Python Function.doExecute怎么用?Python Function.doExecute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myclips.functions.Function.Function
的用法示例。
在下文中一共展示了Function.doExecute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from myclips.functions.Function import Function [as 别名]
# 或者: from myclips.functions.Function.Function import doExecute [as 别名]
def execute(self, theToken):
# resolve variables from the token
resolved = {}
linearToken = theToken.linearize()
for theVar, theLocation in self._variables.items():
try:
assert isinstance(theLocation, VariableLocation)
resolved[theVar] = theLocation.toValue(linearToken[theLocation.patternIndex])
except:
import myclips
myclips.logger.debug("%s: unresolvable variable %s: %s:%s %s", self.completeRuleName(), theVar, theLocation.patternIndex, theLocation, linearToken )
# prepare the FunctionEnv object
theEnv = FunctionEnv(resolved, self._network, self._network.modulesManager, self._network.resources)
# execute all rhs passing FunctionEnv
# theEnv could be modified from the function call.
# This THE way to share memory between functions
for action in self._rhs:
assert isinstance(action, types.FunctionCall)
# get the function definition linked to the FunctionCall
#funcDefinition = action.funcDefinition
#assert isinstance(funcDefinition, FunctionDefinition)
# expand the args
#funcDefinition.linkedType.__class__.execute(funcDefinition.linkedType, theEnv, *(action.funcArgs))
Function.doExecute(action, theEnv)
示例2: isinstance
# 需要导入模块: from myclips.functions.Function import Function [as 别名]
# 或者: from myclips.functions.Function.Function import doExecute [as 别名]
# add the new rule to the network
self._network.addRule(parsed)
elif isinstance(parsed, types.DefFactsConstruct):
# add the deffacts
self._network.addDeffacts(parsed)
elif isinstance(parsed, types.FunctionCall):
# execute the function
assert isinstance(parsed, types.FunctionCall)
# prepare the FunctionEnv object
theEnv = FunctionEnv({}, self._network, self._network.modulesManager, self._network.resources)
#funcDefinition = parsed.funcDefinition
#theResult = funcDefinition.linkedType.__class__.execute(funcDefinition.linkedType, theEnv, *(parsed.funcArgs))
# replace old function bootstrap method with a faster one
theResult = Function.doExecute(parsed, theEnv)
if not isinstance(theResult, types.NullValue):
return theResult
elif isinstance(parsed, types.GlobalVariable):
# resolve the global value
return self._network.modulesManager.currentScope.globalsvars.getDefinition(parsed.evaluate()).linkedType.runningValue
elif isinstance(parsed, types.BaseParsedType):
return parsed
示例3: isinstance
# 需要导入模块: from myclips.functions.Function import Function [as 别名]
# 或者: from myclips.functions.Function.Function import doExecute [as 别名]
parsed = theEnv.network.getParser().parse(aString, extended=True)
except Exception, e:
print >> theEnv.RESOURCES['werror'], theEnv.network.getParser().ExceptionPPrint(e, aString)
os.chdir(oldcwd)
return types.Symbol('FALSE')
else:
cString = ""
for p in parsed:
if isinstance(p, types.DefRuleConstruct):
theEnv.network.addRule(p)
elif isinstance(p, types.DefFactsConstruct):
theEnv.network.addDeffacts(p)
elif isinstance(p, types.FunctionCall):
theResult = Function.doExecute(p, theEnv)
if not isinstance(theResult, types.NullValue):
print >> theEnv.RESOURCES['wtrace'], str(theResult)
os.chdir(oldcwd)
return types.Symbol('TRUE')
Batch.DEFINITION = FunctionDefinition("?SYSTEM?", "batch", Batch(), types.Symbol, Batch.do ,
[
Constraint_ExactArgsLength(1),
Constraint_ArgType((types.Symbol, types.String), 0)
],forward=False)