Beispiel #1
0
        /// <summary>
        /// Convert a integer compare operation (bge, bgt, ble, blt) with enum argument.
        /// </summary>
        private static void ConvertICmpArgument(AstExpression node, int argIndex, XTypeDefinition enumType, AssemblyCompiler compiler)
        {
            Debug.Assert(node.Arguments.Count == 2);
            var isWide = enumType.GetEnumUnderlyingType().IsWide();
            var module = compiler.Module;
            var retType = isWide ? module.TypeSystem.Long : module.TypeSystem.Int;

            // Convert arguments
            ConvertNumericOpArgument(node, argIndex, enumType, isWide, retType);
        }
Beispiel #2
0
        /// <summary>
        /// Convert a binary operation (Add, Sub, Mul, Div, Rem, And, Or, Xor) resulting in an enum.
        /// </summary>
        private static void ConvertBinOp(AstExpression node, XTypeDefinition enumType, AssemblyCompiler compiler)
        {
            Debug.Assert(node.Arguments.Count == 2);
            var isWide = enumType.GetEnumUnderlyingType().IsWide();
            var module = compiler.Module;            
            var retType = isWide ? module.TypeSystem.Long : module.TypeSystem.Int;

            // Convert arguments
            ConvertNumericOpArgument(node, 0, enumType, isWide, retType);
            ConvertNumericOpArgument(node, 1, enumType, isWide, retType);

            // Convert return value
            if ((node.ExpectedType == null) || (!node.ExpectedType.IsPrimitive))
            {
                ConvertNumericToEnum(node, enumType, retType);
            }
            else
            {
                node.InferredType = retType;
            }
        }