当前位置: 首页>>代码示例>>Python>>正文


Python Function.doExecute方法代码示例

本文整理汇总了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)
开发者ID:julianpistorius,项目名称:myclips,代码行数:35,代码来源:PNode.py

示例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
 
 
开发者ID:julianpistorius,项目名称:myclips,代码行数:31,代码来源:Interpreter.py

示例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)
        
        
开发者ID:julianpistorius,项目名称:myclips,代码行数:31,代码来源:Batch.py


注:本文中的myclips.functions.Function.Function.doExecute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。