public void TranslateOffsets(IInstructionList list) { if (IsSwitch) { int origin = _offset; var def = _operands[SW_Default]; int offset = origin + (int)def.Value; int index = list.GetOffsetIndex(offset); list[index].IsBranchTarget = true; def.Value = index; var offsets = (int[])_operands[SW_Cases].Value; for (int i = 0; i < offsets.Length; ++i) { offset = origin + offsets[i]; index = list.GetOffsetIndex(offset); list[index].IsBranchTarget = true; offsets[i] = index; } } else if (IsBranch) { var op = _operands[0]; int offset = _offset + 4 + (int)op.Value; int index = list.GetOffsetIndex(offset); list[index].IsBranchTarget = true; op.Value = index; } }
public void TranslateOffsets(IInstructionList list) { if (IsSwitch) { var offsets = (int[])Value; for (int j = 0; j < offsets.Length; ++j) { int index = list.GetOffsetIndex(offsets[j]); list[index].IsBranchTarget = true; offsets[j] = index; } } else if (IsBranch) { int index = list.GetOffsetIndex((int)Value); list[index].IsBranchTarget = true; Value = index; } }
private static int GetOffsetIndex(IInstructionList code, int offset) { int i = code.GetOffsetIndex(offset); if (i < 0) { throw Errors.ABC.InvalidBranchOffset.CreateException(); } return(i); }
private HandlerBlock CreateHandlerBlock(IMethod method, IMethodContext context, IInstructionList code, SEHBlock block) { switch (block.Type) { case SEHFlags.Catch: { int token = block.Value; var type = context.ResolveType(method, token); if (!HasGenericExceptions && type.IsGenericContext()) { _genericFlags |= GenericFlags.HasGenericExceptions; } var h = new HandlerBlock(BlockType.Catch) { ExceptionType = type }; return(h); } case SEHFlags.Filter: { var h = new HandlerBlock(BlockType.Filter) { FilterIndex = code.GetOffsetIndex(block.Value) }; return(h); } case SEHFlags.Finally: return(new HandlerBlock(BlockType.Finally)); case SEHFlags.Fault: return(new HandlerBlock(BlockType.Fault)); default: throw new IndexOutOfRangeException(); } }