2005-01-19 Sureshkumar T <tsureshkumar@novell.com>
[mono.git] / mcs / gmcs / literal.cs
old mode 100755 (executable)
new mode 100644 (file)
index 4faf428..0a97d50
@@ -22,8 +22,30 @@ using System;
 using System.Reflection;
 using System.Reflection.Emit;
 
+//
+// I put System.Null just so we do not have to special case it on 
+// TypeManager.CSharpName
+//
+namespace System {
+       //
+       // Represents the Null Type, just used as a placeholder for the type in NullLiteral
+       //
+       public class Null {
+       }
+}
+       
 namespace Mono.CSharp {
 
+       //
+       // The NullType just exists to compare type equality, and for
+       // expressions that might have the `null type'
+       //
+       public class NullType {
+       }
+
+       //
+       // The null Literal constant
+       //
        public class NullLiteral : Constant {
                public static readonly NullLiteral Null;
 
@@ -49,7 +71,7 @@ namespace Mono.CSharp {
 
                public override Expression DoResolve (EmitContext ec)
                {
-                       type = TypeManager.object_type;
+                       type = TypeManager.null_type;
                        return this;
                }
 
@@ -58,6 +80,12 @@ namespace Mono.CSharp {
                        ec.ig.Emit (OpCodes.Ldnull);
                }
                
+               public override bool IsNegative {
+                       get {
+                               return false;
+                       }
+               }
+
                public override bool IsZeroInteger {
                        get { return true; }
                }
@@ -74,6 +102,11 @@ namespace Mono.CSharp {
                        Null = new NullPointer ();
                }
                
+               private NullPointer ()
+               {
+                       type = TypeManager.object_type;
+               }
+
                public override void Emit (EmitContext ec)
                {
                        ILGenerator ig = ec.ig;