From 66b2be355035d1a1c4527b53f1c9db8dfee56720 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Thu, 29 Sep 2022 17:05:45 +0200 Subject: [PATCH] Delete code, adjust example to operator overload errors --- core_codegen_c_language.cpp | 31 ++----------------------------- core_compiler.cpp | 5 ++++- core_main.cpp | 5 ++--- examples/raymarcher.kl | 8 ++++---- 4 files changed, 12 insertions(+), 37 deletions(-) diff --git a/core_codegen_c_language.cpp b/core_codegen_c_language.cpp index abcebf1..d95327c 100644 --- a/core_codegen_c_language.cpp +++ b/core_codegen_c_language.cpp @@ -354,7 +354,7 @@ gen_expr(Ast_Expr *ast, Ast_Type *type_of_var){ gen_expr(node->right); return true; } - + else if(node->op == TK_Arrow){ gen("("); gen("("); @@ -649,34 +649,7 @@ gen_ast(Ast *ast){ BREAK(); } - CASE(CONST, Decl){ - switch(node->type->kind){ - CASE_FLOAT:{ - gen("// F64 %Q = ", node->name); - // gen_value(node->pos, node->value); - } break; - CASE_INT:{ - gen("// constant int %Q = ", node->name); - // gen_value(node->pos, node->value); - }break; - CASE_STRING:{ - assert(is_pointer(node->type) ? node->type == type_pointer_to_char : 1); - gen("// const String %Q = ", node->name); - // gen_value(node->pos, node->value); - }break; - CASE_BOOL:{ - gen("// const Bool %Q = ", node->name); - // gen_value(node->pos, node->value); - }break; - case TYPE_LAMBDA:{ - gen("// "); - gen_lambda(node->unique_name, node->lambda); - } break; - invalid_default_case; - } - - BREAK(); - } + CASE(CONST, Decl){unused(node);BREAK();} CASE(SWITCH, Switch){ gen("switch("); diff --git a/core_compiler.cpp b/core_compiler.cpp index 6335ac4..42ad1e0 100644 --- a/core_compiler.cpp +++ b/core_compiler.cpp @@ -270,6 +270,7 @@ const U32 COMPILE_NULL = 0x0; const U32 COMPILE_PRINT_STATS = 0x1; const U32 COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY = 0x2; const U32 COMPILE_AND_RUN = 0x4; +const U32 COMPILE_TESTING = 0x8; function void compile_file(String filename, U32 compile_flags = COMPILE_NULL){ @@ -304,7 +305,9 @@ compile_file(String filename, U32 compile_flags = COMPILE_NULL){ } if(is_flag_set(compile_flags, COMPILE_AND_RUN)){ - int result = system("a.exe testing"); + String testing = compile_flags&COMPILE_TESTING ? "testing"_s : ""_s; + String sys = string_fmt(scratch, "a.exe %Q", testing); + int result = system((char *)sys.str); assert(result != -1); if(result == 0){ log_info(PRINTF_GREEN "OK!" PRINTF_RESET); diff --git a/core_main.cpp b/core_main.cpp index 9a1c1d8..3072aee 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -278,8 +278,7 @@ int main(int argument_count, char **arguments){ emit_line_directives = true; if(argument_count > 1){ String program_name = string_from_cstring(arguments[1]); - compile_file(program_name, COMPILE_AND_RUN); - + compile_file(program_name, COMPILE_PRINT_STATS); } else { @@ -288,7 +287,7 @@ int main(int argument_count, char **arguments){ // compile_file("examples/language_basics.kl"_s, COMPILE_AND_RUN); For(examples){ if(it.is_directory) continue; - compile_file(it.absolute_path, COMPILE_AND_RUN); + compile_file(it.absolute_path, COMPILE_AND_RUN | COMPILE_TESTING); } } __debugbreak(); diff --git a/examples/raymarcher.kl b/examples/raymarcher.kl index 4121c2a..b978903 100644 --- a/examples/raymarcher.kl +++ b/examples/raymarcher.kl @@ -23,7 +23,7 @@ Raymarcher_Update :: () diffuse_color := Vec3{0.7,0.2,0.2} specular_color := Vec3{1,1,1} eye := Vec3{0, 0, 2} - light_intensity :: 1.2 + light_intensity :: 1.2->F32 Xf := 1 / X->F32 Yf := 1 / Y->F32 @@ -61,17 +61,17 @@ Raymarcher_Update :: () eye_to_point := Vec3_Normalize(eye - p) reflected_light := Vec3_Normalize(Vec3_Reflect(Vec3_Negate(light_to_point), normal)) - ambient :: 0.2 + ambient :: 0.2->F32 diffuse := Vec3_Dot(normal, light_to_point) - color := ambient_color*ambient + color := ambient_color*ambient->F32 if diffuse > Epsilon color = color + diffuse_color*diffuse specular := Vec3_Dot(reflected_light, eye_to_point) if specular > Epsilon specular = specular*specular*specular*specular - color = color + specular_color*specular*0.2 + color = color + specular_color*specular*0.2->F32 color = color * light_intensity // Gamma correction