forked from libre-chip/fayalite
		
	add ExprPartialEq/ExprPartialOrd impls for PhantomConst
This commit is contained in:
		
							parent
							
								
									450e1004b6
								
							
						
					
					
						commit
						d453755bb2
					
				
					 1 changed files with 39 additions and 0 deletions
				
			
		|  | @ -4,6 +4,11 @@ | |||
| use serde::{de::DeserializeOwned, Deserialize, Serialize}; | ||||
| 
 | ||||
| use crate::{ | ||||
|     expr::{ | ||||
|         ops::{ExprPartialEq, ExprPartialOrd}, | ||||
|         Expr, ToExpr, | ||||
|     }, | ||||
|     int::Bool, | ||||
|     intern::{Intern, Interned, InternedCompare, LazyInterned, Memoize}, | ||||
|     source_location::SourceLocation, | ||||
|     ty::{impl_match_variant_as_self, CanonicalType, StaticType, Type, TypeProperties}, | ||||
|  | @ -272,3 +277,37 @@ where | |||
|     const TYPE_PROPERTIES: TypeProperties = <()>::TYPE_PROPERTIES; | ||||
|     const MASK_TYPE_PROPERTIES: TypeProperties = <()>::TYPE_PROPERTIES; | ||||
| } | ||||
| 
 | ||||
| impl<T: ?Sized + PhantomConstValue> ExprPartialEq<Self> for PhantomConst<T> { | ||||
|     fn cmp_eq(lhs: Expr<Self>, rhs: Expr<Self>) -> Expr<Bool> { | ||||
|         assert_eq!(Expr::ty(lhs), Expr::ty(rhs)); | ||||
|         true.to_expr() | ||||
|     } | ||||
| 
 | ||||
|     fn cmp_ne(lhs: Expr<Self>, rhs: Expr<Self>) -> Expr<Bool> { | ||||
|         assert_eq!(Expr::ty(lhs), Expr::ty(rhs)); | ||||
|         false.to_expr() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl<T: ?Sized + PhantomConstValue> ExprPartialOrd<Self> for PhantomConst<T> { | ||||
|     fn cmp_lt(lhs: Expr<Self>, rhs: Expr<Self>) -> Expr<Bool> { | ||||
|         assert_eq!(Expr::ty(lhs), Expr::ty(rhs)); | ||||
|         false.to_expr() | ||||
|     } | ||||
| 
 | ||||
|     fn cmp_le(lhs: Expr<Self>, rhs: Expr<Self>) -> Expr<Bool> { | ||||
|         assert_eq!(Expr::ty(lhs), Expr::ty(rhs)); | ||||
|         true.to_expr() | ||||
|     } | ||||
| 
 | ||||
|     fn cmp_gt(lhs: Expr<Self>, rhs: Expr<Self>) -> Expr<Bool> { | ||||
|         assert_eq!(Expr::ty(lhs), Expr::ty(rhs)); | ||||
|         false.to_expr() | ||||
|     } | ||||
| 
 | ||||
|     fn cmp_ge(lhs: Expr<Self>, rhs: Expr<Self>) -> Expr<Bool> { | ||||
|         assert_eq!(Expr::ty(lhs), Expr::ty(rhs)); | ||||
|         true.to_expr() | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue