소스 검색

Fix bug #367114.

In class/PEAPI:
	Fix bug #367114.
	* Code.cs (TryBlock.ResolveCatchBlocks): New.
	(CILInstructions.AddTryBlock): Resolve the catch blocks with the new
	method.
	(Catch..ctor): Add new .ctor to allow exceptions of any type.
	(Catch.ResolveType): New. Add the exception type to the metadata.

In ilasm/codegen:
	Fix bug #367114.
	* CatchBlock.cs: Allow exception to be of any type (BaseTypeRef) and not
	just a class (BaseClassRef).

In ilasm/parser:
	Part of fix for bug #367114.
	* ILParser.jay (seh_clause): Allow exception to be of any type and not
	just class.

svn path=/trunk/mcs/; revision=104636
Ankit Jain 17 년 전
부모
커밋
832218ea3c
6개의 변경된 파일52개의 추가작업 그리고 9개의 파일을 삭제
  1. 9 0
      mcs/class/PEAPI/ChangeLog
  2. 24 2
      mcs/class/PEAPI/Code.cs
  3. 5 5
      mcs/ilasm/codegen/CatchBlock.cs
  4. 6 0
      mcs/ilasm/codegen/ChangeLog
  5. 6 0
      mcs/ilasm/parser/ChangeLog
  6. 2 2
      mcs/ilasm/parser/ILParser.jay

+ 9 - 0
mcs/class/PEAPI/ChangeLog

@@ -1,3 +1,12 @@
+2008-06-02  Ankit Jain  <[email protected]>
+
+	Fix bug #367114.
+	* Code.cs (TryBlock.ResolveCatchBlocks): New.
+	(CILInstructions.AddTryBlock): Resolve the catch blocks with the new
+	method.
+	(Catch..ctor): Add new .ctor to allow exceptions of any type.
+	(Catch.ResolveType): New. Add the exception type to the metadata.
+
 2008-04-07  Rodrigo Kumpera  <[email protected]>
 
 	* Code.cs: Removed Local::TypeSig() as it is not needed

+ 24 - 2
mcs/class/PEAPI/Code.cs

@@ -701,6 +701,7 @@ namespace PEAPI {
 				exceptions = new ArrayList();
 			else if (exceptions.Contains(tryBlock)) return;
 			exceptions.Add(tryBlock);
+			tryBlock.ResolveCatchBlocks (metaData);
 		}
 
 		/// <summary>
@@ -975,6 +976,16 @@ namespace PEAPI {
 			return fatFormat;
 		}
 
+		//Hackish
+		internal void ResolveCatchBlocks (MetaData md)
+		{
+			for (int i=0; i < handlers.Count; i++) {
+				Catch c = handlers [i] as Catch;
+				if (c != null)
+					c.ResolveType (md);
+			}
+		}
+
 		internal override void Write(FileImage output, bool fatFormat) 
 		{
 			// Console.WriteLine("writing exception details");
@@ -1013,7 +1024,7 @@ namespace PEAPI {
 	/// </summary>
 	public class Catch : HandlerBlock  {
 
-		Class exceptType;
+		MetaDataElement exceptType;
 
 		/// <summary>
 		/// Create a new catch clause
@@ -1021,12 +1032,23 @@ namespace PEAPI {
 		/// <param name="except">the exception to be caught</param>
 		/// <param name="handlerStart">start of the handler code</param>
 		/// <param name="handlerEnd">end of the handler code</param>
-		public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd) 
+		public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd)
+			: base(handlerStart, handlerEnd)
+		{
+			exceptType = except;
+		}
+
+		public Catch(Type except, CILLabel handlerStart, CILLabel handlerEnd)
 			: base(handlerStart,handlerEnd) 
 		{
 			exceptType = except;
 		}
 
+		internal void ResolveType (MetaData md)
+		{
+		       exceptType = ((Type) exceptType).GetTypeSpec (md);
+		}
+
 		internal override void Write(FileImage output, bool fatFormat) 
 		{
 			base.Write(output,fatFormat);

+ 5 - 5
mcs/ilasm/codegen/CatchBlock.cs

@@ -15,12 +15,12 @@ namespace Mono.ILASM {
 
         public class CatchBlock : ISehClause {
 
-                private BaseClassRef class_ref;
+                private BaseTypeRef type_ref;
                 private HandlerBlock handler_block;
 
-                public CatchBlock (BaseClassRef class_ref)
+                public CatchBlock (BaseTypeRef type_ref)
                 {
-                        this.class_ref = class_ref;
+                        this.type_ref = type_ref;
                 }
 
                 public void SetHandlerBlock (HandlerBlock hb)
@@ -34,9 +34,9 @@ namespace Mono.ILASM {
                         PEAPI.CILLabel to = handler_block.GetToLabel (code_gen, method);
                         PEAPI.Catch katch;
 
-                        class_ref.Resolve (code_gen);
+                        type_ref.Resolve (code_gen);
 
-                        katch = new PEAPI.Catch (class_ref.PeapiClass, from, to);
+                        katch = new PEAPI.Catch (type_ref.PeapiType, from, to);
 
                         return katch;
                 }

+ 6 - 0
mcs/ilasm/codegen/ChangeLog

@@ -1,3 +1,9 @@
+2008-06-02  Ankit Jain  <[email protected]>
+
+	Fix bug #367114.
+	* CatchBlock.cs: Allow exception to be of any type (BaseTypeRef) and not
+	just a class (BaseClassRef).
+
 2008-06-01  Ankit Jain  <[email protected]>
 
 	Fix bug #364580.

+ 6 - 0
mcs/ilasm/parser/ChangeLog

@@ -1,3 +1,9 @@
+2008-06-02  Ankit Jain  <[email protected]>
+
+	Part of fix for bug #367114.
+	* ILParser.jay (seh_clause): Allow exception to be of any type and not
+	just class.
+
 2008-06-01  Ankit Jain  <[email protected]>
 
 	* ILParser.jay: Track api changes.

+ 2 - 2
mcs/ilasm/parser/ILParser.jay

@@ -2298,12 +2298,12 @@ seh_clauses		: seh_clause
                           }
 			;
 
-seh_clause		: K_CATCH generic_class_ref handler_block
+seh_clause		: K_CATCH type handler_block
                           {
 				if ($2.GetType () == typeof (PrimitiveTypeRef))
 					Report.Error ("Exception not be of a primitive type.");
 					
-                                BaseClassRef type = (BaseClassRef) $2;
+                                BaseTypeRef type = (BaseTypeRef) $2;
                                 CatchBlock cb = new CatchBlock (type);
                                 cb.SetHandlerBlock ((HandlerBlock) $3);
                                 $$ = cb;