minor cleanups

master
Daniel Kolesa 2021-04-04 05:36:19 +02:00
parent 529e34d268
commit a789659387
4 changed files with 18 additions and 17 deletions

View File

@ -22,7 +22,7 @@ std::string_view codegen_state::get_str() {
} }
charbuf codegen_state::get_str_dup() { charbuf codegen_state::get_str_dup() {
charbuf buf{ts.istate}; charbuf buf{ts};
unescape_string(std::back_inserter(buf), get_str()); unescape_string(std::back_inserter(buf), get_str());
return buf; return buf;
} }
@ -217,7 +217,7 @@ static bool compilearg(
); );
static void compilelookup(codegen_state &gs, int ltype) { static void compilelookup(codegen_state &gs, int ltype) {
charbuf lookup{gs.ts.istate}; charbuf lookup{gs.ts};
gs.next_char(); gs.next_char();
switch (gs.current()) { switch (gs.current()) {
case '(': case '(':
@ -488,7 +488,7 @@ done:
} }
static bool compileblocksub(codegen_state &gs) { static bool compileblocksub(codegen_state &gs) {
charbuf lookup{gs.ts.istate}; charbuf lookup{gs.ts};
switch (gs.current()) { switch (gs.current()) {
case '(': case '(':
if (!compilearg(gs, VAL_ANY)) { if (!compilearg(gs, VAL_ANY)) {
@ -1163,7 +1163,7 @@ static void compile_and_or(
} }
static void compilestatements(codegen_state &gs, int rettype, int brak) { static void compilestatements(codegen_state &gs, int rettype, int brak) {
charbuf idname{gs.ts.istate}; charbuf idname{gs.ts};
for (;;) { for (;;) {
gs.skip_comments(); gs.skip_comments();
idname.clear(); idname.clear();

View File

@ -90,7 +90,7 @@ void var_changed(thread_state &ts, ident *id) {
auto *cimp = static_cast<command_impl *>(cid); auto *cimp = static_cast<command_impl *>(cid);
any_value val{*ts.pstate}; any_value val{*ts.pstate};
val.set_ident(id); val.set_ident(id);
cimp->call(*ts.pstate, std::span<any_value>{&val, 1}, val); cimp->call(ts, std::span<any_value>{&val, 1}, val);
} }
void ivar_impl::save_val() { void ivar_impl::save_val() {
@ -105,16 +105,17 @@ void svar_impl::save_val() {
p_override = std::move(p_storage); p_override = std::move(p_storage);
} }
void command_impl::call(state &cs, std::span<any_value> args, any_value &ret) { void command_impl::call(
auto &ts = *cs.thread_pointer(); thread_state &ts, std::span<any_value> args, any_value &ret
) {
auto idstsz = ts.idstack.size(); auto idstsz = ts.idstack.size();
try { try {
p_cb_cftv(cs, args, ret); p_cb_cftv(*ts.pstate, args, ret);
} catch (...) { } catch (...) {
ts.idstack.resize(idstsz, ident_stack{cs}); ts.idstack.resize(idstsz, ident_stack{*ts.pstate});
throw; throw;
} }
ts.idstack.resize(idstsz, ident_stack{cs}); ts.idstack.resize(idstsz, ident_stack{*ts.pstate});
} }
bool ident_is_used_arg(ident *id, thread_state &ts) { bool ident_is_used_arg(ident *id, thread_state &ts) {

View File

@ -126,7 +126,7 @@ struct command_impl: ident_impl, command {
string_ref name, string_ref args, int numargs, command_func func string_ref name, string_ref args, int numargs, command_func func
); );
void call(state &cs, std::span<any_value> args, any_value &ret); void call(thread_state &ts, std::span<any_value> args, any_value &ret);
string_ref p_cargs; string_ref p_cargs;
command_func p_cb_cftv; command_func p_cb_cftv;

View File

@ -173,14 +173,14 @@ void exec_command(
*ts.pstate, std::span{args, std::size_t(i)}, " " *ts.pstate, std::span{args, std::size_t(i)}, " "
)); ));
static_cast<command_impl *>(id)->call( static_cast<command_impl *>(id)->call(
*ts.pstate, std::span<any_value>(&tv, &tv + 1), res ts, std::span<any_value>(&tv, &tv + 1), res
); );
return; return;
} }
case 'V': case 'V':
i = std::max(i + 1, numargs); i = std::max(i + 1, numargs);
static_cast<command_impl *>(id)->call( static_cast<command_impl *>(id)->call(
*ts.pstate, std::span{args, std::size_t(i)}, res ts, std::span{args, std::size_t(i)}, res
); );
return; return;
case '1': case '1':
@ -196,7 +196,7 @@ void exec_command(
} }
++i; ++i;
static_cast<command_impl *>(id)->call( static_cast<command_impl *>(id)->call(
*ts.pstate, std::span<any_value>{args, std::size_t(i)}, res ts, std::span<any_value>{args, std::size_t(i)}, res
); );
} }
@ -1227,7 +1227,7 @@ noid:
); );
std::size_t offset = args.size() - id->get_num_args(); std::size_t offset = args.size() - id->get_num_args();
result.force_none(); result.force_none();
id->call(cs, std::span<any_value>{ id->call(ts, std::span<any_value>{
&args[offset], std::size_t(id->get_num_args()) &args[offset], std::size_t(id->get_num_args())
}, result); }, result);
force_arg(result, op & BC_INST_RET_MASK); force_arg(result, op & BC_INST_RET_MASK);
@ -1245,7 +1245,7 @@ noid:
std::size_t callargs = *code++; std::size_t callargs = *code++;
std::size_t offset = args.size() - callargs; std::size_t offset = args.size() - callargs;
result.force_none(); result.force_none();
id->call(cs, std::span{&args[offset], callargs}, result); id->call(ts, std::span{&args[offset], callargs}, result);
force_arg(result, op & BC_INST_RET_MASK); force_arg(result, op & BC_INST_RET_MASK);
args.resize(offset, any_value{cs}); args.resize(offset, any_value{cs});
continue; continue;
@ -1265,7 +1265,7 @@ noid:
tv.set_str(concat_values(cs, std::span{ tv.set_str(concat_values(cs, std::span{
&args[offset], callargs &args[offset], callargs
}, " ")); }, " "));
id->call(cs, std::span<any_value>{&tv, 1}, result); id->call(ts, std::span<any_value>{&tv, 1}, result);
} }
force_arg(result, op & BC_INST_RET_MASK); force_arg(result, op & BC_INST_RET_MASK);
args.resize(offset, any_value{cs}); args.resize(offset, any_value{cs});