Compiling entire folder, working on examples

This commit is contained in:
Krzosa Karol
2022-07-07 21:03:52 +02:00
parent e7c14010f2
commit 4a0234155c
3 changed files with 28 additions and 56 deletions

View File

@@ -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

View File

@@ -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<OS_File_Info> examples = os_list_dir(scratch, "examples"_s);
For(examples){
if(it.is_directory) continue;
compile_file(it.absolute_path, COMPILE_AND_RUN);
}
__debugbreak();
}