public MethodWeaver(ModuleWeavingContext context, MethodDefinition method, ILogger log) { _context = context; _method = method; _il = new WeaverILProcessor(_method); _sequencePoints = new SequencePointMapper(_method, context.Config); _log = new MethodWeaverLogger(log, _method); _labels = new LabelMapper(_il, _log); _consumer = new ArgumentConsumer(_il); }
private static IEnumerable <InstructionSequence> CreateSequences(IList <Instruction> instructions, IList <SequencePoint>?sequencePoints) { if (sequencePoints?.Any() != true) { yield return(new InstructionSequence(instructions, null, instructions.Count, null)); yield break; } var sequencePointMapper = new SequencePointMapper(sequencePoints); var sequences = instructions .Select(inst => sequencePointMapper.GetNext(inst.Offset)) .GroupBy(item => item); InstructionSequence?previous = null; foreach (var group in sequences) { yield return(previous = new InstructionSequence(instructions, previous, group.Count(), group.Key)); } }