Пример #1
0
 def makeClsMixCode(self):
     if (self._include_classes is not None):
         copyArray = None
         t = len(self._include_classes)
         n = len(self.methods)
         for i in range(n):
             m = self.methods[i]
             if (copyArray is None) or (len(copyArray) <= 0):
                 copyArray = self._include_classes[:]
             classes = JRand.rand_lave_list(copyArray, n, i,
                                            JRand.rand_int(1, t))
             m.makeBody(classes)
     else:
         for m in self.methods:
             m.makeBody()
Пример #2
0
 def makeBody(self, refClasses=None):
     # 初始化局部变量
     if (self.argNames is None):
         JOcHelper.randVars(self.variables, 0.00, random.randint(0, 5))
     else:
         JOcHelper.randVars(self.variables, 0.85, JRand.rand_nearest(5))
     # 生成逻辑
     tree = JOcMixBlock(self)
     self.lineTree = tree
     if (refClasses is not None):
         others = refClasses[:]
         n = JRand.rand_int(1, len(refClasses))
         for i in range(n):
             cls = JRand.rand_lave_list(others, n, i, 1)
             tree.randStatement(cls)
     else:
         n = random.randint(1, 3)
         for i in range(n):
             tree.randStatement()
     if (self.ret != 'void'):
         tree.makeReturn()