Mercurial > hg > octave-terminal
changeset 15233:c27a1e131b16
pt-jit.cc (jit_convert::visit_simple_for_command): Fix block order
author | Max Brister <max@2bass.com> |
---|---|
date | Sat, 25 Aug 2012 15:43:19 -0600 |
parents | 2c0259dc1a82 |
children | ffa0b85a87f4 |
files | libinterp/interp-core/pt-jit.cc |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interp-core/pt-jit.cc +++ b/libinterp/interp-core/pt-jit.cc @@ -243,8 +243,6 @@ vmap[iter_name] = iterator; jit_block *body = factory.create<jit_block> ("for_body"); - blocks.push_back (body); - jit_block *tail = factory.create<jit_block> ("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<jit_cond_branch> (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]); + */