ladybird/Libraries/LibJS/Bytecode/Operand.h
Andreas Kling 984d3033e9 LibJS: Remove obsolete bytecode dump formatting helpers
The Rust bytecode dumper now formats exception handler labels, raw
operands, builtins, labels, and registers. Remove the C++ dump-only
formatters and flatten Operand to expose only the runtime value-array
layout that C++ still observes.
2026-06-15 02:41:57 +02:00

49 lines
1.1 KiB
C++

/*
* Copyright (c) 2024-2025, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <LibJS/Forward.h>
namespace JS::Bytecode {
class Operand {
public:
[[nodiscard]] bool operator==(Operand const&) const = default;
enum class ShouldMakeInvalid { Indeed };
explicit Operand(ShouldMakeInvalid)
: m_raw(0xffffffffu)
{
}
[[nodiscard]] bool is_invalid() const { return m_raw == 0xffffffffu; }
[[nodiscard]] u32 raw() const { return m_raw; }
private:
Operand() = default;
u32 m_raw { 0 };
};
}
namespace AK {
template<>
struct SentinelOptionalTraits<JS::Bytecode::Operand> {
static JS::Bytecode::Operand sentinel_value() { return JS::Bytecode::Operand { JS::Bytecode::Operand::ShouldMakeInvalid::Indeed }; }
static bool is_sentinel(JS::Bytecode::Operand const& value) { return value.is_invalid(); }
};
template<>
class Optional<JS::Bytecode::Operand> : public SentinelOptional<JS::Bytecode::Operand> {
public:
using SentinelOptional::SentinelOptional;
};
}