aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'types.c')
-rw-r--r--types.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/types.c b/types.c
index d71da0e3..f666f667 100644
--- a/types.c
+++ b/types.c
@@ -273,7 +273,10 @@ bool can_promote(type_t *actual, type_t *needed)
if (actual->tag == NumType && needed->tag == IntType)
return false;
- if (actual->tag == IntType && needed->tag == NumType)
+ if (actual->tag == IntType && (needed->tag == NumType || needed->tag == BigIntType))
+ return true;
+
+ if (actual->tag == BigIntType && needed->tag == NumType)
return true;
if (actual->tag == IntType && needed->tag == IntType) {
@@ -402,6 +405,16 @@ bool can_have_cycles(type_t *t)
return _can_have_cycles(t, &seen);
}
+bool is_int_type(type_t *t)
+{
+ return t->tag == IntType || t->tag == BigIntType;
+}
+
+bool is_numeric_type(type_t *t)
+{
+ return t->tag == IntType || t->tag == BigIntType || t->tag == NumType;
+}
+
type_t *replace_type(type_t *t, type_t *target, type_t *replacement)
{
if (type_eq(t, target))