# HG changeset patch # User Max Brister # Date 1345930999 21600 # Node ID c27a1e131b16b7c2a1a3b2149921362377239780 # Parent 2c0259dc1a8216e077aa060ad7f87b6c579b023c pt-jit.cc (jit_convert::visit_simple_for_command): Fix block order diff -r 2c0259dc1a82 -r c27a1e131b16 libinterp/interp-core/pt-jit.cc --- a/libinterp/interp-core/pt-jit.cc Sat Aug 25 14:16:30 2012 -0600 +++ b/libinterp/interp-core/pt-jit.cc Sat Aug 25 15:43:19 2012 -0600 @@ -243,8 +243,6 @@ vmap[iter_name] = iterator; jit_block *body = factory.create ("for_body"); - blocks.push_back (body); - jit_block *tail = factory.create ("for_tail"); // do control expression, iter init, and condition check in prev_block (block) @@ -261,6 +259,8 @@ iterator); block->append (check); block->append (factory.create (check, body, tail)); + + blocks.push_back (body); block = body; // compute the syntactical iterator @@ -2024,4 +2024,22 @@ %!assert (test_overload (1), 1); %!assert (test_overload ([1 2]), [1 2]); +%!function a = bubble (a = [3 2 1]) +%! swapped = 1; +%! n = length (a); +%! while (swapped) +%! swapped = 0; +%! for i = 1:n-1 +%! if a(i) > a(i + 1) +%! swapped = 1; +%! temp = a(i); +%! a(i) = a(i + 1); +%! a(i + 1) = temp; +%! endif +%! endfor +%! endwhile +%!endfunction + +%!assert (bubble (), [1 2 3]); + */