diff options
| author | gingerBill <bill@gingerbill.org> | 2020-01-17 23:30:38 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-01-17 23:30:38 +0000 |
| commit | 7f89f6b582b138f9809d80f7ed133d72c248f56d (patch) | |
| tree | 1a796da5ea2d4dc34351ec4045011a71ab699830 /src/check_expr.cpp | |
| parent | 159150c6d9a7d421c0d58bd582847104799606d4 (diff) | |
Add intrinsics.type_is_specialization_of
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 4f1aed898..c8778a222 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5499,6 +5499,36 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 operand->type = t_untyped_bool; break; + case BuiltinProc_type_is_specialization_of: + { + if (operand->mode != Addressing_Type) { + error(operand->expr, "Expected a type for '%.*s'", LIT(builtin_name)); + operand->mode = Addressing_Invalid; + operand->type = t_invalid; + return false; + } + Type *t = operand->type; + Type *s = nullptr; + + bool prev_ips = c->in_polymorphic_specialization; + c->in_polymorphic_specialization = true; + s = check_type(c, ce->args[1]); + c->in_polymorphic_specialization = prev_ips; + + if (s == t_invalid) { + error(ce->args[1], "Invalid specialization type for '%.*s'", LIT(builtin_name)); + operand->mode = Addressing_Invalid; + operand->type = t_invalid; + return false; + } + + operand->mode = Addressing_Constant; + operand->type = t_untyped_bool; + operand->value = exact_value_bool(check_type_specialization_to(c, s, t, false, false)); + + } + break; + case BuiltinProc_type_proc_parameter_count: operand->value = exact_value_i64(0); if (operand->mode != Addressing_Type) { |