[433103] Support Interpreted evaluation of short-circuit Boolean
operators
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/LibraryOperation.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/LibraryOperation.java
index 0a89192..65064b5 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/LibraryOperation.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/LibraryOperation.java
@@ -14,8 +14,10 @@
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.ocl.pivot.OperationCallExp;
 import org.eclipse.ocl.pivot.TypedElement;
+import org.eclipse.ocl.pivot.evaluation.EvaluationHaltedException;
 import org.eclipse.ocl.pivot.evaluation.Evaluator;
 import org.eclipse.ocl.pivot.evaluation.Executor;
+import org.eclipse.ocl.pivot.values.InvalidValueException;
 
 /**
  */
@@ -51,6 +53,15 @@
 		 */
 		@Nullable Object basicEvaluate(@NonNull Executor executor, @NonNull TypedElement caller, @Nullable Object @NonNull [] boxedSourceAndArgumentValues);
 
+		/**
+		 * Evaluate this operation using the boxedSourceAndArgumentValues in conjunction with the executor. The call
+		 * to this operation is provided by the caller. The impementation of the evaluate API and related methods may
+		 * that the caller has checked that source and arguments conform to this operation's declaration.
+		 *
+		 * @throws InvalidValueException for a well-behaved failure such as an invalid value
+		 * @throws EvaluationHaltedException for an external abort request
+		 * @throws for an uncontrolled failure that should be treated as invalid
+		 */
 		@Nullable Object evaluate(@NonNull Executor executor, @NonNull TypedElement caller, @Nullable Object @NonNull [] boxedSourceAndArgumentValues);
 	}
 
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanAndOperation2.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanAndOperation2.java
index 0fd8b2d..4f5bbb2 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanAndOperation2.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanAndOperation2.java
@@ -19,6 +19,7 @@
 import org.eclipse.ocl.pivot.evaluation.Executor;
 import org.eclipse.ocl.pivot.library.AbstractSimpleBinaryOperation;
 import org.eclipse.ocl.pivot.utilities.ValueUtil;
+import org.eclipse.ocl.pivot.values.InvalidValueException;
 
 /**
  * BooleanAndOperation2 realises the 2-valued and() library operation.
@@ -31,12 +32,18 @@
 
 	@Override
 	public @Nullable Object dispatch(@NonNull Executor executor, @NonNull OperationCallExp callExp, @Nullable Object sourceValue) {
-		if (sourceValue == Boolean.FALSE) {
-			return FALSE_VALUE;
-		}
 		List<? extends OCLExpression> arguments = callExp.getOwnedArguments();
 		OCLExpression argument0 = arguments.get(0);
 		assert argument0 != null;
+//		if (argument0.isInvalid()) {		// FIXME Bug 552782, need static isInvalid analysis
+//			throw new InvalidValueException("null argument");
+//		}
+		if (argument0.isNull()) {
+			throw new InvalidValueException("null argument");
+		}
+		if (sourceValue == Boolean.FALSE) {
+			return FALSE_VALUE;
+		}
 		Object firstArgument = executor.evaluate(argument0);
 		Boolean sourceBoolean = ValueUtil.asBoolean(sourceValue);
 		Boolean argBoolean = ValueUtil.asBoolean(firstArgument);
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanImpliesOperation2.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanImpliesOperation2.java
index 0555517..fbb9eb9 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanImpliesOperation2.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanImpliesOperation2.java
@@ -19,6 +19,7 @@
 import org.eclipse.ocl.pivot.evaluation.Executor;
 import org.eclipse.ocl.pivot.library.AbstractSimpleBinaryOperation;
 import org.eclipse.ocl.pivot.utilities.ValueUtil;
+import org.eclipse.ocl.pivot.values.InvalidValueException;
 
 /**
  * BooleanImpliesOperation2 realises the 2-valued implies() library operation.
@@ -31,12 +32,18 @@
 
 	@Override
 	public @Nullable Object dispatch(@NonNull Executor executor, @NonNull OperationCallExp callExp, @Nullable Object sourceValue) {
-		if (sourceValue == Boolean.FALSE) {
-			return TRUE_VALUE;
-		}
 		List<? extends OCLExpression> arguments = callExp.getOwnedArguments();
 		OCLExpression argument0 = arguments.get(0);
 		assert argument0 != null;
+//		if (argument0.isInvalid()) {		// FIXME Bug 552782, need static isInvalid analysis
+//			throw new InvalidValueException("null argument");
+//		}
+		if (argument0.isNull()) {
+			throw new InvalidValueException("null argument");
+		}
+		if (sourceValue == Boolean.FALSE) {
+			return TRUE_VALUE;
+		}
 		Object firstArgument = executor.evaluate(argument0);
 		Boolean sourceBoolean = ValueUtil.asBoolean(sourceValue);
 		Boolean argBoolean = ValueUtil.asBoolean(firstArgument);
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanOrOperation2.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanOrOperation2.java
index 46cae3c..eba3591 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanOrOperation2.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/library/logical/BooleanOrOperation2.java
@@ -19,6 +19,7 @@
 import org.eclipse.ocl.pivot.evaluation.Executor;
 import org.eclipse.ocl.pivot.library.AbstractSimpleBinaryOperation;
 import org.eclipse.ocl.pivot.utilities.ValueUtil;
+import org.eclipse.ocl.pivot.values.InvalidValueException;
 
 /**
  * BooleanOrOperation2 realises the 2-valued or() library operation.
@@ -31,12 +32,18 @@
 
 	@Override
 	public @Nullable Object dispatch(@NonNull Executor executor, @NonNull OperationCallExp callExp, @Nullable Object sourceValue) {
-		if (sourceValue == Boolean.TRUE) {
-			return TRUE_VALUE;
-		}
 		List<? extends OCLExpression> arguments = callExp.getOwnedArguments();
 		OCLExpression argument0 = arguments.get(0);
 		assert argument0 != null;
+//		if (argument0.isInvalid()) {		// FIXME Bug 552782, need static isInvalid analysis
+//			throw new InvalidValueException("null argument");
+//		}
+		if (argument0.isNull()) {
+			throw new InvalidValueException("null argument");
+		}
+		if (sourceValue == Boolean.TRUE) {
+			return TRUE_VALUE;
+		}
 		Object firstArgument = executor.evaluate(argument0);
 		Boolean sourceBoolean = ValueUtil.asBoolean(sourceValue);
 		Boolean argBoolean = ValueUtil.asBoolean(firstArgument);