From 4a0234155c9752a96a0a3eabfad1597b3b3d3061 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Thu, 7 Jul 2022 21:03:52 +0200 Subject: [PATCH] Compiling entire folder, working on examples --- .gitignore | 2 +- examples/runtime_type_information.kl | 70 +++++++--------------------- main.cpp | 12 +++-- 3 files changed, 28 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index e923190..c1ac5aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ *.bin *.c -backup* \ No newline at end of file +backup* diff --git a/examples/runtime_type_information.kl b/examples/runtime_type_information.kl index 3adbf08..d49caa2 100644 --- a/examples/runtime_type_information.kl +++ b/examples/runtime_type_information.kl @@ -45,59 +45,25 @@ main :: (): int assert(value_to_be_wrapped == 20) + letter := get_first_letter_of_type(value_to_be_wrapped) + assert(letter == 'I) // ' +get_first_letter_of_type :: (a: Any): U8 + type_info := get_type_info(a.type) + if !type_info + return '- // ' + result: U8 + switch type_info.kind + Type_Info_Kind.S64, Type_Info_Kind.S32, Type_Info_Kind.S16, Type_Info_Kind.S8, Type_Info_Kind.INT + result = 'I // ' + Type_Info_Kind.U64, Type_Info_Kind.U32, Type_Info_Kind.U16, Type_Info_Kind.U8 + result = 'U // ' + Type_Info_Kind.F64 + result = 'F // ' + Type_Info_Kind.POINTER + result = '* // ' + default;; result = '- // ' -// print :: (a: Any) -// type_info := get_type_info(a.type) -// if !type_info -// return - -// print_type(a.type) -// OutputDebugStringA(" - ") -// // @todo check for types here -// switch type_info.kind -// Type_Info_Kind.S64, Type_Info_Kind.S32, Type_Info_Kind.S16, Type_Info_Kind.S8, Type_Info_Kind.INT -// OutputDebugStringA("Integer") -// Type_Info_Kind.U64, Type_Info_Kind.U32, Type_Info_Kind.U16, Type_Info_Kind.U8 -// OutputDebugStringA("Unsigned") -// Type_Info_Kind.F64 -// data := a.data->*F64 -// print_float(*data) -// Type_Info_Kind.POINTER -// OutputDebugStringA("Pointer") -// default;; OutputDebugStringA("Unknown") - - -// little_untyped_test :: () -// if true == false;; pass -// if true;; pass -// cast_value1 := 32->S64 -// cast_value2 := true->Bool -// value3 := !true -// value4 := !325252 -// value5 := !42.42 -// some_constant :: 10 -// value6 := !some_constant -// var_not_const := 0 -// value7 := some_constant + - -some_constant + +-32 + -var_not_const - - -// value3 = value3 + value4 + value5 + cast_value2 + value6 -// cast_value1 += 1 + value7 - - - // switch 4 - // 4;; OutputDebugStringA("4") - // 3;; OutputDebugStringA("3") - - // some_type: Type = Vec2 - // char_info := get_type_info(char) - // val := 4232.23 - // thing: Any = val - // print(val) - // print(some_type) - // // print_array({125.23, 32}) - - // assert(char_info.kind == Type_Info_Kind.CHAR) + return result diff --git a/main.cpp b/main.cpp index 3d0ad60..eb4cd7e 100644 --- a/main.cpp +++ b/main.cpp @@ -190,10 +190,11 @@ For modules it's a bit different cause they should be distributed as valid. #include "intermediate_representation.cpp" // #include "bytecode_interpreter.cpp" // #include "bytecode.cpp" +#include "x64_funtime.cpp" int main(int argument_count, char **arguments){ - + // test_x64_stuff(); #if OS_WINDOWS // Set output mode to handle virtual terminal sequences HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); @@ -228,7 +229,12 @@ int main(int argument_count, char **arguments){ program_name = string_from_cstring(arguments[1]); } - compile_file("examples/runtime_type_information.kl"_s, COMPILE_AND_RUN); - compile_file("examples/types_as_first_class_values.kl"_s, COMPILE_AND_RUN); + Scratch scratch; + Array examples = os_list_dir(scratch, "examples"_s); + For(examples){ + if(it.is_directory) continue; + compile_file(it.absolute_path, COMPILE_AND_RUN); + } + __debugbreak(); }