Require identity equality for variable declarations

Variable declarations should only be considered equal if their identity
is equal. In other words, just because two different variable
declarations share the same name, they aren’t automatically equal. This
is to support situations in which nested variable declarations shadow
variable declarations of the same name at a higher level.
This commit is contained in:
Patrick Lühne 2020-02-03 02:39:15 +01:00
parent 171c725fb8
commit 81b9ca4cfa
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
1 changed files with 40 additions and 1 deletions

View File

@ -70,12 +70,51 @@ impl PredicateDeclaration
pub type PredicateDeclarations = std::collections::BTreeSet<std::rc::Rc<PredicateDeclaration>>;
#[derive(Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct VariableDeclaration
{
pub name: String,
}
impl std::cmp::PartialEq for VariableDeclaration
{
#[inline(always)]
fn eq(&self, other: &VariableDeclaration) -> bool
{
let l = self as *const VariableDeclaration;
let r = other as *const VariableDeclaration;
l.eq(&r)
}
}
impl std::cmp::Eq for VariableDeclaration
{
}
impl std::cmp::PartialOrd for VariableDeclaration
{
#[inline(always)]
fn partial_cmp(&self, other: &VariableDeclaration) -> Option<std::cmp::Ordering>
{
let l = self as *const VariableDeclaration;
let r = other as *const VariableDeclaration;
l.partial_cmp(&r)
}
}
impl std::cmp::Ord for VariableDeclaration
{
#[inline(always)]
fn cmp(&self, other: &VariableDeclaration) -> std::cmp::Ordering
{
let l = self as *const VariableDeclaration;
let r = other as *const VariableDeclaration;
l.cmp(&r)
}
}
impl VariableDeclaration
{
pub fn new(name: String) -> Self