s/global_var/builtin_var/
parent
139ead5d72
commit
74f437f851
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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<global_var *>(id)->value();
|
||||
val[2] = static_cast<builtin_var *>(id)->value();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -238,15 +238,15 @@ LIBCUBESCRIPT_EXPORT any_value ident::call(span_type<any_value>, 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<any_value> 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<var_impl const *>(p_impl)->p_storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<global_var *>(id)->value();
|
||||
return static_cast<builtin_var *>(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<global_var &>(id->get()).is_read_only()) {
|
||||
if (static_cast<builtin_var &>(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<global_var &>(idr).value();
|
||||
v = static_cast<builtin_var &>(idr).value();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
|
|
@ -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<global_var *>(
|
||||
args.emplace_back() = static_cast<builtin_var *>(
|
||||
ts.istate->identmap[op >> 8]
|
||||
)->value();
|
||||
force_arg(cs, args.back(), op & BC_INST_RET_MASK);
|
||||
|
|
Loading…
Reference in New Issue