Fix bug with finding function calls
Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
parent
a966ff45a3
commit
a372c4420a
@ -15,16 +15,20 @@ StructType :: struct {
|
||||
}
|
||||
|
||||
Type :: struct {
|
||||
kind: TypeKind,
|
||||
bit_size: u8,
|
||||
is_signed: bool,
|
||||
pointer_to: ^Type,
|
||||
array_of: ^Type,
|
||||
array_size: u64,
|
||||
struct_type: ^StructType,
|
||||
kind: TypeKind,
|
||||
bit_size: u8,
|
||||
is_signed: bool,
|
||||
pointer_to: ^Type,
|
||||
array_of: ^Type,
|
||||
array_size: u64,
|
||||
struct_index: u64,
|
||||
struct_type: ^StructType,
|
||||
}
|
||||
|
||||
type_to_string :: proc(type: ^Type) -> string {
|
||||
if type == nil {
|
||||
return "nil (shouldnt happen lol)"
|
||||
}
|
||||
if type.kind == .Integer {
|
||||
if type.is_signed {
|
||||
return fmt.aprintf("i{}", type.bit_size)
|
||||
|
@ -278,10 +278,12 @@ type_check :: proc(ast: ^Node, parent_ast: ^Node) {
|
||||
}
|
||||
|
||||
found_field := false
|
||||
for &field in struct_.fields {
|
||||
struct_index: u64 = 0
|
||||
for &field, i in struct_.fields {
|
||||
if compare_dyn_arrs(&field.name, &rhs.value.([dynamic]u8)) {
|
||||
ast.return_type = field.type
|
||||
found_field = true
|
||||
struct_index = u64(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -298,6 +300,8 @@ type_check :: proc(ast: ^Node, parent_ast: ^Node) {
|
||||
break
|
||||
}
|
||||
|
||||
ast.return_type.struct_index = struct_index
|
||||
|
||||
case .FunctionCall:
|
||||
if ast.children[0].kind == .FieldAccess {
|
||||
// FIXME: This is some temporary shitfuckery, check if a function is part
|
||||
@ -389,11 +393,12 @@ type_check :: proc(ast: ^Node, parent_ast: ^Node) {
|
||||
} else {
|
||||
ast.kind = .FunctionCall
|
||||
append(&ast.children, node_create_value(.Identifier, ast.range, ast.value))
|
||||
ast.value = nil
|
||||
ast.return_type = fn.return_type
|
||||
ast.value = nil
|
||||
}
|
||||
} else {
|
||||
ast.return_type = type
|
||||
}
|
||||
ast.return_type = type
|
||||
case .BinaryExpression:
|
||||
type_check(ast.children[0], ast)
|
||||
type_check(ast.children[1], ast)
|
||||
@ -446,6 +451,15 @@ type_check :: proc(ast: ^Node, parent_ast: ^Node) {
|
||||
case .UnaryExpression:
|
||||
// FIXME: Verify that the operation is possible
|
||||
type_check(ast.children[0], ast)
|
||||
append(
|
||||
&g_message_list,
|
||||
message_create(
|
||||
.FIXME,
|
||||
fmt.aprintf("Check type before setting return type in unary expression"),
|
||||
ast.range,
|
||||
),
|
||||
)
|
||||
ast.return_type = ast.children[0].return_type
|
||||
case .Ret:
|
||||
function_return_type := scope_function_return_type_lookup()
|
||||
if function_return_type == nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user