From 9b5aed83d6b358ef462424d090478f4ecd2a1b3e Mon Sep 17 00:00:00 2001 From: jbevain Date: Thu, 3 Sep 2009 12:00:32 +0000 Subject: [PATCH] 2009-09-03 Jb Evain * ConstantExpression.cs (Emit): add support for emitting DateTime constants. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mcs@141238 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- class/System.Core/System.Linq.Expressions/ChangeLog | 5 +++++ .../System.Linq.Expressions/ConstantExpression.cs | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/class/System.Core/System.Linq.Expressions/ChangeLog b/class/System.Core/System.Linq.Expressions/ChangeLog index a8183f150a..55387ee3ca 100644 --- a/class/System.Core/System.Linq.Expressions/ChangeLog +++ b/class/System.Core/System.Linq.Expressions/ChangeLog @@ -1,3 +1,8 @@ +2009-09-03 Jb Evain + + * ConstantExpression.cs (Emit): add support for emitting + DateTime constants. + 2009-03-05 Jb Evain * EmitContext.cs diff --git a/class/System.Core/System.Linq.Expressions/ConstantExpression.cs b/class/System.Core/System.Linq.Expressions/ConstantExpression.cs index 475bddbe7f..f59a05d6b6 100644 --- a/class/System.Core/System.Linq.Expressions/ConstantExpression.cs +++ b/class/System.Core/System.Linq.Expressions/ConstantExpression.cs @@ -131,6 +131,19 @@ namespace System.Linq.Expressions { return; } + case TypeCode.DateTime: { + var date = (DateTime) value; + var local = ig.DeclareLocal (typeof (DateTime)); + + ig.Emit (OpCodes.Ldloca, local); + ig.Emit (OpCodes.Ldc_I8, date.Ticks); + ig.Emit (OpCodes.Ldc_I4, (int) date.Kind); + ig.Emit (OpCodes.Call, typeof (DateTime).GetConstructor (new [] { typeof (long), typeof (DateTimeKind) })); + ig.Emit (OpCodes.Ldloc, local); + + return; + } + case TypeCode.String: EmitIfNotNull (ec, c => c.ig.Emit (OpCodes.Ldstr, (string) value)); return; -- 2.11.4.GIT