bool Predicate::operator==(const Predicate& other) const { if (kind() != other.kind()) { return false; } switch (kind()) { case TRUE: case FALSE: case SELFCONST: { return true; } case AND: { return andLeft() == other.andLeft() && andRight() == other.andRight(); } case OR: { return orLeft() == other.orLeft() && orRight() == other.orRight(); } case SATISFIES: { return satisfiesType() == other.satisfiesType() && satisfiesRequirement() == other.satisfiesRequirement(); } case VARIABLE: { return variableTemplateVar() == other.variableTemplateVar(); } } locic_unreachable("Unknown predicate kind."); }
Value Value::PredicateExpr(Predicate predicate, const Type* const boolType) { if (predicate.isTrue()) { return Value::Constant(Constant::True(), boolType); } else if (predicate.isFalse()) { return Value::Constant(Constant::False(), boolType); } else if (predicate.isVariable()) { return Value::TemplateVarRef(predicate.variableTemplateVar(), boolType); } Value value(PREDICATE, boolType, ExitStates::Normal()); value.impl_->predicate = make_optional(std::move(predicate)); return value; }