Пример #1
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            if (constructor != null)
            {
                constructor.GetEffectiveParameterTypes().ProcessTandemStrict(arguments,
                                                                             (t, a) => a.GetILImplicitCast(t).RenderIL_Load(canvas)
                                                                             );

                canvas.Emit_Newobj(constructor);
            }
            else
            {
                if (type.IsStruct())
                {
                    canvas.UseLocal(type, delegate(ILLocal local) {
                        local.RenderIL_LoadAddress(canvas);
                        canvas.Emit_Initobj(type);
                        local.RenderIL_Load(canvas);
                    });
                }
                else
                {
                    canvas.Emit_Newobj(type.GetDefaultConstructor());
                }
            }
        }
Пример #2
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            BasicType basic_type = value_type.GetBasicType();

            switch (basic_type)
            {
            case BasicType.Bool: canvas.Emit_Ldc_I4(0); break;

            case BasicType.SByte: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Short: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Int: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Long: canvas.Emit_Ldc_I8(0); break;

            case BasicType.Byte: canvas.Emit_Ldc_U4(0); break;

            case BasicType.UShort: canvas.Emit_Ldc_U4(0); break;

            case BasicType.UInt: canvas.Emit_Ldc_U4(0); break;

            case BasicType.ULong: canvas.Emit_Ldc_U8(0); break;

            case BasicType.Float: canvas.Emit_Ldc_R4(0.0f); break;

            case BasicType.Double: canvas.Emit_Ldc_R8(0.0); break;

            case BasicType.Char: canvas.Emit_Ldc_I4(0); break;

            case BasicType.String: canvas.Emit_Ldstr(""); break;

            case BasicType.Array: canvas.Emit_Ldnull(); break;

            case BasicType.Enum: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Class: canvas.Emit_Ldnull(); break;

            case BasicType.Struct:
                canvas.UseLocal(value_type, delegate(ILLocal local) {
                    local.RenderIL_LoadAddress(canvas);
                    canvas.Emit_Initobj(value_type);
                    local.RenderIL_Load(canvas);
                });
                break;

            default: throw new UnaccountedBranchException("basic_type", basic_type);
            }
        }