Remove regions from types.

Unification-based inference for regions is useful with a language
that has let bindings (which would propagate the regions) and
functions polymorphic over regions. For reasons of simplicity,
ARTIQ has neither, and making unification-based inference work would
essentially mean adding region coercions between most AST nodes,
and having every source subexpression have its own region variable,
with the appropriate subtyping relationship.

It's simpler to just keep that state outside of typedtree.
This commit is contained in:
whitequark 2015-07-02 22:55:08 +03:00
parent 0ae13ac1b9
commit bfabca494b
3 changed files with 16 additions and 7 deletions

View File

@ -15,6 +15,7 @@ class Module:
inferencer = transforms.Inferencer(engine=engine)
int_monomorphizer = transforms.IntMonomorphizer(engine=engine)
monomorphism_validator = validators.MonomorphismValidator(engine=engine)
escape_validator = validators.EscapeValidator(engine=engine)
parsetree, comments = parse_buffer(source_buffer, engine=engine)
typedtree = asttyped_rewriter.visit(parsetree)
@ -22,6 +23,7 @@ class Module:
int_monomorphizer.visit(typedtree)
inferencer.visit(typedtree)
monomorphism_validator.visit(typedtree)
escape_validator.visit(typedtree)
self.name = os.path.basename(source_buffer.name)
self.globals = asttyped_rewriter.globals

View File

@ -82,8 +82,8 @@ class TMono(Type):
attributes = {}
def __init__(self, name, params={}, region=None):
self.name, self.params, self.region = name, params, region
def __init__(self, name, params={}):
self.name, self.params = name, params
def find(self):
return self
@ -125,7 +125,6 @@ class TTuple(Type):
"""
attributes = {}
region = None
def __init__(self, elts=[]):
self.elts = elts
@ -171,8 +170,8 @@ class TFunction(Type):
attributes = {}
def __init__(self, args, optargs, ret, region=None):
self.args, self.optargs, self.ret, self.region = args, optargs, ret, region
def __init__(self, args, optargs, ret):
self.args, self.optargs, self.ret = args, optargs, ret
def arity(self):
return len(self.args) + len(self.optargs)
@ -219,8 +218,6 @@ class TBuiltin(Type):
type is treated specially according to its name.
"""
region = None
def __init__(self, name):
self.name = name
self.attributes = {}

View File

@ -0,0 +1,10 @@
"""
:class:`EscapeValidator` verifies that no mutable data escapes
the region of its allocation.
"""
from pythonparser import algorithm, diagnostic
from .. import asttyped, types, builtins
class EscapeValidator(algorithm.Visitor):
pass