implement means to learn about a functions source

This implements a way to use the `functions` command to perform
introspection to learn about the characteristics of a function. Such as
where it came from.

Fixes #3295
This commit is contained in:
Kurtis Rader
2017-01-09 22:49:33 -08:00
parent 2be1288cac
commit 2e38cf2a4b
8 changed files with 138 additions and 12 deletions

View File

@@ -259,7 +259,7 @@ std::map<wcstring, env_var_t> function_get_inherit_vars(const wcstring &name) {
return func ? func->inherit_vars : std::map<wcstring, env_var_t>();
}
int function_get_shadow_scope(const wcstring &name) {
bool function_get_shadow_scope(const wcstring &name) {
scoped_lock locker(functions_lock);
const function_info_t *func = function_get(name);
return func ? func->shadow_scope : false;
@@ -325,6 +325,12 @@ const wchar_t *function_get_definition_file(const wcstring &name) {
return func ? func->definition_file : NULL;
}
bool function_is_autoloaded(const wcstring &name) {
scoped_lock locker(functions_lock);
const function_info_t *func = function_get(name);
return func->is_autoload;
}
int function_get_definition_offset(const wcstring &name) {
scoped_lock locker(functions_lock);
const function_info_t *func = function_get(name);