Codegen multiple line strings

This commit is contained in:
Krzosa Karol
2022-09-30 16:05:19 +02:00
parent b17027f431
commit b1d05bc203
6 changed files with 25 additions and 13 deletions

View File

@@ -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

View File

@@ -1479,4 +1479,3 @@ template<class T>
bool should_we_continue(List_Iter<T> *iter){
return iter->item != 0;
}

View File

@@ -471,7 +471,3 @@ string_from_cstring(char *string){
return result;
}

View File

@@ -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;

View File

@@ -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.

View File

@@ -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