public void Emit(OpCode op, Sigil.Local local)
        {
            InstructionSizes.Add(() => InstructionSize.Get(op));

            LengthCache.Clear();

            Buffer.Add(
                (il, logOnly, log) =>
            {
                if (!logOnly)
                {
                    var l = local.LocalDel(il);
                    il.Emit(op, l);
                }

                log.AppendLine(op + " " + local);
            }
                );

            TraversableBuffer.Add(new BufferedILInstruction {
                IsInstruction = op
            });

            Operations.Add(new Operation <DelegateType> {
                OpCode = op, Parameters = new object[] { local }
            });
        }
示例#2
0
        void EmitSimpleStream(Schema schema, ValueWriter writer)
        {
            // push *value
            Emit.LoadArgument(0);
            LoadIndirect(schema.NetType);

            // push stream
            Emit.LoadArgument(ARG_STREAM);

            // push buffer
            Emit.LoadArgument(ARG_BUFFER);

            // push &available
            LocalAvailable = Emit.DeclareLocal(typeof(int), "available");
            PushTotalAvailable();
            Emit.StoreLocal(LocalAvailable);
            Emit.LoadLocalAddress(LocalAvailable);

            // push &ptr;
            Emit.LoadArgumentAddress(ARG_POINTER);

            // call writer
            Emit.Call(writer.MethodInfo);

            Flush(resetAvailable: false, writtenTop: false);

            Emit.Return();
        }