Refactor codegen, allow compiling for linux

This commit is contained in:
Curle 2023-12-06 19:01:20 +00:00
parent bfebf647eb
commit 29b797d7dc
8 changed files with 1356 additions and 9 deletions

View File

@ -9,7 +9,8 @@ add_executable(Erythro
include/Data.h
include/Defs.h
src/assemble/AssemblerDispatcher.c
src/assemble/ASMAssembler.c
src/assemble/Win32GASAssembler.c
src/assemble/LinuxGASAssembler.c
src/assemble/QBEAssembler.c
src/Delegate.c
src/Dump.c
@ -21,4 +22,5 @@ add_executable(Erythro
src/Symbols.c
src/Types.c
src/Importer.c
src/assemble/JVMAssembler.c src/Errors.c)
src/assemble/JVMAssembler.c
src/Errors.c)

View File

@ -609,6 +609,7 @@ void RegisterAllModules();
// Module List
void RegisterQBE();
void RegisterWin32ASM();
void RegisterLinuxASM();
void RegisterJVM();

View File

@ -171,7 +171,11 @@ int main(int argc, char* argv[]) {
OptAssembleFiles = true;
OptLinkFiles = true;
OptVerboseOutput = false;
OptAssemblerName = "Win32 GAS ASM";
OptAssemblerName = "Win32";
struct FileData* InitData = malloc(sizeof(struct FileData));
InitData->CurrentLine = 0;
CurrentFile = InitData;
// Temporary .o storage and counter
int ObjectCount = 0;

View File

@ -9,6 +9,10 @@
#include "Defs.h"
#include "Data.h"
#if defined(__GNUC__) || defined(APPLE)
#include <errno.h>
#endif
/*
* The Precedence of an operator is directly related to Token Type.
* Precedence determines how soon the operator and its surrounding values

View File

@ -6,12 +6,13 @@
#include <Defs.h>
#include <Data.h>
#define MODULES_SIZE 3
#define MODULES_SIZE 4
struct AssemblerModule* modules[MODULES_SIZE];
static int moduleID = 0;
void RegisterAllModules() {
RegisterWin32ASM();
RegisterLinuxASM();
RegisterQBE();
RegisterJVM();

View File

@ -170,7 +170,7 @@ static const struct AssemblerVtable JVMAssemblerVtable = {
};
static const struct AssemblerModule JVMAssemblerModule = {
.name = "JVM Bytecode",
.name = "JVM",
.vtable = &JVMAssemblerVtable
};

File diff suppressed because it is too large Load Diff

View File

@ -146,7 +146,7 @@ static int AsCalcOffset(int Type) {
* @return the highest available label number
*
*/
int NewLabel(void) {
static int NewLabel(void) {
static int id = 1;
return id++;
}
@ -1273,7 +1273,7 @@ static int AssembleTree(struct ASTNode* Node, int Register, int LoopBeginLabel,
}
}
static const struct AssemblerVtable Win32ASMVtable = {
static const struct AssemblerVtable Win32GASVtable = {
.AssembleTree = AssembleTree,
.AsAdd = AsAdd,
.AsAddr = AsAddr,
@ -1331,8 +1331,8 @@ static const struct AssemblerVtable Win32ASMVtable = {
};
static struct AssemblerModule Win32ASMModule = {
.name = "Win32 GAS ASM",
.vtable = &Win32ASMVtable
.name = "Win32",
.vtable = &Win32GASVtable
};
void RegisterWin32ASM() {