diff --git a/include/cubescript/cubescript/ident.hh b/include/cubescript/cubescript/ident.hh index 9555c7d..dda2c07 100644 --- a/include/cubescript/cubescript/ident.hh +++ b/include/cubescript/cubescript/ident.hh @@ -67,24 +67,6 @@ struct LIBCUBESCRIPT_EXPORT ident { /** @brief Check if the idents are not the same. */ bool operator!=(ident &other) const; - /** @brief Check if the ident is a cubescript::alias. - * - * Effectively like `type() == ident_type::ALIAS`. - */ - bool is_alias() const; - - /** @brief Check if the ident is a cubescript::command. - * - * Effectively like `type() == ident_type::COMMAND`. - */ - bool is_command() const; - - /** @brief Check if the ident is a special ident. - * - * Effectively like `type() == ident_type::SPECIAL`. - */ - bool is_special() const; - /** @brief Check if the ident is a cubescript::global_var. * * This will return `true` if ident::type() returns either @@ -92,24 +74,6 @@ struct LIBCUBESCRIPT_EXPORT ident { */ bool is_var() const; - /** @brief Check if the ident is a cubescript::integer_var. - * - * Effectively like `type() == ident_type::IVAR`. - */ - bool is_ivar() const; - - /** @brief Check if the ident is a cubescript::float_var. - * - * Effectively like `type() == ident_type::FVAR`. - */ - bool is_fvar() const; - - /** @brief Check if the ident is a cubescript::string_var. - * - * Effectively like `type() == ident_type::SVAR`. - */ - bool is_svar() const; - /** @brief Get if the ident is overridden. * * This can be true for aliases or builtins. When an alias or a builtin diff --git a/src/cs_ident.cc b/src/cs_ident.cc index 6555682..a2d3550 100644 --- a/src/cs_ident.cc +++ b/src/cs_ident.cc @@ -11,7 +11,8 @@ ident_impl::ident_impl(ident_type tp, string_ref nm, int fl): {} bool ident_is_callable(ident const *id) { - if (!id->is_command() && !id->is_special()) { + auto tp = id->type(); + if ((tp != ident_type::COMMAND) && (tp != ident_type::SPECIAL)) { return false; } return !!static_cast(id)->p_cb_cftv; @@ -197,18 +198,6 @@ LIBCUBESCRIPT_EXPORT bool ident::operator!=(ident &other) const { return this != &other; } -LIBCUBESCRIPT_EXPORT bool ident::is_alias() const { - return type() == ident_type::ALIAS; -} - -LIBCUBESCRIPT_EXPORT bool ident::is_command() const { - return type() == ident_type::COMMAND; -} - -LIBCUBESCRIPT_EXPORT bool ident::is_special() const { - return type() == ident_type::SPECIAL; -} - LIBCUBESCRIPT_EXPORT bool ident::is_var() const { switch (type()) { case ident_type::IVAR: @@ -221,18 +210,6 @@ LIBCUBESCRIPT_EXPORT bool ident::is_var() const { return false; } -LIBCUBESCRIPT_EXPORT bool ident::is_ivar() const { - return type() == ident_type::IVAR; -} - -LIBCUBESCRIPT_EXPORT bool ident::is_fvar() const { - return type() == ident_type::FVAR; -} - -LIBCUBESCRIPT_EXPORT bool ident::is_svar() const { - return type() == ident_type::SVAR; -} - LIBCUBESCRIPT_EXPORT bool ident::is_overridden(state &cs) const { switch (type()) { case ident_type::IVAR: @@ -502,7 +479,7 @@ LIBCUBESCRIPT_EXPORT any_value command::call( /* external API for alias stack management */ LIBCUBESCRIPT_EXPORT alias_local::alias_local(state &cs, ident &a) { - if (!a.is_alias()) { + if (a.type() != ident_type::ALIAS) { throw error{cs, "ident '%s' is not an alias", a.name().data()}; } auto &ts = state_p{cs}.ts(); diff --git a/src/cs_vm.cc b/src/cs_vm.cc index f2ffaf6..efe1e09 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -10,7 +10,10 @@ namespace cubescript { static inline void push_alias(thread_state &ts, ident &id, ident_stack &st) { - if (id.is_alias() && !static_cast(id).is_arg()) { + if (id.type() != ident_type::ALIAS) { + return; + } + if (!static_cast(id).is_arg()) { auto *aimp = static_cast(&id); auto ast = ts.get_astack(aimp); ast.push(st); @@ -19,7 +22,10 @@ static inline void push_alias(thread_state &ts, ident &id, ident_stack &st) { } static inline void pop_alias(thread_state &ts, ident &id) { - if (id.is_alias() && !static_cast(id).is_arg()) { + if (id.type() != ident_type::ALIAS) { + return; + } + if (!static_cast(id).is_arg()) { ts.get_astack(static_cast(&id)).pop(); } } diff --git a/src/lib_base.cc b/src/lib_base.cc index e068e0b..8d61949 100644 --- a/src/lib_base.cc +++ b/src/lib_base.cc @@ -71,10 +71,10 @@ LIBCUBESCRIPT_EXPORT void std_init_base(state &gcs) { new_cmd_quiet(gcs, "pcall", "bvv", [](auto &cs, auto args, auto &ret) { auto &cret = args[1].get_ident(cs); auto &css = args[2].get_ident(cs); - if (!cret.is_alias()) { + if (cret.type() != ident_type::ALIAS) { throw error{cs, "'%s' is not an alias", cret.name().data()}; } - if (!css.is_alias()) { + if (css.type() != ident_type::ALIAS) { throw error{cs, "'%s' is not an alias", css.name().data()}; } any_value result{}, tback{}; diff --git a/tools/edit_linenoise.hh b/tools/edit_linenoise.hh index c955094..5decf4c 100644 --- a/tools/edit_linenoise.hh +++ b/tools/edit_linenoise.hh @@ -16,7 +16,7 @@ static cs::state *ln_cs = nullptr; inline void ln_complete(char const *buf, std::vector &lc) { std::string_view cmd = get_complete_cmd(buf); for (auto id: ln_cs->get_idents()) { - if (!id->is_command()) { + if (id->type() != cs::ident_type::COMMAND) { continue; } std::string_view idname = id->name(); diff --git a/tools/repl.cc b/tools/repl.cc index 153ed73..7d7b612 100644 --- a/tools/repl.cc +++ b/tools/repl.cc @@ -147,7 +147,7 @@ inline cs::command *get_hint_cmd(cs::state &cs, std::string_view buf) { } if (!buf.empty()) { auto cmd = cs.get_ident(buf); - if (cmd && cmd->get().is_command()) { + if (cmd && (cmd->get().type() == cs::ident_type::COMMAND)) { return static_cast(&cmd->get()); } }