Prajwal Suhas P wrote:
> This is the patch for ticket #203.
Great! You appear to be on the right track. Here's some feedback.
> I came out with this, but i did not understand the need for
> freeze_endpoints.I still haven't supplied the complete patch with all
> the tests.This is for confirming whether i'm in the right direction.
ForFromStatNode is used in two situations in Cython code; in the
Cython-specific syntax
cdef int i
for i from start <= i < end [by step]:
...
and in normal syntax
cdef int i
for i in range([start,] end, [step]):
...
In the former case, end should NOT be frozen (i.e. if it is a function
call it should be called again for every iteration, if it is a variable
then changes to it in the loop body should modify the number of
iterations, etc.).
Therefore, it is necesarry to have a flag which is set in the latter
case but not in the former case. See my original post for when and how
the flag should be set.
> diff -r e2365a6d00b8 Cython/Compiler/Nodes.py
> --- a/Cython/Compiler/Nodes.py Tue Mar 17 07:32:51 2009 +0100
> +++ b/Cython/Compiler/Nodes.py Wed Mar 18 00:20:19 2009 +0530
> @@ -3971,11 +3971,13 @@
> code.putln("if (%s%s %s %s) {" % (
> self.bound1.result(), offset, self.relation2,
> self.bound2.result()
> ))
> + temp_for_loop_bound =
> code.funcstate.allocate_temp(PyrexTypes.c_char_ptr_type, manage_ref=False)
Why do you use c_char_ptr_type here? You must use the right type, which
you can look up from the "entry" attributes in the corresponding bounds
nodes (do a "print self.dump()" to see the tree; and then find the types
you need there).
> + code.putln("%s = %s;" % (temp_for_loop_bound,
> self.bound2.result()))
This only tackles the endpoint. What if the start is a function call, or
step is a function call?
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev