Boo.Lang.Compiler.Steps.EmitAssembly.EmitRuntimeCoercionIfNeeded C# (CSharp) Метод

EmitRuntimeCoercionIfNeeded() приватный Метод

private EmitRuntimeCoercionIfNeeded ( IType expectedType, IType actualType ) : void
expectedType IType
actualType IType
Результат void
        private void EmitRuntimeCoercionIfNeeded(IType expectedType, IType actualType)
        {
            // In order to cast to a reference type we emit a castclass opcode
            Context.TraceInfo("castclass: expected type='{0}', type on stack='{1}'", expectedType, actualType);
            var expectedSystemType = GetSystemType(expectedType);
            if (TypeSystemServices.IsSystemObject(actualType))
            {
                Dup();
                Isinst(expectedSystemType);

                var skipCoercion = _il.DefineLabel();
                _il.Emit(OpCodes.Brtrue, skipCoercion);

                EmitGetTypeFromHandle(expectedSystemType); PopType();
                Call(RuntimeServices_Coerce);

                _il.MarkLabel(skipCoercion);
            }
            Castclass(expectedSystemType);
        }
EmitAssembly