![]() |
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 |
const bytecode_t & | bytecode () noexcept |
Return the bytecode object constructed. | |
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 |
Code | code (const Values &values) 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 70 of file BytecodeReader.hpp.
|
default |
Construct a new Bytecode Reader object.
|
nodiscardnoexcept |
Return the bytecode object constructed.
Definition at line 46 of file BytecodeReader.cpp.
References m_bytecode.
Referenced by feed().
|
nodiscard |
Check for the presence of the magic header
Definition at line 39 of file BytecodeReader.cpp.
References m_bytecode, and Ark::internal::NOP.
Referenced by code(), display(), Ark::State::doFile(), Ark::State::feed(), sha256(), symbols(), timestamp(), values(), and version().
values |
Definition at line 170 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::CODE_SEGMENT_START, Ark::Values::end, m_bytecode, Ark::Code::pages, readNumber(), Ark::Code::start, and values().
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 197 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, Ark::internal::GET_FIELD, Ark::HeadersOnly, Ark::internal::InstructionNames, Ark::internal::JUMP, Ark::internal::LIST, Ark::internal::LOAD_CONST, Ark::internal::LOAD_SYMBOL, 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 16 of file BytecodeReader.cpp.
References bytecode(), and 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 21 of file BytecodeReader.cpp.
References m_bytecode.
Referenced by Ark::State::doFile(), Ark::State::feed(), and main().
|
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 449 of file BytecodeReader.cpp.
References m_bytecode.
|
nodiscard |
Definition at line 81 of file BytecodeReader.cpp.
References checkMagic(), and m_bytecode.
Referenced by Ark::State::configure(), and display().
|
nodiscard |
Definition at line 92 of file BytecodeReader.cpp.
References checkMagic(), Ark::Symbols::end, 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 63 of file BytecodeReader.cpp.
References checkMagic(), and m_bytecode.
Referenced by display().
symbols |
Definition at line 120 of file BytecodeReader.cpp.
References checkMagic(), 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 code(), Ark::State::configure(), and display().
|
nodiscard |
Definition at line 51 of file BytecodeReader.cpp.
References checkMagic(), and m_bytecode.
Referenced by Ark::State::configure(), and display().
|
friend |
Definition at line 156 of file BytecodeReader.hpp.
|
private |
Definition at line 159 of file BytecodeReader.hpp.
Referenced by bytecode(), checkMagic(), code(), feed(), feed(), readNumber(), sha256(), symbols(), timestamp(), values(), and version().