void pointer duck typing

This commit is contained in:
Krzosa Karol
2022-06-17 09:16:33 +02:00
parent 66d7c8ca52
commit ed017c79a5
9 changed files with 68 additions and 38 deletions

View File

@@ -41,12 +41,15 @@ want to export all the symbols, we can namespace them optionally.
-------------------------------------------------------------------------------
@todo
[ ] - Better error messages when type difference
[ ] - Casting pointers to and from void should be implicit
[ ] - Kilobyte, Megabyte, Gigabyte
[ ] - Mixing loads and imports leads to code duplication, is that what we want???
[ ] - Fix field access, cant cast, cant index
[ ] - Add parent_scope to Ast_Type
[ ] - Switch
[ ] - Some way to take slice of data
[ ] - Optional function renaming in codegen
[ ] - Multiple return values
[ ] - Using in structs to embed members, then casting offsets to that embedded member
[ ] - Comma notation when declaring variables thing1, thing2: S32
@@ -71,6 +74,7 @@ want to export all the symbols, we can namespace them optionally.
[ ] - Conditional compilation #if
@donzo
[x] - Multiple return values
[x] - Add c string
[-] - Should compound resolution use an algorithm to reorder compounds to initialize all fields in order
[x] - slices should be properly displayed in debugger
@@ -157,36 +161,19 @@ int main(int argument_count, char **arguments){
test_intern_table();
#if 0
if(argument_count > 1){
Scratch scratch;
String name = string_fmt(scratch, "%s.kl", arguments[1]);
String c_filename = string_fmt(scratch, "%s.c", arguments[1]);
String run_program = string_fmt(scratch, "%s.exe", arguments[1]);
Array<String> files = {scratch};
files.add(name);
String result = compile_files(files);
assert(f);
F64 begin = os_time();
system((const char *)compiler_call.str);
printf("\nCompile time: %f", os_time() - begin);
system((const char *)run_program.str);
}
#else
emit_line_directives = true;
String program_name = "main.kl"_s;
if(argument_count > 1){
program_name = string_from_cstring(arguments[1]);
}
F64 total_time = os_time();
begin_compilation();
Ast_Module *module = add_module(pctx->intern("main.kl"_s));
Ast_Module *module = add_module(pctx->intern(program_name));
parse_all_modules();
assert(module);
resolve_everything_in_module(module);
String result = end_compilation();
String result = get_compilation_result();
assert(os_write_file("program.c"_s, result));
{
Scratch scratch;
@@ -200,6 +187,5 @@ int main(int argument_count, char **arguments){
printf("\nparsing = %f", parsing_time_end - parsing_time_begin);
printf("\nresolving = %f", resolving_time_end - resolving_time_begin);
printf("\ngeneratin = %f", generating_time_end - generating_time_begin);
#endif
__debugbreak();
}