diff --git a/ccodegen.cpp b/ccodegen.cpp index ccb998f..c5df184 100644 --- a/ccodegen.cpp +++ b/ccodegen.cpp @@ -136,6 +136,7 @@ gen_expr(Ast_Expr *ast){ } CASE(CALL, Call){ + // @todo: Reach into map instead of direct lookup if(node->type->kind == TYPE_STRUCT){ // @todo: Should this be type_type maybe??? gen("("); gen_simple_decl(node->type, {}); @@ -145,9 +146,9 @@ gen_expr(Ast_Expr *ast){ For(node->exprs){ auto comp = it; if(comp->name){ - gen("["); + gen("."); gen_expr(comp->name); - gen("] = "); + gen(" = "); } if(comp->index){ gen("["); diff --git a/lambdas.kl b/lambdas.kl index 4579694..29af688 100644 --- a/lambdas.kl +++ b/lambdas.kl @@ -16,7 +16,7 @@ if_stmt :: (cond: int): type add_10 :: (size: int): int // @todo: before the generation c pass, each stage should have it's own - // tree transformation phase, where it yanks functions etc. + // tree transformation phase, where it yanks functions out etc. add_20 :: (new_size: int): int return 20 diff --git a/main.cpp b/main.cpp index e0fa2da..876c524 100644 --- a/main.cpp +++ b/main.cpp @@ -37,11 +37,12 @@ /// [x] - Typespecs should probably be expressions so stuff like would be possible :: *[32]int /// [x] - Initial order independence algorithm /// [ ] - Cleanup the mess with constant bindings -/// [ ] - Struct calls -/// [ ] - Default values in calls -/// [ ] - Resolving calls with default values -/// [ ] - Resolving calls with named args, with indexed args -/// [ ] - Structs +/// [x] - Struct calls +/// [x] - Default values in calls +/// [x] - Resolving calls with default values +/// [x] - Resolving calls with named args, with indexed args +/// [x] - Structs +/// [ ] - Default values in structs??? /// [ ] - Enums /// [ ] - For loop /// [ ] - Switch @@ -65,8 +66,8 @@ int main(){ String result = {}; // result = compile_file("order1.kl"_s); - result = compile_file("lambdas.kl"_s); - // result = compile_file("order2.kl"_s); + // result = compile_file("lambdas.kl"_s); + result = compile_file("order2.kl"_s); // result = compile_file("globals.kl"_s); printf("%s", result.str); diff --git a/new_type.cpp b/new_type.cpp index 8ab3fbd..7e550dc 100644 --- a/new_type.cpp +++ b/new_type.cpp @@ -162,7 +162,7 @@ type_incomplete(Ast *ast){ function void type_complete(Ast_Resolved_Type *type){ if(type->kind == TYPE_COMPLETING){ - parsing_error(0, "Cyclic type dependency"); + parsing_error(type->ast->pos, "Cyclic type dependency"); } else if(type->kind != TYPE_INCOMPLETE){ return; diff --git a/order2.kl b/order2.kl index 288ec2f..c337e22 100644 --- a/order2.kl +++ b/order2.kl @@ -11,6 +11,9 @@ Arena :: struct len : int cap : int + get_len :: (s: *Arena): int + return s.len + string16: Str16 String16 :: struct diff --git a/typechecking.cpp b/typechecking.cpp index 34f4cf2..de0c3c9 100644 --- a/typechecking.cpp +++ b/typechecking.cpp @@ -402,6 +402,7 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *const_sym){ assert(name->kind == AST_IDENT); For_It(agg->members, member){ if(member->name.str == name->intern_val.str){ + if(member->kind == AST_CONST) parsing_error(expr->pos, "Initializing a value that is a constant"); found = member; found_type = &type->agg.members[agg->members.get_index(&member)]; break;