momiji
m68k emulator infrastructure
About Source codeTable of contents
Compiler
Component dedicated to compiling a valid piece of code to an executable binary.
This component allows the user to compile the output of the parser (momiji::ParsingInfo
) to an emulator-specific binary file.
The binary file generated is a blob of executable memory and, if needed, a data
section is included for variable declarations.
Both of these sections are delimited by markers, please refer to
momiji::Memory
for more information about them.
The generated executable does not contain any metadata about where each of the sections begin and end, that functionality will be added soon.
Notes
-
The compiler at the moment does not check that the parsed program is valid, that means that an ill-formed program can be passed to the compiler and it will attempt to compile it anyway, resulting in an ill-formed executable.
At the moment, this happens because the compiler expects the output of the parser to be always valid, since there is no public-facing function to validate again the output of the parser. Work is being done to provide such a function.
This situation may arise if the user tries to modify directly the result of the parser by injecting instructions: by doing so an invalid sequence of instructions can be created.
-
The compiler does not try to optimize the input code and it never will. What is passed in is exactly what will be generated.
Basic usage example
auto res = momiji::parse(/* ... */);
if (!res) { /* ... */ }
auto parsingInfo = *res;
momiji::ExecutableMemory compiledBinary = momiji::compile(parsingInfo);
Classes
momiji::CompilerSettings |
A class representing settings for the compiler. |
Free functions
momiji::compile |
Compiles the result of the parser to an executable program. |