浏览代码

Merge pull request #7 from sebastienros/master

Update
fvaneijk 9 年之前
父节点
当前提交
b3328f33b1

文件差异内容过多而无法显示
+ 1170 - 1157
Jint.Tests/Runtime/EngineTests.cs


+ 31 - 0
Jint.Tests/Runtime/InteropTests.cs

@@ -274,6 +274,37 @@ namespace Jint.Tests.Runtime
             Assert.Equal("Donald Duck", dictionary[2]);
         }
 
+        [Fact]
+        public void CanUseGenericMethods()
+        {
+            var dictionary = new Dictionary<int, string>();
+            dictionary.Add(1, "Mickey Mouse");
+
+
+            _engine.SetValue("dictionary", dictionary);
+
+            RunTest(@"
+                dictionary.Add(2, 'Goofy');
+                assert(dictionary[2] === 'Goofy');
+            ");
+
+            Assert.Equal("Mickey Mouse", dictionary[1]);
+            Assert.Equal("Goofy", dictionary[2]);
+        }
+
+        [Fact]
+        public void CanUseMultiGenericTypes()
+        {
+            
+            RunTest(@"
+                var type = System.Collections.Generic.Dictionary(System.Int32, System.String);
+                var dictionary = new type();
+                dictionary.Add(1, 'Mickey Mouse');
+                dictionary.Add(2, 'Goofy');
+                assert(dictionary[2] === 'Goofy');
+            ");
+        }
+
         [Fact]
         public void CanUseIndexOnCollection()
         {

+ 4 - 1
Jint/Engine.cs

@@ -295,7 +295,10 @@ namespace Jint
                 var result = _statements.ExecuteProgram(program);
                 if (result.Type == Completion.Throw)
                 {
-                    throw new JavaScriptException(result.GetValueOrDefault());
+                    throw new JavaScriptException(result.GetValueOrDefault())
+                    {
+                        Location = result.Location
+                    };
                 }
 
                 _completionValue = result.GetValueOrDefault();

+ 10 - 5
Jint/Jint.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
   <metadata>
     <id>Jint</id>
-    <version>2.5.0</version>
+    <version>2.7.1</version>
     <owners>Sebastien Ros</owners>
     <authors>Sebastien Ros</authors>
     <description>Javascript Interpreter for .NET</description>
@@ -10,10 +10,15 @@
     <projectUrl>http://github.com/sebastienros/jint</projectUrl>
     <licenseUrl>https://raw.githubusercontent.com/sebastienros/jint/master/LICENSE.txt</licenseUrl>
     <releaseNotes>
-      Automatic support of camelCase mapping for .NET members.
-      Support for nested types.
-      Support for params JsValue[].
-      Bug fixes.
+Improvement: Significant performance improvements
+Improvement: Configurable local timezone
+Improvement: Configurable local culture
+Bug: Local date and time representation
+Bug: Date prototype allowed usage
+Bug: Date.now precision
+Bug: Array index conversion
+Bug: Object is extensible
+Bug: Correct assignment evaluation
     </releaseNotes>
     <tags>javascript interpreter jint</tags>
   </metadata>

+ 10 - 0
Jint/Native/Array/ArrayInstance.cs

@@ -306,6 +306,16 @@ namespace Jint.Native.Array
                 return uint.MaxValue;
             }
 
+            if(d == 0 && p.Length > 1)
+            {
+                // If p is a number that start with '0' and is not '0' then
+                // its ToString representation can't be the same a p. This is 
+                // not a valid array index. '01' !== ToString(ToUInt32('01'))
+                // http://www.ecma-international.org/ecma-262/5.1/#sec-15.4
+
+                return uint.MaxValue; 
+            }
+
             ulong result = (uint)d;
 
             for (int i = 1; i < p.Length; i++)

+ 13 - 4
Jint/Native/Date/DateConstructor.cs

@@ -56,6 +56,12 @@ namespace Jint.Native.Date
             {
                 if (!DateTime.TryParseExact(date, new[]
                 {
+                    // Formats used in DatePrototype toString methods
+                    "ddd MMM dd yyyy HH:mm:ss 'GMT'K",
+                    "ddd MMM dd yyyy",
+                    "HH:mm:ss 'GMT'K",
+
+                    // standard formats
                     "yyyy-M-dTH:m:s.FFFK",
                     "yyyy/M/dTH:m:s.FFFK",
                     "yyyy-M-dTH:m:sK",
@@ -79,10 +85,13 @@ namespace Jint.Native.Date
                     "THHK"
                 }, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out result))
                 {
-                    if (!DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal,out result))
+                    if (!DateTime.TryParse(date, Engine.Options.GetCulture(), DateTimeStyles.AdjustToUniversal, out result))
                     {
-                        // unrecognized dates should return NaN (15.9.4.2)
-                        return double.NaN;
+                        if (!DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out result))
+                        {
+                            // unrecognized dates should return NaN (15.9.4.2)
+                            return double.NaN;
+                        }
                     }
                 }
             }
@@ -97,7 +106,7 @@ namespace Jint.Native.Date
 
         private JsValue Now(JsValue thisObj, JsValue[] arguments)
         {
-            return (DateTime.UtcNow - Epoch).TotalMilliseconds;
+            return System.Math.Floor((DateTime.UtcNow - Epoch).TotalMilliseconds);
         }
 
         public override JsValue Call(JsValue thisObject, JsValue[] arguments)

+ 82 - 69
Jint/Native/Date/DatePrototype.cs

@@ -78,54 +78,66 @@ namespace Jint.Native.Date
             FastAddProperty("toJSON", new ClrFunctionInstance(Engine, ToJSON, 1), true, false, true);
         }
 
-        private static JsValue ValueOf(JsValue thisObj, JsValue[] arguments)
+        private JsValue ValueOf(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.TryCast<DateInstance>().PrimitiveValue;
+            return EnsureDateInstance(thisObj).PrimitiveValue;
+        }
+
+        /// <summary>
+        /// Converts a value to a <see cref="DateInstance"/> or throws a TypeError exception.
+        /// c.f., http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5
+        /// </summary>
+        private DateInstance EnsureDateInstance(JsValue thisObj)
+        {
+            return thisObj.TryCast<DateInstance>(value =>
+               {
+                   throw new JavaScriptException(Engine.TypeError, "Invalid Date");
+               });
         }
 
         public JsValue ToString(JsValue thisObj, JsValue[] arg2)
         {
-            return ToLocalTime(thisObj.TryCast<DateInstance>().ToDateTime()).ToString("ddd MMM dd yyyy HH:mm:ss 'GMT'K", CultureInfo.InvariantCulture);
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("ddd MMM dd yyyy HH:mm:ss 'GMT'K", CultureInfo.InvariantCulture);
         }
 
-        private static JsValue ToDateString(JsValue thisObj, JsValue[] arguments)
+        private JsValue ToDateString(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.TryCast<DateInstance>().ToDateTime().ToString("D", CultureInfo.InvariantCulture);
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("ddd MMM dd yyyy", CultureInfo.InvariantCulture);
         }
 
-        private static JsValue ToTimeString(JsValue thisObj, JsValue[] arguments)
+        private JsValue ToTimeString(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.TryCast<DateInstance>().ToDateTime().ToString("T", CultureInfo.InvariantCulture);
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("HH:mm:ss 'GMT'K", CultureInfo.InvariantCulture);
         }
 
-        private static JsValue ToLocaleString(JsValue thisObj, JsValue[] arguments)
+        private JsValue ToLocaleString(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.TryCast<DateInstance>().ToDateTime().ToString("F");
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("F", Engine.Options.GetCulture());
         }
 
-        private static JsValue ToLocaleDateString(JsValue thisObj, JsValue[] arguments)
+        private JsValue ToLocaleDateString(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.TryCast<DateInstance>().ToDateTime().ToString("D");
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("D", Engine.Options.GetCulture());
         }
 
         private JsValue ToLocaleTimeString(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.TryCast<DateInstance>().ToDateTime().ToString("T");
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("T", Engine.Options.GetCulture());
         }
 
-        private static JsValue GetTime(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetTime(JsValue thisObj, JsValue[] arguments)
         {
-            if (double.IsNaN(thisObj.TryCast<DateInstance>().PrimitiveValue))
+            if (double.IsNaN(EnsureDateInstance(thisObj).PrimitiveValue))
             {
                 return double.NaN;
             }
 
-            return thisObj.TryCast<DateInstance>().PrimitiveValue;
+            return EnsureDateInstance(thisObj).PrimitiveValue;
         }
 
         private JsValue GetFullYear(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -136,7 +148,7 @@ namespace Jint.Native.Date
 
         private JsValue GetYear(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -145,9 +157,9 @@ namespace Jint.Native.Date
             return YearFromTime(LocalTime(t)) - 1900;
         }
 
-        private static JsValue GetUTCFullYear(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCFullYear(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -158,7 +170,7 @@ namespace Jint.Native.Date
 
         private JsValue GetMonth(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -167,9 +179,9 @@ namespace Jint.Native.Date
             return MonthFromTime(LocalTime(t));
         }
 
-        private static JsValue GetUTCMonth(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCMonth(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -180,7 +192,7 @@ namespace Jint.Native.Date
 
         private JsValue GetDate(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -189,9 +201,9 @@ namespace Jint.Native.Date
             return DateFromTime(LocalTime(t));
         }
 
-        private static JsValue GetUTCDate(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCDate(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -202,7 +214,7 @@ namespace Jint.Native.Date
 
         private JsValue GetDay(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -211,9 +223,9 @@ namespace Jint.Native.Date
             return WeekDay(LocalTime(t));
         }
 
-        private static JsValue GetUTCDay(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCDay(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -224,7 +236,7 @@ namespace Jint.Native.Date
 
         private JsValue GetHours(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -233,9 +245,9 @@ namespace Jint.Native.Date
             return HourFromTime(LocalTime(t));
         }
 
-        private static JsValue GetUTCHours(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCHours(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -246,7 +258,7 @@ namespace Jint.Native.Date
 
         private JsValue GetMinutes(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -255,9 +267,9 @@ namespace Jint.Native.Date
             return MinFromTime(LocalTime(t));
         }
 
-        private static JsValue GetUTCMinutes(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCMinutes(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -277,9 +289,9 @@ namespace Jint.Native.Date
             return SecFromTime(LocalTime(t));
         }
 
-        private static JsValue GetUTCSeconds(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCSeconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -290,7 +302,7 @@ namespace Jint.Native.Date
 
         private JsValue GetMilliseconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -299,9 +311,9 @@ namespace Jint.Native.Date
             return MsFromTime(LocalTime(t));
         }
 
-        private static JsValue GetUTCMilliseconds(JsValue thisObj, JsValue[] arguments)
+        private JsValue GetUTCMilliseconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -312,7 +324,7 @@ namespace Jint.Native.Date
 
         private JsValue GetTimezoneOffset(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.TryCast<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             if (double.IsNaN(t))
             {
                 return double.NaN;
@@ -321,23 +333,23 @@ namespace Jint.Native.Date
             return (t - LocalTime(t))/MsPerMinute;
         }
 
-        private static JsValue SetTime(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetTime(JsValue thisObj, JsValue[] arguments)
         {
-            return thisObj.As<DateInstance>().PrimitiveValue = TimeClip(TypeConverter.ToNumber(arguments.At(0)));
+            return EnsureDateInstance(thisObj).PrimitiveValue = TimeClip(TypeConverter.ToNumber(arguments.At(0)));
         }
 
         private JsValue SetMilliseconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = LocalTime(thisObj.As<DateInstance>().PrimitiveValue);
+            var t = LocalTime(EnsureDateInstance(thisObj).PrimitiveValue);
             var time = MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), TypeConverter.ToNumber(arguments.At(0)));
             var u = TimeClip(Utc(MakeDate(Day(t), time)));
             thisObj.As<DateInstance>().PrimitiveValue = u;
             return u;
         }
 
-        private static JsValue SetUTCMilliseconds(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCMilliseconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.As<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             var time = MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), TypeConverter.ToNumber(arguments.At(0)));
             var u = TimeClip(MakeDate(Day(t), time));
             thisObj.As<DateInstance>().PrimitiveValue = u;
@@ -346,7 +358,7 @@ namespace Jint.Native.Date
 
         private JsValue SetSeconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = LocalTime(thisObj.As<DateInstance>().PrimitiveValue);
+            var t = LocalTime(EnsureDateInstance(thisObj).PrimitiveValue);
             var s = TypeConverter.ToNumber(arguments.At(0));
             var milli = arguments.Length <= 1 ? MsFromTime(t) : TypeConverter.ToNumber(arguments.At(1)); 
             var date = MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, milli));
@@ -355,9 +367,9 @@ namespace Jint.Native.Date
             return u;
         }
 
-        private static JsValue SetUTCSeconds(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCSeconds(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.As<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             var s = TypeConverter.ToNumber(arguments.At(0));
             var milli = arguments.Length <= 1 ? MsFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var date = MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, milli));
@@ -368,7 +380,7 @@ namespace Jint.Native.Date
 
         private JsValue SetMinutes(JsValue thisObj, JsValue[] arguments)
         {
-            var t = LocalTime(thisObj.As<DateInstance>().PrimitiveValue);
+            var t = LocalTime(EnsureDateInstance(thisObj).PrimitiveValue);
             var m = TypeConverter.ToNumber(arguments.At(0));
             var s = arguments.Length <= 1 ? SecFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var milli = arguments.Length <= 2 ? MsFromTime(t) : TypeConverter.ToNumber(arguments.At(2));
@@ -378,9 +390,9 @@ namespace Jint.Native.Date
             return u;
         }
 
-        private static JsValue SetUTCMinutes(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCMinutes(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.As<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             var m = TypeConverter.ToNumber(arguments.At(0));
             var s = arguments.Length <= 1 ? SecFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var milli = arguments.Length <= 2 ? MsFromTime(t) : TypeConverter.ToNumber(arguments.At(2));
@@ -392,7 +404,7 @@ namespace Jint.Native.Date
 
         private JsValue SetHours(JsValue thisObj, JsValue[] arguments)
         {
-            var t = LocalTime(thisObj.As<DateInstance>().PrimitiveValue);
+            var t = LocalTime(EnsureDateInstance(thisObj).PrimitiveValue);
             var h = TypeConverter.ToNumber(arguments.At(0));
             var m = arguments.Length <= 1 ? MinFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var s = arguments.Length <= 2 ? SecFromTime(t) : TypeConverter.ToNumber(arguments.At(2));
@@ -403,9 +415,9 @@ namespace Jint.Native.Date
             return u;
         }
 
-        private static JsValue SetUTCHours(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCHours(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.As<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             var h = TypeConverter.ToNumber(arguments.At(0));
             var m = arguments.Length <= 1 ? MinFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var s = arguments.Length <= 2 ? SecFromTime(t) : TypeConverter.ToNumber(arguments.At(2));
@@ -418,7 +430,7 @@ namespace Jint.Native.Date
 
         private JsValue SetDate(JsValue thisObj, JsValue[] arguments)
         {
-            var t = LocalTime(thisObj.As<DateInstance>().PrimitiveValue);
+            var t = LocalTime(EnsureDateInstance(thisObj).PrimitiveValue);
             var dt = TypeConverter.ToNumber(arguments.At(0));
             var newDate = MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), TimeWithinDay(t));
             var u = TimeClip(Utc(newDate));
@@ -426,9 +438,9 @@ namespace Jint.Native.Date
             return u;
         }
 
-        private static JsValue SetUTCDate(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCDate(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.As<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             var dt = TypeConverter.ToNumber(arguments.At(0));
             var newDate = MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), TimeWithinDay(t));
             var u = TimeClip(newDate);
@@ -438,7 +450,7 @@ namespace Jint.Native.Date
 
         private JsValue SetMonth(JsValue thisObj, JsValue[] arguments)
         {
-            var t = LocalTime(thisObj.As<DateInstance>().PrimitiveValue);
+            var t = LocalTime(EnsureDateInstance(thisObj).PrimitiveValue);
             var m = TypeConverter.ToNumber(arguments.At(0));
             var dt = arguments.Length <= 1 ? DateFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var newDate = MakeDate(MakeDay(YearFromTime(t), m, dt), TimeWithinDay(t));
@@ -447,9 +459,9 @@ namespace Jint.Native.Date
             return u;
         }
 
-        private static JsValue SetUTCMonth(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCMonth(JsValue thisObj, JsValue[] arguments)
         {
-            var t = thisObj.As<DateInstance>().PrimitiveValue;
+            var t = EnsureDateInstance(thisObj).PrimitiveValue;
             var m = TypeConverter.ToNumber(arguments.At(0));
             var dt = arguments.Length <= 1 ? DateFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
             var newDate = MakeDate(MakeDay(YearFromTime(t), m, dt), TimeWithinDay(t));
@@ -460,7 +472,7 @@ namespace Jint.Native.Date
 
         private JsValue SetFullYear(JsValue thisObj, JsValue[] arguments)
         {
-            var thisTime = thisObj.As<DateInstance>().PrimitiveValue;
+            var thisTime = EnsureDateInstance(thisObj).PrimitiveValue;
             var t = double.IsNaN(thisTime) ? +0 : LocalTime(thisTime);
             var y = TypeConverter.ToNumber(arguments.At(0));
             var m = arguments.Length <= 1 ? MonthFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
@@ -473,12 +485,12 @@ namespace Jint.Native.Date
 
         private JsValue SetYear(JsValue thisObj, JsValue[] arguments)
         {
-            var thisTime = thisObj.As<DateInstance>().PrimitiveValue;
+            var thisTime = EnsureDateInstance(thisObj).PrimitiveValue;
             var t = double.IsNaN(thisTime) ? +0 : LocalTime(thisTime);
             var y = TypeConverter.ToNumber(arguments.At(0));
             if (double.IsNaN(y))
             {
-                thisObj.As<DateInstance>().PrimitiveValue = double.NaN;
+                EnsureDateInstance(thisObj).PrimitiveValue = double.NaN;
                 return double.NaN;
             }
 
@@ -490,13 +502,13 @@ namespace Jint.Native.Date
 
             var newDate = MakeDay(fy, MonthFromTime(t), DateFromTime(t));
             var u = Utc(MakeDate(newDate, TimeWithinDay(t)));
-            thisObj.As<DateInstance>().PrimitiveValue = TimeClip(u);
+            EnsureDateInstance(thisObj).PrimitiveValue = TimeClip(u);
             return u;
         }
 
-        private static JsValue SetUTCFullYear(JsValue thisObj, JsValue[] arguments)
+        private JsValue SetUTCFullYear(JsValue thisObj, JsValue[] arguments)
         {
-            var thisTime = thisObj.As<DateInstance>().PrimitiveValue;
+            var thisTime = EnsureDateInstance(thisObj).PrimitiveValue;
             var t = double.IsNaN(thisTime) ? +0 : thisTime;
             var y = TypeConverter.ToNumber(arguments.At(0));
             var m = arguments.Length <= 1 ? MonthFromTime(t) : TypeConverter.ToNumber(arguments.At(1));
@@ -513,7 +525,7 @@ namespace Jint.Native.Date
             {
                 throw new JavaScriptException(Engine.TypeError);
             } )
-            .ToDateTime().ToUniversalTime().ToString("r");
+            .ToDateTime().ToUniversalTime().ToString("ddd MMM dd yyyy HH:mm:ss 'GMT'", CultureInfo.InvariantCulture);
         }
 
         private JsValue ToISOString(JsValue thisObj, JsValue[] arguments)
@@ -864,14 +876,15 @@ namespace Jint.Native.Date
             return Engine.Options.GetLocalTimeZone().IsDaylightSavingTime(dateTime) ? MsPerHour : 0;
         }
 
-        public DateTime ToLocalTime(DateTime t)
+        public DateTimeOffset ToLocalTime(DateTime t)
         {
             if (t.Kind == DateTimeKind.Unspecified)
             {
                 return t;
             }
 
-            return TimeZoneInfo.ConvertTime(t, Engine.Options.GetLocalTimeZone());
+            var offset = Engine.Options.GetLocalTimeZone().BaseUtcOffset;
+            return new DateTimeOffset(t.Ticks + offset.Ticks, offset);
         }
 
         public double LocalTime(double t)

+ 24 - 43
Jint/Native/JsValue.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics.Contracts;
@@ -14,7 +13,6 @@ using Jint.Native.RegExp;
 using Jint.Native.String;
 using Jint.Runtime;
 using Jint.Runtime.Interop;
-using System.Runtime.InteropServices;
 
 namespace Jint.Native
 {
@@ -28,19 +26,14 @@ namespace Jint.Native
 
         public JsValue(bool value)
         {
-            _double = double.NaN;
+            _double = value ? 1.0 : 0.0;
             _object = null;
-            _string = null;
             _type = Types.Boolean;
-
-            _bool = value; //Set value last because of 'FieldOffset' constraints
         }
 
         public JsValue(double value)
         {
-            _bool = false;
             _object = null;
-            _string = null;
             _type = Types.Number;
 
             _double = value;
@@ -48,19 +41,14 @@ namespace Jint.Native
 
         public JsValue(string value)
         {
-            _bool = false;
             _double = double.NaN;
-            _object = null;
+            _object = value;
             _type = Types.String;
-
-            _string = value;
         }
 
         public JsValue(ObjectInstance value)
         {
-            _bool = false;
             _double = double.NaN;
-            _string = null;
             _type = Types.Object;
 
             _object = value;
@@ -68,20 +56,14 @@ namespace Jint.Native
 
         private JsValue(Types type)
         {
-            _bool = false;
             _double = double.NaN;
             _object = null;
-            _string = null;
             _type = type;
         }
 
-        private readonly bool _bool;
-
         private readonly double _double;
 
-        private readonly ObjectInstance _object;
-
-        private readonly string _string;
+        private readonly object _object;
 
         private readonly Types _type;
 
@@ -153,7 +135,7 @@ namespace Jint.Native
                 throw new ArgumentException("The value is not an object");
             }
 
-            return _object;
+            return _object as ObjectInstance;
         }
 
         [Pure]
@@ -163,7 +145,8 @@ namespace Jint.Native
             {
                 throw new ArgumentException("The value is not an array");
             }
-            return AsObject() as ArrayInstance;
+
+            return _object as ArrayInstance;
         }
 
         [Pure]
@@ -173,7 +156,8 @@ namespace Jint.Native
             {
                 throw new ArgumentException("The value is not a date");
             }
-            return AsObject() as DateInstance;
+
+            return _object as DateInstance;
         }
 
         [Pure]
@@ -183,7 +167,8 @@ namespace Jint.Native
             {
                 throw new ArgumentException("The value is not a date");
             }
-            return AsObject() as RegExpInstance;
+
+            return _object as RegExpInstance;
         }
 
         [Pure]
@@ -225,7 +210,7 @@ namespace Jint.Native
                 throw new ArgumentException("The value is not a boolean");
             }
 
-            return _bool;
+            return _double != 0;
         }
 
         [Pure]
@@ -236,12 +221,12 @@ namespace Jint.Native
                 throw new ArgumentException("The value is not a string");
             }
 
-            if (_string == null)
+            if (_object == null)
             {
                 throw new ArgumentException("The value is not defined");
             }
 
-            return _string;
+            return _object as string;
         }
 
         [Pure]
@@ -271,11 +256,9 @@ namespace Jint.Native
                 case Types.Null:
                     return true;
                 case Types.Boolean:
-                    return _bool == other._bool;
-                case Types.String:
-                    return _string == other._string;
                 case Types.Number:
                     return _double == other._double;
+                case Types.String:
                 case Types.Object:
                     return _object == other._object;
                 default:
@@ -416,10 +399,10 @@ namespace Jint.Native
                 case Types.Undefined:
                 case Types.Null:
                     return null;
-                case Types.Boolean:
-                    return _bool;
                 case Types.String:
-                    return _string;
+                    return _object;
+                case Types.Boolean:
+                    return _double != 0;
                 case Types.Number:
                     return _double;
                 case Types.Object:
@@ -429,7 +412,7 @@ namespace Jint.Native
                         return wrapper.Target;
                     }
 
-                    switch (_object.Class)
+                    switch ((_object as ObjectInstance).Class)
                     {
                         case "Array":
                             var arrayInstance = _object as ArrayInstance;
@@ -516,14 +499,14 @@ namespace Jint.Native
                             IDictionary<string, object> o = new ExpandoObject();
 #endif
 
-                            foreach (var p in _object.GetOwnProperties())
+                            foreach (var p in (_object as ObjectInstance).GetOwnProperties())
                             {
                                 if (!p.Value.Enumerable.HasValue || p.Value.Enumerable.Value == false)
                                 {
                                     continue;
                                 }
 
-                                o.Add(p.Key, _object.Get(p.Key).ToObject());
+                                o.Add(p.Key, (_object as ObjectInstance).Get(p.Key).ToObject());
                             }
 
                             return o;
@@ -575,11 +558,10 @@ namespace Jint.Native
                 case Types.Null:
                     return "null";
                 case Types.Boolean:
-                    return _bool.ToString();
-                case Types.String:
-                    return _string;
+                    return _double != 0 ? bool.TrueString : bool.FalseString;
                 case Types.Number:
                     return _double.ToString();
+                case Types.String:
                 case Types.Object:
                     return _object.ToString();
                 default:
@@ -662,13 +644,12 @@ namespace Jint.Native
         {
             unchecked
             {
-                var hashCode = _bool.GetHashCode();
+                var hashCode = 0;
                 hashCode = (hashCode * 397) ^ _double.GetHashCode();
                 hashCode = (hashCode * 397) ^ (_object != null ? _object.GetHashCode() : 0);
-                hashCode = (hashCode * 397) ^ (_string != null ? _string.GetHashCode() : 0);
                 hashCode = (hashCode * 397) ^ (int)_type;
                 return hashCode;
             }
         }
     }
-}
+}

+ 1 - 5
Jint/Native/Number/NumberConstructor.cs

@@ -1,8 +1,6 @@
-using Jint.Native.Array;
-using Jint.Native.Function;
+using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Runtime;
-using Jint.Runtime.Descriptors;
 
 namespace Jint.Native.Number
 {
@@ -71,7 +69,5 @@ namespace Jint.Native.Number
 
             return instance;
         }
-
-
     }
 }

+ 1 - 1
Jint/Native/Number/NumberPrototype.cs

@@ -60,7 +60,7 @@ namespace Jint.Native.Number
 
             if (m < 0)
             {
-                return "-" + ToNumberString(-m);
+                return "-" + ToLocaleString(-m, arguments);
             }
 
             if (double.IsPositiveInfinity(m) || m >= double.MaxValue)

+ 2 - 1
Jint/Native/Object/ObjectInstance.cs

@@ -69,7 +69,8 @@ namespace Jint.Native.Object
 
             if (desc.IsDataDescriptor())
             {
-                return desc.Value.HasValue ? desc.Value.Value : Undefined.Instance;
+                var val = desc.Value;
+                return val.HasValue ? val.Value : Undefined.Instance;
             }
 
             var getter = desc.Get.HasValue ? desc.Get.Value : Undefined.Instance;

+ 6 - 1
Jint/Native/String/StringPrototype.cs

@@ -74,10 +74,15 @@ namespace Jint.Native.String
         // http://msdn.microsoft.com/en-us/library/system.char.iswhitespace(v=vs.110).aspx
         // http://en.wikipedia.org/wiki/Byte_order_mark
         const char BOM_CHAR = '\uFEFF';
+        const char MONGOLIAN_VOWEL_SEPARATOR = '\u180E';
 
         private static bool IsWhiteSpaceEx(char c)
         {
-            return char.IsWhiteSpace(c) || c == BOM_CHAR;
+            return 
+                char.IsWhiteSpace(c) || 
+                c == BOM_CHAR ||
+                // In .NET 4.6 this was removed from WS based on Unicode 6.3 changes
+                c == MONGOLIAN_VOWEL_SEPARATOR;
         }
 
         private static string TrimEndEx(string s)

+ 3 - 3
Jint/Properties/AssemblyInfo.cs

@@ -9,10 +9,10 @@ using System.Reflection;
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("Sebastien Ros")]
 [assembly: AssemblyProduct("Jint")]
-[assembly: AssemblyCopyright("Copyright © Sébastien Ros 2013")]
+[assembly: AssemblyCopyright("Copyright © Sébastien Ros")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 [assembly: NeutralResourcesLanguage("en")]
 
-[assembly: AssemblyVersion("2.5.0")]
-[assembly: AssemblyFileVersion("2.5.0")]
+[assembly: AssemblyVersion("2.7.1")]
+[assembly: AssemblyFileVersion("2.7.1")]

+ 1 - 2
Jint/Runtime/ExpressionIntepreter.cs

@@ -41,9 +41,8 @@ namespace Jint.Runtime
 
         public JsValue EvaluateAssignmentExpression(AssignmentExpression assignmentExpression)
         {
-            JsValue rval = _engine.GetValue(EvaluateExpression(assignmentExpression.Right));
-
             var lref = EvaluateExpression(assignmentExpression.Left) as Reference;
+            JsValue rval = _engine.GetValue(EvaluateExpression(assignmentExpression.Right));
 
             if (lref == null)
             {

+ 1 - 0
Jint/Runtime/Interop/ClrFunctionInstance.cs

@@ -17,6 +17,7 @@ namespace Jint.Runtime.Interop
             _func = func;
             Prototype = engine.Function.PrototypeObject;
             FastAddProperty("length", length, false, false, false);
+            Extensible = true;
         }
 
         public ClrFunctionInstance(Engine engine, Func<JsValue, JsValue[], JsValue> func)

+ 15 - 1
Jint/Runtime/Interop/DefaultTypeConverter.cs

@@ -72,7 +72,21 @@ namespace Jint.Runtime.Interop
                         {
                             @params[i] = Expression.Parameter(genericArguments[i], genericArguments[i].Name + i);
                         }
-                        var @vars = Expression.NewArrayInit(typeof(JsValue), @params.Select(p => Expression.Call(null, jsValueFromObject, Expression.Constant(_engine, typeof(Engine)), p)));
+                        var tmpVars = new Expression[@params.Length];
+                        for (var i = 0; i < @params.Count(); i++)
+                        {
+                            var param = @params[i];
+                            if (param.Type.IsValueType)
+                            {
+                                var boxing = Expression.Convert(param, typeof(object));
+                                tmpVars[i] = Expression.Call(null, jsValueFromObject, Expression.Constant(_engine, typeof(Engine)), boxing);
+                            }
+                            else
+                            {
+                                tmpVars[i] = Expression.Call(null, jsValueFromObject, Expression.Constant(_engine, typeof(Engine)), param);
+                            }
+                        }
+                        var @vars = Expression.NewArrayInit(typeof(JsValue), tmpVars);
 
                         var callExpresion = Expression.Block(Expression.Call(
                                                 Expression.Call(Expression.Constant(function.Target),

+ 137 - 137
Jint/Runtime/Interop/NamespaceReference.cs

@@ -1,124 +1,124 @@
 using System;
 using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Reflection;
-using Jint.Native;
-using Jint.Native.Object;
-using Jint.Runtime.Descriptors;
-
-namespace Jint.Runtime.Interop
-{
-    /// <summary>
-    /// Any instance on this class represents a reference to a CLR namespace.
-    /// Accessing its properties will look for a class of the full name, or instantiate
-    /// a new <see cref="NamespaceReference"/> as it assumes that the property is a deeper
-    /// level of the current namespace
-    /// </summary>
-    public class NamespaceReference : ObjectInstance, ICallable
-    {
-        private readonly string _path;
-
-        public NamespaceReference(Engine engine, string path) : base(engine)
-        {
-            _path = path;
-        }
-
-        public override bool DefineOwnProperty(string propertyName, PropertyDescriptor desc, bool throwOnError)
-        {
-            if (throwOnError)
-            {
-                throw new JavaScriptException(Engine.TypeError, "Can't define a property of a NamespaceReference");
-            }
-
-            return false;
-        }
-
-        public override bool Delete(string propertyName, bool throwOnError)
-        {
-            if (throwOnError)
-            {
-                throw new JavaScriptException(Engine.TypeError, "Can't delete a property of a NamespaceReference");
-            }
-
-            return false;
-        }
-
-        public JsValue Call(JsValue thisObject, JsValue[] arguments)
-        {
-            // direct calls on a NamespaceReference constructor object is creating a generic type 
-            var genericTypes = new Type[arguments.Length];
-            for (int i = 0; i < arguments.Length; i++)
-            {
-                var genericTypeReference = arguments.At(i);
-                if (genericTypeReference == Undefined.Instance || !genericTypeReference.IsObject() || genericTypeReference.AsObject().Class != "TypeReference")
-                {
-                    throw new JavaScriptException(Engine.TypeError, "Invalid generic type parameter");
-                }
-
-                genericTypes[i] = arguments.At(0).As<TypeReference>().Type;
-            }
-
-            var typeReference = GetPath(_path + "`" + arguments.Length.ToString(CultureInfo.InvariantCulture)).As<TypeReference>();
-
-            if (typeReference == null)
-            {
-                return Undefined.Instance;
-            }
-
-            var genericType = typeReference.Type.MakeGenericType(genericTypes);
-
-            return TypeReference.CreateTypeReference(Engine, genericType);
-        }
-
-        public override JsValue Get(string propertyName)
-        {
-            var newPath = _path + "." + propertyName;
-
-            return GetPath(newPath);
-        }
-
-        public JsValue GetPath(string path)
-        {
-            Type type;
-
-            if (Engine.TypeCache.TryGetValue(path, out type))
-            {
-                if (type == null)
-                {
-                    return new NamespaceReference(Engine, path);
-                }
-
-                return TypeReference.CreateTypeReference(Engine, type);
-            }
-
-            // search for type in mscorlib
-            type = Type.GetType(path);
-            if (type != null)
-            {
-                Engine.TypeCache.Add(path, type);
-                return TypeReference.CreateTypeReference(Engine, type);
-            }
-
-            // search in loaded assemblies
-            foreach (var assembly in new[] { Assembly.GetCallingAssembly(), Assembly.GetExecutingAssembly() }.Distinct())
-            {
-                type = assembly.GetType(path);
-                if (type != null)
-                {
-                    Engine.TypeCache.Add(path, type);
-                    return TypeReference.CreateTypeReference(Engine, type);
-                }
-            }
-
-            // search in lookup assemblies
-            foreach (var assembly in Engine.Options.GetLookupAssemblies())
-            {
-                type = assembly.GetType(path);
-                if (type != null)
-                {
-                    Engine.TypeCache.Add(path, type);
-                    return TypeReference.CreateTypeReference(Engine, type);
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using Jint.Native;
+using Jint.Native.Object;
+using Jint.Runtime.Descriptors;
+
+namespace Jint.Runtime.Interop
+{
+    /// <summary>
+    /// Any instance on this class represents a reference to a CLR namespace.
+    /// Accessing its properties will look for a class of the full name, or instantiate
+    /// a new <see cref="NamespaceReference"/> as it assumes that the property is a deeper
+    /// level of the current namespace
+    /// </summary>
+    public class NamespaceReference : ObjectInstance, ICallable
+    {
+        private readonly string _path;
+
+        public NamespaceReference(Engine engine, string path) : base(engine)
+        {
+            _path = path;
+        }
+
+        public override bool DefineOwnProperty(string propertyName, PropertyDescriptor desc, bool throwOnError)
+        {
+            if (throwOnError)
+            {
+                throw new JavaScriptException(Engine.TypeError, "Can't define a property of a NamespaceReference");
+            }
+
+            return false;
+        }
+
+        public override bool Delete(string propertyName, bool throwOnError)
+        {
+            if (throwOnError)
+            {
+                throw new JavaScriptException(Engine.TypeError, "Can't delete a property of a NamespaceReference");
+            }
+
+            return false;
+        }
+
+        public JsValue Call(JsValue thisObject, JsValue[] arguments)
+        {
+            // direct calls on a NamespaceReference constructor object is creating a generic type 
+            var genericTypes = new Type[arguments.Length];
+            for (int i = 0; i < arguments.Length; i++)
+            {
+                var genericTypeReference = arguments.At(i);
+                if (genericTypeReference == Undefined.Instance || !genericTypeReference.IsObject() || genericTypeReference.AsObject().Class != "TypeReference")
+                {
+                    throw new JavaScriptException(Engine.TypeError, "Invalid generic type parameter");
+                }
+
+                genericTypes[i] = arguments.At(i).As<TypeReference>().Type;
+            }
+
+            var typeReference = GetPath(_path + "`" + arguments.Length.ToString(CultureInfo.InvariantCulture)).As<TypeReference>();
+
+            if (typeReference == null)
+            {
+                return Undefined.Instance;
+            }
+
+            var genericType = typeReference.Type.MakeGenericType(genericTypes);
+
+            return TypeReference.CreateTypeReference(Engine, genericType);
+        }
+
+        public override JsValue Get(string propertyName)
+        {
+            var newPath = _path + "." + propertyName;
+
+            return GetPath(newPath);
+        }
+
+        public JsValue GetPath(string path)
+        {
+            Type type;
+
+            if (Engine.TypeCache.TryGetValue(path, out type))
+            {
+                if (type == null)
+                {
+                    return new NamespaceReference(Engine, path);
+                }
+
+                return TypeReference.CreateTypeReference(Engine, type);
+            }
+
+            // search for type in mscorlib
+            type = Type.GetType(path);
+            if (type != null)
+            {
+                Engine.TypeCache.Add(path, type);
+                return TypeReference.CreateTypeReference(Engine, type);
+            }
+
+            // search in loaded assemblies
+            foreach (var assembly in new[] { Assembly.GetCallingAssembly(), Assembly.GetExecutingAssembly() }.Distinct())
+            {
+                type = assembly.GetType(path);
+                if (type != null)
+                {
+                    Engine.TypeCache.Add(path, type);
+                    return TypeReference.CreateTypeReference(Engine, type);
+                }
+            }
+
+            // search in lookup assemblies
+            foreach (var assembly in Engine.Options.GetLookupAssemblies())
+            {
+                type = assembly.GetType(path);
+                if (type != null)
+                {
+                    Engine.TypeCache.Add(path, type);
+                    return TypeReference.CreateTypeReference(Engine, type);
                 }
 
                 var lastPeriodPos = path.LastIndexOf(".", StringComparison.Ordinal);
@@ -132,13 +132,13 @@ namespace Jint.Runtime.Interop
                       Engine.TypeCache.Add(path.Replace("+", "."), nType);
                       return TypeReference.CreateTypeReference(Engine, nType);
                     }
-                  }            
-            }
-
-            // the new path doesn't represent a known class, thus return a new namespace instance
-
-            Engine.TypeCache.Add(path, null);
-            return new NamespaceReference(Engine, path);
+                  }            
+            }
+
+            // the new path doesn't represent a known class, thus return a new namespace instance
+
+            Engine.TypeCache.Add(path, null);
+            return new NamespaceReference(Engine, path);
         }
 
         /// <summary>   Gets a type. </summary>
@@ -178,14 +178,14 @@ namespace Jint.Runtime.Interop
           }
         }
 
-      public override PropertyDescriptor GetOwnProperty(string propertyName)
-        {
-            return PropertyDescriptor.Undefined;
-        }
-
-        public override string ToString()
-        {
-            return "[Namespace: " + _path + "]";
-        }
-    }
-}
+      public override PropertyDescriptor GetOwnProperty(string propertyName)
+        {
+            return PropertyDescriptor.Undefined;
+        }
+
+        public override string ToString()
+        {
+            return "[Namespace: " + _path + "]";
+        }
+    }
+}

+ 4 - 1
Jint/Runtime/StatementInterpreter.cs

@@ -420,7 +420,10 @@ namespace Jint.Runtime
                     c = ExecuteStatement(statement);
                     if (c.Type != Completion.Normal)
                     {
-                        return new Completion(c.Type, c.Value.HasValue ? c.Value : sl.Value, c.Identifier);
+                        return new Completion(c.Type, c.Value.HasValue ? c.Value : sl.Value, c.Identifier)
+                        {
+                            Location = c.Location
+                        };
                     }
 
                     sl = c;

+ 28 - 1
README.md

@@ -10,6 +10,12 @@ Jint is a __Javascript interpreter__ for .NET which provides full __ECMA 5.1__ c
 - .NET Portable Class Library - http://msdn.microsoft.com/en-us/library/gg597391(v=vs.110).aspx
 - .NET Interoperability 
 
+# Discussion
+
+[![Join the chat at https://gitter.im/sebastienros/jint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sebastienros/jint)
+
+Or post your questions with the `jint` tag on [stackoverflow](http://stackoverflow.com/questions/tagged/jint).
+
 # Examples
 
 This example defines a new value named `log` pointing to `Console.WriteLine`, then executes 
@@ -76,7 +82,7 @@ Then you have access to the `System` namespace as a global value. Here is how it
     jint> file.WriteLine('Hello World !');
     jint> file.Dispose();
 ```
-And even create shortcuts to commong .NET methods
+And even create shortcuts to common .NET methods
 ```javascript
     jint> var log = System.Console.WriteLine;
     jint> log('Hello World !');
@@ -103,6 +109,27 @@ Generic types are also supported. Here is how to declare, instantiate and use a
     jint> list.Count; // 2
 ```
 
+## Internationalization
+
+You can enforce what Time Zone or Culture the engine should use when locale JavaScript methods are used if you don't want to use the computer's default values.
+
+This example forces the Time Zone to Pacific Standard Time.
+```c#
+    var PST = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
+    var engine = new Engine(cfg => cfg.LocalTimeZone(PST));
+    
+    engine.Execute("new Date().toString()"); // Wed Dec 31 1969 16:00:00 GMT-08:00
+```
+
+This example is using French as the default culture.
+```c#
+    var FR = CultureInfo.GetCultureInfo("fr-FR");
+    var engine = new Engine(cfg => cfg.Culture(FR));
+    
+    engine.Execute("new Number(1.23).toString()"); // 1.23
+    engine.Execute("new Number(1.23).toLocaleString()"); // 1,23
+```
+
 ## Implemented features:
 
 - ECMAScript 5.1 test suite (http://test262.ecmascript.org/) 

+ 1 - 1
buildnuget.cmd

@@ -1 +1 @@
-nuget pack jint\Jint.csproj -Properties Configuration=Release 
+.nuget\nuget pack jint\Jint.csproj -Properties Configuration=Release 

部分文件因为文件数量过多而无法显示