![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
This class is just a helper to. More...
#include <BytecodeReader.hpp>
Public Member Functions | |
| BytecodeReader () | |
| 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 |
| std::optional< internal::InstLoc > | findSourceLocation (const std::vector< internal::InstLoc > &inst_locations, std::size_t ip, std::size_t pp) const |
| Find the location of an instruction. | |
| 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. | |
| void | printInstruction (std::ostream &os, uint8_t inst, uint8_t padding, uint16_t imm_arg, const Symbols &syms, const Values &vals, bool colorize=true) const |
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 |
| std::unordered_map< internal::Instruction, internal::ArgKind > | m_arg_kinds |
Friends | |
| class | Ark::State |
This class is just a helper to.
Definition at line 126 of file BytecodeReader.hpp.
| Ark::BytecodeReader::BytecodeReader | ( | ) |
Construct a new Bytecode Reader object.
Definition at line 18 of file BytecodeReader.cpp.
References m_arg_kinds.
|
nodiscard |
Check for the presence of the magic header
Definition at line 128 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 335 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::internal::Debugger::compile(), 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 385 of file BytecodeReader.cpp.
References Ark::All, checkMagic(), Ark::Code, code(), filenames(), findSourceLocation(), Ark::HeadersOnly, instLocations(), Ark::InstructionLocation, Ark::Number, Ark::PageAddr, printInstruction(), sha256(), Ark::String, Ark::Symbols, symbols(), timestamp(), std::to_string(), 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 105 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 110 of file BytecodeReader.cpp.
References m_bytecode.
Referenced by Ark::internal::Debugger::compile(), Ark::State::doFile(), Ark::State::feed(), main(), and Ark::internal::Debugger::showPreviousInstructions().
| values |
Definition at line 262 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::internal::Debugger::compile(), Ark::State::configure(), display(), and instLocations().
| std::optional< InstLoc > Ark::BytecodeReader::findSourceLocation | ( | const std::vector< internal::InstLoc > & | inst_locations, |
| std::size_t | ip, | ||
| std::size_t | pp ) const |
Find the location of an instruction.
| inst_locations | |
| ip | |
| pp |
Definition at line 362 of file BytecodeReader.cpp.
Referenced by display().
|
nodiscard |
| filenames |
Definition at line 292 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::internal::Debugger::compile(), Ark::State::configure(), and display().
| void Ark::BytecodeReader::printInstruction | ( | std::ostream & | os, |
| uint8_t | inst, | ||
| uint8_t | padding, | ||
| uint16_t | imm_arg, | ||
| const Symbols & | syms, | ||
| const Values & | vals, | ||
| bool | colorize = true ) const |
Definition at line 612 of file BytecodeReader.cpp.
References Ark::internal::Builtins::builtins, Ark::internal::InstructionNames, m_arg_kinds, Ark::Number, Ark::PageAddr, Ark::String, Ark::Symbols::symbols, Ark::Values::values, and Ark::withForeColor().
Referenced by display(), and Ark::internal::Debugger::showPreviousInstructions().
|
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 598 of file BytecodeReader.cpp.
References m_bytecode.
Referenced by code(), filenames(), instLocations(), symbols(), and values().
|
nodiscard |
Definition at line 167 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::bytecode::HeaderSize, and m_bytecode.
Referenced by Ark::State::configure(), and display().
|
nodiscard |
Definition at line 178 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::internal::Debugger::compile(), Ark::State::configure(), display(), Ark::internal::Debugger::showPreviousInstructions(), and values().
|
nodiscard |
Return the read timestamp from the bytecode file.
Definition at line 149 of file BytecodeReader.cpp.
References checkMagic(), Ark::internal::bytecode::HeaderSize, and m_bytecode.
Referenced by display().
| symbols |
Definition at line 206 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::internal::Debugger::compile(), Ark::State::configure(), display(), filenames(), and Ark::internal::Debugger::showPreviousInstructions().
|
nodiscard |
Definition at line 137 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 228 of file BytecodeReader.hpp.
|
private |
Definition at line 232 of file BytecodeReader.hpp.
Referenced by BytecodeReader(), and printInstruction().
|
private |
Definition at line 231 of file BytecodeReader.hpp.
Referenced by checkMagic(), code(), feed(), feed(), filenames(), instLocations(), readNumber(), sha256(), symbols(), timestamp(), values(), and version().