mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibJS: Rename Bytecode::Op::PropertyKind => Bytecode::PutKind
This is only used to specify how a property is being added to an object by Put* instructions, so let's call it PutKind. Also add an enumeration X macro for it to prepare for upcoming specializations.
This commit is contained in:
parent
1c10421316
commit
e7a3c4dbad
Notes:
github-actions[bot]
2025-10-11 18:10:24 +00:00
Author: https://github.com/awesomekling
Commit: e7a3c4dbad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6450
7 changed files with 87 additions and 67 deletions
|
@ -645,15 +645,15 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AssignmentExpression::g
|
|||
|
||||
if (expression.is_computed()) {
|
||||
if (!lhs_is_super_expression)
|
||||
generator.emit_put_by_value(*base, *computed_property, rval, Bytecode::Op::PropertyKind::KeyValue, move(base_identifier));
|
||||
generator.emit_put_by_value(*base, *computed_property, rval, Bytecode::PutKind::Normal, move(base_identifier));
|
||||
else
|
||||
generator.emit_put_by_value_with_this(*base, *computed_property, *this_value, rval, Op::PropertyKind::KeyValue);
|
||||
generator.emit_put_by_value_with_this(*base, *computed_property, *this_value, rval, PutKind::Normal);
|
||||
} else if (expression.property().is_identifier()) {
|
||||
auto identifier_table_ref = generator.intern_identifier(as<Identifier>(expression.property()).string());
|
||||
if (!lhs_is_super_expression)
|
||||
generator.emit_put_by_id(*base, identifier_table_ref, rval, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache(), move(base_identifier));
|
||||
generator.emit_put_by_id(*base, identifier_table_ref, rval, Bytecode::PutKind::Normal, generator.next_property_lookup_cache(), move(base_identifier));
|
||||
else
|
||||
generator.emit<Bytecode::Op::PutByIdWithThis>(*base, *this_value, identifier_table_ref, rval, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache());
|
||||
generator.emit<Bytecode::Op::PutByIdWithThis>(*base, *this_value, identifier_table_ref, rval, Bytecode::PutKind::Normal, generator.next_property_lookup_cache());
|
||||
} else if (expression.property().is_private_identifier()) {
|
||||
auto identifier_table_ref = generator.intern_identifier(as<PrivateIdentifier>(expression.property()).string());
|
||||
generator.emit<Bytecode::Op::PutPrivateById>(*base, identifier_table_ref, rval);
|
||||
|
@ -1151,19 +1151,19 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ObjectExpression::gener
|
|||
generator.push_home_object(object);
|
||||
|
||||
for (auto& property : m_properties) {
|
||||
Bytecode::Op::PropertyKind property_kind;
|
||||
Bytecode::PutKind property_kind;
|
||||
switch (property->type()) {
|
||||
case ObjectProperty::Type::KeyValue:
|
||||
property_kind = Bytecode::Op::PropertyKind::DirectKeyValue;
|
||||
property_kind = Bytecode::PutKind::Own;
|
||||
break;
|
||||
case ObjectProperty::Type::Getter:
|
||||
property_kind = Bytecode::Op::PropertyKind::Getter;
|
||||
property_kind = Bytecode::PutKind::Getter;
|
||||
break;
|
||||
case ObjectProperty::Type::Setter:
|
||||
property_kind = Bytecode::Op::PropertyKind::Setter;
|
||||
property_kind = Bytecode::PutKind::Setter;
|
||||
break;
|
||||
case ObjectProperty::Type::ProtoSetter:
|
||||
property_kind = Bytecode::Op::PropertyKind::ProtoSetter;
|
||||
property_kind = Bytecode::PutKind::Prototype;
|
||||
break;
|
||||
case ObjectProperty::Type::Spread:
|
||||
generator.emit<Bytecode::Op::PutBySpread>(object, TRY(property->key().generate_bytecode(generator)).value());
|
||||
|
@ -1175,13 +1175,13 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ObjectExpression::gener
|
|||
Bytecode::IdentifierTableIndex key_name = generator.intern_identifier(string_literal.value());
|
||||
|
||||
Optional<ScopedOperand> value;
|
||||
if (property_kind == Bytecode::Op::PropertyKind::ProtoSetter) {
|
||||
if (property_kind == Bytecode::PutKind::Prototype) {
|
||||
value = TRY(property->value().generate_bytecode(generator)).value();
|
||||
} else {
|
||||
auto identifier = string_literal.value();
|
||||
if (property_kind == Bytecode::Op::PropertyKind::Getter)
|
||||
if (property_kind == Bytecode::PutKind::Getter)
|
||||
identifier = Utf16String::formatted("get {}", identifier);
|
||||
else if (property_kind == Bytecode::Op::PropertyKind::Setter)
|
||||
else if (property_kind == Bytecode::PutKind::Setter)
|
||||
identifier = Utf16String::formatted("set {}", identifier);
|
||||
|
||||
auto name = generator.intern_identifier(identifier);
|
||||
|
@ -2540,7 +2540,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> TaggedTemplateLiteral::
|
|||
generator.emit_with_extra_operand_slots<Bytecode::Op::NewArray>(raw_string_regs.size(), raw_strings_array, raw_string_regs);
|
||||
}
|
||||
|
||||
generator.emit_put_by_id(strings_array, generator.intern_identifier("raw"_utf16_fly_string), raw_strings_array, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache());
|
||||
generator.emit_put_by_id(strings_array, generator.intern_identifier("raw"_utf16_fly_string), raw_strings_array, Bytecode::PutKind::Normal, generator.next_property_lookup_cache());
|
||||
|
||||
auto arguments = generator.allocate_register();
|
||||
if (!argument_regs.is_empty())
|
||||
|
|
|
@ -761,21 +761,21 @@ CodeGenerationErrorOr<void> Generator::emit_store_to_reference(JS::ASTNode const
|
|||
if (super_reference.referenced_name.has_value()) {
|
||||
// 5. Let propertyKey be ? ToPropertyKey(propertyNameValue).
|
||||
// FIXME: This does ToPropertyKey out of order, which is observable by Symbol.toPrimitive!
|
||||
emit_put_by_value_with_this(*super_reference.base, *super_reference.referenced_name, *super_reference.this_value, value, Op::PropertyKind::KeyValue);
|
||||
emit_put_by_value_with_this(*super_reference.base, *super_reference.referenced_name, *super_reference.this_value, value, PutKind::Normal);
|
||||
} else {
|
||||
// 3. Let propertyKey be StringValue of IdentifierName.
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::PutByIdWithThis>(*super_reference.base, *super_reference.this_value, identifier_table_ref, value, Bytecode::Op::PropertyKind::KeyValue, next_property_lookup_cache());
|
||||
emit<Bytecode::Op::PutByIdWithThis>(*super_reference.base, *super_reference.this_value, identifier_table_ref, value, Bytecode::PutKind::Normal, next_property_lookup_cache());
|
||||
}
|
||||
} else {
|
||||
auto object = TRY(expression.object().generate_bytecode(*this)).value();
|
||||
|
||||
if (expression.is_computed()) {
|
||||
auto property = TRY(expression.property().generate_bytecode(*this)).value();
|
||||
emit_put_by_value(object, property, value, Op::PropertyKind::KeyValue, {});
|
||||
emit_put_by_value(object, property, value, PutKind::Normal, {});
|
||||
} else if (expression.property().is_identifier()) {
|
||||
auto identifier_table_ref = intern_identifier(as<Identifier>(expression.property()).string());
|
||||
emit_put_by_id(object, identifier_table_ref, value, Bytecode::Op::PropertyKind::KeyValue, next_property_lookup_cache());
|
||||
emit_put_by_id(object, identifier_table_ref, value, Bytecode::PutKind::Normal, next_property_lookup_cache());
|
||||
} else if (expression.property().is_private_identifier()) {
|
||||
auto identifier_table_ref = intern_identifier(as<PrivateIdentifier>(expression.property()).string());
|
||||
emit<Bytecode::Op::PutPrivateById>(object, identifier_table_ref, value);
|
||||
|
@ -804,15 +804,15 @@ CodeGenerationErrorOr<void> Generator::emit_store_to_reference(ReferenceOperands
|
|||
}
|
||||
if (reference.referenced_identifier.has_value()) {
|
||||
if (reference.base == reference.this_value)
|
||||
emit_put_by_id(*reference.base, *reference.referenced_identifier, value, Bytecode::Op::PropertyKind::KeyValue, next_property_lookup_cache());
|
||||
emit_put_by_id(*reference.base, *reference.referenced_identifier, value, Bytecode::PutKind::Normal, next_property_lookup_cache());
|
||||
else
|
||||
emit<Bytecode::Op::PutByIdWithThis>(*reference.base, *reference.this_value, *reference.referenced_identifier, value, Bytecode::Op::PropertyKind::KeyValue, next_property_lookup_cache());
|
||||
emit<Bytecode::Op::PutByIdWithThis>(*reference.base, *reference.this_value, *reference.referenced_identifier, value, Bytecode::PutKind::Normal, next_property_lookup_cache());
|
||||
return {};
|
||||
}
|
||||
if (reference.base == reference.this_value)
|
||||
emit_put_by_value(*reference.base, *reference.referenced_name, value, Op::PropertyKind::KeyValue, {});
|
||||
emit_put_by_value(*reference.base, *reference.referenced_name, value, PutKind::Normal, {});
|
||||
else
|
||||
emit_put_by_value_with_this(*reference.base, *reference.referenced_name, *reference.this_value, value, Op::PropertyKind::KeyValue);
|
||||
emit_put_by_value_with_this(*reference.base, *reference.referenced_name, *reference.this_value, value, PutKind::Normal);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1153,7 +1153,7 @@ void Generator::emit_get_by_value_with_this(ScopedOperand dst, ScopedOperand bas
|
|||
emit<Op::GetByValueWithThis>(dst, base, property, this_value);
|
||||
}
|
||||
|
||||
void Generator::emit_put_by_id(Operand base, IdentifierTableIndex property, Operand src, Op::PropertyKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier)
|
||||
void Generator::emit_put_by_id(Operand base, IdentifierTableIndex property, Operand src, PutKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier)
|
||||
{
|
||||
auto string = m_identifier_table->get(property);
|
||||
if (!string.is_empty() && !(string.code_unit_at(0) == '0' && string.length_in_code_units() > 1)) {
|
||||
|
@ -1166,7 +1166,7 @@ void Generator::emit_put_by_id(Operand base, IdentifierTableIndex property, Oper
|
|||
emit<Op::PutById>(base, property, src, kind, cache_index, move(base_identifier));
|
||||
}
|
||||
|
||||
void Generator::emit_put_by_value(ScopedOperand base, ScopedOperand property, ScopedOperand src, Bytecode::Op::PropertyKind kind, Optional<IdentifierTableIndex> base_identifier)
|
||||
void Generator::emit_put_by_value(ScopedOperand base, ScopedOperand property, ScopedOperand src, Bytecode::PutKind kind, Optional<IdentifierTableIndex> base_identifier)
|
||||
{
|
||||
if (property.operand().is_constant() && get_constant(property).is_string()) {
|
||||
auto property_key = MUST(get_constant(property).to_property_key(vm()));
|
||||
|
@ -1178,7 +1178,7 @@ void Generator::emit_put_by_value(ScopedOperand base, ScopedOperand property, Sc
|
|||
emit<Op::PutByValue>(base, property, src, kind, base_identifier);
|
||||
}
|
||||
|
||||
void Generator::emit_put_by_value_with_this(ScopedOperand base, ScopedOperand property, ScopedOperand this_value, ScopedOperand src, Bytecode::Op::PropertyKind kind)
|
||||
void Generator::emit_put_by_value_with_this(ScopedOperand base, ScopedOperand property, ScopedOperand this_value, ScopedOperand src, Bytecode::PutKind kind)
|
||||
{
|
||||
if (property.operand().is_constant() && get_constant(property).is_string()) {
|
||||
auto property_key = MUST(get_constant(property).to_property_key(vm()));
|
||||
|
|
|
@ -329,10 +329,10 @@ public:
|
|||
void emit_get_by_value(ScopedOperand dst, ScopedOperand base, ScopedOperand property, Optional<IdentifierTableIndex> base_identifier = {});
|
||||
void emit_get_by_value_with_this(ScopedOperand dst, ScopedOperand base, ScopedOperand property, ScopedOperand this_value);
|
||||
|
||||
void emit_put_by_id(Operand base, IdentifierTableIndex property, Operand src, Op::PropertyKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {});
|
||||
void emit_put_by_id(Operand base, IdentifierTableIndex property, Operand src, PutKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {});
|
||||
|
||||
void emit_put_by_value(ScopedOperand base, ScopedOperand property, ScopedOperand src, Bytecode::Op::PropertyKind, Optional<IdentifierTableIndex> base_identifier);
|
||||
void emit_put_by_value_with_this(ScopedOperand base, ScopedOperand property, ScopedOperand this_value, ScopedOperand src, Bytecode::Op::PropertyKind);
|
||||
void emit_put_by_value(ScopedOperand base, ScopedOperand property, ScopedOperand src, Bytecode::PutKind, Optional<IdentifierTableIndex> base_identifier);
|
||||
void emit_put_by_value_with_this(ScopedOperand base, ScopedOperand property, ScopedOperand this_value, ScopedOperand src, Bytecode::PutKind);
|
||||
|
||||
void emit_iterator_value(ScopedOperand dst, ScopedOperand result);
|
||||
void emit_iterator_complete(ScopedOperand dst, ScopedOperand result);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2024, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2021-2025, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/Span.h>
|
||||
#include <LibJS/Bytecode/Executable.h>
|
||||
#include <LibJS/Bytecode/PutKind.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/SourceRange.h>
|
||||
|
||||
|
|
|
@ -1188,7 +1188,7 @@ inline ThrowCompletionOr<Value> get_global(Interpreter& interpreter, IdentifierT
|
|||
return vm.throw_completion<ReferenceError>(ErrorType::UnknownIdentifier, identifier);
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value this_value, Value value, Optional<Utf16FlyString const&> const& base_identifier, PropertyKey name, Op::PropertyKind kind, PropertyLookupCache* caches = nullptr)
|
||||
inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value this_value, Value value, Optional<Utf16FlyString const&> const& base_identifier, PropertyKey name, PutKind kind, PropertyLookupCache* caches = nullptr)
|
||||
{
|
||||
// Better error message than to_object would give
|
||||
if (vm.in_strict_mode() && base.is_nullish())
|
||||
|
@ -1200,26 +1200,26 @@ inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value thi
|
|||
return throw_null_or_undefined_property_access(vm, base, base_identifier, name);
|
||||
auto object = maybe_object.release_value();
|
||||
|
||||
if (kind == Op::PropertyKind::Getter || kind == Op::PropertyKind::Setter) {
|
||||
if (kind == PutKind::Getter || kind == PutKind::Setter) {
|
||||
// The generator should only pass us functions for getters and setters.
|
||||
VERIFY(value.is_function());
|
||||
}
|
||||
switch (kind) {
|
||||
case Op::PropertyKind::Getter: {
|
||||
case PutKind::Getter: {
|
||||
auto& function = value.as_function();
|
||||
if (is<ECMAScriptFunctionObject>(function) && static_cast<ECMAScriptFunctionObject const&>(function).name().is_empty())
|
||||
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(Utf16String::formatted("get {}", name));
|
||||
object->define_direct_accessor(name, &function, nullptr, Attribute::Configurable | Attribute::Enumerable);
|
||||
break;
|
||||
}
|
||||
case Op::PropertyKind::Setter: {
|
||||
case PutKind::Setter: {
|
||||
auto& function = value.as_function();
|
||||
if (is<ECMAScriptFunctionObject>(function) && static_cast<ECMAScriptFunctionObject const&>(function).name().is_empty())
|
||||
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(Utf16String::formatted("set {}", name));
|
||||
object->define_direct_accessor(name, nullptr, &function, Attribute::Configurable | Attribute::Enumerable);
|
||||
break;
|
||||
}
|
||||
case Op::PropertyKind::KeyValue: {
|
||||
case PutKind::Normal: {
|
||||
auto this_value_object = MUST(this_value.to_object(vm));
|
||||
auto& from_shape = this_value_object->shape();
|
||||
if (caches) {
|
||||
|
@ -1338,10 +1338,10 @@ inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value thi
|
|||
}
|
||||
break;
|
||||
}
|
||||
case Op::PropertyKind::DirectKeyValue:
|
||||
case PutKind::Own:
|
||||
object->define_direct_property(name, value, Attribute::Enumerable | Attribute::Writable | Attribute::Configurable);
|
||||
break;
|
||||
case Op::PropertyKind::ProtoSetter:
|
||||
case PutKind::Prototype:
|
||||
if (value.is_object() || value.is_null())
|
||||
MUST(object->internal_set_prototype_of(value.is_object() ? &value.as_object() : nullptr));
|
||||
break;
|
||||
|
@ -1414,10 +1414,10 @@ inline Value new_function(VM& vm, FunctionNode const& function_node, Optional<Id
|
|||
return value;
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Optional<Utf16FlyString const&> const& base_identifier, Value property_key_value, Value value, Op::PropertyKind kind)
|
||||
inline ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Optional<Utf16FlyString const&> const& base_identifier, Value property_key_value, Value value, PutKind kind)
|
||||
{
|
||||
// OPTIMIZATION: Fast path for simple Int32 indexes in array-like objects.
|
||||
if ((kind == Op::PropertyKind::KeyValue || kind == Op::PropertyKind::DirectKeyValue)
|
||||
if ((kind == PutKind::Normal || kind == PutKind::Own)
|
||||
&& base.is_object() && property_key_value.is_int32() && property_key_value.as_i32() >= 0) {
|
||||
auto& object = base.as_object();
|
||||
auto* storage = object.indexed_properties().storage();
|
||||
|
@ -3591,18 +3591,18 @@ ByteString SetVariableBinding::to_byte_string_impl(Bytecode::Executable const& e
|
|||
format_operand("src"sv, src(), executable));
|
||||
}
|
||||
|
||||
static StringView property_kind_to_string(PropertyKind kind)
|
||||
static StringView property_kind_to_string(PutKind kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case PropertyKind::Getter:
|
||||
case PutKind::Getter:
|
||||
return "getter"sv;
|
||||
case PropertyKind::Setter:
|
||||
case PutKind::Setter:
|
||||
return "setter"sv;
|
||||
case PropertyKind::KeyValue:
|
||||
case PutKind::Normal:
|
||||
return "key-value"sv;
|
||||
case PropertyKind::DirectKeyValue:
|
||||
case PutKind::Own:
|
||||
return "direct-key-value"sv;
|
||||
case PropertyKind::ProtoSetter:
|
||||
case PutKind::Prototype:
|
||||
return "proto-setter"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -1180,14 +1180,6 @@ private:
|
|||
IdentifierTableIndex m_property;
|
||||
};
|
||||
|
||||
enum class PropertyKind {
|
||||
Getter,
|
||||
Setter,
|
||||
KeyValue,
|
||||
DirectKeyValue, // Used for Object expressions. Always sets an own property, never calls a setter.
|
||||
ProtoSetter,
|
||||
};
|
||||
|
||||
class PutBySpread final : public Instruction {
|
||||
public:
|
||||
PutBySpread(Operand base, Operand src)
|
||||
|
@ -1215,7 +1207,7 @@ private:
|
|||
|
||||
class PutById final : public Instruction {
|
||||
public:
|
||||
explicit PutById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {})
|
||||
explicit PutById(Operand base, IdentifierTableIndex property, Operand src, PutKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {})
|
||||
: Instruction(Type::PutById)
|
||||
, m_base(base)
|
||||
, m_property(property)
|
||||
|
@ -1237,21 +1229,21 @@ public:
|
|||
Operand base() const { return m_base; }
|
||||
IdentifierTableIndex property() const { return m_property; }
|
||||
Operand src() const { return m_src; }
|
||||
PropertyKind kind() const { return m_kind; }
|
||||
PutKind kind() const { return m_kind; }
|
||||
u32 cache_index() const { return m_cache_index; }
|
||||
|
||||
private:
|
||||
Operand m_base;
|
||||
IdentifierTableIndex m_property;
|
||||
Operand m_src;
|
||||
PropertyKind m_kind;
|
||||
PutKind m_kind;
|
||||
u32 m_cache_index { 0 };
|
||||
Optional<IdentifierTableIndex> m_base_identifier {};
|
||||
};
|
||||
|
||||
class PutByNumericId final : public Instruction {
|
||||
public:
|
||||
explicit PutByNumericId(Operand base, u64 property_index, Operand src, PropertyKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {})
|
||||
explicit PutByNumericId(Operand base, u64 property_index, Operand src, PutKind kind, u32 cache_index, Optional<IdentifierTableIndex> base_identifier = {})
|
||||
: Instruction(Type::PutByNumericId)
|
||||
, m_base(base)
|
||||
, m_property_index(property_index)
|
||||
|
@ -1274,14 +1266,14 @@ private:
|
|||
Operand m_base;
|
||||
u64 m_property_index;
|
||||
Operand m_src;
|
||||
PropertyKind m_kind;
|
||||
PutKind m_kind;
|
||||
u32 m_cache_index { 0 };
|
||||
Optional<IdentifierTableIndex> m_base_identifier {};
|
||||
};
|
||||
|
||||
class PutByIdWithThis final : public Instruction {
|
||||
public:
|
||||
PutByIdWithThis(Operand base, Operand this_value, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index)
|
||||
PutByIdWithThis(Operand base, Operand this_value, IdentifierTableIndex property, Operand src, PutKind kind, u32 cache_index)
|
||||
: Instruction(Type::PutByIdWithThis)
|
||||
, m_base(base)
|
||||
, m_this_value(this_value)
|
||||
|
@ -1305,7 +1297,7 @@ public:
|
|||
Operand this_value() const { return m_this_value; }
|
||||
IdentifierTableIndex property() const { return m_property; }
|
||||
Operand src() const { return m_src; }
|
||||
PropertyKind kind() const { return m_kind; }
|
||||
PutKind kind() const { return m_kind; }
|
||||
u32 cache_index() const { return m_cache_index; }
|
||||
|
||||
private:
|
||||
|
@ -1313,13 +1305,13 @@ private:
|
|||
Operand m_this_value;
|
||||
IdentifierTableIndex m_property;
|
||||
Operand m_src;
|
||||
PropertyKind m_kind;
|
||||
PutKind m_kind;
|
||||
u32 m_cache_index { 0 };
|
||||
};
|
||||
|
||||
class PutPrivateById final : public Instruction {
|
||||
public:
|
||||
explicit PutPrivateById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
||||
explicit PutPrivateById(Operand base, IdentifierTableIndex property, Operand src, PutKind kind = PutKind::Normal)
|
||||
: Instruction(Type::PutPrivateById)
|
||||
, m_base(base)
|
||||
, m_property(property)
|
||||
|
@ -1344,7 +1336,7 @@ private:
|
|||
Operand m_base;
|
||||
IdentifierTableIndex m_property;
|
||||
Operand m_src;
|
||||
PropertyKind m_kind;
|
||||
PutKind m_kind;
|
||||
};
|
||||
|
||||
class DeleteById final : public Instruction {
|
||||
|
@ -1473,7 +1465,7 @@ private:
|
|||
|
||||
class PutByValue final : public Instruction {
|
||||
public:
|
||||
PutByValue(Operand base, Operand property, Operand src, PropertyKind kind = PropertyKind::KeyValue, Optional<IdentifierTableIndex> base_identifier = {})
|
||||
PutByValue(Operand base, Operand property, Operand src, PutKind kind = PutKind::Normal, Optional<IdentifierTableIndex> base_identifier = {})
|
||||
: Instruction(Type::PutByValue)
|
||||
, m_base(base)
|
||||
, m_property(property)
|
||||
|
@ -1495,19 +1487,19 @@ public:
|
|||
Operand base() const { return m_base; }
|
||||
Operand property() const { return m_property; }
|
||||
Operand src() const { return m_src; }
|
||||
PropertyKind kind() const { return m_kind; }
|
||||
PutKind kind() const { return m_kind; }
|
||||
|
||||
private:
|
||||
Operand m_base;
|
||||
Operand m_property;
|
||||
Operand m_src;
|
||||
PropertyKind m_kind;
|
||||
PutKind m_kind;
|
||||
Optional<IdentifierTableIndex> m_base_identifier;
|
||||
};
|
||||
|
||||
class PutByValueWithThis final : public Instruction {
|
||||
public:
|
||||
PutByValueWithThis(Operand base, Operand property, Operand this_value, Operand src, PropertyKind kind = PropertyKind::KeyValue)
|
||||
PutByValueWithThis(Operand base, Operand property, Operand this_value, Operand src, PutKind kind = PutKind::Normal)
|
||||
: Instruction(Type::PutByValueWithThis)
|
||||
, m_base(base)
|
||||
, m_property(property)
|
||||
|
@ -1531,14 +1523,14 @@ public:
|
|||
Operand property() const { return m_property; }
|
||||
Operand this_value() const { return m_this_value; }
|
||||
Operand src() const { return m_src; }
|
||||
PropertyKind kind() const { return m_kind; }
|
||||
PutKind kind() const { return m_kind; }
|
||||
|
||||
private:
|
||||
Operand m_base;
|
||||
Operand m_property;
|
||||
Operand m_this_value;
|
||||
Operand m_src;
|
||||
PropertyKind m_kind;
|
||||
PutKind m_kind;
|
||||
};
|
||||
|
||||
class DeleteByValue final : public Instruction {
|
||||
|
|
27
Libraries/LibJS/Bytecode/PutKind.h
Normal file
27
Libraries/LibJS/Bytecode/PutKind.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
// PutKind indicates how a property is being set.
|
||||
// `Normal` is a normal `o.foo = x` or `o[foo] = x` operation.
|
||||
// The others are used for object expressions.
|
||||
#define JS_ENUMERATE_PUT_KINDS(X) \
|
||||
X(Normal) \
|
||||
X(Getter) \
|
||||
X(Setter) \
|
||||
X(Prototype) \
|
||||
X(Own) // Always sets an own property, never calls a setter.
|
||||
|
||||
enum class PutKind {
|
||||
#define __JS_ENUMERATE_PUT_KIND(name) name,
|
||||
JS_ENUMERATE_PUT_KINDS(__JS_ENUMERATE_PUT_KIND)
|
||||
#undef __JS_ENUMERATE_PUT_KIND
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue