mirror of https://github.com/m-labs/artiq.git
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:
parent
0ae13ac1b9
commit
bfabca494b
|
@ -15,6 +15,7 @@ class Module:
|
||||||
inferencer = transforms.Inferencer(engine=engine)
|
inferencer = transforms.Inferencer(engine=engine)
|
||||||
int_monomorphizer = transforms.IntMonomorphizer(engine=engine)
|
int_monomorphizer = transforms.IntMonomorphizer(engine=engine)
|
||||||
monomorphism_validator = validators.MonomorphismValidator(engine=engine)
|
monomorphism_validator = validators.MonomorphismValidator(engine=engine)
|
||||||
|
escape_validator = validators.EscapeValidator(engine=engine)
|
||||||
|
|
||||||
parsetree, comments = parse_buffer(source_buffer, engine=engine)
|
parsetree, comments = parse_buffer(source_buffer, engine=engine)
|
||||||
typedtree = asttyped_rewriter.visit(parsetree)
|
typedtree = asttyped_rewriter.visit(parsetree)
|
||||||
|
@ -22,6 +23,7 @@ class Module:
|
||||||
int_monomorphizer.visit(typedtree)
|
int_monomorphizer.visit(typedtree)
|
||||||
inferencer.visit(typedtree)
|
inferencer.visit(typedtree)
|
||||||
monomorphism_validator.visit(typedtree)
|
monomorphism_validator.visit(typedtree)
|
||||||
|
escape_validator.visit(typedtree)
|
||||||
|
|
||||||
self.name = os.path.basename(source_buffer.name)
|
self.name = os.path.basename(source_buffer.name)
|
||||||
self.globals = asttyped_rewriter.globals
|
self.globals = asttyped_rewriter.globals
|
||||||
|
|
|
@ -82,8 +82,8 @@ class TMono(Type):
|
||||||
|
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
|
||||||
def __init__(self, name, params={}, region=None):
|
def __init__(self, name, params={}):
|
||||||
self.name, self.params, self.region = name, params, region
|
self.name, self.params = name, params
|
||||||
|
|
||||||
def find(self):
|
def find(self):
|
||||||
return self
|
return self
|
||||||
|
@ -125,7 +125,6 @@ class TTuple(Type):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
attributes = {}
|
attributes = {}
|
||||||
region = None
|
|
||||||
|
|
||||||
def __init__(self, elts=[]):
|
def __init__(self, elts=[]):
|
||||||
self.elts = elts
|
self.elts = elts
|
||||||
|
@ -171,8 +170,8 @@ class TFunction(Type):
|
||||||
|
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
|
||||||
def __init__(self, args, optargs, ret, region=None):
|
def __init__(self, args, optargs, ret):
|
||||||
self.args, self.optargs, self.ret, self.region = args, optargs, ret, region
|
self.args, self.optargs, self.ret = args, optargs, ret
|
||||||
|
|
||||||
def arity(self):
|
def arity(self):
|
||||||
return len(self.args) + len(self.optargs)
|
return len(self.args) + len(self.optargs)
|
||||||
|
@ -219,8 +218,6 @@ class TBuiltin(Type):
|
||||||
type is treated specially according to its name.
|
type is treated specially according to its name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
region = None
|
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue