diff --git a/artiq/compiler/module.py b/artiq/compiler/module.py index d5d21391b..2b847eb27 100644 --- a/artiq/compiler/module.py +++ b/artiq/compiler/module.py @@ -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 diff --git a/artiq/compiler/types.py b/artiq/compiler/types.py index 47d6f055b..7e8c611f6 100644 --- a/artiq/compiler/types.py +++ b/artiq/compiler/types.py @@ -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 = {} diff --git a/artiq/compiler/validators/escape.py b/artiq/compiler/validators/escape.py new file mode 100644 index 000000000..4f02b1b7c --- /dev/null +++ b/artiq/compiler/validators/escape.py @@ -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