Skip to content

Commit

Permalink
LibJS: Rename Value::typeof() to Value::typeof_()
Browse files Browse the repository at this point in the history
This to avoid clashing with the GCC typeof extension, which apparently
confuses clang-format.
  • Loading branch information
awesomekling committed Jul 23, 2024
1 parent cc8a18b commit 36d7606
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Userland/Libraries/LibJS/Bytecode/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value thi
if (!succeeded && vm.in_strict_mode()) {
if (base.is_object())
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, name, base.to_string_without_side_effects());
return vm.throw_completion<TypeError>(ErrorType::ReferencePrimitiveSetProperty, name, base.typeof(vm)->utf8_string(), base.to_string_without_side_effects());
return vm.throw_completion<TypeError>(ErrorType::ReferencePrimitiveSetProperty, name, base.typeof_(vm)->utf8_string(), base.to_string_without_side_effects());
}
break;
}
Expand Down Expand Up @@ -2018,7 +2018,7 @@ static ThrowCompletionOr<Value> not_(VM&, Value value)

static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
{
return value.typeof(vm);
return value.typeof_(vm);
}

#define JS_DEFINE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
Expand Down Expand Up @@ -2873,7 +2873,7 @@ ThrowCompletionOr<void> TypeofBinding::execute_impl(Bytecode::Interpreter& inter
environment = environment->outer_environment();
if (!environment->is_permanently_screwed_by_eval()) {
auto value = TRY(static_cast<DeclarativeEnvironment const&>(*environment).get_binding_value_direct(vm, m_cache.index));
interpreter.set(dst(), value.typeof(vm));
interpreter.set(dst(), value.typeof_(vm));
return {};
}
m_cache = {};
Expand All @@ -2897,7 +2897,7 @@ ThrowCompletionOr<void> TypeofBinding::execute_impl(Bytecode::Interpreter& inter

// 4. NOTE: This step is replaced in section B.3.6.3.
// 5. Return a String according to Table 41.
interpreter.set(dst(), value.typeof(vm));
interpreter.set(dst(), value.typeof_(vm));
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibJS/Runtime/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ ThrowCompletionOr<bool> Value::is_regexp(VM& vm) const
}

// 13.5.3 The typeof Operator, https://tc39.es/ecma262/#sec-typeof-operator
NonnullGCPtr<PrimitiveString> Value::typeof(VM& vm) const
NonnullGCPtr<PrimitiveString> Value::typeof_(VM& vm) const
{
// 9. If val is a Number, return "number".
if (is_number())
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibJS/Runtime/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ class Value {
return *this;
}

[[nodiscard]] NonnullGCPtr<PrimitiveString> typeof(VM&) const;
[[nodiscard]] NonnullGCPtr<PrimitiveString> typeof_(VM&) const;

bool operator==(Value const&) const;

Expand Down

0 comments on commit 36d7606

Please sign in to comment.