internal void SetAndResolveInstructions(CILInstruction[] insts)
{
offset = 0;
ArrayList labels = new ArrayList();
for (int i=0; i < insts.Length; i++) {
insts[i].offset = offset;
offset += insts[i].size;
if (insts[i] is BranchInstr) {
((BranchInstr)insts[i]).MakeTargetLabel(labels);
} else if (insts[i] is SwitchInstr) {
((SwitchInstr)insts[i]).MakeTargetLabels(labels);
}
}
if (exceptions != null) {
for (int i=0; i < exceptions.Count; i++) {
exceptions[i] = ((EHClause)exceptions[i]).MakeTryBlock(labels);
}
}
if (labels.Count == 0) { buffer = insts; tide = buffer.Length; return; }
buffer = new CILInstruction[insts.Length + labels.Count];
int currentPos = 0;
tide = 0;
for (int i=0; i < labels.Count; i++) {
CILLabel lab = (CILLabel)labels[i];
while ((currentPos < insts.Length) && (insts[currentPos].offset < lab.offset))
buffer[tide++] = insts[currentPos++];
buffer[tide++] = lab;
}
while (currentPos < insts.Length) {
buffer[tide++] = insts[currentPos++];
}
}