Core: Small cleanup

This commit is contained in:
Krzosa Karol
2023-04-21 15:19:38 +02:00
parent 19fa0509c6
commit 07dcb418dd
5 changed files with 13 additions and 26 deletions

View File

@@ -28,18 +28,11 @@ Fix backlog
- [ ] String declaration in Language.core this way we can compound create it and access fields and stuff
- [ ] This error is valid error case when someone creates a compound out of basic type C:/AProgramming/cparse/compiler/examples/arms_race/arms_race.core:137 Internal compiler error: Invalid type was passed to the compound expression, should have been an array, struct or slice
result := String{data, filesize}
- [ ] Fix tuple being able to colapse into a single variable
- [ ] Fix Found multiple definitions of not showing multiple definitions in the error message
- [ ] How to cast from U64 to pointer?
```
Future features
- [ ] Add some directive that passes metadata arguments to compiler, stores them
in array and then those can be searched etc. Then we could add the link thing there
- [ ] The ability for a type to also be a namespace seems like a good idea, a common pattern
emerges. Not sure how to execute it though without complications. Data for sure needs
to be nicely visible in a struct and those functions should be separate
- [ ] Other kinds of casts, a cast from structs of same layout, a cast without conversion
- [ ] Inject symbols into a declaration / namespace ??
- [ ] Using directive to bring symbols into local scope
@@ -102,17 +95,16 @@ static void compile_file(Allocator *allocator, String filename, U32 compile_flag
F64 total_compiler_time = os_time() - pctx->time.start;
printf("%f - ", total_compiler_time);
Arena *scratch = pctx->scratch;
Scoped_Arena _scope(scratch);
Scoped_Arena scratch(pctx->scratch);
F64 begin = os_time();
if (!is_flag_set(compile_flags, DONT_USE_C_COMPILER)) {
String_Builder builder = {scratch};
String_Builder builder = {scratch.arena};
builder.addf("clang generated_main.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);
String compiler_call = string_flatten(scratch.arena, &builder);
system((const char *)compiler_call.str);
printf("%s\n", compiler_call.str);
}
@@ -135,9 +127,9 @@ static void compile_file(Allocator *allocator, String filename, U32 compile_flag
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {
String testing = compile_flags & COMPILE_TESTING ? "testing"_s : ""_s;
#if OS_WINDOWS
String sys = string_fmt(scratch, "a.exe %Q", testing);
String sys = string_fmt(scratch.arena, "a.exe %Q", testing);
#else
String sys = string_fmt(scratch, "./a.out %Q", testing);
String sys = string_fmt(scratch.arena, "./a.out %Q", testing);
#endif
int result = system((char *)sys.str);
assert(result != -1);