Example #1
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));
            }
        }