remove the auxiliary run_<type> APIs, they are fairly useless now
parent
d626fba537
commit
4068c96ec2
|
@ -463,22 +463,6 @@ struct OSTD_EXPORT cs_state {
|
|||
void reset_var(std::string_view name);
|
||||
void touch_var(std::string_view name);
|
||||
|
||||
cs_strref run_str(cs_bcode *code);
|
||||
cs_strref run_str(std::string_view code);
|
||||
cs_strref run_str(cs_ident *id, cs_value_r args);
|
||||
|
||||
cs_int run_int(cs_bcode *code);
|
||||
cs_int run_int(std::string_view code);
|
||||
cs_int run_int(cs_ident *id, cs_value_r args);
|
||||
|
||||
cs_float run_float(cs_bcode *code);
|
||||
cs_float run_float(std::string_view code);
|
||||
cs_float run_float(cs_ident *id, cs_value_r args);
|
||||
|
||||
bool run_bool(cs_bcode *code);
|
||||
bool run_bool(std::string_view code);
|
||||
bool run_bool(cs_ident *id, cs_value_r args);
|
||||
|
||||
void run(cs_bcode *code, cs_value &ret);
|
||||
void run(std::string_view code, cs_value &ret);
|
||||
void run(std::string_view code, cs_value &ret, std::string_view source);
|
||||
|
|
72
src/cs_vm.cc
72
src/cs_vm.cc
|
@ -1661,78 +1661,6 @@ void cs_state::run(cs_ident *id, cs_value_r args, cs_value &ret) {
|
|||
}
|
||||
}
|
||||
|
||||
cs_strref cs_state::run_str(cs_bcode *code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_str();
|
||||
}
|
||||
|
||||
cs_strref cs_state::run_str(std::string_view code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_str();
|
||||
}
|
||||
|
||||
cs_strref cs_state::run_str(cs_ident *id, cs_value_r args) {
|
||||
cs_value ret{*this};
|
||||
run(id, args, ret);
|
||||
return ret.get_str();
|
||||
}
|
||||
|
||||
cs_int cs_state::run_int(cs_bcode *code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_int();
|
||||
}
|
||||
|
||||
cs_int cs_state::run_int(std::string_view code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_int();
|
||||
}
|
||||
|
||||
cs_int cs_state::run_int(cs_ident *id, cs_value_r args) {
|
||||
cs_value ret{*this};
|
||||
run(id, args, ret);
|
||||
return ret.get_int();
|
||||
}
|
||||
|
||||
cs_float cs_state::run_float(cs_bcode *code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_float();
|
||||
}
|
||||
|
||||
cs_float cs_state::run_float(std::string_view code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_float();
|
||||
}
|
||||
|
||||
cs_float cs_state::run_float(cs_ident *id, cs_value_r args) {
|
||||
cs_value ret{*this};
|
||||
run(id, args, ret);
|
||||
return ret.get_float();
|
||||
}
|
||||
|
||||
bool cs_state::run_bool(cs_bcode *code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_bool();
|
||||
}
|
||||
|
||||
bool cs_state::run_bool(std::string_view code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
return ret.get_bool();
|
||||
}
|
||||
|
||||
bool cs_state::run_bool(cs_ident *id, cs_value_r args) {
|
||||
cs_value ret{*this};
|
||||
run(id, args, ret);
|
||||
return ret.get_bool();
|
||||
}
|
||||
|
||||
cs_value cs_state::run(cs_bcode *code) {
|
||||
cs_value ret{*this};
|
||||
run(code, ret);
|
||||
|
|
|
@ -972,7 +972,7 @@ static inline void cs_do_loop(
|
|||
for (cs_int i = 0; i < n; ++i) {
|
||||
idv.set_int(offset + i * step);
|
||||
idv.push();
|
||||
if (cond && !cs.run_bool(cond)) {
|
||||
if (cond && !cs.run(cond).get_bool()) {
|
||||
break;
|
||||
}
|
||||
switch (cs.run_loop(body)) {
|
||||
|
@ -1057,7 +1057,7 @@ void cs_init_lib_base(cs_state &gcs) {
|
|||
gcs.new_command("cond", "ee2V", [](auto &cs, auto args, auto &res) {
|
||||
for (size_t i = 0; i < args.size(); i += 2) {
|
||||
if ((i + 1) < args.size()) {
|
||||
if (cs.run_bool(args[i].get_code())) {
|
||||
if (cs.run(args[i].get_code()).get_bool()) {
|
||||
cs.run(args[i + 1].get_code(), res);
|
||||
break;
|
||||
}
|
||||
|
@ -1177,7 +1177,7 @@ void cs_init_lib_base(cs_state &gcs) {
|
|||
|
||||
gcs.new_command("while", "ee", [](auto &cs, auto args, auto &) {
|
||||
cs_bcode *cond = args[0].get_code(), *body = args[1].get_code();
|
||||
while (cs.run_bool(cond)) {
|
||||
while (cs.run(cond).get_bool()) {
|
||||
switch (cs.run_loop(body)) {
|
||||
case cs_loop_state::BREAK:
|
||||
goto end;
|
||||
|
|
|
@ -209,7 +209,7 @@ void cs_init_lib_list(cs_state &gcs) {
|
|||
++n;
|
||||
idv.set_str(p.item);
|
||||
idv.push();
|
||||
if (cs.run_bool(body)) {
|
||||
if (cs.run(body).get_bool()) {
|
||||
res.set_int(cs_int(n));
|
||||
return;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void cs_init_lib_list(cs_state &gcs) {
|
|||
++n;
|
||||
idv.set_str(p.item);
|
||||
idv.push();
|
||||
if (cs.run_bool(body)) {
|
||||
if (cs.run(body).get_bool()) {
|
||||
if (list_parse(p, cs)) {
|
||||
res.set_str(list_get_item(p, cs));
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ end:
|
|||
for (cs_list_parse_state p{args[1].get_str()}; list_parse(p, cs); ++n) {
|
||||
idv.set_str(p.item);
|
||||
idv.push();
|
||||
if (cs.run_bool(body)) {
|
||||
if (cs.run(body).get_bool()) {
|
||||
if (r.size()) {
|
||||
r.push_back(' ');
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ end:
|
|||
for (cs_list_parse_state p{args[1].get_str()}; list_parse(p, cs); ++n) {
|
||||
idv.set_str(p.item);
|
||||
idv.push();
|
||||
if (cs.run_bool(body)) {
|
||||
if (cs.run(body).get_bool()) {
|
||||
r++;
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ struct ListSortFun {
|
|||
yv.set_str(yval.str);
|
||||
xv.push();
|
||||
yv.push();
|
||||
return cs.run_bool(body);
|
||||
return cs.run(body).get_bool();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue