comparison libinterp/corefcn/fcn-info.cc @ 31110:670a0d878af1

eliminate WHO arguments from interpreter-private functions * interpreter-private.h, inpterpreter-private.cc (__get_interpreter__, __get_dynamic_loader__, __get_error_system__, __get_gh_manager__, __get_help_system__, __get_input_system__, __get_load_path__, __get_load_save_system__, __get_event_manager__, __get_output_system__, __get_type_info__, __get_symbol_table__, __get_current_scope__, __require_current_scope__, __get_evaluator__, __get_bp_table__, __get_child_list__, __get_cdef_manager__, __get_display_info__, __get_gtk_manager__): Eliminate WHO argument. Previously, it was never displayed by __get_interpreter__. And, as pointed out by Petter Tomner in patch #10216, passing a std::string object could have performance issues. (__get_interpreter__): Eliminate useless call to error. Display message to std::cerr then abort.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Jun 2022 12:48:59 -0400
parents 243b51ec9ff0
children
comparison
equal deleted inserted replaced
31109:90549b20fb28 31110:670a0d878af1
52 octave_value 52 octave_value
53 fcn_info::fcn_info_rep::load_private_function (const std::string& dir_name) 53 fcn_info::fcn_info_rep::load_private_function (const std::string& dir_name)
54 { 54 {
55 octave_value retval; 55 octave_value retval;
56 56
57 load_path& lp 57 load_path& lp = __get_load_path__ ();
58 = __get_load_path__ ("fcn_info::fcn_info_rep::load_private_function");
59 58
60 std::string file_name = lp.find_private_fcn (dir_name, name); 59 std::string file_name = lp.find_private_fcn (dir_name, name);
61 60
62 if (file_name.empty ()) 61 if (file_name.empty ())
63 return retval; 62 return retval;
96 { 95 {
97 octave_value retval; 96 octave_value retval;
98 97
99 std::string dir_name; 98 std::string dir_name;
100 99
101 load_path& lp 100 load_path& lp = __get_load_path__ ();
102 = __get_load_path__ ("fcn_info::fcn_info_rep::load_class_constructor");
103 101
104 std::string file_name = lp.find_method (name, name, dir_name, package_name); 102 std::string file_name = lp.find_method (name, name, dir_name, package_name);
105 103
106 if (! file_name.empty ()) 104 if (! file_name.empty ())
107 { 105 {
157 155
158 if (full_name () == dispatch_type) 156 if (full_name () == dispatch_type)
159 retval = load_class_constructor (); 157 retval = load_class_constructor ();
160 else 158 else
161 { 159 {
162 cdef_manager& cdm 160 cdef_manager& cdm = __get_cdef_manager__ ();
163 = __get_cdef_manager__ ("fcn_info::fcn_info_rep::load_class_method");
164 161
165 retval = cdm.find_method_symbol (name, dispatch_type); 162 retval = cdm.find_method_symbol (name, dispatch_type);
166 163
167 if (! retval.is_defined ()) 164 if (! retval.is_defined ())
168 { 165 {
169 std::string dir_name; 166 std::string dir_name;
170 167
171 load_path& lp = __get_load_path__ ("fcn_info::fcn_info_rep::load_class_method"); 168 load_path& lp = __get_load_path__ ();
172 169
173 std::string file_name = lp.find_method (dispatch_type, name, 170 std::string file_name = lp.find_method (dispatch_type, name,
174 dir_name); 171 dir_name);
175 172
176 if (! file_name.empty ()) 173 if (! file_name.empty ())
194 191
195 if (retval.is_undefined ()) 192 if (retval.is_undefined ())
196 { 193 {
197 // Search parent classes 194 // Search parent classes
198 195
199 symbol_table& symtab 196 symbol_table& symtab = __get_symbol_table__ ();
200 = __get_symbol_table__ ("fcn_info::fcn_info_rep::load_class_method");
201 197
202 const std::list<std::string>& plist 198 const std::list<std::string>& plist
203 = symtab.parent_classes (dispatch_type); 199 = symtab.parent_classes (dispatch_type);
204 200
205 auto it = plist.begin (); 201 auto it = plist.begin ();
301 if (builtin_type == btyp_unknown) 297 if (builtin_type == btyp_unknown)
302 { 298 {
303 // There's a non-builtin class in the argument list. 299 // There's a non-builtin class in the argument list.
304 dispatch_type = args(i).class_name (); 300 dispatch_type = args(i).class_name ();
305 301
306 symbol_table& symtab = __get_symbol_table__ ("get_dispatch_type"); 302 symbol_table& symtab = __get_symbol_table__ ();
307 303
308 for (int j = i+1; j < n; j++) 304 for (int j = i+1; j < n; j++)
309 { 305 {
310 octave_value arg = args(j); 306 octave_value arg = args(j);
311 307
354 fcn_info::fcn_info_rep::find (const symbol_scope& scope, 350 fcn_info::fcn_info_rep::find (const symbol_scope& scope,
355 const octave_value_list& args) 351 const octave_value_list& args)
356 { 352 {
357 symbol_scope search_scope 353 symbol_scope search_scope
358 = (scope 354 = (scope
359 ? scope : __get_current_scope__("fcn_info::fcn_info_rep::find")); 355 ? scope : __get_current_scope__ ());
360 356
361 octave_value retval = xfind (search_scope, args); 357 octave_value retval = xfind (search_scope, args);
362 358
363 if (retval.is_undefined ()) 359 if (retval.is_undefined ())
364 { 360 {
365 // It is possible that the user created a file on the fly since 361 // It is possible that the user created a file on the fly since
366 // the last prompt or chdir, so try updating the load path and 362 // the last prompt or chdir, so try updating the load path and
367 // searching again. 363 // searching again.
368 364
369 load_path& lp = __get_load_path__ ("fcn_info::fcn_info_rep::find"); 365 load_path& lp = __get_load_path__ ();
370 366
371 lp.update (); 367 lp.update ();
372 368
373 retval = xfind (search_scope, args); 369 retval = xfind (search_scope, args);
374 } 370 }
523 // because load_fcn_file looks at the name to 519 // because load_fcn_file looks at the name to
524 // decide whether it came from a relative lookup. 520 // decide whether it came from a relative lookup.
525 521
526 if (! dispatch_type.empty ()) 522 if (! dispatch_type.empty ())
527 { 523 {
528 load_path& lp 524 load_path& lp = __get_load_path__ ();
529 = __get_load_path__ ("out_of_date_check");
530 525
531 file = lp.find_method (dispatch_type, nm, 526 file = lp.find_method (dispatch_type, nm,
532 dir_name, pack); 527 dir_name, pack);
533 528
534 if (file.empty ()) 529 if (file.empty ())
535 { 530 {
536 std::string s_name; 531 std::string s_name;
537 std::string s_pack; 532 std::string s_pack;
538 533
539 symbol_table& symtab 534 symbol_table& symtab = __get_symbol_table__ ();
540 = __get_symbol_table__ ("out_of_date_check");
541 535
542 const std::list<std::string>& plist 536 const std::list<std::string>& plist
543 = symtab.parent_classes (dispatch_type); 537 = symtab.parent_classes (dispatch_type);
544 538
545 std::list<std::string>::const_iterator it 539 std::list<std::string>::const_iterator it
564 } 558 }
565 559
566 // Maybe it's an autoload? 560 // Maybe it's an autoload?
567 if (file.empty ()) 561 if (file.empty ())
568 { 562 {
569 tree_evaluator& tw 563 tree_evaluator& tw = __get_evaluator__ ();
570 = __get_evaluator__ ("out_of_data_check");
571 564
572 file = tw.lookup_autoload (nm); 565 file = tw.lookup_autoload (nm);
573 } 566 }
574 567
575 if (file.empty ()) 568 if (file.empty ())
576 { 569 {
577 load_path& lp 570 load_path& lp = __get_load_path__ ();
578 = __get_load_path__ ("out_of_date_check");
579 file = lp.find_fcn (nm, dir_name, pack); 571 file = lp.find_fcn (nm, dir_name, pack);
580 } 572 }
581 } 573 }
582 574
583 if (! file.empty ()) 575 if (! file.empty ())
646 638
647 // If the function has been replaced then clear any 639 // If the function has been replaced then clear any
648 // breakpoints associated with it 640 // breakpoints associated with it
649 if (clear_breakpoints) 641 if (clear_breakpoints)
650 { 642 {
651 bp_table& bptab 643 bp_table& bptab = __get_bp_table__ ();
652 = __get_bp_table__ ("out_of_date_check");
653 644
654 bptab.remove_all_breakpoints_from_function (canonical_nm, 645 bptab.remove_all_breakpoints_from_function (canonical_nm,
655 true); 646 true);
656 } 647 }
657 } 648 }
855 octave_value 846 octave_value
856 fcn_info::fcn_info_rep::builtin_find (const symbol_scope& scope) 847 fcn_info::fcn_info_rep::builtin_find (const symbol_scope& scope)
857 { 848 {
858 symbol_scope search_scope 849 symbol_scope search_scope
859 = (scope 850 = (scope
860 ? scope : __get_current_scope__("fcn_info::fcn_info_rep::find")); 851 ? scope : __get_current_scope__ ());
861 852
862 octave_value retval = x_builtin_find (search_scope); 853 octave_value retval = x_builtin_find (search_scope);
863 854
864 if (! retval.is_defined ()) 855 if (! retval.is_defined ())
865 { 856 {
866 // It is possible that the user created a file on the fly since 857 // It is possible that the user created a file on the fly since
867 // the last prompt or chdir, so try updating the load path and 858 // the last prompt or chdir, so try updating the load path and
868 // searching again. 859 // searching again.
869 860
870 load_path& lp = __get_load_path__ ("fcn_info::fcn_info_rep::builtin_find"); 861 load_path& lp = __get_load_path__ ();
871 862
872 lp.update (); 863 lp.update ();
873 864
874 retval = x_builtin_find (search_scope); 865 retval = x_builtin_find (search_scope);
875 } 866 }
1015 if (autoload_function.is_defined ()) 1006 if (autoload_function.is_defined ())
1016 out_of_date_check (autoload_function); 1007 out_of_date_check (autoload_function);
1017 1008
1018 if (! autoload_function.is_defined ()) 1009 if (! autoload_function.is_defined ())
1019 { 1010 {
1020 tree_evaluator& tw 1011 tree_evaluator& tw = __get_evaluator__ ();
1021 = __get_evaluator__ ("fcn_info::fcn_info_rep::x_builtin_find");
1022 1012
1023 std::string file_name = tw.lookup_autoload (name); 1013 std::string file_name = tw.lookup_autoload (name);
1024 1014
1025 if (! file_name.empty ()) 1015 if (! file_name.empty ())
1026 { 1016 {
1049 1039
1050 if (function_on_path.is_undefined ()) 1040 if (function_on_path.is_undefined ())
1051 { 1041 {
1052 std::string dir_name; 1042 std::string dir_name;
1053 1043
1054 load_path& lp 1044 load_path& lp = __get_load_path__ ();
1055 = __get_load_path__ ("fcn_info::fcn_info_rep::find_user_function");
1056 1045
1057 1046
1058 std::string file_name = lp.find_fcn (name, dir_name, package_name); 1047 std::string file_name = lp.find_fcn (name, dir_name, package_name);
1059 1048
1060 if (! file_name.empty ()) 1049 if (! file_name.empty ())
1077 //if (package.is_defined ()) 1066 //if (package.is_defined ())
1078 // out_of_date_check (package); 1067 // out_of_date_check (package);
1079 1068
1080 if (package.is_undefined ()) 1069 if (package.is_undefined ())
1081 { 1070 {
1082 cdef_manager& cdm 1071 cdef_manager& cdm = __get_cdef_manager__ ();
1083 = __get_cdef_manager__ ("fcn_info::fcn_info_rep::find_package");
1084 1072
1085 package = cdm.find_package_symbol (full_name ()); 1073 package = cdm.find_package_symbol (full_name ());
1086 } 1074 }
1087 1075
1088 return package; 1076 return package;