mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 18:20:29 +00:00
Support for user-defined Eq impls (#1730)
Related to #1549; user-defined equality is a prerequisite for user-defined comparison.
This commit is contained in:
1 parent
b988d5353c
commit
5665f32bf7
18 files changed
+237
-23
No files matched your search
@@ -30,7 +30,9 @@ auto IntrinsicExpression::FindIntrinsic(std::string_view name,
|
||||
{{"print", Intrinsic::Print},
|
||||
{"new", Intrinsic::Alloc},
|
||||
{"delete", Intrinsic::Dealloc},
|
||||
{"rand", Intrinsic::Rand}});
|
||||
{"rand", Intrinsic::Rand},
|
||||
{"int_eq", Intrinsic::IntEq},
|
||||
{"str_eq", Intrinsic::StrEq}});
|
||||
name.remove_prefix(std::strlen("__intrinsic_"));
|
||||
auto it = intrinsic_map.find(name);
|
||||
if (it == intrinsic_map.end()) {
|
||||
@@ -191,6 +193,11 @@ void Expression::Print(llvm::raw_ostream& out) const {
|
||||
case IntrinsicExpression::Intrinsic::Rand:
|
||||
out << "rand";
|
||||
break;
|
||||
case IntrinsicExpression::Intrinsic::IntEq:
|
||||
out << "int_eq";
|
||||
break;
|
||||
case IntrinsicExpression::Intrinsic::StrEq:
|
||||
out << "str_eq";
|
||||
}
|
||||
out << iexp.args();
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user