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