[GME-commit] GMESRC/GME/ConstraintManager OCLTree.cpp,1.25,1.26

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Tue Aug 17 17:59:12 CDT 2004


Update of /var/lib/gme/GMESRC/GME/ConstraintManager
In directory braindrain:/tmp/cvs-serv28617

Modified Files:
	OCLTree.cpp 
Log Message:
and, or, implies modified according to the OCL specification

CVS User: bogyom

Index: OCLTree.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/ConstraintManager/OCLTree.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** OCLTree.cpp	14 Jun 2004 20:28:23 -0000	1.25
--- OCLTree.cpp	17 Aug 2004 21:59:10 -0000	1.26
***************
*** 810,814 ****
  		// Evaluation of Logical Operators
  
! 		if ( m_pOperandNode1->IsBooleanReturned() && m_pOperandNode2 && m_pOperandNode2->IsBooleanReturned() && m_vecType[ 0 ] == "ocl::Boolean" ) {
  
  			if ( m_strName == "and" || m_strName == "&&" ) {
--- 810,814 ----
  		// Evaluation of Logical Operators
  
! /*		if ( m_pOperandNode1->IsBooleanReturned() && m_pOperandNode2 && m_pOperandNode2->IsBooleanReturned() && m_vecType[ 0 ] == "ocl::Boolean" ) {
  
  			if ( m_strName == "and" || m_strName == "&&" ) {
***************
*** 833,839 ****
  				DECL_BOOLEAN( bOperand2, spOperand2 );
  				return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand2 ), iLineFeatureName, signature.Print() );
  			}
  
! 			if ( m_strName == "or" || m_strName == "||" ) {
  				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
  				if ( ! spOperand1.IsUndefined() ) {
--- 833,879 ----
  				DECL_BOOLEAN( bOperand2, spOperand2 );
  				return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand2 ), iLineFeatureName, signature.Print() );
+ 			}*/
+ 
+ 		// undef and/&& false = false and/&& undef = false
+ 		// undef and/&& anything = undef
+ 		if ( m_pOperandNode1->IsBooleanReturned() && m_pOperandNode2 && m_pOperandNode2->IsBooleanReturned() && m_vecType[ 0 ] == "ocl::Boolean" ) {
+ 
+ 			if ( m_strName == "and" || m_strName == "&&" ) {
+ 				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
+ 				if ( ! spOperand1.IsUndefined() ) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					if ( ! bOperand1 ) {
+ 						if ( m_strName == "&&" || context.m_bShortCircuitLogical )
+ 							return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), false ), iLineFeatureName, signature.Print() );
+ 					}
+ 				}
+ 				OclMeta::Object spOperand2 = m_pOperandNode2->Evaluate( context );
+ 				if ( ! spOperand1.IsUndefined()  &&  ! spOperand2.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					DECL_BOOLEAN( bOperand2, spOperand2 );
+ 					return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand1 && bOperand2 ), iLineFeatureName, signature.Print() );
+ 				}
+ 				// cannot create UNDEFINED result
+ 				else if (spOperand1.IsUndefined()  &&  spOperand2.IsUndefined()) {
+ 					return spOperand1;
+ 				}
+ 				else if (spOperand1.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand2, spOperand2 );
+ 					if (bOperand2)
+ 						return spOperand1;
+ 					else
+ 						return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), false ), iLineFeatureName, signature.Print() );
+ 				}
+ 				else if (spOperand2.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					if (bOperand1)
+ 						return spOperand2;
+ 					else
+ 						return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), false ), iLineFeatureName, signature.Print() );
+ 				}
  			}
  
