Fix type complete not called properly
This commit is contained in:
40
main.cpp
40
main.cpp
@@ -100,13 +100,14 @@ Expr:
|
|||||||
[ ] - Type aliases :: should probably be strictly typed, but assigning constant values should work
|
[ ] - Type aliases :: should probably be strictly typed, but assigning constant values should work
|
||||||
|
|
||||||
@ideas
|
@ideas
|
||||||
|
[ ] - Var args using Any array - args: []Any - delete vargs
|
||||||
[ ] - [Using] keyword that brings in the struct enviroment into current scope etc.
|
[ ] - [Using] keyword that brings in the struct enviroment into current scope etc.
|
||||||
[ ] - Constant arrays that evaluate fully at compile time
|
[ ] - Constant arrays that evaluate fully at compile time
|
||||||
[ ] - Rust like enum where you associate values(other structs) with keys
|
[ ] - Rust like enum where you associate values(other structs) with keys
|
||||||
[ ] - Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {}
|
[ ] - Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {}
|
||||||
[ ] - Inject stack traces into the program
|
[ ] - Inject stack traces into the program
|
||||||
[ ] - Rewrite constants to embed lambda, types, structs etc.? ???
|
[ ] - Rewrite constants to embed lambda, types, structs etc.
|
||||||
[ ] - Var args using Any array - args: []Any - delete vargs
|
[ ] - Conditional compilation #if
|
||||||
|
|
||||||
@donzo
|
@donzo
|
||||||
[x] - We need ++ -- operators
|
[x] - We need ++ -- operators
|
||||||
@@ -175,21 +176,7 @@ int main(int argument_count, char **arguments){
|
|||||||
test_intern_table();
|
test_intern_table();
|
||||||
|
|
||||||
|
|
||||||
String result = {};
|
|
||||||
#if 1
|
|
||||||
result = compile_file("globals.kl"_s);
|
|
||||||
printf("%s", result.str);
|
|
||||||
result = compile_file("enums.kl"_s);
|
|
||||||
printf("%s", result.str);
|
|
||||||
result = compile_file("order1.kl"_s);
|
|
||||||
printf("%s", result.str);
|
|
||||||
result = compile_file("order2.kl"_s);
|
|
||||||
printf("%s", result.str);
|
|
||||||
result = compile_file("lambdas.kl"_s);
|
|
||||||
printf("%s", result.str);
|
|
||||||
result = compile_file("new_types.kl"_s);
|
|
||||||
printf("%s", result.str);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(argument_count > 1){
|
if(argument_count > 1){
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
@@ -197,13 +184,30 @@ int main(int argument_count, char **arguments){
|
|||||||
String c_filename = string_fmt(scratch, "%s.c", arguments[1]);
|
String c_filename = string_fmt(scratch, "%s.c", arguments[1]);
|
||||||
String call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe && %s.exe", arguments[1], arguments[1], arguments[1]);
|
String call = string_fmt(scratch, "clang.exe %s.c -g -o %s.exe && %s.exe", arguments[1], arguments[1], arguments[1]);
|
||||||
|
|
||||||
result = compile_file(name);
|
String result = compile_file(name);
|
||||||
FILE *f = fopen((const char *)c_filename.str, "w");
|
FILE *f = fopen((const char *)c_filename.str, "w");
|
||||||
assert(f);
|
assert(f);
|
||||||
fprintf(f, "%.*s", (int)result.len, result.str);
|
fprintf(f, "%.*s", (int)result.len, result.str);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
system((const char *)call.str);
|
system((const char *)call.str);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
String result = {};
|
||||||
|
#if 1
|
||||||
|
result = compile_file("globals.kl"_s);
|
||||||
|
printf("%s", result.str);
|
||||||
|
result = compile_file("enums.kl"_s);
|
||||||
|
printf("%s", result.str);
|
||||||
|
result = compile_file("order1.kl"_s);
|
||||||
|
printf("%s", result.str);
|
||||||
|
result = compile_file("order2.kl"_s);
|
||||||
|
printf("%s", result.str);
|
||||||
|
result = compile_file("lambdas.kl"_s);
|
||||||
|
printf("%s", result.str);
|
||||||
|
result = compile_file("new_types.kl"_s);
|
||||||
|
printf("%s", result.str);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
}
|
}
|
||||||
|
|||||||
16
new_types.kl
16
new_types.kl
@@ -60,34 +60,28 @@ binary_test :: (thing: S32 = 442)
|
|||||||
|
|
||||||
|
|
||||||
basic_type_assignment :: ()
|
basic_type_assignment :: ()
|
||||||
custom_data: Custom_Data
|
custom_data1 := Custom_Data(thing = 23)
|
||||||
|
custom_data2: Custom_Data
|
||||||
some_constant :: true
|
some_constant :: true
|
||||||
thing: Bool = some_constant
|
thing: Bool = some_constant
|
||||||
float_val :: 325.42
|
float_val :: 325.42
|
||||||
float_var := float_val
|
float_var := float_val
|
||||||
|
|
||||||
|
|
||||||
compounds :: ()
|
for_loops :: ()
|
||||||
custom_data := Custom_Data(thing = 23)
|
|
||||||
|
|
||||||
for thing2 := 10
|
for thing2 := 10
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for thing1 := 10,,thing1+=1
|
for thing1 := 10,,thing1+=1
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for
|
for
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for i := 0, i == 4, i+=1
|
for i := 0, i == 4, i+=1
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for j:=0, j < 10
|
for j:=0, j < 10
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
Custom_Data :: struct
|
Custom_Data :: struct
|
||||||
thing: S32
|
thing: S32
|
||||||
|
|
||||||
// constant_proc :: ()
|
array_test :: ()
|
||||||
// constant_proc()
|
pass
|
||||||
@@ -583,7 +583,6 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *lambda_to_res
|
|||||||
CASE(CALL, Call){
|
CASE(CALL, Call){
|
||||||
Operand name = resolve_expr(node->name);
|
Operand name = resolve_expr(node->name);
|
||||||
Ast_Resolved_Type *type = name.type;
|
Ast_Resolved_Type *type = name.type;
|
||||||
type_complete(type);
|
|
||||||
if(name.type == type_type){
|
if(name.type == type_type){
|
||||||
type = name.type_val;
|
type = name.type_val;
|
||||||
if(expected_type && expected_type != type)
|
if(expected_type && expected_type != type)
|
||||||
@@ -591,6 +590,7 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *lambda_to_res
|
|||||||
if(type->kind == TYPE_LAMBDA)
|
if(type->kind == TYPE_LAMBDA)
|
||||||
parsing_error(node->pos, "Calling a lambda type");
|
parsing_error(node->pos, "Calling a lambda type");
|
||||||
}
|
}
|
||||||
|
type_complete(type);
|
||||||
node->type = type;
|
node->type = type;
|
||||||
|
|
||||||
if(type->kind == TYPE_ARRAY){
|
if(type->kind == TYPE_ARRAY){
|
||||||
|
|||||||
Reference in New Issue
Block a user