![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
This class is just a helper to. More...
#include <BytecodeReader.hpp>
Public Member Functions | |
BytecodeReader ()=default | |
Construct a new Bytecode Reader object. | |
void | feed (const std::string &file) |
Construct needed data before displaying information about a given file. | |
void | feed (const bytecode_t &bytecode) |
Construct needed data before displaying information about a given bytecode. | |
bool | checkMagic () const |
Version | version () const |
unsigned long long | timestamp () const |
Return the read timestamp from the bytecode file. | |
std::vector< unsigned char > | sha256 () const |
Symbols | symbols () const |
Values | values (const Symbols &symbols) const |
Filenames | filenames (const Values &values) const |
InstLocations | instLocations (const Filenames &filenames) const |
Code | code (const InstLocations &instLocations) const |
void | display (BytecodeSegment segment=BytecodeSegment::All, std::optional< uint16_t > sStart=std::nullopt, std::optional< uint16_t > sEnd=std::nullopt, std::optional< uint16_t > cPage=std::nullopt) const |
Display the bytecode opcode in a human friendly way. | |
Private Member Functions | |
uint16_t | readNumber (std::size_t &i) const |
Read a number from the bytecode, under the instruction pointer i. | |
Private Attributes | |
bytecode_t | m_bytecode |
Friends | |
class | Ark::State |
This class is just a helper to.
Definition at line 85 of file BytecodeReader.hpp.
|
default |
Construct a new Bytecode Reader object.
|
nodiscard |
Check for the presence of the magic header
Definition at line 40 of file BytecodeReader.cpp.
References m_bytecode, and Ark::internal::bytecode::Magic.
Referenced by code(), display(), Ark::State::doFile(), Ark::State::feed(), filenames(), instLocations(), main(), sha256(), symbols(), timestamp(), values(), and version().
|
nodiscard |
instLocations |
Definition at line 247 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::CODE_SEGMENT_START, Ark::InstLocations::end, instLocations(), m_bytecode, Ark::Code::pages, readNumber(), and Ark::Code::start.
Referenced by Ark::State::configure(), and display().
void Ark::BytecodeReader::display | ( | BytecodeSegment | segment = BytecodeSegment::All, |
std::optional< uint16_t > | sStart = std::nullopt, | ||
std::optional< uint16_t > | sEnd = std::nullopt, | ||
std::optional< uint16_t > | cPage = std::nullopt ) const |
Display the bytecode opcode in a human friendly way.
segment | selected bytecode segment that will be displayed |
sStart | start of the segment slice to display (Ignored in code segment if no page is available) |
sEnd | end of the segment slice to display (Ignored in code segment if no page is available) |
cPage | selected page of the code segment (Used only for the code segment) |
Definition at line 274 of file BytecodeReader.cpp.
References Ark::All, Ark::internal::APPEND, Ark::internal::APPEND_IN_PLACE, Ark::internal::BUILTIN, Ark::internal::Builtins::builtins, Ark::internal::CALL, Ark::internal::CALL_BUILTIN, Ark::internal::CAPTURE, checkMagic(), Ark::Code, code(), Ark::internal::CONCAT, Ark::internal::CONCAT_IN_PLACE, Ark::internal::DEL, filenames(), Ark::internal::GET_FIELD, Ark::HeadersOnly, instLocations(), Ark::InstructionLocation, Ark::internal::InstructionNames, Ark::internal::JUMP, Ark::internal::LIST, Ark::internal::LOAD_CONST, Ark::internal::LOAD_SYMBOL, Ark::internal::LOAD_SYMBOL_BY_INDEX, Ark::internal::MAKE_CLOSURE, Ark::Number, Ark::PageAddr, Ark::internal::PLUGIN, Ark::internal::POP_JUMP_IF_FALSE, Ark::internal::POP_JUMP_IF_TRUE, Ark::internal::SET_VAL, sha256(), Ark::internal::STORE, Ark::String, Ark::internal::Symbol, Ark::Symbols, symbols(), timestamp(), Ark::types_to_str, Ark::Values, values(), and version().
Referenced by main().
void Ark::BytecodeReader::feed | ( | const bytecode_t & | bytecode | ) |
Construct needed data before displaying information about a given bytecode.
bytecode |
Definition at line 17 of file BytecodeReader.cpp.
References m_bytecode.
void Ark::BytecodeReader::feed | ( | const std::string & | file | ) |
Construct needed data before displaying information about a given file.
file | filename of the bytecode file |
Definition at line 22 of file BytecodeReader.cpp.
References m_bytecode.
Referenced by Ark::State::doFile(), Ark::State::feed(), and main().
values |
Definition at line 174 of file BytecodeReader.cpp.
References checkMagic(), Ark::Filenames::end, Ark::Values::end, Ark::Filenames::filenames, Ark::internal::FILENAMES_TABLE_START, m_bytecode, readNumber(), Ark::Filenames::start, and values().
Referenced by Ark::State::configure(), display(), and instLocations().
|
nodiscard |
filenames |
Definition at line 204 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::deserializeBE(), Ark::Filenames::end, Ark::InstLocations::end, filenames(), Ark::internal::INST_LOC_TABLE_START, Ark::InstLocations::locations, m_bytecode, readNumber(), and Ark::InstLocations::start.
Referenced by code(), Ark::State::configure(), and display().
|
nodiscardprivate |
Read a number from the bytecode, under the instruction pointer i.
i | this parameter is being modified to point to the next value |
Definition at line 559 of file BytecodeReader.cpp.
References m_bytecode.
Referenced by code(), filenames(), instLocations(), symbols(), and values().
|
nodiscard |
Definition at line 79 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::bytecode::HeaderSize, and m_bytecode.
Referenced by Ark::State::configure(), and display().
|
nodiscard |
Definition at line 90 of file BytecodeReader.cpp.
References checkMagic(), Ark::Symbols::end, Ark::internal::bytecode::HeaderSize, m_bytecode, readNumber(), Ark::Symbols::start, Ark::internal::SYM_TABLE_START, and Ark::Symbols::symbols.
Referenced by Ark::State::configure(), display(), and values().
|
nodiscard |
Return the read timestamp from the bytecode file.
Definition at line 61 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::bytecode::HeaderSize, and m_bytecode.
Referenced by display().
symbols |
Definition at line 118 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::ieee754::deserialize(), Ark::internal::deserializeLE(), Ark::Symbols::end, Ark::Values::end, Ark::internal::FUNC_TYPE, m_bytecode, Ark::internal::NUMBER_TYPE, readNumber(), Ark::Values::start, Ark::internal::STRING_TYPE, symbols(), Ark::internal::VAL_TABLE_START, and Ark::Values::values.
Referenced by Ark::State::configure(), display(), and filenames().
|
nodiscard |
Definition at line 49 of file BytecodeReader.cpp.
References checkMagic(), m_bytecode, Ark::internal::bytecode::Magic, and Ark::internal::bytecode::Version.
Referenced by Ark::State::configure(), and display().
|
friend |
Definition at line 176 of file BytecodeReader.hpp.
|
private |
Definition at line 179 of file BytecodeReader.hpp.
Referenced by checkMagic(), code(), feed(), feed(), filenames(), instLocations(), readNumber(), sha256(), symbols(), timestamp(), values(), and version().