! 
! /*			if ( m_strName == "or" || m_strName == "||" ) {
  				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
  				if ( ! spOperand1.IsUndefined() ) {
***************
*** 853,859 ****
  				DECL_BOOLEAN( bOperand2, spOperand2 );
  				return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand2 ), iLineFeatureName, signature.Print() );
  			}
  
! 			if ( m_strName == "implies" || m_strName == "=>" ) {
  				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
  				if ( spOperand1.IsUndefined() )
--- 893,936 ----
  				DECL_BOOLEAN( bOperand2, spOperand2 );
  				return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand2 ), iLineFeatureName, signature.Print() );
+ 			}*/
+ 
+ 			// true OR/|| UNDEF = UNDEF OR/|| true = true
+ 			// UNDEF OR/|| anything = UNDEF
+ 			if ( m_strName == "or" || m_strName == "||" ) {
+ 				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
+ 				if ( ! spOperand1.IsUndefined() ) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					if ( bOperand1 ) {
+ 						if ( m_strName == "||"  ||  context.m_bShortCircuitLogical )
+ 							return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), true ), iLineFeatureName, signature.Print() );
+ 					}
+ 				}
+ 				OclMeta::Object spOperand2 = m_pOperandNode2->Evaluate( context );
+ 				if ( ! spOperand1.IsUndefined()  &&  ! spOperand2.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					DECL_BOOLEAN( bOperand2, spOperand2 );
+ 					return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand1 || bOperand2 ), iLineFeatureName, signature.Print() );
+ 				}
+ 				else if (spOperand1.IsUndefined()  &&  spOperand2.IsUndefined() )
+ 					return spOperand1;
+ 				else if (spOperand1.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand2, spOperand2 );
+ 					if (!bOperand2)
+ 						return spOperand1;
+ 					else
+ 						return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), true ), iLineFeatureName, signature.Print() );
+ 				}
+ 				else if (spOperand2.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					if (!bOperand1)
+ 						return spOperand2;
+ 					else
+ 						return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), true ), iLineFeatureName, signature.Print() );
+ 				}
  			}
  
! 
! 
! /*			if ( m_strName == "implies" || m_strName == "=>" ) {
  				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
  				if ( spOperand1.IsUndefined() )
***************
*** 871,874 ****
--- 948,987 ----
  				return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), bOperand2 ), iLineFeatureName, signature.Print() );
  			}
+ 		}*/
+ 
+ 			// FALSE =>/implies anything - true
+ 			// anything =>/implies TRUE - true
+ 			if ( m_strName == "implies" || m_strName == "=>" ) {
+ 				OclMeta::Object spOperand1 = m_pOperandNode1->Evaluate( context );
+ 				if ( !spOperand1.IsUndefined() ) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					if (! bOperand1) {
+ 						if ( m_strName == "=>" || context.m_bShortCircuitLogical )
+ 							return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), true ), iLineFeatureName, signature.Print() );
+ 					}
+ 				}
+ 				OclMeta::Object spOperand2 = m_pOperandNode2->Evaluate( context );
+ 				if ( ! spOperand1.IsUndefined()  &&  ! spOperand2.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					DECL_BOOLEAN( bOperand2, spOperand2 );
+ 					return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), !bOperand1  ||  bOperand2), iLineFeatureName, signature.Print() );
+ 				}
+ 				else if (spOperand1.IsUndefined()  &&  spOperand2.IsUndefined() )
+ 					return spOperand1;
+ 				else if (spOperand1.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand2, spOperand2 );
+ 					if (!bOperand2)
+ 						return spOperand1;
+ 					else
+ 						return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), true), iLineFeatureName, signature.Print() );
+ 				}
+ 				else if (spOperand2.IsUndefined()) {
+ 					DECL_BOOLEAN( bOperand1, spOperand1 );
+ 					if (bOperand1)
+ 						return spOperand2;
+ 					else
+ 						return CheckFalseResult( context, CREATE_BOOLEAN( GetTreeManager()->GetTypeManager(), true ), iLineFeatureName, signature.Print() );
+ 				}
+ 			}
  		}
  
***************
*** 1522,1526 ****
  	}
  
! #define MAX_CONSTR_FUNC_LEVEL 200 // max level of constraint function encapsulation
  
  	OclMeta::Object MethodNode::Evaluate( ObjectContext& context )
--- 1635,1639 ----
  	}
  
! #define MAX_CONSTR_FUNC_LEVEL 100 // max level of constraint function encapsulation
  
  	OclMeta::Object MethodNode::Evaluate( ObjectContext& context )



More information about the GME-commit mailing list