🎨 add global variable info in global dump

This commit is contained in:
ValKmjolnir 2024-08-03 14:53:41 +08:00
parent cf2323623b
commit 99298b86ab
2 changed files with 33 additions and 22 deletions

View File

@ -31,9 +31,11 @@ void vm::vm_init_enrty(const std::vector<std::string>& strs,
/* init vm globals */
auto map_instance = ngc.alloc(vm_type::vm_map);
global_symbol_name.resize(global_symbol.size());
global[global_symbol.at("globals")] = map_instance;
for(const auto& i : global_symbol) {
map_instance.map().mapper[i.first] = global + i.second;
global_symbol_name[i.second] = i.first;
}
/* init vm arg */
@ -370,6 +372,14 @@ void vm::global_state() {
std::clog << " 0x" << std::hex << std::setw(8)
<< std::setfill('0') << i << std::dec
<< " ";
auto name = global_symbol_name[i];
if (name.length()>=10) {
name = name.substr(0, 7) + "...";
} else {
}
std::clog << "| " << std::left << std::setw(10)
<< std::setfill(' ') << name << " ";
value_info(global[i]);
}
}

View File

@ -42,6 +42,7 @@ protected:
/* values used for debugger */
const std::string* files = nullptr; // file name list
const opcode* bytecode = nullptr; // bytecode buffer address
std::vector<std::string> global_symbol_name; // global symbol name
/* variables for repl mode */
bool is_repl_mode = false;