don't use print_stack in repl

master
Daniel Kolesa 2021-05-10 01:16:27 +02:00
parent 1739cbed6e
commit a8d2bfc442
3 changed files with 10 additions and 6 deletions

View File

@ -349,7 +349,7 @@ float_type any_value::get_float() const {
case value_type::FLOAT:
return p_stor.f;
case value_type::INTEGER:
return p_stor.i;
return float_type(p_stor.i);
case value_type::STRING:
return parse_float(str_managed_view(p_stor.s));
default:

View File

@ -172,7 +172,7 @@ bool exec_alias(
auto oldflags = ts.ident_flags;
ts.ident_flags = aast.flags;
any_value cv;
cv.set_integer(callargs);
cv.set_integer(integer_type(callargs));
anargs->set_raw_value(*ts.pstate, std::move(cv));
ident_link aliaslink = {a, ts.callstack, uargs};
ts.callstack = &aliaslink;

View File

@ -253,10 +253,14 @@ static bool do_call(cs::state &cs, std::string_view line, bool file = false) {
std::printf(
"%s%s\n", !is_lnum ? "stdin: " : "stdin:", e.what().data()
);
if (e.stack()) {
std::string str;
cs::print_stack(std::back_inserter(str), e.stack());
std::printf("%s\n", str.data());
std::size_t pindex = 1;
for (auto *nd = e.stack(); nd; nd = nd->next) {
std::printf(" ");
if ((nd->index == 1) && (pindex > 2)) {
std::printf("..");
}
pindex = nd->index;
std::printf("%zu) %s\n", nd->index, nd->id->name().data());
}
return false;
}