svn commit: r16439 - trunk/src/argouml-app/src/org/argouml/profile/internal/ocl/EvaluateExpression.java

Marcos Aurélio <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-12-23 18:38:21-0800
New Revision: 16439

Modified:
   trunk/src/argouml-app/src/org/argouml/profile/internal/ocl/EvaluateExpression.java

Log:
fixing implementation of 'and' and 'or' in the OCL Evaluator

Modified: trunk/src/argouml-app/src/org/argouml/profile/internal/ocl/EvaluateExpression.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/profile/internal/ocl/EvaluateExpression.java?view=diff&pathrev=16439&r1=16438&r2=16439
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/profile/internal/ocl/EvaluateExpression.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/profile/internal/ocl/EvaluateExpression.java	2008-12-23 18:38:21-0800
@@ -236,11 +236,23 @@
 
         if (op != null) {
             if (op instanceof AAndLogicalOperator) {
-                val = asBoolean(left, node) && asBoolean(right, node);
+                if (left != null && left instanceof Boolean && ((Boolean)left).booleanValue() == false) {
+                    val = false;
+                } else if (right != null && right instanceof Boolean && ((Boolean)right).booleanValue() == false) {
+                    val = false;
+                } else {
+                    val = asBoolean(left, node) && asBoolean(right, node);
+                }
             } else if (op instanceof AImpliesLogicalOperator) {
                 val = !asBoolean(left, node) || asBoolean(right, node);
             } else if (op instanceof AOrLogicalOperator) {
-                val = asBoolean(left, node) || asBoolean(right, node);
+                if (left != null && left instanceof Boolean && ((Boolean)left).booleanValue() == true) {
+                    val = true;
+                } else if (right != null && right instanceof Boolean && ((Boolean)right).booleanValue() == true) {
+                    val = true;
+                } else {
+                    val = asBoolean(left, node) || asBoolean(right, node);
+                }
             } else if (op instanceof AXorLogicalOperator) {
                 val = !asBoolean(left, node) ^ asBoolean(right, node);
             } else {

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=991165

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.