Example #1
0
        private void EmitConversionExpression(BoundConversion conversion, bool used)
        {
            switch (conversion.ConversionKind)
            {
            case ConversionKind.MethodGroup:
                EmitMethodGroupConversion(conversion, used);
                return;

            case ConversionKind.NullToPointer:
                // The null pointer is represented as 0u.
                _builder.EmitIntConstant(0);
                _builder.EmitOpCode(ILOpCode.Conv_u);
                EmitPopIfUnused(used);
                return;
            }

            if (!used && !conversion.ConversionHasSideEffects())
            {
                EmitExpression(conversion.Operand, false); // just do expr side effects
                return;
            }

            EmitExpression(conversion.Operand, true);
            EmitConversion(conversion);

            EmitPopIfUnused(used);
        }
Example #2
0
        private void EmitConversionExpression(BoundConversion conversion, bool used)
        {
            switch (conversion.ConversionKind)
            {
            case ConversionKind.MethodGroup:
                throw ExceptionUtilities.UnexpectedValue(conversion.ConversionKind);

            case ConversionKind.ImplicitNullToPointer:
                // The null pointer is represented as 0u.
                _builder.EmitIntConstant(0);
                _builder.EmitOpCode(ILOpCode.Conv_u);
                EmitPopIfUnused(used);
                return;
            }

            var operand = conversion.Operand;

            if (!used && !conversion.ConversionHasSideEffects())
            {
                EmitExpression(operand, false); // just do expr side effects
                return;
            }

            EmitExpression(operand, true);
            EmitConversion(conversion);

            EmitPopIfUnused(used);
        }
Example #3
0
        private void EmitConversionExpression(BoundConversion conversion, bool used)
        {
            switch (conversion.ConversionKind)
            {
                case ConversionKind.MethodGroup:
                    EmitMethodGroupConversion(conversion, used);
                    return;
                case ConversionKind.NullToPointer:
                    // The null pointer is represented as 0u.
                    _builder.EmitIntConstant(0);
                    _builder.EmitOpCode(ILOpCode.Conv_u);
                    EmitPopIfUnused(used);
                    return;
            }

            if (!used && !conversion.ConversionHasSideEffects())
            {
                EmitExpression(conversion.Operand, false); // just do expr side effects
                return;
            }

            EmitExpression(conversion.Operand, true);
            EmitConversion(conversion);

            EmitPopIfUnused(used);
        }