Skip to content

Commit bfabca4

Browse files
author
whitequark
committedJul 2, 2015
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.
1 parent 0ae13ac commit bfabca4

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed
 

Diff for: ‎artiq/compiler/module.py

+2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ def __init__(self, source_buffer, engine=None):
1515
inferencer = transforms.Inferencer(engine=engine)
1616
int_monomorphizer = transforms.IntMonomorphizer(engine=engine)
1717
monomorphism_validator = validators.MonomorphismValidator(engine=engine)
18+
escape_validator = validators.EscapeValidator(engine=engine)
1819

1920
parsetree, comments = parse_buffer(source_buffer, engine=engine)
2021
typedtree = asttyped_rewriter.visit(parsetree)
2122
inferencer.visit(typedtree)
2223
int_monomorphizer.visit(typedtree)
2324
inferencer.visit(typedtree)
2425
monomorphism_validator.visit(typedtree)
26+
escape_validator.visit(typedtree)
2527

2628
self.name = os.path.basename(source_buffer.name)
2729
self.globals = asttyped_rewriter.globals

Diff for: ‎artiq/compiler/types.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class TMono(Type):
8282

8383
attributes = {}
8484

85-
def __init__(self, name, params={}, region=None):
86-
self.name, self.params, self.region = name, params, region
85+
def __init__(self, name, params={}):
86+
self.name, self.params = name, params
8787

8888
def find(self):
8989
return self
@@ -125,7 +125,6 @@ class TTuple(Type):
125125
"""
126126

127127
attributes = {}
128-
region = None
129128

130129
def __init__(self, elts=[]):
131130
self.elts = elts
@@ -171,8 +170,8 @@ class TFunction(Type):
171170

172171
attributes = {}
173172

174-
def __init__(self, args, optargs, ret, region=None):
175-
self.args, self.optargs, self.ret, self.region = args, optargs, ret, region
173+
def __init__(self, args, optargs, ret):
174+
self.args, self.optargs, self.ret = args, optargs, ret
176175

177176
def arity(self):
178177
return len(self.args) + len(self.optargs)
@@ -219,8 +218,6 @@ class TBuiltin(Type):
219218
type is treated specially according to its name.
220219
"""
221220

222-
region = None
223-
224221
def __init__(self, name):
225222
self.name = name
226223
self.attributes = {}

Diff for: ‎artiq/compiler/validators/escape.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
:class:`EscapeValidator` verifies that no mutable data escapes
3+
the region of its allocation.
4+
"""
5+
6+
from pythonparser import algorithm, diagnostic
7+
from .. import asttyped, types, builtins
8+
9+
class EscapeValidator(algorithm.Visitor):
10+
pass

0 commit comments

Comments
 (0)
Please sign in to comment.