public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var opcodes = new OpcodeHistogram();

            var opcodeStrings = OpcodeCsv.GetFirstValue(payload.Data).Split(',');

            var opcodeFrequencies = (from f in FrequencyCsv.GetFirstValue(payload.Data).Split(',') select int.Parse(f.Trim())).ToArray();

            for (int i = 0; i < Mathf.Min(opcodeStrings.Length, opcodeFrequencies.Count()); i++)
            {
                opcodes.Add(opcodeStrings[i], new OpcodePair(opcodeFrequencies[i], opcodeStrings[i]));
            }

            OpcodeTarget.SetValue(opcodes, payload.Data);

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
Пример #2
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            var totalHistogram = new OpcodeHistogram();

            foreach (var entry in InputHistograms.GetEntries(mutable))
            {
                var foundOpcodes = InputHistograms.GetValue(entry);
                foreach (var kvp in foundOpcodes)
                {
                    if (!totalHistogram.ContainsKey(kvp.Key))
                    {
                        totalHistogram.Add(kvp.Key, kvp.Value);
                    }

                    totalHistogram[kvp.Key].Frequency += kvp.Value.Frequency;
                }
            }

            CombinedTarget.SetValue(totalHistogram, mutable);

            return(mutable);
        }