New module scheme

This commit is contained in:
Krzosa Karol
2022-06-13 10:49:10 +02:00
parent cdaf85438e
commit b0553c38cf
12 changed files with 247 additions and 165 deletions

View File

@@ -31,6 +31,14 @@ For now I don't thing it should be overloadable.
-------------------------------------------------------------------------------
We compile lot's of files, we keep track of them in Parse_Ctx, making sure we don't
parse same thing twice. Files belong to a module, files can be loaded #load "file".
All the files see all the decls from all the files in that module. We can import
other modules using a different directive #import. #import perhaps should be lazily
evaluated, making sure we don't resolve stuff we don't require. Currently probably
want to export all the symbols, we can namespace them optionally.
-------------------------------------------------------------------------------
@todo
[ ] - Should compound resolution use an algorithm to reorder compounds to initialize all fields in order
@@ -40,6 +48,7 @@ For now I don't thing it should be overloadable.
[ ] - slices should be properly displayed in debugger
[ ] - Rewrite where # happen,
[ ] - cast ->
[ ] - elif
[ ] - #assert that handles constants at compile time and vars at runtime
[ ] - Comma notation when declaring variables thing1, thing2: S32
@@ -163,16 +172,21 @@ int main(int argument_count, char **arguments){
system((const char *)run_program.str);
}
#else
Scratch scratch;
Array<String> files = {scratch};
files.add("lambdas.kl"_s);
files.add("order1.kl"_s);
files.add("order2.kl"_s);
files.add("new_types.kl"_s);
files.add("enums.kl"_s);
files.add("Windows.kl"_s);
// Scratch scratch;
// Array<String> files = {scratch};
// files.add("lambdas.kl"_s);
// files.add("order1.kl"_s);
// files.add("order2.kl"_s);
// files.add("new_types.kl"_s);
// files.add("enums.kl"_s);
// files.add("Windows.kl"_s);
// files.add("euler.kl"_s);
String result = compile_files(files);
// String result = compile_files(files);
begin_compilation();
Ast_Module *module = parse_module("Windows.kl"_s);
assert(module);
resolve_everything_in_module(module);
String result = end_compilation();
printf("%s", result.str);
#endif
__debugbreak();