IKVM.Internal.CodeEmitter.EmitUnboxSpecial C# (CSharp) Method

EmitUnboxSpecial() private method

private EmitUnboxSpecial ( Type type ) : void
type IKVM.Reflection.Type
return void
        internal void EmitUnboxSpecial(Type type)
        {
            // NOTE if the reference is null, we treat it as a default instance of the value type.
            Emit(OpCodes.Dup);
            CodeEmitterLabel label1 = DefineLabel();
            Emit(OpCodes.Brtrue_S, label1);
            Emit(OpCodes.Pop);
            CodeEmitterLocal local = AllocTempLocal(type);
            Emit(OpCodes.Ldloca, local);
            Emit(OpCodes.Initobj, type);
            Emit(OpCodes.Ldloc, local);
            ReleaseTempLocal(local);
            CodeEmitterLabel label2 = DefineLabel();
            Emit(OpCodes.Br_S, label2);
            MarkLabel(label1);
            Emit(OpCodes.Unbox, type);
            Emit(OpCodes.Ldobj, type);
            MarkLabel(label2);
        }