Exemplo n.º 1
0
        public IEnumerable <CodeInstruction> TransMethod(TranspilerFactory factory)
        {
            var instructions = factory.CodeEnumerator;

            while (instructions.MoveNext())
            {
                yield return(instructions.Current);
            }
        }
        public IEnumerable <CodeInstruction> TransMethod(TranspilerFactory factory)
        {
            _ = factory.CodeEnumerator;
            var generator = factory.Generator;
            var locals    = factory.Locals;
            var labels    = factory.Labels;

            foreach (var code in list)
            {
                var no = code.opcode.Value;
                if (code.opcode == CodeParser.LocalvarOpcode)
                {
                    locals.Add(generator.DeclareLocal((Type)code.operand));
                }
                else if (code.opcode == CodeParser.LabelOpcode)
                {
                    var index = (int)code.operand;
                    for (var i = labels.Count - 1; i < index; i++)
                    {
                        labels.Add(generator.DefineLabel());
                    }

                    var t = new List <Label> {
                        labels[index]
                    };
                    yield return(new CodeInstruction(OpCodes.Nop)
                    {
                        labels = t
                    });
                }
                else if (no == 17 || no == 18 || no == 19 || no == -500 || no == -499 || no == -498)
                {
                    code.operand = locals[Convert.ToInt32(code.operand)];
                    yield return(code);
                }
                else if (code.opcode.OperandType == OperandType.InlineBrTarget ||
                         code.opcode.OperandType == OperandType.ShortInlineBrTarget)
                {
                    var index = (int)code.operand;
                    for (var i = labels.Count - 1; i < index; i++)
                    {
                        labels.Add(generator.DefineLabel());
                    }

                    code.operand = labels[index];
                    yield return(code);
                }
                else
                {
                    yield return(code);
                }
            }
        }
Exemplo n.º 3
0
        public IEnumerable <CodeInstruction> TransMethod(TranspilerFactory factory)
        {
            var t            = count;
            var instructions = factory.CodeEnumerator;

            while (t > 0 && instructions.MoveNext())
            {
                t--;
            }

            return(null);
        }
Exemplo n.º 4
0
        public IEnumerable <CodeInstruction> TransMethod(TranspilerFactory factory)
        {
            var queue        = new Queue <CodeInstruction>();
            var instructions = factory.CodeEnumerator;

            while (instructions.MoveNext())
            {
                var current = instructions.Current;
                queue.Enqueue(current);
                if (queue.Count > search.Count)
                {
                    yield return(queue.Dequeue());
                }

                if (queue.Count != search.Count)
                {
                    continue;
                }

                var count = 0;
                foreach (var item in queue)
                {
                    if (search[count].IsMatchWith(item))
                    {
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (count < search.Count)
                {
                    continue;
                }

                while (queue.Count > 0)
                {
                    yield return(queue.Dequeue());
                }

                yield break;
            }

            while (queue.Count > 0)
            {
                yield return(queue.Dequeue());
            }
        }