dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/engine verify_branch.c,1.11,1.12


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine verify_branch.c,1.11,1.12
Date: Thu, 24 Jul 2003 14:24:08 -0400

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv11630/engine

Modified Files:
        verify_branch.c 
Log Message:
Merge the stack states by taking the common type fixing Bug #4430


Index: verify_branch.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify_branch.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** verify_branch.c     23 May 2002 07:24:12 -0000      1.11
--- verify_branch.c     24 Jul 2003 18:24:06 -0000      1.12
***************
*** 116,119 ****
--- 116,165 ----
  }
  
+ /* 
+  * Find the nearest type in the type2 heirarchy that is assign 
+  * compatible to type1.
+  */
+ static ILType* TryCommonType(ILImage* image, ILType * type1, ILType *type2)
+ {
+       ILClass *classInfo;
+       
+       /* Note: boxing conversions are not allowed because both
+        * types have to be reference types.
+        */ 
+       if(ILTypeAssignCompatibleNonBoxing(image, type1,type2))
+       {
+               return type2;
+       }
+ 
+       classInfo=ILClassFromType(image, 0, type2, 0);
+       
+       if((classInfo=ILClassGetParent(classInfo))!=NULL)
+       {
+               return TryCommonType(image, type1, ILClassToType(classInfo));
+       }
+       
+       return type2;
+ }
+ 
+ /* 
+  * Obtain a common parent for 2 types 
+  * TODO: handle interfaces
+  */
+ static ILType * CommonType(ILImage * image, ILType *type1, ILType *type2)
+ {
+       ILType *ctype12=TryCommonType(image, type1, type2);
+       ILType *ctype21=TryCommonType(image, type2, type1);
+       
+       if(ILTypeAssignCompatibleNonBoxing(image, ctype12, ctype21))
+       {
+               return ctype12;
+       }
+       else if(ILTypeAssignCompatibleNonBoxing(image, ctype21, ctype12))
+       {
+               return ctype21;
+       }
+       return NULL;
+ }
+ 
  /*
   * Validate the current contents of the stack against
***************
*** 125,128 ****
--- 171,175 ----
        ILUInt32 posn;
        ILEngineStackItem *labelStack;
+       ILType *commonType;
        if(stackSize != label->stackSize)
        {
***************
*** 148,173 ****
                else if(stack[posn].engineType == ILEngineType_O)
                {
!                       /* Check the sub-class relationships */
!                       if(ILTypeAssignCompatible(image, stack[posn].typeInfo,
!                                                                         
labelStack[posn].typeInfo))
!                       {
!                               /* The current stack is a subclass of the label 
stack, so
!                                  use the type from the label stack as the 
common type */
!                               stack[posn].typeInfo = 
labelStack[posn].typeInfo;
!                               return 1;
!                       }
!                       else if(ILTypeAssignCompatible(image, 
labelStack[posn].typeInfo,
!                                                                               
   stack[posn].typeInfo))
!                       {
!                               /* The label stack is a subclass of the current 
stack, so
!                                  update the label stack to reflect the new 
common type */
!                               labelStack[posn].typeInfo = 
stack[posn].typeInfo;
!                               return 1;
!                       }
!                       else
                        {
-                               /* Incompatible types */
                                return 0;
                        }
                }
        }
--- 195,207 ----
                else if(stack[posn].engineType == ILEngineType_O)
                {
!                       commonType=CommonType(image,
!                                                                 
stack[posn].typeInfo,
!                                                                 
labelStack[posn].typeInfo);
!                       if(commonType==NULL)
                        {
                                return 0;
                        }
+                       labelStack[posn].typeInfo = commonType;
+                       stack[posn].typeInfo = commonType;
                }
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]