예제 #1
0
		Predicate Predicate::Or(Predicate left, Predicate right) {
			if (left.isTrue() || right.isTrue()) {
				return Predicate::True();
			} else if (left.isFalse()) {
				return right;
			} else if (right.isFalse()) {
				return left;
			} else if (left == right) {
				return left;
			} else if (left.isOr() && (left.orLeft() == right || left.orRight() == right)) {
				return left;
			} else if (right.isOr() && (right.orLeft() == left || right.orRight() == left)) {
				return right;
			}
			
			Predicate predicate(OR);
			predicate.left_ = std::unique_ptr<Predicate>(new Predicate(std::move(left)));
			predicate.right_ = std::unique_ptr<Predicate>(new Predicate(std::move(right)));
			return predicate;
		}
예제 #2
0
		Predicate Predicate::And(Predicate left, Predicate right) {
			if (left.isFalse() || right.isFalse()) {
				return Predicate::False();
			} else if (left.isTrue()) {
				return right;
			} else if (right.isTrue()) {
				return left;
			} else if (left == right) {
				return left;
			} else if (left.isAnd() && (left.andLeft() == right || left.andRight() == right)) {
				return left;
			} else if (right.isAnd() && (right.andLeft() == left || right.andRight() == left)) {
				return right;
			}
			
			Predicate predicate(AND);
			predicate.left_ = std::unique_ptr<Predicate>(new Predicate(std::move(left)));
			predicate.right_ = std::unique_ptr<Predicate>(new Predicate(std::move(right)));
			return predicate;
		}
예제 #3
0
파일: Value.cpp 프로젝트: scrossuk/locic
		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;
		}