示例#1
0
        internal Local(object owner, ushort index, Type localType, DeclareLocallDelegate local, string name, LocalReusableDelegate reusable, int declaredAt)
        {
            _Owner   = owner;
            LocalDel = local;
            Name     = name;

            Index     = index;
            LocalType = localType;
            StackType = TypeOnStack.Get(localType);

            Reusable = reusable;

            DeclaredAtIndex = declaredAt;
        }
示例#2
0
        internal Local(object owner, ushort index, Type localType, DeclareLocallDelegate local, string name, LocalReusableDelegate reusable, int declaredAt)
        {
            _Owner = owner;
            LocalDel = local;
            Name = name;

            Index = index;
            LocalType = localType;
            StackType = TypeOnStack.Get(localType);

            Reusable = reusable;

            DeclaredAtIndex = declaredAt;
        }
        public DeclareLocallDelegate DeclareLocal(Type type)
        {
            ILGenerator  forIl = null;
            LocalBuilder l     = null;

            DeclareLocallDelegate ret =
                il =>
            {
                if (forIl != null && il != forIl)
                {
                    l = null;
                }

                if (l != null)
                {
                    return(l);
                }

                forIl = il;
                l     = forIl.DeclareLocal(type);

                return(l);
            };

            InstructionSizes.Add(() => InstructionSize.DeclareLocal());

            LengthCache.Clear();

            Buffer.Add(
                (il, logOnly, log) =>
            {
                if (!logOnly)
                {
                    ret(il);
                }
            }
                );

            TraversableBuffer.Add(new BufferedILInstruction {
                DeclaresLocal = true
            });

            Operations.Add(null);

            return(ret);
        }