Reduce redundant code
This commit is contained in:
parent
3bdc01ab0a
commit
7fcb2d22b4
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,7 +1,7 @@
|
||||
build/
|
||||
nest/
|
||||
*.data
|
||||
perf.data*
|
||||
/build/
|
||||
/nest/
|
||||
/*.data
|
||||
/perf.data*
|
||||
project
|
||||
project.dSYM/
|
||||
.cache/
|
||||
/project.dSYM/
|
||||
/.cache/
|
||||
|
@ -33,8 +33,8 @@ add_executable("${RUNNER_NAME}" "bootstrap/runner/runner.c")
|
||||
target_link_libraries(${RUNNER_NAME} PRIVATE ${LIBRARY_NAME})
|
||||
|
||||
add_executable("${COMPILER_NAME}"
|
||||
"bootstrap/src/main.c"
|
||||
"bootstrap/src/pdb_image.c"
|
||||
"bootstrap/nest/main.c"
|
||||
"bootstrap/nest/pdb_image.c"
|
||||
)
|
||||
|
||||
target_compile_definitions(${COMPILER_NAME} PRIVATE ${LLVM_DEFINITIONS})
|
||||
|
10
bootstrap/include/nest/base.h
Normal file
10
bootstrap/include/nest/base.h
Normal file
@ -0,0 +1,10 @@
|
||||
#include <std/base.h>
|
||||
|
||||
typedef enum CompilerBackend : u8
|
||||
{
|
||||
COMPILER_BACKEND_NEST = 'm',
|
||||
// COMPILER_BACKEND_LLVM,
|
||||
COMPILER_BACKEND_COUNT,
|
||||
} CompilerBackend;
|
||||
|
||||
|
2
bootstrap/include/nest/pdb_image.h
Normal file
2
bootstrap/include/nest/pdb_image.h
Normal file
@ -0,0 +1,2 @@
|
||||
#include <std/base.h>
|
||||
extern u8 pdb_image[143360];
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
#include <std/base.h>
|
||||
#include <nest/pdb_image.h>
|
||||
|
||||
u8 pdb_image[] = {
|
||||
u8 pdb_image[143360] = {
|
||||
0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, 0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20,
|
||||
0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, 0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00,
|
||||
0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0xB8, 0x00, 0x00, 0x00,
|
@ -4,15 +4,10 @@
|
||||
#include <std/virtual_buffer.h>
|
||||
#include <std/string.h>
|
||||
|
||||
#include <nest/base.h>
|
||||
|
||||
#define nest_dir "nest"
|
||||
|
||||
typedef enum CompilerBackend
|
||||
{
|
||||
COMPILER_BACKEND_INTERPRETER,
|
||||
COMPILER_BACKEND_C,
|
||||
COMPILER_BACKEND_MACHINE,
|
||||
COMPILER_BACKEND_COUNT,
|
||||
} CompilerBackend;
|
||||
declare_slice(CompilerBackend);
|
||||
|
||||
typedef enum CMakeBuildType
|
||||
@ -30,13 +25,15 @@ fn void run(Arena* arena, char** envp, String compiler_path, CompilerBackend com
|
||||
char* compiler_backend_string;
|
||||
switch (compiler_backend)
|
||||
{
|
||||
case COMPILER_BACKEND_C:
|
||||
compiler_backend_string = "c";
|
||||
break;
|
||||
case COMPILER_BACKEND_INTERPRETER:
|
||||
compiler_backend_string = "i";
|
||||
break;
|
||||
case COMPILER_BACKEND_MACHINE:
|
||||
// case COMPILER_BACKEND_C:
|
||||
// compiler_backend_string = "c";
|
||||
// break;
|
||||
// case COMPILER_BACKEND_INTERPRETER:
|
||||
// compiler_backend_string = "i";
|
||||
// break;
|
||||
|
||||
// TODO: change ch
|
||||
case COMPILER_BACKEND_NEST:
|
||||
compiler_backend_string = "m";
|
||||
break;
|
||||
case COMPILER_BACKEND_COUNT:
|
||||
@ -119,13 +116,13 @@ fn void run_tests(Arena* arena, String compiler_path, TestOptions const * const
|
||||
char* compiler_backend_string;
|
||||
switch (compiler_backend)
|
||||
{
|
||||
case COMPILER_BACKEND_C:
|
||||
compiler_backend_string = "c";
|
||||
break;
|
||||
case COMPILER_BACKEND_INTERPRETER:
|
||||
compiler_backend_string = "i";
|
||||
break;
|
||||
case COMPILER_BACKEND_MACHINE:
|
||||
// case COMPILER_BACKEND_C:
|
||||
// compiler_backend_string = "c";
|
||||
// break;
|
||||
// case COMPILER_BACKEND_INTERPRETER:
|
||||
// compiler_backend_string = "i";
|
||||
// break;
|
||||
case COMPILER_BACKEND_NEST:
|
||||
compiler_backend_string = "m";
|
||||
break;
|
||||
case COMPILER_BACKEND_COUNT:
|
||||
@ -141,7 +138,7 @@ fn void run_tests(Arena* arena, String compiler_path, TestOptions const * const
|
||||
|
||||
run_command(arena, (CStringSlice) array_to_slice(arguments), envp);
|
||||
|
||||
if (compiler_backend != COMPILER_BACKEND_INTERPRETER)
|
||||
// if (compiler_backend != COMPILER_BACKEND_INTERPRETER)
|
||||
{
|
||||
String path_split[] = {
|
||||
strlit("./" nest_dir "/"),
|
||||
@ -204,17 +201,17 @@ void entry_point(int argc, char* argv[], char* envp[])
|
||||
|
||||
assert(build_type != CMAKE_BUILD_TYPE_COUNT);
|
||||
}
|
||||
else if (s_equal(argument, strlit("i")))
|
||||
{
|
||||
preferred_compiler_backend = COMPILER_BACKEND_INTERPRETER;
|
||||
}
|
||||
else if (s_equal(argument, strlit("c")))
|
||||
{
|
||||
preferred_compiler_backend = COMPILER_BACKEND_C;
|
||||
}
|
||||
// else if (s_equal(argument, strlit("i")))
|
||||
// {
|
||||
// preferred_compiler_backend = COMPILER_BACKEND_INTERPRETER;
|
||||
// }
|
||||
// else if (s_equal(argument, strlit("c")))
|
||||
// {
|
||||
// preferred_compiler_backend = COMPILER_BACKEND_C;
|
||||
// }
|
||||
else if (s_equal(argument, strlit("m")))
|
||||
{
|
||||
preferred_compiler_backend = COMPILER_BACKEND_MACHINE;
|
||||
preferred_compiler_backend = COMPILER_BACKEND_NEST;
|
||||
}
|
||||
else if (s_equal(argument, strlit("test")))
|
||||
{
|
||||
@ -277,7 +274,7 @@ void entry_point(int argc, char* argv[], char* envp[])
|
||||
{
|
||||
if (preferred_compiler_backend == COMPILER_BACKEND_COUNT)
|
||||
{
|
||||
preferred_compiler_backend = COMPILER_BACKEND_MACHINE;
|
||||
preferred_compiler_backend = COMPILER_BACKEND_NEST;
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +317,7 @@ void entry_point(int argc, char* argv[], char* envp[])
|
||||
CompilerBackend all_compiler_backends[] = {
|
||||
// COMPILER_BACKEND_INTERPRETER,
|
||||
// COMPILER_BACKEND_C,
|
||||
COMPILER_BACKEND_MACHINE,
|
||||
COMPILER_BACKEND_NEST,
|
||||
};
|
||||
|
||||
Slice(CompilerBackend) compiler_backend_selection;
|
||||
|
Loading…
x
Reference in New Issue
Block a user