diff --git a/include/cubescript/cubescript/state.hh b/include/cubescript/cubescript/state.hh index 5646e5d..0e4944b 100644 --- a/include/cubescript/cubescript/state.hh +++ b/include/cubescript/cubescript/state.hh @@ -316,17 +316,14 @@ struct LIBCUBESCRIPT_EXPORT state { * check the type explicitly for whether it was actually provided. * * Commands also support variadics. Variadic commands have their type - * list suffixed with `V` or `C`. A `V` variadic is a traditional variadic - * function, while `C` will concatenate all inputs into a single big - * string. + * list suffixed with `V`. * - * If either `C` or `V` is used alone, the inputs are any arbitrary - * values. However, they can also be used with repetition. Repetition - * works for example like `if2V`. The `2` is the number of types to - * repeat; it must be at most the number of simple types preceeding - * it. It must be followed by `V` or `C`. This specific example means - * that the variadic arguments are a sequence of integer, float, integer, - * float, integer, float and so on. + * If `V` is used alone, the inputs are any arbitrary values. However, + * they can also be used with repetition. Repetition works for example + * like `if2V`. The `2` is the number of types to repeat; it must be at + * most the number of simple types preceeding it. It must be followed by + * `V`. This specific example means that the variadic arguments are a + * sequence of integer, float, integer, float, integer, float and so on. * * The resulting command stores the number of arguments it takes. The * variadic part is not a part of it (neither is the part subject to diff --git a/src/cs_bcode.hh b/src/cs_bcode.hh index b84807e..bf42ed1 100644 --- a/src/cs_bcode.hh +++ b/src/cs_bcode.hh @@ -173,10 +173,6 @@ enum { * instruction, arguments are popped off the stack and passed as is */ BC_INST_COM_V, - /* call builtin command with index D and arg count following the - * instruction, arguments are popped off the stack and concatenated - */ - BC_INST_COM_C, /* opcode mask */ BC_INST_OP_MASK = 0x3F, diff --git a/src/cs_parser.cc b/src/cs_parser.cc index 6119952..16abdfb 100644 --- a/src/cs_parser.cc +++ b/src/cs_parser.cc @@ -543,9 +543,6 @@ lookup_id: gs.gen_val_integer(-1); ++numargs; break; - case 'C': - comtype = BC_INST_COM_C; - break; case 'V': comtype = BC_INST_COM_V; break; @@ -994,9 +991,8 @@ bool parser_state::parse_call_command( gs.gen_val_integer(numargs - fakeargs); ++numargs; break; - case 'C': /* concatenated string */ case 'V': /* varargs */ - comtype = (*it == 'C') ? BC_INST_COM_C : BC_INST_COM_V; + comtype = BC_INST_COM_V; if (more) { for (;;) { more = parse_arg(VAL_ANY); @@ -1275,9 +1271,8 @@ static bool parse_assign_var( ps.gs.gen_val_integer(nargs); ++nargs; break; - case 'C': case 'V': - comtype = (*it == 'C') ? BC_INST_COM_C : BC_INST_COM_V; + comtype = BC_INST_COM_V; if (more && !got) { more = ps.parse_arg(VAL_ANY); if (more) { diff --git a/src/cs_state.cc b/src/cs_state.cc index 86eab69..ec43337 100644 --- a/src/cs_state.cc +++ b/src/cs_state.cc @@ -621,7 +621,7 @@ LIBCUBESCRIPT_EXPORT command &state::new_command( *this, "malformed argument list" }; } - if ((fmt[1] != 'C') && (fmt[1] != 'V')) { + if (fmt[1] != 'V') { throw error{ *this, "repetition without variadic arguments" }; @@ -629,7 +629,6 @@ LIBCUBESCRIPT_EXPORT command &state::new_command( nargs -= nrep; break; } - case 'C': case 'V': if ((fmt + 1) != args.end()) { throw error{ diff --git a/src/cs_vm.cc b/src/cs_vm.cc index bb892b9..356c7e8 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -112,17 +112,6 @@ void exec_command( i += 1; args[i].set_integer(integer_type(lookup ? -1 : i - fakeargs)); break; - case 'C': { - i = std::max(i + 1, numargs); - any_value tv{}; - tv.set_string(concat_values( - *ts.pstate, span_type{args, std::size_t(i)}, " " - )); - static_cast(id)->call( - ts, span_type(&tv, &tv + 1), res - ); - return; - } case 'V': i = std::max(i + 1, numargs); static_cast(id)->call( @@ -1010,27 +999,6 @@ noid: args.resize(offset); continue; } - case BC_INST_COM_C | BC_RET_NULL: - case BC_INST_COM_C | BC_RET_STRING: - case BC_INST_COM_C | BC_RET_FLOAT: - case BC_INST_COM_C | BC_RET_INT: { - command_impl *id = static_cast( - ts.istate->identmap[op >> 8] - ); - std::size_t callargs = *code++; - std::size_t offset = args.size() - callargs; - result.force_none(); - { - any_value tv{}; - tv.set_string(concat_values(cs, span_type{ - &args[offset], callargs - }, " ")); - id->call(ts, span_type{&tv, 1}, result); - } - force_arg(cs, result, op & BC_INST_RET_MASK); - args.resize(offset); - continue; - } } } return code; diff --git a/tests/runner.cc b/tests/runner.cc index 0bced93..8b5e260 100644 --- a/tests/runner.cc +++ b/tests/runner.cc @@ -50,8 +50,8 @@ int main(int argc, char **argv) { cs::state gcs; cs::std_init_all(gcs); - gcs.new_command("echo", "C", [](auto &s, auto args, auto &) { - std::printf("%s\n", args[0].get_string(s).view().data()); + gcs.new_command("echo", "V", [](auto &s, auto args, auto &) { + std::printf("%s\n", cs::concat_values(s, args, " ").data()); }); gcs.new_command("skip_test", "", [](auto &, auto, auto &) { diff --git a/tools/repl.cc b/tools/repl.cc index 10e14ce..f68823a 100644 --- a/tools/repl.cc +++ b/tools/repl.cc @@ -371,8 +371,8 @@ int main(int argc, char **argv) { } }); - gcs.new_command("echo", "C", [](auto &css, auto args, auto &) { - std::printf("%s\n", std::string_view{args[0].get_string(css)}.data()); + gcs.new_command("echo", "V", [](auto &css, auto args, auto &) { + std::printf("%s\n", cs::concat_values(css, args, " ").data()); }); int firstarg = 0;