2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / ilasm / codegen / TryBlock.cs
blob9ec09d7a23b0c7ef616245bdb18fb5e2f0c7bc72
1 //
2 // Mono.ILASM.TryBlock
3 //
4 // Author(s):
5 // Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
11 using System;
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class TryBlock : IInstr {
18 private HandlerBlock block;
19 private ArrayList clause_list;
21 public TryBlock (HandlerBlock block, Location loc)
22 : base (loc)
24 this.block = block;
25 clause_list = new ArrayList ();
28 public void AddSehClause (ISehClause clause)
30 clause_list.Add (clause);
33 public override void Emit (CodeGen code_gen, MethodDef meth,
34 PEAPI.CILInstructions cil)
36 PEAPI.CILLabel from = block.GetFromLabel (code_gen, meth);
37 PEAPI.CILLabel to = block.GetToLabel (code_gen, meth);
38 PEAPI.TryBlock try_block = new PEAPI.TryBlock (from, to);
40 foreach (ISehClause clause in clause_list)
41 try_block.AddHandler (clause.Resolve (code_gen, meth));
43 cil.AddTryBlock (try_block);