def __init__(self, className, baseClass=None, protocol=None): JOcClass.__init__(self, className, baseClass, protocol) self.imports = [] self.variables = {} self._include_classes = None # 引用的类数组 JOcHelper.randVars(self.variables, 0.85, JRand.rand_nearest(8)) # 初始化私有类变量
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()