Mercurial > octave
changeset 32719:90d3b8ad2a98 bytecode-interpreter
Implement inputname for bytecode interpreter (bug #65029)
The way inputname is resolved was changed in the main branch.
Non-bytecode user function frames called from a bytecode frame
need to lookup inputname in the caller bytecode frame.
* stack-frame.cc: Implement inputname() for bytecode frames
author | Petter T. <petter.vilhelm@gmail.com> |
---|---|
date | Wed, 10 Jan 2024 20:05:12 +0100 |
parents | eca3683c88dc |
children | 925c2d47edb7 |
files | libinterp/corefcn/stack-frame.cc |
diffstat | 1 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/stack-frame.cc Wed Jan 10 15:07:40 2024 -0500 +++ b/libinterp/corefcn/stack-frame.cc Wed Jan 10 20:05:12 2024 +0100 @@ -1065,12 +1065,22 @@ return varref_internal (local_offset, deref_refs); } - std::string inputname (int /*n*/, bool /*ids_only*/) const + std::string inputname (int n, bool ids_only) const { - // FIXME: To make inputname work properly, this function must be - // defined. - - return ""; + std::string name; + + octave_value ov_arg_names = get_auto_fcn_var (stack_frame::ARG_NAMES); + Array<std::string> arg_names = ov_arg_names.cellstr_value (); + + if (n >= 0 && n < arg_names.numel ()) + { + name = arg_names(n); + + if (ids_only && ! m_static_link->is_variable (name)) + name = ""; + } + + return name; } void mark_scope (const symbol_record& sym, @@ -4375,8 +4385,18 @@ { std::string name; - Array<std::string> arg_names - = m_auto_vars.at (stack_frame::ARG_NAMES).cellstr_value (); + Array<std::string> arg_names; + + auto parent_frame = parent_link (); + + if (parent_frame && parent_frame->is_bytecode_fcn_frame ()) + { + // The bytecode interpreter does not set ARG_NAMES for called non bytecode functions, + // since the bytecode interpreter looks up ARG_NAMES in the calling stack frame. + arg_names = parent_frame->get_active_bytecode_call_arg_names ().cellstr_value (); + } + else + arg_names = m_auto_vars.at (stack_frame::ARG_NAMES).cellstr_value (); if (n >= 0 && n < arg_names.numel ()) {