diff --git a/main.cpp b/main.cpp index 3c4441c..4bcf491 100644 --- a/main.cpp +++ b/main.cpp @@ -100,13 +100,14 @@ Expr: [ ] - Type aliases :: should probably be strictly typed, but assigning constant values should work @ideas +[ ] - Var args using Any array - args: []Any - delete vargs [ ] - [Using] keyword that brings in the struct enviroment into current scope etc. [ ] - Constant arrays that evaluate fully at compile time [ ] - Rust like enum where you associate values(other structs) with keys [ ] - Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {} [ ] - Inject stack traces into the program -[ ] - Rewrite constants to embed lambda, types, structs etc.? ??? -[ ] - Var args using Any array - args: []Any - delete vargs +[ ] - Rewrite constants to embed lambda, types, structs etc. +[ ] - Conditional compilation #if @donzo [x] - We need ++ -- operators @@ -175,21 +176,7 @@ int main(int argument_count, char **arguments){ test_intern_table(); - String result = {}; -#if 1 - result = compile_file("globals.kl"_s); - printf("%s", result.str); - result = compile_file("enums.kl"_s); - printf("%s", result.str); - result = compile_file("order1.kl"_s); - printf("%s", result.str); - result = compile_file("order2.kl"_s); - printf("%s", result.str); - result = compile_file("lambdas.kl"_s); - printf("%s", result.str); - result = compile_file("new_types.kl"_s); - printf("%s", result.str); -#endif + if(argument_count > 1){ Scratch scratch; @@ -197,13 +184,30 @@ int main(int argument_count, char **arguments){ String c_filename = string_fmt(scratch, "%s.c", arguments[1]); String call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe && %s.exe", arguments[1], arguments[1], arguments[1]); - result = compile_file(name); + String result = compile_file(name); FILE *f = fopen((const char *)c_filename.str, "w"); assert(f); fprintf(f, "%.*s", (int)result.len, result.str); fclose(f); system((const char *)call.str); } + else{ + String result = {}; + #if 1 + result = compile_file("globals.kl"_s); + printf("%s", result.str); + result = compile_file("enums.kl"_s); + printf("%s", result.str); + result = compile_file("order1.kl"_s); + printf("%s", result.str); + result = compile_file("order2.kl"_s); + printf("%s", result.str); + result = compile_file("lambdas.kl"_s); + printf("%s", result.str); + result = compile_file("new_types.kl"_s); + printf("%s", result.str); + #endif + } __debugbreak(); } diff --git a/new_types.kl b/new_types.kl index e766be1..d849b6b 100644 --- a/new_types.kl +++ b/new_types.kl @@ -60,34 +60,28 @@ binary_test :: (thing: S32 = 442) basic_type_assignment :: () - custom_data: Custom_Data + custom_data1 := Custom_Data(thing = 23) + custom_data2: Custom_Data some_constant :: true thing: Bool = some_constant float_val :: 325.42 float_var := float_val -compounds :: () - custom_data := Custom_Data(thing = 23) - +for_loops :: () for thing2 := 10 pass - for thing1 := 10,,thing1+=1 pass - for pass - for i := 0, i == 4, i+=1 pass - for j:=0, j < 10 pass - Custom_Data :: struct thing: S32 - // constant_proc :: () - // constant_proc() +array_test :: () + pass \ No newline at end of file diff --git a/typecheck.cpp b/typecheck.cpp index 439cdbe..dd3fff3 100644 --- a/typecheck.cpp +++ b/typecheck.cpp @@ -583,7 +583,6 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *lambda_to_res CASE(CALL, Call){ Operand name = resolve_expr(node->name); Ast_Resolved_Type *type = name.type; - type_complete(type); if(name.type == type_type){ type = name.type_val; if(expected_type && expected_type != type) @@ -591,6 +590,7 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *lambda_to_res if(type->kind == TYPE_LAMBDA) parsing_error(node->pos, "Calling a lambda type"); } + type_complete(type); node->type = type; if(type->kind == TYPE_ARRAY){