Fixing bugs with strings
This commit is contained in:
124
README.md
124
README.md
@@ -74,79 +74,55 @@ Stuff that helped me a lot programming the compiler. Hopefully they also will be
|
|||||||
* https://github.com/c3lang/c3c - I sometimes looked at C3 compiler as a reference, the author also let me use his big int library he wrote sometime in the past! Thanks a lot!
|
* https://github.com/c3lang/c3c - I sometimes looked at C3 compiler as a reference, the author also let me use his big int library he wrote sometime in the past! Thanks a lot!
|
||||||
* https://go.dev/blog/constants - article on golang type system, untyped types, constants that kind of stuff.
|
* https://go.dev/blog/constants - article on golang type system, untyped types, constants that kind of stuff.
|
||||||
|
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
- [x] Type as a parameter to a function, alloc :: (size: U64, type: Type)
|
- [x] Constant evaluation and constant folding - Folding and precomputing every expression that can be calculated at compile time. Which allows to check if a given constant expression is actually something that can be computed at compile time.
|
||||||
- [x] Add token information to instructions
|
- [ ] Constant expressions with types specified by the user.
|
||||||
- [-] Mixing loads and imports leads to code duplication, is that what we want???
|
|
||||||
- [x] print those token lines nicely
|
- [x] Untyped types - Context dependent type assignment of constant expressions, this is a feature I really loved in Go, it makes constants work very well with a very strict type system and it makes errors like overflow of constants in C due to bad size specifier impossible.
|
||||||
- [x] Improve the python metaprogram
|
- [x] Infinite precision integers in constants.
|
||||||
- [x] Implementing type Any
|
- [x] Resolution of all untyped types in the typechecking stage.
|
||||||
- [x] Runtime TypeInfo
|
- [x] Special case of booleans and their type propagation.
|
||||||
- [x] Proper type Type support
|
|
||||||
- [x] Switch
|
- [x] Module system
|
||||||
- [x] Type aliases :: should probably be strictly typed, but assigning constant values should work
|
- [x] Lazy evaluation of modules (unused code is not compiled or typechecked)
|
||||||
- [x] Array of inferred size
|
- [x] Import module, load project file distinction
|
||||||
- [x] Casting pointers to and from void should be implicit
|
|
||||||
- [x] Multiple return values
|
- [x] Order independent declarations - The ordering of functions in code files or modules does not matter, compiler figures all that stuff out for you. "main" can be wherever you want it to be and all functions should be available without problems.
|
||||||
- [x] Add c string
|
- [ ] Should constants and others be disallowed inside of structs?
|
||||||
- [-] Should compound resolution use an algorithm to reorder compounds to initialize all fields in order
|
|
||||||
- [x] slices should be properly displayed in debugger
|
- [x] Synchronize generated C code with original source using line directives so that debuggers work.
|
||||||
- [x] Imports inside of import shouldn't spill outside
|
|
||||||
- [x] Scope
|
- [ ] Expressions
|
||||||
- [x] #assert that handles constants at compile time and vars at runtime
|
- [x] Compounds with named fields and numbered fields
|
||||||
- [x] Hex 0x42
|
- [x] Functions calls with named arguments
|
||||||
- [x] Rewrite where # happen,
|
- [x] All the standard binary, unary expressions
|
||||||
- [x] elif
|
- [ ] Dot access expression needs a redesign
|
||||||
- [x] cast ->
|
- [ ] Casting might need a redesign not sure
|
||||||
- [x] Remodel compound from call to {}
|
- [x] Pointer arithmetic and pointer as array
|
||||||
- [x] Fix codegen renames
|
|
||||||
- [x] Field access rewrite
|
- [ ] Tuples
|
||||||
- [-] Constants embeded in structs should be able to refer to other constants in that namespace without prefix
|
- [x] Multiple return values from a function
|
||||||
- [-] Order independent constants in structs
|
- [ ] Some kind of tuple expressions
|
||||||
- [-] Fix recursive lambdas in structs
|
- [ ] Using tuples as single values without unpacking
|
||||||
- [x] Error message when file not found
|
|
||||||
- [x] Better error messages when type difference
|
- [x] Runtime reflection
|
||||||
- [-] Fixing access to functions/structs, in C we cant have functons inside of structs / functions so we need to rewrite the tree
|
- [x] Dumping info
|
||||||
- [x] Emitting #line
|
- [ ] Is the design of this correct? That's a lot of data.
|
||||||
- [x] Making sure debugger works
|
|
||||||
- [x] We need ++ -- operators
|
- [ ] Builtin data structures
|
||||||
- [x] Arrays with size passed
|
- [x] Arrays
|
||||||
- [x] Values inited to 0 by default
|
- [x] Slices
|
||||||
- [x] Some way to call foreign functions
|
- [ ] Dynamic arrays
|
||||||
- [x] We are parsing wrong here: (t.str=(&string_to_lex.str)[i]);
|
- [ ] Hash tables
|
||||||
- [x] Test new operators, add constant eval for them
|
|
||||||
- [x] lvalue, rvalue concept so we cant assign value to some arbitrary weird expression
|
- [ ] Generics
|
||||||
- [x] Passing down program to compile through command line
|
|
||||||
- [x] More basic types
|
- [ ] Language constructs
|
||||||
- [x] Implementing required operations int128
|
- [x] If
|
||||||
- [x] Fix casting
|
- [x] For loops
|
||||||
- [x] More for loop variations
|
- [x] Functions
|
||||||
- [x] Add basic support for floats
|
- [x] Structures
|
||||||
- [x] Converting from U64 token to S64 Atom introduces unnanounced error (negates) - probably need big int
|
- [ ] Unions (or something like unions)
|
||||||
- [x] Add basic setup for new type system
|
- [x] Switch (but maybe needs redesign?)
|
||||||
- [x] Access through struct names to constants Arena.CONSTANT
|
- [ ] Unnamed blocks
|
||||||
- [x] Enums
|
|
||||||
- [x] Make sure pointer arithmetic works
|
|
||||||
- [x] Initial for loop
|
|
||||||
- [x] Enum . access to values
|
|
||||||
- [x] Character literal
|
|
||||||
- [x] Compiling and running a program
|
|
||||||
- [x] Infinite for loop
|
|
||||||
- [x] in new typesystem: Fix calls, fix all example programs
|
|
||||||
- [x] Fix arithmetic operations in new type system
|
|
||||||
- [x] Init statements, different kinds [+=] [-=] etc.
|
|
||||||
- [x] Struct calls
|
|
||||||
- [x] Operators: Bit negation, Not
|
|
||||||
- [x] Default values in calls
|
|
||||||
- [x] Resolving calls with default values
|
|
||||||
- [x] Pass statement
|
|
||||||
- [x] Lexer: Need to insert scope endings when hitting End of file
|
|
||||||
- [x] Resolving calls with named args, with indexed args
|
|
||||||
- [x] Structs
|
|
||||||
- [x] Struct field access
|
|
||||||
- [x] Struct field access with dots while compiling to arrows in c
|
|
||||||
- [x] Typespecs should probably be expressions so stuff like would be possible :: \*[32]int
|
|
||||||
- [x] Initial order independence algorithm
|
|
||||||
- [x] Think about compound expressions, unify with calls - maybe Thing(a=1) instead of Thing{a=1}
|
|
||||||
|
|||||||
@@ -302,9 +302,8 @@ gen_expr(Ast_Expr *ast, Ast_Type *type_of_var){
|
|||||||
CASE(INDEX, Index){
|
CASE(INDEX, Index){
|
||||||
gen("(");
|
gen("(");
|
||||||
gen_expr(node->expr);
|
gen_expr(node->expr);
|
||||||
if(is_string(node->resolved_type)){
|
if(node->index_original_type == type_string){
|
||||||
if(!(type_of_var && type_of_var == type_pointer_to_char))
|
gen(".str");
|
||||||
gen(".str");
|
|
||||||
}
|
}
|
||||||
else if(is_slice(node->index_original_type)){
|
else if(is_slice(node->index_original_type)){
|
||||||
gen(".data");
|
gen(".data");
|
||||||
|
|||||||
@@ -98,6 +98,82 @@ For modules it's a bit different cause they should be distributed as valid.
|
|||||||
[ ] - Conditional compilation #if
|
[ ] - Conditional compilation #if
|
||||||
[ ] - Polymorphism - create declaration of a polymorphic thing, when it's called just copy it, replace types and typecheck normally, when someone calls again you just search for the instantiation again
|
[ ] - Polymorphism - create declaration of a polymorphic thing, when it's called just copy it, replace types and typecheck normally, when someone calls again you just search for the instantiation again
|
||||||
|
|
||||||
|
|
||||||
|
## Done
|
||||||
|
|
||||||
|
- [x] Type as a parameter to a function, alloc :: (size: U64, type: Type)
|
||||||
|
- [x] Add token information to instructions
|
||||||
|
- [-] Mixing loads and imports leads to code duplication, is that what we want???
|
||||||
|
- [x] print those token lines nicely
|
||||||
|
- [x] Improve the python metaprogram
|
||||||
|
- [x] Implementing type Any
|
||||||
|
- [x] Runtime TypeInfo
|
||||||
|
- [x] Proper type Type support
|
||||||
|
- [x] Switch
|
||||||
|
- [x] Type aliases :: should probably be strictly typed, but assigning constant values should work
|
||||||
|
- [x] Array of inferred size
|
||||||
|
- [x] Casting pointers to and from void should be implicit
|
||||||
|
- [x] Multiple return values
|
||||||
|
- [x] Add c string
|
||||||
|
- [-] Should compound resolution use an algorithm to reorder compounds to initialize all fields in order
|
||||||
|
- [x] slices should be properly displayed in debugger
|
||||||
|
- [x] Imports inside of import shouldn't spill outside
|
||||||
|
- [x] Scope
|
||||||
|
- [x] #assert that handles constants at compile time and vars at runtime
|
||||||
|
- [x] Hex 0x42
|
||||||
|
- [x] Rewrite where # happen,
|
||||||
|
- [x] elif
|
||||||
|
- [x] cast ->
|
||||||
|
- [x] Remodel compound from call to {}
|
||||||
|
- [x] Fix codegen renames
|
||||||
|
- [x] Field access rewrite
|
||||||
|
- [-] Constants embeded in structs should be able to refer to other constants in that namespace without prefix
|
||||||
|
- [-] Order independent constants in structs
|
||||||
|
- [-] Fix recursive lambdas in structs
|
||||||
|
- [x] Error message when file not found
|
||||||
|
- [x] Better error messages when type difference
|
||||||
|
- [-] Fixing access to functions/structs, in C we cant have functons inside of structs / functions so we need to rewrite the tree
|
||||||
|
- [x] Emitting #line
|
||||||
|
- [x] Making sure debugger works
|
||||||
|
- [x] We need ++ -- operators
|
||||||
|
- [x] Arrays with size passed
|
||||||
|
- [x] Values inited to 0 by default
|
||||||
|
- [x] Some way to call foreign functions
|
||||||
|
- [x] We are parsing wrong here: (t.str=(&string_to_lex.str)[i]);
|
||||||
|
- [x] Test new operators, add constant eval for them
|
||||||
|
- [x] lvalue, rvalue concept so we cant assign value to some arbitrary weird expression
|
||||||
|
- [x] Passing down program to compile through command line
|
||||||
|
- [x] More basic types
|
||||||
|
- [x] Implementing required operations int128
|
||||||
|
- [x] Fix casting
|
||||||
|
- [x] More for loop variations
|
||||||
|
- [x] Add basic support for floats
|
||||||
|
- [x] Converting from U64 token to S64 Atom introduces unnanounced error (negates) - probably need big int
|
||||||
|
- [x] Add basic setup for new type system
|
||||||
|
- [x] Access through struct names to constants Arena.CONSTANT
|
||||||
|
- [x] Enums
|
||||||
|
- [x] Make sure pointer arithmetic works
|
||||||
|
- [x] Initial for loop
|
||||||
|
- [x] Enum . access to values
|
||||||
|
- [x] Character literal
|
||||||
|
- [x] Compiling and running a program
|
||||||
|
- [x] Infinite for loop
|
||||||
|
- [x] in new typesystem: Fix calls, fix all example programs
|
||||||
|
- [x] Fix arithmetic operations in new type system
|
||||||
|
- [x] Init statements, different kinds [+=] [-=] etc.
|
||||||
|
- [x] Struct calls
|
||||||
|
- [x] Operators: Bit negation, Not
|
||||||
|
- [x] Default values in calls
|
||||||
|
- [x] Resolving calls with default values
|
||||||
|
- [x] Pass statement
|
||||||
|
- [x] Lexer: Need to insert scope endings when hitting End of file
|
||||||
|
- [x] Resolving calls with named args, with indexed args
|
||||||
|
- [x] Structs
|
||||||
|
- [x] Struct field access
|
||||||
|
- [x] Struct field access with dots while compiling to arrows in c
|
||||||
|
- [x] Typespecs should probably be expressions so stuff like would be possible :: \*[32]int
|
||||||
|
- [x] Initial order independence algorithm
|
||||||
|
- [x] Think about compound expressions, unify with calls - maybe Thing(a=1) instead of Thing{a=1}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base.cpp"
|
#include "base.cpp"
|
||||||
|
|||||||
@@ -1055,6 +1055,14 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
|||||||
|
|
||||||
node->index_original_type = left.type;
|
node->index_original_type = left.type;
|
||||||
node->resolved_type = left.type->arr.base;
|
node->resolved_type = left.type->arr.base;
|
||||||
|
if(is_string(left.type)){
|
||||||
|
if(left.type == type_pointer_to_char){
|
||||||
|
node->resolved_type = type_char;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
node->resolved_type = type_u8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @todo: type_architecture?
|
// @todo: type_architecture?
|
||||||
// we only try to convert the index cause array can't be const
|
// we only try to convert the index cause array can't be const
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
|||||||
|
|
||||||
|
|
||||||
frame_time := time() - frame_start_time
|
frame_time := time() - frame_start_time
|
||||||
print_float(frame_time)
|
|
||||||
if frame_time < requested_time_per_frame
|
if frame_time < requested_time_per_frame
|
||||||
if good_scheduling
|
if good_scheduling
|
||||||
time_to_sleep := (requested_time_per_frame - frame_time) * 1000
|
time_to_sleep := (requested_time_per_frame - frame_time) * 1000
|
||||||
|
|||||||
Reference in New Issue
Block a user