forked from M-Labs/artiq
1
0
Fork 0

Add types.TBuiltin.

This commit is contained in:
whitequark 2015-06-24 11:24:35 +03:00
parent 3adb4150f4
commit 8762729e80
1 changed files with 29 additions and 0 deletions

View File

@ -183,6 +183,33 @@ class TFunction(Type):
def __ne__(self, other):
return not (self == other)
class TBuiltin(Type):
"""
An instance of builtin type. Every instance of a builtin
type is treated specially according to its name.
"""
def __init__(self, name):
self.name = name
def find(self):
return self
def unify(self, other):
if self != other:
raise UnificationError(self, other)
def __repr__(self):
return "py2llvm.types.TBuiltin(%s)" % repr(self.name)
def __eq__(self, other):
return isinstance(other, TBuiltin) and \
self.name == other.name
def __ne__(self, other):
return not (self == other)
class TValue(Type):
"""
A type-level value (such as the integer denoting width of
@ -276,6 +303,8 @@ class TypePrinter(object):
args += [ "%s:%s" % (arg, self.name(typ.args[arg])) for arg in typ.args]
args += ["?%s:%s" % (arg, self.name(typ.optargs[arg])) for arg in typ.optargs]
return "(%s)->%s" % (", ".join(args), self.name(typ.ret))
elif isinstance(typ, TBuiltin):
return "<built-in %s>" % typ.name
elif isinstance(typ, TValue):
return repr(typ.value)
else: