Ejemplo n.º 1
0
 def __init__(self, source, **substitutions):
     source = "#include <pykit_ir.h>\n" + source
     for name, value in substitutions.iteritems():
         if isinstance(value, types.Type):
             substitutions[name] = types.typename(value)
     source = substitute(source, **substitutions)
     self.state = pykitcompile(source)
     self.m, self.f, self.b, self.entry, self.env = self.state
Ejemplo n.º 2
0
def build_conversion_table(convertable=types.scalar_set):
    """Returns { (from_type, to_type) -> funcname }"""
    table = {}
    for type in convertable:
        typename = types.typename(type).lower()
        table[(type, types.Object)] = "object_from_%s" % typename
        table[(types.Object, type)] = "%s_from_object" % typename
    return table