Esempio n. 1
0
        internal override void Emit(EmitContext ec)
        {
            var ig   = ec.ig;
            var type = this.Type;

            LocalBuilder local = null;

            if (type.IsValueType)
            {
                local = ig.DeclareLocal(type);
                ig.Emit(OpCodes.Ldloca, local);

                if (constructor == null)
                {
                    ig.Emit(OpCodes.Initobj, type);
                    ig.Emit(OpCodes.Ldloc, local);
                    return;
                }
            }

            ec.EmitCollection(arguments);

            if (type.IsValueType)
            {
                ig.Emit(OpCodes.Call, constructor);
                ig.Emit(OpCodes.Ldloc, local);
            }
            else
            {
                ig.Emit(OpCodes.Newobj, constructor ?? GetDefaultConstructor(type));
            }
        }
Esempio n. 2
0
        internal override void Emit(EmitContext ec)
        {
            ILGenerator  ig    = ec.ig;
            Type         type  = base.Type;
            LocalBuilder local = null;

            if (type.IsValueType)
            {
                local = ig.DeclareLocal(type);
                ig.Emit(OpCodes.Ldloca, local);
                if (this.constructor == null)
                {
                    ig.Emit(OpCodes.Initobj, type);
                    ig.Emit(OpCodes.Ldloc, local);
                    return;
                }
            }
            ec.EmitCollection <Expression>(this.arguments);
            if (type.IsValueType)
            {
                ig.Emit(OpCodes.Call, this.constructor);
                ig.Emit(OpCodes.Ldloc, local);
            }
            else
            {
                ig.Emit(OpCodes.Newobj, this.constructor ?? NewExpression.GetDefaultConstructor(type));
            }
        }
Esempio n. 3
0
        internal override void Emit(EmitContext ec)
        {
            var local = ec.EmitStored(new_expression);

            ec.EmitCollection(initializers, local);
            ec.EmitLoad(local);
        }
Esempio n. 4
0
        internal override void Emit(EmitContext ec)
        {
            LocalBuilder local = ec.EmitStored(this.new_expression);

            ec.EmitCollection(this.bindings, local);
            ec.EmitLoad(local);
        }
Esempio n. 5
0
        private void EmitNewArrayBounds(EmitContext ec, Type type)
        {
            int count = this.expressions.Count;

            ec.EmitCollection <Expression>(this.expressions);
            if (count == 1)
            {
                ec.ig.Emit(OpCodes.Newarr, type);
                return;
            }
            ec.ig.Emit(OpCodes.Newobj, NewArrayExpression.GetArrayConstructor(type, count));
        }
Esempio n. 6
0
        void EmitNewArrayBounds(EmitContext ec, Type type)
        {
            int rank = expressions.Count;

            ec.EmitCollection(expressions);

            if (rank == 1)
            {
                ec.ig.Emit(OpCodes.Newarr, type);
                return;
            }

            ec.ig.Emit(OpCodes.Newobj, GetArrayConstructor(type, rank));
        }
Esempio n. 7
0
        private void EmitNewArrayBounds(EmitContext ec, Type type)
        {
            int count = expressions.Count;

            ec.EmitCollection(expressions);
            if (count == 1)
            {
                ec.ig.Emit(OpCodes.Newarr, type);
            }
            else
            {
                ec.ig.Emit(OpCodes.Newobj, GetArrayConstructor(type, count));
            }
        }