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

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

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit ILGene


From: Richard Baumann <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit ILGenerator.cs, 1.15, 1.16
Date: Mon, 28 Jul 2003 22:39:59 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit
In directory subversions:/tmp/cvs-serv8505/runtime/System/Reflection/Emit

Modified Files:
        ILGenerator.cs 
Log Message:
Fix some stack height and long opcode bugs in ILGenerator.


Index: ILGenerator.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/ILGenerator.cs,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** ILGenerator.cs      25 Jul 2003 08:33:37 -0000      1.15
--- ILGenerator.cs      29 Jul 2003 02:39:57 -0000      1.16
***************
*** 414,417 ****
--- 414,418 ----
        private void EmitRawOpcode(int value)
                        {
+                               value &= 0xFFFF;
                                if(value < 0x0100)
                                {
***************
*** 420,425 ****
                                else
                                {
                                        EmitByte(value);
-                                       EmitByte(value & 0xFF);
                                }
                        }
--- 421,426 ----
                                else
                                {
+                                       EmitByte(value >> 8);
                                        EmitByte(value);
                                }
                        }
***************
*** 432,436 ****
                        {
                                // Output the opcode to the instruction stream.
!                               int value = opcode.value;
                                if(value < 0x0100)
                                {
--- 433,437 ----
                        {
                                // Output the opcode to the instruction stream.
!                               int value = (opcode.value & 0xFFFF);
                                if(value < 0x0100)
                                {
***************
*** 439,444 ****
                                else
                                {
                                        EmitByte(value);
-                                       EmitByte(value & 0xFF);
                                }
  
--- 440,445 ----
                                else
                                {
+                                       EmitByte(value >> 8);
                                        EmitByte(value);
                                }
  
***************
*** 594,616 ****
  
                                // Adjust the stack to account for the changes.
!                               if(opcode.stackPush == 
(int)(StackBehaviour.Varpush))
!                               {
!                                       ++height;
!                               }
!                               if(opcode.stackPop == 
(int)(StackBehaviour.Varpop))
                                {
!                                       if(constructor is ConstructorBuilder)
!                                       {
!                                               height -= 
((ConstructorBuilder)constructor).numParams;
!                                       }
!                                       else
                                        {
!                                               ParameterInfo[] paramList = 
constructor.GetParameters();
!                                               if(paramList != null)
                                                {
!                                                       height -= 
paramList.Length;
                                                }
                                        }
                                }
                                if(height > maxHeight)
                                {
--- 595,670 ----
  
                                // Adjust the stack to account for the changes.
!                               switch((StackBehaviour)(opcode.stackPop))
                                {
!                                       case StackBehaviour.Pop0:
!                                               break;
! 
!                                       case StackBehaviour.Varpop:
                                        {
!                                               if(constructor is 
ConstructorBuilder)
!                                               {
!                                                       height -= 
((ConstructorBuilder)constructor).numParams;
!                                               }
!                                               else
                                                {
!                                                       ParameterInfo[] 
paramList = constructor.GetParameters();
!                                                       if(paramList != null)
!                                                       {
!                                                               height -= 
paramList.Length;
!                                                       }
                                                }
                                        }
+                                       break;
+ 
+                                       case StackBehaviour.Pop1:
+                                       case StackBehaviour.Popi:
+                                       case StackBehaviour.Popref:
+                                               --height;
+                                               break;
+ 
+                                       case StackBehaviour.Pop1_pop1:
+                                       case StackBehaviour.Popi_pop1:
+                                       case StackBehaviour.Popi_popi:
+                                       case StackBehaviour.Popi_popi8:
+                                       case StackBehaviour.Popi_popr4:
+                                       case StackBehaviour.Popi_popr8:
+                                       case StackBehaviour.Popref_pop1:
+                                       case StackBehaviour.Popref_popi:
+                                               height -= 2;
+                                               break;
+ 
+                                       case StackBehaviour.Popi_popi_popi:
+                                       case StackBehaviour.Popref_popi_popi:
+                                       case StackBehaviour.Popref_popi_popi8:
+                                       case StackBehaviour.Popref_popi_popr4:
+                                       case StackBehaviour.Popref_popi_popr8:
+                                       case StackBehaviour.Popref_popi_popref:
+                                               height -= 3;
+                                               break;
+ 
+                                       default: break;
+                               }
+                               switch((StackBehaviour)(opcode.stackPush))
+                               {
+                                       case StackBehaviour.Push0:
+                                               break;
+ 
+                                       case StackBehaviour.Push1:
+                                       case StackBehaviour.Pushi:
+                                       case StackBehaviour.Pushi8:
+                                       case StackBehaviour.Pushr4:
+                                       case StackBehaviour.Pushr8:
+                                       case StackBehaviour.Pushref:
+                                       case StackBehaviour.Varpush:
+                                               ++height;
+                                               break;
+ 
+                                       case StackBehaviour.Push1_push1:
+                                               height += 2;
+                                               break;
+ 
+                                       default: break;
                                }
+ 
                                if(height > maxHeight)
                                {
***************
*** 862,891 ****
  
                                // Adjust the stack to account for the changes.
!                               if(opcode.stackPush == 
(int)(StackBehaviour.Varpush))
                                {
!                                       if(method.ReturnType != typeof(void))
                                        {
!                                               ++height;
                                        }
                                }
!                               if(opcode.stackPop == 
(int)(StackBehaviour.Varpop))
                                {
!                                       if(method is MethodBuilder)
!                                       {
!                                               height -= 
((MethodBuilder)method).numParams;
!                                       }
!                                       else
                                        {
!                                               ParameterInfo[] paramList = 
method.GetParameters();
!                                               if(paramList != null)
                                                {
!                                                       height -= 
paramList.Length;
                                                }
                                        }
!                                       if(!method.IsStatic && opcode.value != 
0x73) // "newobj"
!                                       {
!                                               --height;
!                                       }
                                }
                                if(height > maxHeight)
                                {
--- 916,1003 ----
  
                                // Adjust the stack to account for the changes.
!                               switch((StackBehaviour)(opcode.stackPop))
                                {
!                                       case StackBehaviour.Pop0:
!                                               break;
! 
!                                       case StackBehaviour.Varpop:
                                        {
!                                               if(method is MethodBuilder)
!                                               {
!                                                       height -= 
((MethodBuilder)method).numParams;
!                                               }
!                                               else
!                                               {
!                                                       ParameterInfo[] 
paramList = method.GetParameters();
!                                                       if(paramList != null)
!                                                       {
!                                                               height -= 
paramList.Length;
!                                                       }
!                                               }
!                                               if(!method.IsStatic && 
opcode.value != 0x73) // "newobj"
!                                               {
!                                                       --height;
!                                               }
                                        }
+                                       break;
+ 
+                                       case StackBehaviour.Pop1:
+                                       case StackBehaviour.Popi:
+                                       case StackBehaviour.Popref:
+                                               --height;
+                                               break;
+ 
+                                       case StackBehaviour.Pop1_pop1:
+                                       case StackBehaviour.Popi_pop1:
+                                       case StackBehaviour.Popi_popi:
+                                       case StackBehaviour.Popi_popi8:
+                                       case StackBehaviour.Popi_popr4:
+                                       case StackBehaviour.Popi_popr8:
+                                       case StackBehaviour.Popref_pop1:
+                                       case StackBehaviour.Popref_popi:
+                                               height -= 2;
+                                               break;
+ 
+                                       case StackBehaviour.Popi_popi_popi:
+                                       case StackBehaviour.Popref_popi_popi:
+                                       case StackBehaviour.Popref_popi_popi8:
+                                       case StackBehaviour.Popref_popi_popr4:
+                                       case StackBehaviour.Popref_popi_popr8:
+                                       case StackBehaviour.Popref_popi_popref:
+                                               height -= 3;
+                                               break;
+ 
+                                       default: break;
                                }
!                               switch((StackBehaviour)(opcode.stackPush))
                                {
!                                       case StackBehaviour.Push0:
!                                               break;
! 
!                                       case StackBehaviour.Push1:
!                                       case StackBehaviour.Pushi:
!                                       case StackBehaviour.Pushi8:
!                                       case StackBehaviour.Pushr4:
!                                       case StackBehaviour.Pushr8:
!                                       case StackBehaviour.Pushref:
!                                               ++height;
!                                               break;
! 
!                                       case StackBehaviour.Varpush:
                                        {
!                                               if(method.ReturnType != 
typeof(void))
                                                {
!                                                       ++height;
                                                }
                                        }
!                                       break;
! 
!                                       case StackBehaviour.Push1_push1:
!                                               height += 2;
!                                               break;
! 
!                                       default: break;
                                }
+ 
                                if(height > maxHeight)
                                {





reply via email to

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