private static BoundNode RewriteConstant(BoundExpression node)
        {
            var syntax = node.Syntax;

            Debug.Assert(node != null);
            var constantValue = node.ConstantValue;
            Debug.Assert(constantValue != null);
            Debug.Assert(node.ConstantValue.IsDecimal);

            var decimalType = node.Type as NamedTypeSymbol;

            Debug.Assert(decimalType != null);
            Debug.Assert(decimalType.SpecialType == SpecialType.System_Decimal);

            var value = node.ConstantValue.DecimalValue;
            var parts = new DecimalParts(value);
            var scale = parts.Scale;

            var arguments = new ArrayBuilder<BoundExpression>();
            MethodSymbol ctor = null;
            var ctors = decimalType.InstanceConstructors;

            // check if we can call a simple constructor
            if (scale == 0 && !parts.IsNegative && value == 0m)
            {
                // new decimal();
                foreach (MethodSymbol c in ctors)
                {
                    if (c.Parameters.Count == 0)
                    {
                        ctor = c;
                        break;
                    }
                }
            }
            else if (scale == 0 && int.MinValue <= value && value <= int.MaxValue)
            {
                //new decimal(int);
                foreach (MethodSymbol c in ctors)
                {
                    if (c.Parameters.Count == 1 && c.Parameters[0].Type.SpecialType == SpecialType.System_Int32)
                    {
                        ctor = c;
                        break;
                    }
                }
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((int)value), ctor.Parameters[0].Type));
            }
            else if (scale == 0 && uint.MinValue <= value && value <= uint.MaxValue)
            {
                //new decimal(uint);
                foreach (MethodSymbol c in ctors)
                {
                    if (c.Parameters.Count == 1 && c.Parameters[0].Type.SpecialType == SpecialType.System_UInt32)
                    {
                        ctor = c;
                        break;
                    }
                }
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((uint)value), ctor.Parameters[0].Type));
            }
            else if (scale == 0 && long.MinValue <= value && value <= long.MaxValue)
            {
                //new decimal(long);
                foreach (MethodSymbol c in ctors)
                {
                    if (c.Parameters.Count == 1 && c.Parameters[0].Type.SpecialType == SpecialType.System_Int64)
                    {
                        ctor = c;
                        break;
                    }
                }
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((long)value), ctor.Parameters[0].Type));
            }
            else if (scale == 0 && ulong.MinValue <= value && value <= ulong.MaxValue)
            {
                //new decimal(ulong);
                foreach (MethodSymbol c in ctors)
                {
                    if (c.Parameters.Count == 1 && c.Parameters[0].Type.SpecialType == SpecialType.System_UInt64)
                    {
                        ctor = c;
                        break;
                    }
                }
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((ulong)value), ctor.Parameters[0].Type));
            }
            else
            {
                //new decimal(int low, int mid, int high, bool isNegative, byte scale);
                foreach (MethodSymbol c in ctors)
                {
                    if (c.Parameters.Count == 5)
                    {
                        ctor = c;
                        break;
                    }
                }
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(parts.Low), ctor.Parameters[0].Type));
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(parts.Mid), ctor.Parameters[1].Type));
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(parts.High), ctor.Parameters[2].Type));
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create(parts.IsNegative), ctor.Parameters[3].Type));
                arguments.Add(new BoundLiteral(syntax, ConstantValue.Create((byte)parts.Scale), ctor.Parameters[4].Type));
            }
            return new BoundObjectCreationExpression(
                node.Syntax,
                ctor,
                arguments.ToReadOnlyAndFree());
        }