Basic polymorphic named procedure parameters for procedures and records

This commit is contained in:
gingerBill
2020-04-13 15:48:56 +01:00
parent f09b6a4c90
commit f229084baa
9 changed files with 165 additions and 44 deletions

View File

@@ -592,6 +592,10 @@ i32 exact_value_order(ExactValue const &v) {
return 5;
case ExactValue_Pointer:
return 6;
case ExactValue_Procedure:
return 7;
// case ExactValue_Compound:
// return 8;
default:
GB_PANIC("How'd you get here? Invalid Value.kind");
@@ -652,6 +656,9 @@ void match_exact_values(ExactValue *x, ExactValue *y) {
return;
}
break;
case ExactValue_Procedure:
return;
}
compiler_error("match_exact_values: How'd you get here? Invalid ExactValueKind %d", x->kind);
@@ -915,12 +922,23 @@ bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) {
case Token_NotEq: return !are_types_identical(x.value_typeid, y.value_typeid);
}
break;
case ExactValue_Procedure:
switch (op) {
case Token_CmpEq: return are_types_identical(x.value_typeid, y.value_typeid);
case Token_NotEq: return !are_types_identical(x.value_typeid, y.value_typeid);
}
break;
}
GB_PANIC("Invalid comparison");
return false;
}
Entity *strip_entity_wrapping(Ast *expr);
Entity *strip_entity_wrapping(Entity *e);
gbString write_expr_to_string(gbString str, Ast *node);
gbString write_exact_value_to_string(gbString str, ExactValue const &v, isize string_limit=36) {
switch (v.kind) {
@@ -956,9 +974,9 @@ gbString write_exact_value_to_string(gbString str, ExactValue const &v, isize st
case ExactValue_Pointer:
return str;
case ExactValue_Compound:
return str;
return write_expr_to_string(str, v.value_compound);
case ExactValue_Procedure:
return str;
return write_expr_to_string(str, v.value_procedure);
}
return str;
};