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

View File

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

View File

@ -126,7 +126,7 @@ struct command_impl: ident_impl, command {
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;
command_func p_cb_cftv;

View File

@ -173,14 +173,14 @@ void exec_command(
*ts.pstate, std::span{args, std::size_t(i)}, " "
));
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;
}
case 'V':
i = std::max(i + 1, numargs);
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;
case '1':
@ -196,7 +196,7 @@ void exec_command(
}
++i;
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();
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())
}, result);
force_arg(result, op & BC_INST_RET_MASK);
@ -1245,7 +1245,7 @@ noid:
std::size_t callargs = *code++;
std::size_t offset = args.size() - callargs;
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);
args.resize(offset, any_value{cs});
continue;
@ -1265,7 +1265,7 @@ noid:
tv.set_str(concat_values(cs, std::span{
&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);
args.resize(offset, any_value{cs});