private ArrayList label_list;
- public SwitchInstr (ArrayList label_list)
+ public SwitchInstr (ArrayList label_list, Location loc)
+ : base (loc)
{
this.label_list = label_list;
}
- public void Emit (CodeGen code_gen, MethodDef meth, PEAPI.CILInstructions cil)
+ public override void Emit (CodeGen code_gen, MethodDef meth,
+ PEAPI.CILInstructions cil)
{
int count = 0;
- PEAPI.CILLabel[] 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 {
- // TODO: int32 labels
- throw new NotImplementedException ("offsets in switch statements.");
+ 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 LabelInfo) {
+ label_array[count++] = ((LabelInfo)lab).Label;
+ } else {
+ throw new InternalErrorException ("offsets in switch statements.");
+ }
}
+ } else {
+ label_array = new PEAPI.CILLabel [0];
}
cil.Switch (label_array);