- // The NullType just exists to compare type equality, and for
- // expressions that might have the `null type'
- //
- public class NullType {
- }
-
-
- public class NullConstant : Constant
- {
- public NullConstant (Location loc):
- base (loc)
- {
- eclass = ExprClass.Value;
- type = TypeManager.null_type;
- }
-
- override public string AsString ()
- {
- return "null";
- }
-
- public override object GetValue ()
- {
- return null;
- }
-
- public override void Emit (EmitContext ec)
- {
- ec.ig.Emit(OpCodes.Ldnull);
- }
-
- public override string GetSignatureForError ()
- {
- return "null";
- }
-
- public override Constant Increment ()
- {
- throw new NotSupportedException ();
- }
-
- public override bool IsDefaultValue
- {
- get { return true; }
- }
-
- public override bool IsNegative
- {
- get { return false; }
- }
-
- public override bool IsZeroInteger
- {
- get { return true; }
- }
-
- 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;
- }
- }
-