[Cython] Control flow graph
Stefan Behnel
stefan_ml at behnel.de
Tue Feb 22 21:27:18 CET 2011
Vitja Makarov, 20.02.2011 18:23:
> 2011/2/16 Vitja Makarov:
>> Hmm... both python and codespeaks in the thread
Yes, we should keep it to cython-devel only. Sorry for mixing it up.
>> Here is my commit it's mostly broken now but anyway
>> https://github.com/vitek/cython/commit/5579b23c3c1c06981331b6427a73e5cb19980b8a
Flow control support is large enough to merit its own module. Not sure how
'smart' git is here, but you can always keep the history by explicitly
copying ParseTreeTransforms.py to FlowControl.py and removing the unrelated
sections from both files.
You are duplicating some code from the type inferencer. We might want to
clean that up at some point. However, given that flow control analysis will
allow us to improve the type inferencer, I think it's best to keep this
code in the FCA part.
> I've update stuff:
> - algo for finding definitions
> - warnings for uninitialized and may be uninitialised use
> - few test cases
That looks very nice so far. Any idea how well it scales?
> Trying to compile ParseTreeTransforms.py I've found this for example:
>
> warning: Cython/Compiler/ParseTreeTransforms.py:1182:27: Variable
> 'template' may be used uninitialized
>
> def create_Property(self, entry):
> if entry.visibility == 'public':
> if entry.type.is_pyobject:
> template = self.basic_pyobject_property
> else:
> template = self.basic_property
> elif entry.visibility == 'readonly':
> template = self.basic_property_ro
> property = template.substitute({
> u"ATTR": ExprNodes.AttributeNode(pos=entry.pos,
>
> obj=ExprNodes.NameNode(pos=entry.pos, name="self"),
> attribute=entry.name),
> }, pos=entry.pos).stats[0]
Ok, I guess that code generally works, but it's better to get rid of the
code smell.
Stefan
More information about the cython-devel
mailing list