44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
#include <cstdint>
|
|
#include <execute/virtualmachine.hpp>
|
|
#include <token/tokenizer.hpp>
|
|
|
|
class Wassembler
|
|
{
|
|
private:
|
|
Execute::VirtualMachine vm;
|
|
bool printSubstitutions;
|
|
bool printTokens;
|
|
bool printTranslatedBytes;
|
|
|
|
bool LoadTextFile(
|
|
std::string const & filePath,
|
|
std::vector<std::string> & lines) const;
|
|
bool Preprocess(std::vector<std::string> & lines) const;
|
|
bool Tokenize(
|
|
std::vector<std::string> const & lines,
|
|
std::vector<Token::Token> & tokens) const;
|
|
bool CompileToBytes(
|
|
std::vector<Token::Token> const & tokens,
|
|
std::vector<std::string> const & lines,
|
|
std::vector<std::uint8_t> & bytes) const;
|
|
void ExecuteCode(std::vector<std::uint8_t> const & bytes);
|
|
|
|
bool CompileFile(
|
|
std::string const & filePath,
|
|
std::vector<std::uint8_t> & bytes) const;
|
|
|
|
public:
|
|
void SetMemorySize(unsigned const size);
|
|
|
|
void EnableSubstitutionsLogging();
|
|
void EnableTokensLogging();
|
|
void EnableByteTranslationLogging();
|
|
|
|
bool CompileAndRun(std::string const & filePath);
|
|
bool CompileToFile(
|
|
std::string const & inputFilePath,
|
|
std::string const & outputFilePath);
|
|
|
|
Wassembler() = default;
|
|
}; |