ArkScript
A small, fast, functional and scripting language for video games
Ark::BytecodeReader Class Reference

This class is just a helper to. More...

#include <BytecodeReader.hpp>

+ Collaboration diagram for Ark::BytecodeReader:

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.
 
const bytecode_tbytecode () noexcept
 Return the bytecode object constructed.
 
unsigned long long timestamp ()
 Return the read timestamp from the bytecode file.
 
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)
 Display the bytecode opcode in a human friendly way.
 

Private Member Functions

uint16_t readNumber (std::size_t &i)
 Read a number from the bytecode, under the instruction pointer i.
 

Private Attributes

bytecode_t m_bytecode
 

Detailed Description

This class is just a helper to.

  • check if a bytecode is valid
  • display it in a human readable way by using the opcode names

Definition at line 42 of file BytecodeReader.hpp.

Constructor & Destructor Documentation

◆ BytecodeReader()

Ark::BytecodeReader::BytecodeReader ( )
default

Construct a new Bytecode Reader object.

Member Function Documentation

◆ bytecode()

const bytecode_t & Ark::BytecodeReader::bytecode ( )
noexcept

Return the bytecode object constructed.

Returns
const bytecode_t&

Definition at line 32 of file BytecodeReader.cpp.

References m_bytecode.

Referenced by display(), Ark::State::feed(), and timestamp().

◆ 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 
)

Display the bytecode opcode in a human friendly way.

Parameters
segmentselected bytecode segment that will be displayed
sStartstart of the segment slice to display (Ignored in code segment if no page is available)
sEndend of the segment slice to display (Ignored in code segment if no page is available)
cPageselected page of the code segment (Used only for the code segment)

Definition at line 71 of file BytecodeReader.cpp.

References Ark::All, Ark::internal::Builtins::builtins, bytecode(), Ark::Code, Ark::HeadersOnly, m_bytecode, readNumber(), Ark::Symbols, timestamp(), and Ark::Values.

Referenced by main().

◆ feed()

void Ark::BytecodeReader::feed ( const std::string &  file)

Construct needed data before displaying information about a given file.

Parameters
filefilename of the bytecode file

Definition at line 15 of file BytecodeReader.cpp.

References m_bytecode.

Referenced by Ark::State::doFile(), Ark::State::feed(), and main().

◆ readNumber()

uint16_t Ark::BytecodeReader::readNumber ( std::size_t &  i)
private

Read a number from the bytecode, under the instruction pointer i.

Parameters
ithis parameter is being modified to point to the next value
Returns
uint16_t the number we read (big endian)

Definition at line 628 of file BytecodeReader.cpp.

References m_bytecode.

Referenced by display(), and timestamp().

◆ timestamp()

unsigned long long Ark::BytecodeReader::timestamp ( )

Return the read timestamp from the bytecode file.

Returns
unsigned long long

Definition at line 37 of file BytecodeReader.cpp.

References bytecode(), m_bytecode, readNumber(), and timestamp().

Referenced by display(), Ark::State::doFile(), and timestamp().

Member Data Documentation

◆ m_bytecode

bytecode_t Ark::BytecodeReader::m_bytecode
private

Definition at line 86 of file BytecodeReader.hpp.

Referenced by bytecode(), display(), feed(), readNumber(), and timestamp().


The documentation for this class was generated from the following files: