def pyF1ToWhile(whileNd):
     ''' extract a reg/field poll from an ast While node - returns new model While node else returns None on no match '''
     compNd = whileNd.test
     if type(compNd) is not ast.Compare:
         return None
     compare = __class__.pyF1ToCfgCompare(compNd)
     if not compare.isValid():
         return None
     return Cm.CfgWhileNode(compare, whileNd)
Exemple #2
0
 def enterWhile_loop(self, ctx: ConfigParser.While_loopContext):
     #print('enterWhile_loop: ')
     leftOp = ctx.value(0).getText()
     rightOp = ctx.value(1).getText()
     compareOp = ctx.compare_op().getText()
     #print(' ' + compareOp + ' ' + rightOp)
     leftVal = Cm.CfgVariable.resolveRhsExpression(
         leftOp, Cm.CfgNumDataType)  # numeric var or instance
     rightVal = Cm.CfgVariable.resolveRhsExpression(
         rightOp, Cm.CfgNumDataType)  # numeric var or instance
     whileCompare = Cm.CfgCompare(leftVal, compareOp, rightVal)
     Cm.CfgWhileNode(whileCompare)
Exemple #3
0
 def enterPoll_config_call(self, ctx: ConfigParser.Poll_config_callContext):
     #print('enterPoll_config_call: ')
     readType = ctx.getChild(0).getText()
     readPath = ctx.path().getText()
     pollOp = ctx.compare_op().getText()
     pollVal = ctx.value(0).getText()
     #print(' ' + readType + ' ' + readPath + ' ' + pollOp + ' ' + pollVal)
     rtype = Cm.CfgPathHierType.resolve(
         readType)  # poll is compare of read value, so explicitly set type
     rNode = Cm.CfgReadNode(readPath, rtype, None)
     pVal = Cm.CfgVariable.resolveRhsExpression(
         pollVal,
         Cm.CfgNumDataType)  # read compares to a numeric var or instance
     whileCompare = Cm.CfgCompare(rNode, pollOp, pVal)
     Cm.CfgWhileNode(whileCompare)