//
using System;
+
+#if STATIC
+using IKVM.Reflection.Emit;
+#else
using System.Reflection.Emit;
+#endif
namespace Mono.CSharp {
/// </summary>
public abstract object GetValue ();
+#if !STATIC
+ //
+ // Returns an object value which is typed to contant type
+ //
public virtual object GetTypedValue ()
{
return GetValue ();
}
+#endif
public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl)
{
Error_ValueCannotBeConverted (ec, loc, target_type, false);
}
- return New.Constantify (target_type).Resolve (ec);
+ return New.Constantify (target_type, loc).Resolve (ec);
}
}
// do nothing
}
+ public sealed override Expression Clone (CloneContext clonectx)
+ {
+ // No cloning is not needed for constants
+ return this;
+ }
+
protected override void CloneTo (CloneContext clonectx, Expression target)
{
- // CloneTo: Nothing, we do not keep any state on this expression
+ throw new NotSupportedException ("should not be reached");
}
public override System.Linq.Expressions.Expression MakeExpression (BuilderContext ctx)
{
+#if STATIC
+ return base.MakeExpression (ctx);
+#else
return System.Linq.Expressions.Expression.Constant (GetTypedValue (), type.GetMetaInfo ());
+#endif
}
public new Constant Resolve (ResolveContext rc)
}
}
- public abstract class IntegralConstant : Constant {
+ public abstract class IntegralConstant : Constant
+ {
protected IntegralConstant (Location loc) :
base (loc)
{
var ac = targetType as ArrayContainer;
if (ac != null) {
- if (ac.Rank != 1)
+ if (ac.Rank != 1 || ac.Element.IsArray)
base.EncodeAttributeValue (rc, enc, targetType);
else
enc.Stream.Write (uint.MaxValue);
}
// Exlude internal compiler types
- if (targetType == InternalType.AnonymousMethod)
+ if (targetType.Kind == MemberKind.InternalCompilerType && targetType != InternalType.Dynamic && targetType != InternalType.Null)
return null;
if (!IsLiteral && !Convert.ImplicitStandardConversionExists (this, targetType))