Cleanup iterators, remove logging, add message queue
This commit is contained in:
@@ -257,39 +257,69 @@ For modules it's a bit different cause they should be distributed as valid.
|
||||
- [x] Think about compound expressions, unify with calls - maybe Thing(a=1) instead of Thing{a=1}
|
||||
*/
|
||||
|
||||
#include "base.cpp"
|
||||
#define STB_SPRINTF_IMPLEMENTATION
|
||||
#include "stb_sprintf.h"
|
||||
#include "base_unicode.cpp"
|
||||
#include "base_arena.cpp"
|
||||
#include "base_data_structures.cpp"
|
||||
#include "base_string.cpp"
|
||||
#include "core_compiler_includes.cpp"
|
||||
|
||||
#include "os.h"
|
||||
const U32 COMPILE_NULL = 0x0;
|
||||
const U32 COMPILE_PRINT_STATS = 0x1;
|
||||
const U32 COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY = 0x2;
|
||||
const U32 COMPILE_AND_RUN = 0x4;
|
||||
const U32 COMPILE_TESTING = 0x8;
|
||||
|
||||
static void compile_file(Allocator *allocator, String filename, U32 compile_flags = COMPILE_NULL) {
|
||||
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {
|
||||
printf("%s - ", filename.str);
|
||||
}
|
||||
String result = compile_file_to_string(allocator, filename);
|
||||
|
||||
B32 r = os_write_file("program.c"_s, result);
|
||||
assert(r);
|
||||
F64 total_compiler_time = os_time() - pctx->total_time;
|
||||
printf("%f - ", total_compiler_time);
|
||||
|
||||
Scratch_Arena *scratch = pctx->scratch;
|
||||
Scratch_Scope _scope(scratch);
|
||||
|
||||
F64 begin = os_time();
|
||||
String_Builder builder = {scratch};
|
||||
builder.addf("clang program.c -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a" OS_EXE " ");
|
||||
For(pctx->files_to_link) {
|
||||
builder.addf("-l%Q ", it->intern_val);
|
||||
}
|
||||
String compiler_call = string_flatten(scratch, &builder);
|
||||
|
||||
system((const char *)compiler_call.str);
|
||||
F64 end = os_time();
|
||||
|
||||
if (is_flag_set(compile_flags, COMPILE_PRINT_STATS)) {
|
||||
printf("total = %f\n", os_time() - pctx->total_time);
|
||||
printf("clang = %f\n", end - begin);
|
||||
printf("parsing = %f\n", pctx->parsing_time_end - pctx->parsing_time_begin);
|
||||
printf("resolving = %f\n", pctx->resolving_time_end - pctx->resolving_time_begin);
|
||||
printf("generatin = %f\n", pctx->generating_time_end - pctx->generating_time_begin);
|
||||
}
|
||||
|
||||
if (is_flag_set(compile_flags, COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY)) {
|
||||
// @! Allocator stats
|
||||
}
|
||||
|
||||
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {
|
||||
String testing = compile_flags & COMPILE_TESTING ? "testing"_s : ""_s;
|
||||
#if OS_WINDOWS
|
||||
#include "os_windows.cpp"
|
||||
#elif OS_LINUX
|
||||
#include "os_linux.cpp"
|
||||
String sys = string_fmt(scratch, "a.exe %Q", testing);
|
||||
#else
|
||||
#error Couldnt figure out OS using macros
|
||||
String sys = string_fmt(scratch, "./a.out %Q", testing);
|
||||
#endif
|
||||
|
||||
#include "core_compiler_interface.hpp"
|
||||
#include "c3_big_int.h"
|
||||
#include "core_compiler.h"
|
||||
#include "core_types.h"
|
||||
#include "core_globals.cpp"
|
||||
#include "core_generated.cpp"
|
||||
#include "c3_big_int.cpp"
|
||||
#include "core_lexing.cpp"
|
||||
#include "core_ast.cpp"
|
||||
#include "core_parsing.cpp"
|
||||
#include "core_typechecking.h"
|
||||
#include "core_types.cpp"
|
||||
#include "core_typechecking.cpp"
|
||||
#include "core_compiler.cpp"
|
||||
#include "core_codegen_c_language.cpp"
|
||||
|
||||
int result = system((char *)sys.str);
|
||||
assert(result != -1);
|
||||
if (result == 0) {
|
||||
printf(PRINTF_GREEN "OK!" PRINTF_RESET);
|
||||
}
|
||||
if (result != 0) {
|
||||
printf(PRINTF_RED "ERROR!" PRINTF_RESET);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argument_count, char **arguments){
|
||||
Arena arena = {};
|
||||
@@ -303,7 +333,7 @@ int main(int argument_count, char **arguments){
|
||||
}
|
||||
|
||||
if(!args.len){
|
||||
log_info("Please specify a file to compile!");
|
||||
printf("Please specify a file to compile!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user