values can get data from namespace type

This commit is contained in:
ValKmjolnir 2023-10-21 18:13:52 +08:00
parent dfcccd4523
commit 1e1ab37e83
3 changed files with 25 additions and 11 deletions

View File

@ -405,13 +405,19 @@ var builtin_char(context* ctx, gc* ngc) {
var builtin_values(context* ctx, gc* ngc) { var builtin_values(context* ctx, gc* ngc) {
auto hash = ctx->localr[1]; auto hash = ctx->localr[1];
if (hash.type!=vm_hash) { if (hash.type!=vm_hash && hash.type!=vm_map) {
return nas_err("values", "\"hash\" must be hash"); return nas_err("values", "\"hash\" must be hash or namespace");
} }
var vec = ngc->alloc(vm_vec); auto vec = ngc->alloc(vm_vec);
auto& v = vec.vec().elems; auto& v = vec.vec().elems;
for(auto& i : hash.hash().elems) { if (hash.type==vm_hash) {
v.push_back(i.second); for(auto& i : hash.hash().elems) {
v.push_back(i.second);
}
} else {
for(auto& i : hash.map().mapper) {
v.push_back(*i.second);
}
} }
return vec; return vec;
} }

View File

@ -200,7 +200,10 @@ void dbg::interact() {
} else if (res.size()==1) { } else if (res.size()==1) {
switch(get_cmd_type(res[0])) { switch(get_cmd_type(res[0])) {
case dbg_cmd::cmd_help: help(); break; case dbg_cmd::cmd_help: help(); break;
case dbg_cmd::cmd_backtrace: trace_back(); break; case dbg_cmd::cmd_backtrace:
function_call_trace();
trace_back();
break;
case dbg_cmd::cmd_continue: return; case dbg_cmd::cmd_continue: return;
case dbg_cmd::cmd_list_file: list_file(); break; case dbg_cmd::cmd_list_file: list_file(); break;
case dbg_cmd::cmd_global: global_state(); break; case dbg_cmd::cmd_global: global_state(); break;
@ -240,13 +243,18 @@ void dbg::run(
set_detail_report_info(true); set_detail_report_info(true);
do_profiling = profile || show_all_prof_result; do_profiling = profile || show_all_prof_result;
next = true;
const auto& file_list = linker.get_file_list(); const auto& file_list = linker.get_file_list();
fsize = file_list.size(); fsize = file_list.size();
init(gen.strs(), gen.nums(), gen.natives(), init(
gen.codes(), gen.globals(), gen.strs(),
file_list, argv); gen.nums(),
gen.natives(),
gen.codes(),
gen.globals(),
file_list,
argv
);
data.init(file_list); data.init(file_list);
std::vector<u32> code; std::vector<u32> code;

View File

@ -158,7 +158,7 @@ private:
public: public:
dbg(): dbg():
next(false), fsize(0), next(true), fsize(0),
bk_fidx(0), bk_line(0), bk_fidx(0), bk_line(0),
do_profiling(false) {} do_profiling(false) {}
void run( void run(