From 74f437f8515e03ef708718f697d004ea5865acb7 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 6 May 2021 03:47:38 +0200 Subject: [PATCH] s/global_var/builtin_var/ --- include/cubescript/cubescript/ident.hh | 26 +++++++++++++------------- src/cs_ident.cc | 14 +++++++------- src/cs_state.cc | 6 +++--- src/cs_vm.cc | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/cubescript/cubescript/ident.hh b/include/cubescript/cubescript/ident.hh index d61aa10..6d39767 100644 --- a/include/cubescript/cubescript/ident.hh +++ b/include/cubescript/cubescript/ident.hh @@ -67,7 +67,7 @@ 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::global_var. + /** @brief Check if the ident is a cubescript::builtin_var. * * This will return `true` if ident::type() returns either * ident_type::IVAR, ident_type::FVAR or ident_type::SVAR. @@ -120,7 +120,7 @@ protected: struct ident_impl *p_impl{}; }; -/** @brief An additional cubescript::global_var type. +/** @brief An additional cubescript::builtin_var type. * * Global vars can have no additional type, or they can be persistent, or * they can be overridable. Persistent variables are meant to be saved and @@ -144,7 +144,7 @@ enum class var_type { * This represents one of cubescript::integer_var, cubescript::float_var or * cubescript::string_var as a single interface, with shared operations. */ -struct LIBCUBESCRIPT_EXPORT global_var: ident { +struct LIBCUBESCRIPT_EXPORT builtin_var: ident { /** @brief Get whether the variable is read only. * * Variables can be set as read only during their creation (but not @@ -189,20 +189,20 @@ struct LIBCUBESCRIPT_EXPORT global_var: ident { any_value value() const; protected: - global_var() = default; + builtin_var() = default; }; /** @brief An integer variable. * - * A specialization of cubescript::global_var for integer values. + * A specialization of cubescript::builtin_var for integer values. */ -struct LIBCUBESCRIPT_EXPORT integer_var: global_var { +struct LIBCUBESCRIPT_EXPORT integer_var: builtin_var { /** @brief Set the value of the variable. * * If read only, an error is raised. If `do_write` is `false`, nothing * will be performed other than the read-only checking. If `trigger` is * `false`, a potential variable change trigger command will not be - * invoked. The value is saved with global_var::save(), assuming + * invoked. The value is saved with builtin_var::save(), assuming * `do_write` is `true`. After that, integer_var::set_raw_value() * is invoked, and then the trigger. * @@ -228,15 +228,15 @@ protected: /** @brief A float variable. * - * A specialization of cubescript::global_var for float values. + * A specialization of cubescript::builtin_var for float values. */ -struct LIBCUBESCRIPT_EXPORT float_var: global_var { +struct LIBCUBESCRIPT_EXPORT float_var: builtin_var { /** @brief Set the value of the variable. * * If read only, an error is raised. If `do_write` is `false`, nothing * will be performed other than the read-only checking. If `trigger` is * `false`, a potential variable change trigger command will not be - * invoked. The value is saved with global_var::save(), assuming + * invoked. The value is saved with builtin_var::save(), assuming * `do_write` is `true`. After that, integer_var::set_raw_value() * is invoked, and then the trigger. * @@ -262,15 +262,15 @@ protected: /** @brief A string variable. * - * A specialization of cubescript::global_var for string values. + * A specialization of cubescript::builtin_var for string values. */ -struct LIBCUBESCRIPT_EXPORT string_var: global_var { +struct LIBCUBESCRIPT_EXPORT string_var: builtin_var { /** @brief Set the value of the variable. * * If read only, an error is raised. If `do_write` is `false`, nothing * will be performed other than the read-only checking. If `trigger` is * `false`, a potential variable change trigger command will not be - * invoked. The value is saved with global_var::save(), assuming + * invoked. The value is saved with builtin_var::save(), assuming * `do_write` is `true`. After that, integer_var::set_raw_value() * is invoked, and then the trigger. * diff --git a/src/cs_ident.cc b/src/cs_ident.cc index f010e78..a40e7ed 100644 --- a/src/cs_ident.cc +++ b/src/cs_ident.cc @@ -100,7 +100,7 @@ void var_changed(thread_state &ts, ident *id, any_value &oldval) { case ident_type::IVAR: case ident_type::FVAR: case ident_type::SVAR: - val[2] = static_cast(id)->value(); + val[2] = static_cast(id)->value(); break; default: return; @@ -238,15 +238,15 @@ LIBCUBESCRIPT_EXPORT any_value ident::call(span_type, state &cs) { throw error{cs, "this ident type is not callable"}; } -LIBCUBESCRIPT_EXPORT bool global_var::is_read_only() const { +LIBCUBESCRIPT_EXPORT bool builtin_var::is_read_only() const { return (p_impl->p_flags & IDENT_FLAG_READONLY); } -LIBCUBESCRIPT_EXPORT bool global_var::is_overridable() const { +LIBCUBESCRIPT_EXPORT bool builtin_var::is_overridable() const { return (p_impl->p_flags & IDENT_FLAG_OVERRIDE); } -LIBCUBESCRIPT_EXPORT var_type global_var::variable_type() const { +LIBCUBESCRIPT_EXPORT var_type builtin_var::variable_type() const { if (p_impl->p_flags & IDENT_FLAG_OVERRIDE) { return var_type::OVERRIDABLE; } else if (p_impl->p_flags & IDENT_FLAG_PERSIST) { @@ -256,7 +256,7 @@ LIBCUBESCRIPT_EXPORT var_type global_var::variable_type() const { } } -LIBCUBESCRIPT_EXPORT void global_var::save(state &cs) { +LIBCUBESCRIPT_EXPORT void builtin_var::save(state &cs) { auto &ts = state_p{cs}.ts(); if ((ts.ident_flags & IDENT_FLAG_OVERRIDDEN) || is_overridable()) { if (p_impl->p_flags & IDENT_FLAG_PERSIST) { @@ -274,13 +274,13 @@ LIBCUBESCRIPT_EXPORT void global_var::save(state &cs) { } } -LIBCUBESCRIPT_EXPORT any_value global_var::call( +LIBCUBESCRIPT_EXPORT any_value builtin_var::call( span_type args, state &cs ) { return ident::call(args, cs); } -LIBCUBESCRIPT_EXPORT any_value global_var::value() const { +LIBCUBESCRIPT_EXPORT any_value builtin_var::value() const { return static_cast(p_impl)->p_storage; } diff --git a/src/cs_state.cc b/src/cs_state.cc index 0c304ca..6e618f9 100644 --- a/src/cs_state.cc +++ b/src/cs_state.cc @@ -532,7 +532,7 @@ LIBCUBESCRIPT_EXPORT any_value state::lookup_value(std::string_view name) { case ident_type::SVAR: case ident_type::IVAR: case ident_type::FVAR: - return static_cast(id)->value(); + return static_cast(id)->value(); case ident_type::COMMAND: { any_value val{}; /* make sure value stack gets restored */ @@ -561,7 +561,7 @@ LIBCUBESCRIPT_EXPORT void state::reset_value(std::string_view name) { throw error{*this, "variable '%s' does not exist", name.data()}; } if (id->get().is_var()) { - if (static_cast(id->get()).is_read_only()) { + if (static_cast(id->get()).is_read_only()) { throw error{*this, "variable '%s' is read only", name.data()}; } } @@ -579,7 +579,7 @@ LIBCUBESCRIPT_EXPORT void state::touch_value(std::string_view name) { case ident_type::IVAR: case ident_type::FVAR: case ident_type::SVAR: - v = static_cast(idr).value(); + v = static_cast(idr).value(); break; default: return; diff --git a/src/cs_vm.cc b/src/cs_vm.cc index 9b466ab..2906b51 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -720,7 +720,7 @@ std::uint32_t *vm_exec( case BC_INST_VAR | BC_RET_INT: case BC_INST_VAR | BC_RET_FLOAT: case BC_INST_VAR | BC_RET_STRING: - args.emplace_back() = static_cast( + args.emplace_back() = static_cast( ts.istate->identmap[op >> 8] )->value(); force_arg(cs, args.back(), op & BC_INST_RET_MASK);