Exemplo n.º 1
0
    def get_stepper_code(self):
        classes = {}
        for dest, stepper in self.object.steppers.items():
            cls = stepper.__class__.__name__
            classes[cls] = stepper

        known_types = dict(self.acceleration_eval_helper.known_types)
        known_types.update(dict(t=0.0, dt=0.0))
        code_gen = CythonGenerator(known_types=known_types)

        wrappers = []
        for cls in sorted(classes.keys()):
            code_gen.parse(classes[cls])
            wrappers.append(code_gen.get_code())
        return '\n'.join(wrappers)
Exemplo n.º 2
0
 def get_equation_wrappers(self, known_types={}):
     classes = defaultdict(lambda: 0)
     eqs = {}
     for equation in self.equations:
         cls = equation.__class__.__name__
         n = classes[cls]
         equation.var_name = '%s%d' % (camel_to_underscore(
             equation.name), n)
         classes[cls] += 1
         eqs[cls] = equation
     wrappers = []
     predefined = dict(get_predefined_types(self.pre_comp))
     predefined.update(known_types)
     code_gen = CythonGenerator(known_types=predefined)
     for cls in sorted(classes.keys()):
         code_gen.parse(eqs[cls])
         wrappers.append(code_gen.get_code())
     return '\n'.join(wrappers)