view test/compile/bytecode_script_topscope_assert.m @ 32370:9155a67023bc

VM Support globals in scripts properly (bug #64705) Fix globalization and deglobalization in scripts with the same top scope. * test/compile/bytecode.tst: Update tests * test/compile/module.mk: Add new files * test/compile/bytecode_script_topscope_setup.m: New * test/compile/bytecode_script_topscope_assert.m: New * test/compile/bytecode_script_topscope.m: New * libinterp/corefcn/compile.cc: Support clearing scripts with __vm_compile__ * libinterp/corefcn/stack-frame.cc: Reorganize bytecode dynamic stackframe to support scripts. * libinterp/octave-value/ov-ref.cc: New function to notify globalness change * libinterp/octave-value/ov-ref.h: * libinterp/octave-value/ov-usr-fcn.cc: Limit script vm execution to top or vm frames * libinterp/octave-value/ov.h: base_value_stack_frame friend to access is_ref * libinterp/parse-tree/pt-bytecode-vm.cc: Remove inaccurate comment * libinterp/parse-tree/pt-bytecode-walk.cc: Add function name to scope in cleaner way. Set m_n_orig_scope_size. * libinterp/parse-tree/pt-bytecode.h: Field m_n_orig_scope_size for original amount of symbols in scope
author Petter T.
date Fri, 22 Sep 2023 15:46:36 +0200
parents
children 67945d0339cf
line wrap: on
line source

function bytecode_script_topscope_assert (place = "base")
 evalin (place, "assert (isglobal ('glb_a'))");
 evalin (place, "assert (isglobal ('glb_b'))");
 evalin (place, "assert (!isglobal ('glb_c'))"); % Unglobalized in script
 evalin (place, "assert (isglobal ('glb_d'))");
 evalin (place, "assert (isglobal ('glb_e'))");
 evalin (place, "assert (glb_a == 2)");
 evalin (place, "assert (glb_b == 33)");
 evalin (place, "assert (!exist ('glb_c'))");
 evalin (place, "assert (glb_d == 55)");
 evalin (place, "assert (glb_e == 6)"); % Added in the script
 evalin (place, "assert (local_a == 102)"); % Local added in script
 evalin (place, "assert (local_b == 113)");
 evalin (place, "assert (!exist ('local_c'))"); % Cleared in script
 evalin (place, "assert (!exist ('local_d'))"); % Cleared in script
 evalin (place, "assert (!exist ('local_e'))"); % Cleared in script
 evalin (place, "assert (!exist ('local_f'))"); % Cleared in script
 evalin (place, "assert (!exist ('local_g'))"); % Cleared in script

 evalin (place, "clear global glb_a glb_b glb_c glb_d glb_e glb_f");
 evalin (place, "clear local_a local_b local_c local_d local_e local_f local_g");
endfunction