🎨 add global variable info in global dump
This commit is contained in:
parent
cf2323623b
commit
99298b86ab
|
@ -31,9 +31,11 @@ void vm::vm_init_enrty(const std::vector<std::string>& strs,
|
||||||
|
|
||||||
/* init vm globals */
|
/* init vm globals */
|
||||||
auto map_instance = ngc.alloc(vm_type::vm_map);
|
auto map_instance = ngc.alloc(vm_type::vm_map);
|
||||||
|
global_symbol_name.resize(global_symbol.size());
|
||||||
global[global_symbol.at("globals")] = map_instance;
|
global[global_symbol.at("globals")] = map_instance;
|
||||||
for(const auto& i : global_symbol) {
|
for(const auto& i : global_symbol) {
|
||||||
map_instance.map().mapper[i.first] = global + i.second;
|
map_instance.map().mapper[i.first] = global + i.second;
|
||||||
|
global_symbol_name[i.second] = i.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init vm arg */
|
/* init vm arg */
|
||||||
|
@ -370,6 +372,14 @@ void vm::global_state() {
|
||||||
std::clog << " 0x" << std::hex << std::setw(8)
|
std::clog << " 0x" << std::hex << std::setw(8)
|
||||||
<< std::setfill('0') << i << std::dec
|
<< 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]);
|
value_info(global[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ protected:
|
||||||
/* values used for debugger */
|
/* values used for debugger */
|
||||||
const std::string* files = nullptr; // file name list
|
const std::string* files = nullptr; // file name list
|
||||||
const opcode* bytecode = nullptr; // bytecode buffer address
|
const opcode* bytecode = nullptr; // bytecode buffer address
|
||||||
|
std::vector<std::string> global_symbol_name; // global symbol name
|
||||||
|
|
||||||
/* variables for repl mode */
|
/* variables for repl mode */
|
||||||
bool is_repl_mode = false;
|
bool is_repl_mode = false;
|
||||||
|
|
Loading…
Reference in New Issue