aboutsummaryrefslogtreecommitdiff
path: root/src/exact_value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/exact_value.cpp')
-rw-r--r--src/exact_value.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/exact_value.cpp b/src/exact_value.cpp
index e84b5b794..3bee3cdb2 100644
--- a/src/exact_value.cpp
+++ b/src/exact_value.cpp
@@ -5,6 +5,8 @@
struct AstNode;
struct HashKey;
+struct Type;
+bool are_types_identical(Type *x, Type *y);
struct Complex128 {
f64 real, imag;
@@ -20,6 +22,7 @@ enum ExactValueKind {
ExactValue_Complex,
ExactValue_Pointer,
ExactValue_Compound, // TODO(bill): Is this good enough?
+ ExactValue_Type,
ExactValue_Count,
};
@@ -34,6 +37,7 @@ struct ExactValue {
i64 value_pointer;
Complex128 value_complex;
AstNode * value_compound;
+ Type * value_type;
};
};
@@ -99,6 +103,12 @@ ExactValue exact_value_pointer(i64 ptr) {
return result;
}
+ExactValue exact_value_type(Type *type) {
+ ExactValue result = {ExactValue_Type};
+ result.value_type = type;
+ return result;
+}
+
ExactValue exact_value_integer_from_string(String string) {
return exact_value_u128(u128_from_string(string));
@@ -639,6 +649,13 @@ bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) {
case Token_GtEq: return a >= b;
}
} break;
+
+ case ExactValue_Type:
+ switch (op) {
+ case Token_CmpEq: return are_types_identical(x.value_type, y.value_type);
+ case Token_NotEq: return !are_types_identical(x.value_type, y.value_type);
+ }
+ break;
}
GB_PANIC("Invalid comparison");