comparison libinterp/octave-value/ov-builtin.cc @ 30919:4ed7dfe28584

move eval of anon fcn handles and built-in and mex functions to pt-eval.cc For consistency with the evaluation of user-defined functions and scripts, move the evaluation of anonymous function handles and built-in and mex functions to the tree_evaluator class in pt-eval.cc. * pt-eval.h, pt-eval.cc (tree_evaluator::evaluate_anon_fcn_handle, tree_evaluator::execute_builtin_function, tree_evaluator::execute_mex_function): New functions extracted from tree_anon_fcn_handle::evalueate, octave_builtin::execute and octave_mex_function::execute, respectively. * ov-builtin.cc (octave_builtin::execute): Forward to tree_evaluator::execute_builtin_function. * ov-mex-fcn.cc (octave_mex_function::execute): Forward to tree_evaluator::execute_mex_function. * pt-fcn-handle.cc (tree_anon_fcn_handle::evaluate): Forward to tree_evaluator::evaluate_anon_fcn_handle. * mex.cc: Move call_mex inside octave namespace. * mex-private.h: New file. * libinterp/corefcn/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Fri, 08 Apr 2022 14:11:05 -0400
parents 796f54d4ddbf
children 597f3ee61a48
comparison
equal deleted inserted replaced
30918:297f32524dd8 30919:4ed7dfe28584
44 44
45 octave_value_list 45 octave_value_list
46 octave_builtin::execute (octave::tree_evaluator& tw, int nargout, 46 octave_builtin::execute (octave::tree_evaluator& tw, int nargout,
47 const octave_value_list& args) 47 const octave_value_list& args)
48 { 48 {
49 octave_value_list retval; 49 return tw.execute_builtin_function (*this, nargout, args);
50
51 if (args.has_magic_colon ())
52 error ("invalid use of colon in function argument list");
53
54 octave::profiler& profiler = tw.get_profiler ();
55
56 octave::profiler::enter<octave_builtin> block (profiler, *this);
57
58 if (m_fcn)
59 retval = (*m_fcn) (args, nargout);
60 else
61 {
62 octave::interpreter& interp
63 = octave::__get_interpreter__ ("octave_builtin::call");
64
65 retval = (*m_meth) (interp, args, nargout);
66 }
67
68 // Do not allow null values to be returned from functions.
69 // FIXME: perhaps true builtins should be allowed?
70
71 retval.make_storable_values ();
72
73 // Fix the case of a single undefined value.
74 // This happens when a compiled function uses
75 //
76 // octave_value retval;
77 //
78 // instead of
79 //
80 // octave_value_list retval;
81 //
82 // the idiom is very common, so we solve that here.
83
84 if (retval.length () == 1 && retval.xelem (0).is_undefined ())
85 retval.clear ();
86
87 return retval;
88 } 50 }
89 51
90 octave_builtin::fcn 52 octave_builtin::fcn
91 octave_builtin::function (void) const 53 octave_builtin::function (void) const
92 { 54 {