[corlib] Fix tests for watchOS. (#3131)
[mono.git] / mcs / ilasm / codegen / TryBlock.cs
index 756cb95f21f38d1469ab75c138b420f0ad91def1..9ec09d7a23b0c7ef616245bdb18fb5e2f0c7bc72 100644 (file)
@@ -15,23 +15,14 @@ namespace Mono.ILASM {
 
         public class TryBlock : IInstr {
 
-                private MethodDef method;
-                private string from_label;
-                private string to_label;
+                private HandlerBlock block;
                 private ArrayList clause_list;
 
-                public TryBlock (string from_label, string to_label)
+                public TryBlock (HandlerBlock block, Location loc)
+                       : base (loc)
                 {
-                        this.method = method;
-                        this.from_label = from_label;
-                        this.to_label = to_label;
-
-                        clause_list = new ArrayList ();
-                }
-
-                public void SetMethod (MethodDef method)
-                {
-                        this.method = method;
+                       this.block = block;
+                       clause_list = new ArrayList ();
                 }
 
                 public void AddSehClause (ISehClause clause)
@@ -39,15 +30,16 @@ namespace Mono.ILASM {
                         clause_list.Add (clause);
                 }
 
-                public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+                public override void Emit (CodeGen code_gen, MethodDef meth,
+                                          PEAPI.CILInstructions cil)
                 {
-                        PEAPI.CILLabel from = method.GetLabelDef (from_label);
-                        PEAPI.CILLabel to = method.GetLabelDef (to_label);
+                        PEAPI.CILLabel from = block.GetFromLabel (code_gen, meth);
+                        PEAPI.CILLabel to = block.GetToLabel (code_gen, meth);
                         PEAPI.TryBlock try_block = new PEAPI.TryBlock (from, to);
 
                         foreach (ISehClause clause in clause_list)
-                                try_block.AddHandler (clause.Resolve (code_gen, method));
-
+                                try_block.AddHandler (clause.Resolve (code_gen, meth));
+                       
                         cil.AddTryBlock (try_block);
                 }