Added support for 'print' command in local (command line -d) debugger
This commit is contained in:
parent
0a4aedb360
commit
9a94353fa3
2 changed files with 28 additions and 4 deletions
|
@ -208,10 +208,10 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
|
|||
print_variables(members, values, variable_prefix);
|
||||
|
||||
} else if (line.begins_with("p") || line.begins_with("print")) {
|
||||
if (line.get_slice_count(" ") <= 1) {
|
||||
print_line("Usage: print <expre>");
|
||||
if (line.find_char(' ') < 0) {
|
||||
print_line("Usage: print <expression>");
|
||||
} else {
|
||||
String expr = line.get_slicec(' ', 2);
|
||||
String expr = line.split(" ", true, 1)[1];
|
||||
String res = script_lang->debug_parse_stack_level_expression(current_frame, expr);
|
||||
print_line(res);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue