Delete code, adjust example to operator overload errors

This commit is contained in:
Krzosa Karol
2022-09-29 17:05:45 +02:00
parent 5cb5f12cda
commit 66b2be3550
4 changed files with 12 additions and 37 deletions

View File

@@ -649,34 +649,7 @@ gen_ast(Ast *ast){
BREAK(); BREAK();
} }
CASE(CONST, Decl){ CASE(CONST, Decl){unused(node);BREAK();}
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(SWITCH, Switch){ CASE(SWITCH, Switch){
gen("switch("); gen("switch(");

View File

@@ -270,6 +270,7 @@ const U32 COMPILE_NULL = 0x0;
const U32 COMPILE_PRINT_STATS = 0x1; const U32 COMPILE_PRINT_STATS = 0x1;
const U32 COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY = 0x2; const U32 COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY = 0x2;
const U32 COMPILE_AND_RUN = 0x4; const U32 COMPILE_AND_RUN = 0x4;
const U32 COMPILE_TESTING = 0x8;
function void function void
compile_file(String filename, U32 compile_flags = COMPILE_NULL){ 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)){ 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); assert(result != -1);
if(result == 0){ if(result == 0){
log_info(PRINTF_GREEN "OK!" PRINTF_RESET); log_info(PRINTF_GREEN "OK!" PRINTF_RESET);

View File

@@ -278,8 +278,7 @@ int main(int argument_count, char **arguments){
emit_line_directives = true; emit_line_directives = true;
if(argument_count > 1){ if(argument_count > 1){
String program_name = string_from_cstring(arguments[1]); String program_name = string_from_cstring(arguments[1]);
compile_file(program_name, COMPILE_AND_RUN); compile_file(program_name, COMPILE_PRINT_STATS);
} }
else { else {
@@ -288,7 +287,7 @@ int main(int argument_count, char **arguments){
// compile_file("examples/language_basics.kl"_s, COMPILE_AND_RUN); // compile_file("examples/language_basics.kl"_s, COMPILE_AND_RUN);
For(examples){ For(examples){
if(it.is_directory) continue; if(it.is_directory) continue;
compile_file(it.absolute_path, COMPILE_AND_RUN); compile_file(it.absolute_path, COMPILE_AND_RUN | COMPILE_TESTING);
} }
} }
__debugbreak(); __debugbreak();

View File

@@ -23,7 +23,7 @@ Raymarcher_Update :: ()
diffuse_color := Vec3{0.7,0.2,0.2} diffuse_color := Vec3{0.7,0.2,0.2}
specular_color := Vec3{1,1,1} specular_color := Vec3{1,1,1}
eye := Vec3{0, 0, 2} eye := Vec3{0, 0, 2}
light_intensity :: 1.2 light_intensity :: 1.2->F32
Xf := 1 / X->F32 Xf := 1 / X->F32
Yf := 1 / Y->F32 Yf := 1 / Y->F32
@@ -61,17 +61,17 @@ Raymarcher_Update :: ()
eye_to_point := Vec3_Normalize(eye - p) eye_to_point := Vec3_Normalize(eye - p)
reflected_light := Vec3_Normalize(Vec3_Reflect(Vec3_Negate(light_to_point), normal)) 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) diffuse := Vec3_Dot(normal, light_to_point)
color := ambient_color*ambient color := ambient_color*ambient->F32
if diffuse > Epsilon if diffuse > Epsilon
color = color + diffuse_color*diffuse color = color + diffuse_color*diffuse
specular := Vec3_Dot(reflected_light, eye_to_point) specular := Vec3_Dot(reflected_light, eye_to_point)
if specular > Epsilon if specular > Epsilon
specular = specular*specular*specular*specular specular = specular*specular*specular*specular
color = color + specular_color*specular*0.2 color = color + specular_color*specular*0.2->F32
color = color * light_intensity color = color * light_intensity
// Gamma correction // Gamma correction