b32 type_is_pointer(Type* type);
b32 type_is_struct(Type* type);
b32 type_is_bool(Type* type);
+b32 type_results_in_void(Type* type);
#endif // #ifndef ONYX_TYPES
*parent = link;
}
-link_print :: proc (start: ^Link) {
+link_print :: proc (start: ^Link) -> i32 {
+ count := 0;
+
walker := start;
while (walker as i32) != 0 {
print(walker.data);
walker = walker.next;
+ count += 1;
}
+
+ return count;
}
link_test :: proc #export "main2" {
if (binop->operation >= Binary_Op_Equal
&& binop->operation <= Binary_Op_Greater_Equal) {
binop->type = &basic_types[Basic_Kind_Bool];
+ } else if (binop_is_assignment(binop)) {
+ binop->type = &basic_types[Basic_Kind_Void];
} else {
binop->type = binop->left->type;
}
CHECK(statement, AstNode* stmt) {
switch (stmt->kind) {
+ case Ast_Kind_Break: return 0;
+ case Ast_Kind_Continue: return 0;
+
case Ast_Kind_Return: return check_return((AstReturn *) stmt);
case Ast_Kind_If: return check_if((AstIf *) stmt);
case Ast_Kind_While: return check_while((AstWhile *) stmt);
case Ast_Kind_For: return check_for((AstFor *) stmt);
- case Ast_Kind_Call: return check_call((AstCall *) stmt);
case Ast_Kind_Block: return check_block((AstBlock *) stmt);
- case Ast_Kind_Binary_Op: return check_binaryop((AstBinaryOp *) stmt, 1);
-
- case Ast_Kind_Break: return 0;
- case Ast_Kind_Continue: return 0;
+ case Ast_Kind_Binary_Op:
+ stmt->flags |= Ast_Flag_Expr_Ignored;
+ return check_binaryop((AstBinaryOp *) stmt, 1);
default:
stmt->flags |= Ast_Flag_Expr_Ignored;
b32 type_is_bool(Type* type) {
return type != NULL && type->kind == Type_Kind_Basic && type->Basic.kind == Basic_Kind_Bool;
}
+
+b32 type_results_in_void(Type* type) {
+ return (type == NULL)
+ || (type->kind == Type_Kind_Basic && type->Basic.kind == Basic_Kind_Void)
+ || ( (type->kind == Type_Kind_Function)
+ && (type->Function.return_type->kind == Type_Kind_Basic)
+ && (type->Function.return_type->Basic.kind == Basic_Kind_Void));
+}