diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-12 12:13:13 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-12 12:13:13 -0600 |
commit | 4d4353179e22ed441604ded8715a511406634814 (patch) | |
tree | c4d0e6b54cee0bd17aed9c267acdaeb8fb411a62 /modules | |
parent | 179321a0a3decf8b2b759160b348f4b969465089 (diff) | |
parent | 9a94353fa3644c8a99f35694c59d51708a496080 (diff) | |
download | redot-engine-4d4353179e22ed441604ded8715a511406634814.tar.gz |
Merge pull request #97218 from wenqiangwang/local_debuggger_expr_evalulation
Add support for `print` command in local (command line `-d`) debugger
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 951ae6ce99..a29bd1fdb5 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -43,6 +43,7 @@ #include "core/config/engine.h" #include "core/core_constants.h" #include "core/io/file_access.h" +#include "core/math/expression.h" #ifdef TOOLS_ENABLED #include "core/config/project_settings.h" @@ -427,7 +428,30 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> } String GDScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { - return ""; + List<String> names; + List<Variant> values; + debug_get_stack_level_locals(p_level, &names, &values, p_max_subitems, p_max_depth); + + Vector<String> name_vector; + for (const String &name : names) { + name_vector.push_back(name); + } + + Array value_array; + for (const Variant &value : values) { + value_array.push_back(value); + } + + Expression expression; + if (expression.parse(p_expression, name_vector) == OK) { + ScriptInstance *instance = debug_get_stack_level_instance(p_level); + if (instance) { + Variant return_val = expression.execute(value_array, instance->get_owner()); + return return_val.get_construct_string(); + } + } + + return String(); } void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const { |