Added support for 'print' command in local (command line -d) debugger

This commit is contained in:
Wenqiang 2024-09-19 22:35:51 -07:00
parent 0a4aedb360
commit 9a94353fa3
2 changed files with 28 additions and 4 deletions

View file

@ -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 {