From ae8e992e9cd61196e92fa10bc8dca265316c36e0 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Wed, 4 Oct 2023 01:50:39 +0200 Subject: [PATCH] Make everything compile for Linux --- Sources/backends/d3d11.c | 3 ++- Sources/backends/d3d11.h | 1 + Sources/backends/d3d9.c | 3 ++- Sources/compiler.h | 7 +++++-- Sources/dir.c | 21 +++++++++++++++++---- Sources/parser.h | 1 + Sources/tokenizer.h | 1 + Sources/types.h | 1 + 8 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Sources/backends/d3d11.c b/Sources/backends/d3d11.c index 130922d..6579768 100644 --- a/Sources/backends/d3d11.c +++ b/Sources/backends/d3d11.c @@ -1,8 +1,9 @@ #include "d3d11.h" +#include "../errors.h" + #ifdef _WIN32 -#include "../errors.h" #include "../log.h" #define INITGUID diff --git a/Sources/backends/d3d11.h b/Sources/backends/d3d11.h index 9434f2b..1abcaf0 100644 --- a/Sources/backends/d3d11.h +++ b/Sources/backends/d3d11.h @@ -3,6 +3,7 @@ #include "../shader_stage.h" #include +#include #include int compile_hlsl_to_d3d11(const char *source, uint8_t **output, size_t *outputlength, shader_stage stage, bool debug); diff --git a/Sources/backends/d3d9.c b/Sources/backends/d3d9.c index 6b59629..5264d69 100644 --- a/Sources/backends/d3d9.c +++ b/Sources/backends/d3d9.c @@ -1,7 +1,8 @@ +#include "../shader_stage.h" + #ifdef _WIN32 #include "../log.h" -#include "../shader_stage.h" #include #include diff --git a/Sources/compiler.h b/Sources/compiler.h index 0a9a57c..006905d 100644 --- a/Sources/compiler.h +++ b/Sources/compiler.h @@ -1,10 +1,11 @@ #pragma once -#include - #include "names.h" #include "types.h" +#include +#include + typedef struct variable { uint64_t index; type_ref type; @@ -85,4 +86,6 @@ typedef struct opcodes { void convert_globals(void); +struct statement; + void convert_function_block(opcodes *code, struct statement *block); diff --git a/Sources/dir.c b/Sources/dir.c index f67fa77..5bdcaa5 100644 --- a/Sources/dir.c +++ b/Sources/dir.c @@ -44,16 +44,29 @@ void close_dir(directory *dir) { #else +#include + +#include +#include +#include + directory open_dir(const char *dirname) { directory dir; - dir.handle = NULL; + dir.handle = opendir(dirname); return dir; } file read_next_file(directory *dir) { - File file; - file.valid = false; - return file; + struct dirent *entry = readdir(dir->handle); + + file f; + f.valid = entry != NULL; + + if (f.valid) { + strcpy(f.name, entry->d_name); + } + + return f; } void close_dir(directory *dir) { diff --git a/Sources/parser.h b/Sources/parser.h index dd5973d..0343e96 100644 --- a/Sources/parser.h +++ b/Sources/parser.h @@ -7,6 +7,7 @@ #include "types.h" #include +#include struct expression; diff --git a/Sources/tokenizer.h b/Sources/tokenizer.h index e8265de..9ff5cb2 100644 --- a/Sources/tokenizer.h +++ b/Sources/tokenizer.h @@ -3,6 +3,7 @@ #include "names.h" #include +#include typedef enum operatorr { OPERATOR_EQUALS, diff --git a/Sources/types.h b/Sources/types.h index 23e2c19..c58a978 100644 --- a/Sources/types.h +++ b/Sources/types.h @@ -4,6 +4,7 @@ #include "tokenizer.h" #include +#include #define NO_TYPE 0xFFFFFFFF