Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/ilasm/codegen/SwitchInstr.cs')
-rw-r--r--mcs/ilasm/codegen/SwitchInstr.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/mcs/ilasm/codegen/SwitchInstr.cs b/mcs/ilasm/codegen/SwitchInstr.cs
new file mode 100644
index 00000000000..5b6178ee15b
--- /dev/null
+++ b/mcs/ilasm/codegen/SwitchInstr.cs
@@ -0,0 +1,50 @@
+//
+// Mono.ILASM.SwitchInstr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class SwitchInstr : IInstr {
+
+ private ArrayList label_list;
+
+ public SwitchInstr (ArrayList label_list, Location loc)
+ : base (loc)
+ {
+ this.label_list = label_list;
+ }
+
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
+ {
+ int count = 0;
+ PEAPI.CILLabel[] label_array;
+
+ if (label_list != null) {
+ label_array = new PEAPI.CILLabel[label_list.Count];
+ foreach (object lab in label_list) {
+ if (lab is string) {
+ label_array[count++] = meth.GetLabelDef ((string) lab);
+ } else {
+ throw new InternalErrorException ("offsets in switch statements.");
+ }
+ }
+ } else {
+ label_array = new PEAPI.CILLabel [0];
+ }
+
+ cil.Switch (label_array);
+ }
+ }
+
+}
+