From 6f5dbd5b99a416685dc049a55e1f4de2aa1dd1d5 Mon Sep 17 00:00:00 2001
From: Adam Wardynski <award@.(win7-laptop)>
Date: Fri, 19 Nov 2010 11:53:55 +0100
Subject: [PATCH] Update Equals operator to reflect recent changes

---
 libwccl/ops/equals.h | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/libwccl/ops/equals.h b/libwccl/ops/equals.h
index c646208..1c29644 100644
--- a/libwccl/ops/equals.h
+++ b/libwccl/ops/equals.h
@@ -44,8 +44,8 @@ protected:
 	 * False otherwise.
 	 */
 	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
-		boost::shared_ptr<T> arg1 = this->arg1_expr_->apply(context);
-		boost::shared_ptr<T> arg2 = this->arg2_expr_->apply(context);
+		const boost::shared_ptr<const T>& arg1 = this->arg1_expr_->apply(context);
+		const boost::shared_ptr<const T>& arg2 = this->arg2_expr_->apply(context);
 		if(arg1->equals(*arg2)) {
 			return Predicate::True(context);
 		}
@@ -87,22 +87,14 @@ protected:
 	typedef FunctionBase::BaseRetValPtr BaseRetValPtr;
 
 	/**
-	 * Take values of arguments from expressions and return True if they are equal,
-	 * False otherwise.
+	 * Take values of arguments from expressions and return True if Positions
+	 * are equal, in given context, False otherwise.
 	 */
 	virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
-		boost::shared_ptr<Position> arg1 = this->arg1_expr_->apply(context);
-		boost::shared_ptr<Position> arg2 = this->arg2_expr_->apply(context);
-		if(arg1->equals(*arg2)) {
+		const boost::shared_ptr<const Position>& arg1 = this->arg1_expr_->apply(context);
+		const boost::shared_ptr<const Position>& arg2 = this->arg2_expr_->apply(context);
+		if(arg1->equals(*arg2, context.sentence_context())) {
 			return Predicate::True(context);
-		} else {
-			//in the given context both positions can still point nowhere
-			//even if they have different underlying value
-			int abs_pos1 = context.get_abs_position(*arg1);
-			int abs_pos2 = context.get_abs_position(*arg2);
-			if(!context.is_inside(abs_pos1) && !context.is_inside(abs_pos2)) {
-				return Predicate::True(context);
-			}
 		}
 		return Predicate::False(context);
 	}
-- 
GitLab