This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / ilasm / codegen / SwitchInstr.cs
1 //
2 // Mono.ILASM.SwitchInstr
3 //
4 // Author(s):
5 //  Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
9
10
11 using System;
12 using System.Collections;
13
14 namespace Mono.ILASM {
15
16         public class SwitchInstr : IInstr {
17
18                 private ArrayList label_list;
19
20                 public SwitchInstr (ArrayList label_list)
21                 {
22                         this.label_list = label_list;
23                 }
24
25                 public void Emit (CodeGen code_gen, MethodDef meth, PEAPI.CILInstructions cil)
26                 {
27                         int count = 0;
28                         PEAPI.CILLabel[] label_array;
29
30                         if (label_list != null) {
31                                 label_array = new PEAPI.CILLabel[label_list.Count];
32                                 foreach (object lab in label_list) {
33                                         if (lab is string) {
34                                                 label_array[count++] = meth.GetLabelDef ((string) lab);
35                                         } else {                                                
36                                                 throw new NotImplementedException ("offsets in switch statements.");
37                                         }
38                                 }
39                         } else {
40                                 label_array = new PEAPI.CILLabel [0];
41                         }
42
43                         cil.Switch (label_array);
44                 }
45         }
46
47 }
48