Phasor 3.1.1
Stack VM based Programming Language
Loading...
Searching...
No Matches
CppCodeGenerator.hpp
Go to the documentation of this file.
1#pragma once
2#include "../CodeGen.hpp"
3#include <filesystem>
4#include <sstream>
5#include <string>
6
8namespace Phasor
9{
10
21{
22 public:
31 bool generate(const Bytecode &bytecode, const std::filesystem::path &outputPath,
32 const std::string &moduleName = "");
33
40 Bytecode generateBytecodeFromEmbedded(const std::string &input);
41
42 private:
43 std::ostringstream output;
44 const Bytecode *bytecode = nullptr;
45 std::string moduleName;
46 std::vector<uint8_t> serializedBytecode;
47
48 // Code generation methods
49 void generateFileHeader();
50 void generateModuleName();
55
56 // Deserialization helper
57 std::vector<unsigned char> parseEmbeddedBytecode(const std::string &input);
58
59 // Helper methods
60 std::string escapeString(const std::string &str);
61 std::string getValueTypeString(ValueType type);
62 std::string sanitizeModuleName(const std::string &name);
63};
64
65} // namespace Phasor
Generates C++ header files with embedded Phasor bytecode.
std::vector< uint8_t > serializedBytecode
Serialized bytecode in .phsb format.
std::string getValueTypeString(ValueType type)
bool generate(const Bytecode &bytecode, const std::filesystem::path &outputPath, const std::string &moduleName="")
Generate C++ header file from bytecode.
std::string escapeString(const std::string &str)
std::vector< unsigned char > parseEmbeddedBytecode(const std::string &input)
std::ostringstream output
Output stream for generated code.
std::string sanitizeModuleName(const std::string &name)
Bytecode generateBytecodeFromEmbedded(const std::string &input)
Generate Bytecode object from embedded bytecode string.
The Phasor Programming Language and Runtime.
Definition AST.hpp:11
ValueType
Runtime value types for the VM.
Definition Value.hpp:51
Complete bytecode structure.
Definition CodeGen.hpp:47