diff --git a/README.md b/README.md index 23689df..afdc53e 100644 --- a/README.md +++ b/README.md @@ -99,20 +99,20 @@ Release :: (m: *Memory) - [ ] Dynamic arrays - [ ] Hash tables - [ ] Tuples + - [x] Beginnings - [x] Multiple return values from a function + - [ ] But do we actually want this? - [ ] Some kind of tuple expressions - [ ] Using tuples as single values without unpacking - [ ] Generics / Parametric polymorphism -- [ ] Function overloading - - [x] Operator overloading - [x] Binary operators - [x] Unary operators + - [x] Bulletproof - [ ] Assignment expressions? - - [ ] Bulletproof - [ ] Platforms - [x] Windows diff --git a/base.cpp b/base.cpp index 0b47c6f..f4ad60c 100644 --- a/base.cpp +++ b/base.cpp @@ -806,7 +806,7 @@ thread_ctx_init(){ function void handle_log_message(Log_Kind kind, int line, const char *file, const char *str, ...){ if(kind == Log_Kind_Trace) return; - + Scratch scratch; STRING_FMT(scratch, str, message); if(thread_ctx.log_proc) thread_ctx.log_proc(kind, message, (char *)file, line); @@ -1479,4 +1479,3 @@ template bool should_we_continue(List_Iter *iter){ return iter->item != 0; } - diff --git a/base_string.cpp b/base_string.cpp index 138492d..322e207 100644 --- a/base_string.cpp +++ b/base_string.cpp @@ -471,7 +471,3 @@ string_from_cstring(char *string){ return result; } - - - - diff --git a/core_codegen_c_language.cpp b/core_codegen_c_language.cpp index bc9ebd5..36c20aa 100644 --- a/core_codegen_c_language.cpp +++ b/core_codegen_c_language.cpp @@ -197,9 +197,18 @@ gen_value(Token *pos, Value a){ gen("0x%llx", pointer_value); } }break; - case TYPE_STRING: - gen("(String){(U8 *)\"%Q\", %d}", a.intern_val, a.intern_val.len); - break; + case TYPE_STRING:{ + int length = 0; + gen("(String){(U8 *)\""); + for(int i = 0; i < a.intern_val.len; i++){ + if(a.intern_val.str[i] == '\n'){length += 2; gen("\\n");} + else if(a.intern_val.str[i] == '\r'){length += 2; gen("\\r");} + else{length += 1; gen("%c", a.intern_val.str[i]);} + + } + gen("\", %d}", length); + + }break; CASE_BOOL: { a.bool_val ? gen("true"):gen("false"); }break; diff --git a/core_main.cpp b/core_main.cpp index 074cab4..280073f 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -5,7 +5,6 @@ - [ ] '.' Operator doesn't handle expressions inside the dot chain, no good, so casts don't work - [ ] Basic - - [ ] Introduce List to reduce heap allocations and make it more arena friendly, can we get rid of heap completly? - [ ] Detecting if return was called - [ ] Builtin data structures @@ -146,6 +145,7 @@ For modules it's a bit different cause they should be distributed as valid. ## Done +- [x] Introduce List to reduce heap allocations and make it more arena friendly, can we get rid of heap completly? - [x] Function renaming to prevent colissions, we can't really touch other stuff cause I want it to be easily debuggable - [x] Fix Length etc. they should be function calls not operators - [x] Idea to fix overshoot when debugging and it goes to the close bracket and there is not enough line directives. Store the last outputed line and propagate it on the close brace etc. diff --git a/examples/operator_overloading.kl b/examples/operator_overloading.kl index 7145b3f..34c9ed4 100644 --- a/examples/operator_overloading.kl +++ b/examples/operator_overloading.kl @@ -18,4 +18,12 @@ main :: (): int Assert(d.x == -3 && d.y == -4 && d.z == -5) e := c - d Assert(e.x == 6 && e.y == 8 && e.z == 10) + + test_string := " + + Memes + + + " + return 0 \ No newline at end of file