forked from M-Labs/artiq
1
0
Fork 0

Add region field to types.

This commit is contained in:
whitequark 2015-07-02 18:44:09 +03:00
parent 86cdc84f7e
commit 1702251ee5
2 changed files with 14 additions and 6 deletions

View File

@ -67,12 +67,17 @@ class TVar(Type):
# any lookups or comparisons.
class TMono(Type):
"""A monomorphic type, possibly parametric."""
"""
A monomorphic type, possibly parametric.
:class:`TMono` is supposed to be subclassed by builtin types,
unlike all other :class:`Type` descendants.
"""
attributes = {}
def __init__(self, name, params={}):
self.name, self.params = name, params
def __init__(self, name, params={}, region=None):
self.name, self.params, self.region = name, params, region
def find(self):
return self
@ -109,6 +114,7 @@ class TTuple(Type):
"""
attributes = {}
region = None
def __init__(self, elts=[]):
self.elts = elts
@ -149,8 +155,8 @@ class TFunction(Type):
attributes = {}
def __init__(self, args, optargs, ret):
self.args, self.optargs, self.ret = args, optargs, ret
def __init__(self, args, optargs, ret, region=None):
self.args, self.optargs, self.ret, self.region = args, optargs, ret, region
def arity(self):
return len(self.args) + len(self.optargs)
@ -189,6 +195,8 @@ class TBuiltin(Type):
type is treated specially according to its name.
"""
region = None
def __init__(self, name):
self.name = name
self.attributes = {}

View File

@ -444,7 +444,7 @@ class Inferencer(algorithm.Visitor):
def visit_ListT(self, node):
self.generic_visit(node)
for elt in node.elts:
self._unify(node.type["elt"], elt.type,
self._unify(node.type, builtins.TList(elt.type),
node.loc, elt.loc, self._makenotes_elts(node.elts, "a list element"))
def visit_AttributeT(self, node):