forked from M-Labs/artiq
validators.escape: infer correct region for arguments.
This commit is contained in:
parent
72b6cca9c3
commit
25e2824709
|
@ -248,6 +248,9 @@ class TFunction(Type):
|
||||||
def arity(self):
|
def arity(self):
|
||||||
return len(self.args) + len(self.optargs)
|
return len(self.args) + len(self.optargs)
|
||||||
|
|
||||||
|
def arg_names(self):
|
||||||
|
return list(self.args.keys()) + list(self.optargs.keys())
|
||||||
|
|
||||||
def find(self):
|
def find(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ class EscapeValidator(algorithm.Visitor):
|
||||||
loc)
|
loc)
|
||||||
]
|
]
|
||||||
|
|
||||||
def visit_in_region(self, node, region, typing_env):
|
def visit_in_region(self, node, region, typing_env, args=[]):
|
||||||
try:
|
try:
|
||||||
old_youngest_region = self.youngest_region
|
old_youngest_region = self.youngest_region
|
||||||
self.youngest_region = region
|
self.youngest_region = region
|
||||||
|
@ -221,6 +221,9 @@ class EscapeValidator(algorithm.Visitor):
|
||||||
|
|
||||||
for name in typing_env:
|
for name in typing_env:
|
||||||
if has_region(typing_env[name]):
|
if has_region(typing_env[name]):
|
||||||
|
if name in args:
|
||||||
|
self.youngest_env[name] = self.youngest_region
|
||||||
|
else:
|
||||||
self.youngest_env[name] = Region(None) # not yet known
|
self.youngest_env[name] = Region(None) # not yet known
|
||||||
else:
|
else:
|
||||||
self.youngest_env[name] = None # lives forever
|
self.youngest_env[name] = None # lives forever
|
||||||
|
@ -237,7 +240,8 @@ class EscapeValidator(algorithm.Visitor):
|
||||||
|
|
||||||
def visit_FunctionDefT(self, node):
|
def visit_FunctionDefT(self, node):
|
||||||
self.youngest_env[node.name] = self.youngest_region
|
self.youngest_env[node.name] = self.youngest_region
|
||||||
self.visit_in_region(node, Region(node.loc), node.typing_env)
|
self.visit_in_region(node, Region(node.loc), node.typing_env,
|
||||||
|
args=node.signature_type.find().arg_names())
|
||||||
|
|
||||||
def visit_ClassDefT(self, node):
|
def visit_ClassDefT(self, node):
|
||||||
self.youngest_env[node.name] = self.youngest_region
|
self.youngest_env[node.name] = self.youngest_region
|
||||||
|
|
Loading…
Reference in New Issue