- public override Constant ConvertExplicitly(bool inCheckedContext, Type target_type)
- {
- if (!TypeManager.IsValueType (target_type))
- return new EmptyConstantCast (this, target_type);
-
- return null;
- }
-
- public override Constant ConvertImplicitly (Type targetType)
- {
- if (!TypeManager.IsValueType (targetType))
- return new EmptyConstantCast (this, targetType);
-
- return null;
- }
- }
-
- //
- // Represents default(X) when result can be reduced to null
- //
- public class NullDefault : EmptyConstantCast
- {
- public NullDefault(Constant value, Type type)
- : base (value, type)
- {
- }
-
- public override void Error_ValueCannotBeConverted (EmitContext ec, Location loc, Type target, bool expl)
- {
- base.Error_ValueCannotBeConverted (ec, loc, target, expl);
- }
- }
-
- //
- // The null Literal constant
- //
- public class NullLiteral : NullConstant {
- public NullLiteral (Location loc):
- base (loc)
- {
- }
-
- public override Expression DoResolve (EmitContext ec)
- {
- type = TypeManager.null_type;
- return this;
- }
-
- public override void Error_ValueCannotBeConverted (EmitContext ec, Location loc, Type t, bool expl)