- //
- // Null can have its own type, think of default (Foo)
- //
- public NullLiteral (Type type, Location loc)
- : base (loc)
- {
- eclass = ExprClass.Value;
- this.type = type;
- }
-
- override public string AsString ()
- {
- return GetSignatureForError ();
- }
-
- public override Expression CreateExpressionTree (EmitContext ec)
- {
- // HACK: avoid referencing mcs internal type
- if (type == typeof (NullLiteral))
- type = TypeManager.object_type;
-
- return base.CreateExpressionTree (ec);
- }
-
- public override Expression DoResolve (EmitContext ec)
- {
- return this;
- }
-
- public override void Emit (EmitContext ec)
- {
- ec.ig.Emit (OpCodes.Ldnull);
-
-#if GMCS_SOURCE
- // Only to make verifier happy
- if (TypeManager.IsGenericParameter (type))
- ec.ig.Emit (OpCodes.Unbox_Any, type);
-#endif
- }
-
- public override string ExprClassName {
- get {
- return GetSignatureForError ();
- }
- }
-
- public override string GetSignatureForError ()
- {
- return "null";
- }
-
- public override void Error_ValueCannotBeConverted (EmitContext ec, Location loc, Type t, bool expl)