Esempio n. 1
0
 def test_comparisons(self):
     # A bunch of mutually unequal types
     types = [
         ir.LabelType(), ir.VoidType(),
         ir.FunctionType(int1, (int8, int8)), ir.FunctionType(int1, (int8,)),
         ir.FunctionType(int1, (int8,), var_arg=True),
         ir.FunctionType(int8, (int8,)),
         int1, int8, int32, flt, dbl,
         ir.ArrayType(flt, 5), ir.ArrayType(dbl, 5), ir.ArrayType(dbl, 4),
         ir.LiteralStructType((int1, int8)), ir.LiteralStructType((int8, int1)),
         ]
     types.extend([ir.PointerType(tp) for tp in types
                   if not isinstance(tp, ir.VoidType)])
     for a, b in itertools.product(types, types):
         if a is not b:
             self.assertFalse(a == b, (a, b))
             self.assertTrue(a != b, (a, b))
     # We assume copy.copy() works fine here...
     for tp in types:
         other = copy.copy(tp)
         self.assertIsNot(other, tp)
         if isinstance(tp, ir.LabelType):
             self.assertFalse(tp == other, (tp, other))
             self.assertTrue(tp != other, (tp, other))
         else:
             self.assertTrue(tp == other, (tp, other))
             self.assertFalse(tp != other, (tp, other))
Esempio n. 2
0
def irbase(base):
    ir_base = dict({
        "int": ir.IntType(32),
        "byte": ir.IntType(8),
        "logic": ir.IntType(1),
        "void": ir.VoidType(),
        "label": ir.LabelType(),
    })
    return ir_base[base]