Skip to content
Snippets Groups Projects
Commit 6f5dbd5b authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Update Equals operator to reflect recent changes

parent e5557334
Branches
No related merge requests found
......@@ -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);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment