Mercurial > octave
changeset 32327:55ea70c8d00a
VM Remove forgotten feature block for nested functions (bug #64703)
Also allow compiling inline functions.
* libinterp/parse-tree/pt-bytecode-walk.cc: Remove check for nested, inline
* test/compile/bytecode_nested.m: Update tests
author | Petter T. <petter.vilhelm@gmail.com> |
---|---|
date | Sat, 23 Sep 2023 08:03:06 -0400 |
parents | 084fc89a253b |
children | dfcbe2dcd8e2 |
files | libinterp/parse-tree/pt-bytecode-walk.cc test/compile/bytecode_nested.m |
diffstat | 2 files changed, 23 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-bytecode-walk.cc Fri Sep 22 09:58:42 2023 +0200 +++ b/libinterp/parse-tree/pt-bytecode-walk.cc Sat Sep 23 08:03:06 2023 -0400 @@ -60,8 +60,6 @@ if (ufn.is_classdef_constructor ()) error ("Classdef constructors are not supported by the VM yet"); // Needs special handling - if (ufn.is_inline_function () || ufn.is_nested_function ()) - error ("Inlined or scoped functions are not supported by the VM yet"); // Begin with clearing the old bytecode, if any ufn.clear_bytecode (); @@ -147,8 +145,6 @@ { if (ufn.is_classdef_constructor ()) error ("Classdef constructors are not supported by the VM yet"); // Needs special handling - if (ufn.is_inline_function () || ufn.is_nested_function ()) - error ("Inlined or scoped functions are not supported by the VM yet"); // Begin with clearing the old bytecode, if any ufn.clear_bytecode ();
--- a/test/compile/bytecode_nested.m Fri Sep 22 09:58:42 2023 +0200 +++ b/test/compile/bytecode_nested.m Sat Sep 23 08:03:06 2023 -0400 @@ -331,6 +331,15 @@ h4 = sub_returns_nested_fn2; assert (h4 () == 1) assert (h4 () == 2) + + % Try a function with both nested and anonymous functions (bug #64703) + assert (sub_nestandanon (2) == [6; 8]) + + % Try some legacy inline functions + h1i = inline ("x + 1"); + assert (h1i (2) == 3) + h2i = inline ("__vm_is_executing__()"); + assert (h2i() == __vm_is_executing__); end function subby @@ -369,4 +378,17 @@ end h1 = nested_fn1 (); -end \ No newline at end of file +end + +function retval = sub_nestandanon(x) + retval = zeros(2,1); + + f1 = @(x) 3 .* x; + retval(1) = f1(x); + + function [ret] = f2(x) + ret = 4 .* x; + endfunction + + retval(2) = f2(x); +endfunction