11#ifndef ARK_COMPILER_INTERMEDIATEREPRESENTATION_ENTITY_HPP
12#define ARK_COMPILER_INTERMEDIATEREPRESENTATION_ENTITY_HPP
246 std::optional<std::string>
name;
279 flags +=
"recursive";
281 flags += std::string(flags.empty() ?
"" :
" ") +
"simple";
283 flags += std::string(flags.empty() ?
"" :
" ") +
"mutating";
286 flags += std::string(flags.empty() ?
"" :
" ") +
"closure";
288 flags += std::string(flags.empty() ?
"" :
" ") +
"function";
294 const auto length = std::ranges::count_if(
data, [](
const auto& a) {
300 return static_cast<std::size_t
>(length);
The different instructions used by the compiler and virtual machine.
Describe an instruction and its immediate argument.
uint16_t secondaryArg() const
Return the second argument of the IR Entity.
std::optional< uint16_t > related_res_id
Used by a few instructions to know the original symbol/constant id and deoptimize when necessary.
Kind kind() const
Return the kind of IR Entity.
label_t label() const
Return the label of the IR Entity.
bool hasLabel() const
Check if the Entity has a label attached.
uint16_t tertiaryArg() const
Return the third argument of the IR Entity.
Entity(Kind kind)
Create a new IR Entity.
Instruction inst() const
Return the underlying instruction of the IR Entity.
std::size_t sourceLine() const
void replaceLabel(label_t replacement)
static Entity GotoIf(const Entity &label, bool cond)
Create a new Goto IR Entity.
void setRelatedResourceId(std::optional< uint16_t > id)
bool hasValidSourceLocation() const
uint16_t primaryArg() const
Return the primary argument of the IR Entity (can be 0 if the argument isn't used)
void setSourceLocation(const std::string &filename, std::size_t line)
Set the source location for an IR Entity, which is used to generate the file loc table.
Word bytecode() const
Return the bytecode representation of the IR Entity if it's an Opcode.
const std::string & filename() const
void replaceInstruction(Instruction replacement)
std::optional< uint16_t > relatedResourceId() const
Return the related constant/symbol id an IR Entity refers to (only populated for LOAD_FAST_BY_INDEX,...
struct Ark::internal::IR::Entity::@0 m_metadata
constexpr uint16_t MaxValueForSmallNumber
constexpr uint16_t MaxValueForDualArg
The maximum value an argument can have when an IR entity has two arguments.
constexpr std::string_view AnonymousBlockName
Instruction
The different bytecodes are stored here.
Block of IR entities, with attached metadata.
std::size_t instructionCount() const
static Block InitWithMetadata(const Block &source)
Create a new empty IR::Block with the same metadata as the source block.
std::string metadataRepr() const
struct Ark::internal::IR::Block::Metadata metadata
std::vector< Entity > vec_t
std::string debugName() const