1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:57:45 +00:00

Revert "LibJS: Add bytecode instruction handles"

This reverts commit a01bd35c67.

This broke simple programs like:

function sum(a, b) { return a + b; }
console.log(sum(1, 2));
This commit is contained in:
Andreas Kling 2021-06-09 00:50:42 +02:00
parent a01bd35c67
commit b8a5ea1f8d
8 changed files with 79 additions and 81 deletions

View file

@ -7,7 +7,6 @@
#pragma once
#include <AK/Forward.h>
#include <LibJS/Bytecode/Block.h>
#include <LibJS/Forward.h>
#define ENUMERATE_BYTECODE_OPS(O) \
@ -84,45 +83,4 @@ private:
Type m_type {};
};
template<typename OpType>
class InstructionHandle {
public:
InstructionHandle() = default;
InstructionHandle(size_t offset, Block* block)
: m_offset(offset)
, m_block(block)
{
}
OpType* operator->() const
{
VERIFY(m_block);
return reinterpret_cast<OpType*>(m_block->buffer().data() + m_offset);
}
OpType& operator*() const
{
VERIFY(m_block);
return *reinterpret_cast<OpType*>(m_block->buffer().data() + m_offset);
}
template<typename T>
InstructionHandle<OpType>& operator=(InstructionHandle<T> const& other) requires(IsBaseOf<OpType, T>)
{
m_offset = other.offset();
m_block = other.block();
return *this;
}
size_t offset() const { return m_offset; }
Block* block() const { return m_block; }
private:
friend class Block;
size_t m_offset { 0 };
Block* m_block { nullptr };
};
}