Phasor 2.2.0
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
7namespace Phasor
8{
9
20{
21 public:
30 bool generate(const Bytecode &bytecode, const std::filesystem::path &outputPath,
31 const std::string &moduleName = "");
32
39 Bytecode generateBytecodeFromEmbedded(const std::string &input);
40
41 private:
42 std::ostringstream output;
43 const Bytecode *bytecode = nullptr;
44 std::string moduleName;
45 std::vector<uint8_t> serializedBytecode;
46
47 // Code generation methods
48 void generateFileHeader();
49 void generateModuleName();
54
55 // Deserialization helper
56 std::vector<unsigned char> parseEmbeddedBytecode(const std::string &input);
57
58 // Helper methods
59 std::string escapeString(const std::string &str);
60 std::string getValueTypeString(ValueType type);
61 std::string sanitizeModuleName(const std::string &name);
62};
63
64} // 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:8
ValueType
Runtime value types for the VM.
Definition Value.hpp:17
Complete bytecode structure.
Definition CodeGen.hpp:201