Browse Source

Renaming option's internal properties

Sebastien Ros 9 years ago
parent
commit
0612a7a49b

+ 6 - 6
Jint/Engine.cs

@@ -129,7 +129,7 @@ namespace Jint
             _statements = new StatementInterpreter(this);
             _statements = new StatementInterpreter(this);
             _expressions = new ExpressionInterpreter(this);
             _expressions = new ExpressionInterpreter(this);
 
 
-            if (Options.IsClrAllowed())
+            if (Options._IsClrAllowed)
             {
             {
                 Global.FastAddProperty("System", new NamespaceReference(this, "System"), false, false, false);
                 Global.FastAddProperty("System", new NamespaceReference(this, "System"), false, false, false);
                 Global.FastAddProperty("importNamespace", new ClrFunctionInstance(this, (thisObj, arguments) =>
                 Global.FastAddProperty("importNamespace", new ClrFunctionInstance(this, (thisObj, arguments) =>
@@ -257,7 +257,7 @@ namespace Jint
         
         
         public void ResetTimeoutTicks()
         public void ResetTimeoutTicks()
         {
         {
-            var timeoutIntervalTicks = Options.GetTimeoutInterval().Ticks;
+            var timeoutIntervalTicks = Options._TimeoutInterval.Ticks;
             _timeoutTicks = timeoutIntervalTicks > 0 ? DateTime.UtcNow.Ticks + timeoutIntervalTicks : 0;
             _timeoutTicks = timeoutIntervalTicks > 0 ? DateTime.UtcNow.Ticks + timeoutIntervalTicks : 0;
         }
         }
 
 
@@ -288,7 +288,7 @@ namespace Jint
             ResetLastStatement();
             ResetLastStatement();
             ResetCallStack();
             ResetCallStack();
 
 
-            using (new StrictModeScope(Options.IsStrict() || program.Strict))
+            using (new StrictModeScope(Options._IsStrict || program.Strict))
             {
             {
                 DeclarationBindingInstantiation(DeclarationBindingType.GlobalCode, program.FunctionDeclarations, program.VariableDeclarations, null, null);
                 DeclarationBindingInstantiation(DeclarationBindingType.GlobalCode, program.FunctionDeclarations, program.VariableDeclarations, null, null);
 
 
@@ -322,7 +322,7 @@ namespace Jint
 
 
         public Completion ExecuteStatement(Statement statement)
         public Completion ExecuteStatement(Statement statement)
         {
         {
-            var maxStatements = Options.GetMaxStatements();
+            var maxStatements = Options._MaxStatements;
             if (maxStatements > 0 && _statementsCount++ > maxStatements)
             if (maxStatements > 0 && _statementsCount++ > maxStatements)
             {
             {
                 throw new StatementsCountOverflowException();
                 throw new StatementsCountOverflowException();
@@ -335,7 +335,7 @@ namespace Jint
 
 
             _lastSyntaxNode = statement;
             _lastSyntaxNode = statement;
             
             
-            if (Options.IsDebugMode())
+            if (Options._IsDebugMode)
             {
             {
                 DebugHandler.OnStep(statement);
                 DebugHandler.OnStep(statement);
             }
             }
@@ -690,7 +690,7 @@ namespace Jint
                 throw new ArgumentException("propertyName");
                 throw new ArgumentException("propertyName");
             }
             }
 
 
-            var reference = new Reference(scope, propertyName, Options.IsStrict());
+            var reference = new Reference(scope, propertyName, Options._IsStrict);
 
 
             return GetValue(reference);
             return GetValue(reference);
         }
         }

+ 1 - 1
Jint/Native/Date/DateConstructor.cs

@@ -85,7 +85,7 @@ namespace Jint.Native.Date
                     "THHK"
                     "THHK"
                 }, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out result))
                 }, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out result))
                 {
                 {
-                    if (!DateTime.TryParse(date, Engine.Options.GetCulture(), DateTimeStyles.AdjustToUniversal, out result))
+                    if (!DateTime.TryParse(date, Engine.Options._Culture, DateTimeStyles.AdjustToUniversal, out result))
                     {
                     {
                         if (!DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out result))
                         if (!DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out result))
                         {
                         {

+ 6 - 6
Jint/Native/Date/DatePrototype.cs

@@ -112,17 +112,17 @@ namespace Jint.Native.Date
 
 
         private JsValue ToLocaleString(JsValue thisObj, JsValue[] arguments)
         private JsValue ToLocaleString(JsValue thisObj, JsValue[] arguments)
         {
         {
-            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("F", Engine.Options.GetCulture());
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("F", Engine.Options._Culture);
         }
         }
 
 
         private JsValue ToLocaleDateString(JsValue thisObj, JsValue[] arguments)
         private JsValue ToLocaleDateString(JsValue thisObj, JsValue[] arguments)
         {
         {
-            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("D", Engine.Options.GetCulture());
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("D", Engine.Options._Culture);
         }
         }
 
 
         private JsValue ToLocaleTimeString(JsValue thisObj, JsValue[] arguments)
         private JsValue ToLocaleTimeString(JsValue thisObj, JsValue[] arguments)
         {
         {
-            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("T", Engine.Options.GetCulture());
+            return ToLocalTime(EnsureDateInstance(thisObj).ToDateTime()).ToString("T", Engine.Options._Culture);
         }
         }
 
 
         private JsValue GetTime(JsValue thisObj, JsValue[] arguments)
         private JsValue GetTime(JsValue thisObj, JsValue[] arguments)
@@ -846,7 +846,7 @@ namespace Jint.Native.Date
         {
         {
             get
             get
             {
             {
-                return Engine.Options.GetLocalTimeZone().BaseUtcOffset.TotalMilliseconds;
+                return Engine.Options._LocalTimeZone.BaseUtcOffset.TotalMilliseconds;
             }
             }
         }
         }
 
 
@@ -873,7 +873,7 @@ namespace Jint.Native.Date
 
 
             var dateTime = new DateTime((int)year, 1, 1).AddMilliseconds(timeInYear);
             var dateTime = new DateTime((int)year, 1, 1).AddMilliseconds(timeInYear);
 
 
-            return Engine.Options.GetLocalTimeZone().IsDaylightSavingTime(dateTime) ? MsPerHour : 0;
+            return Engine.Options._LocalTimeZone.IsDaylightSavingTime(dateTime) ? MsPerHour : 0;
         }
         }
 
 
         public DateTimeOffset ToLocalTime(DateTime t)
         public DateTimeOffset ToLocalTime(DateTime t)
@@ -883,7 +883,7 @@ namespace Jint.Native.Date
                 return t;
                 return t;
             }
             }
 
 
-            var offset = Engine.Options.GetLocalTimeZone().BaseUtcOffset;
+            var offset = Engine.Options._LocalTimeZone.BaseUtcOffset;
             return new DateTimeOffset(t.Ticks + offset.Ticks, offset);
             return new DateTimeOffset(t.Ticks + offset.Ticks, offset);
         }
         }
 
 

+ 1 - 1
Jint/Native/JsValue.cs

@@ -284,7 +284,7 @@ namespace Jint.Native
                 return Null;
                 return Null;
             }
             }
 
 
-            foreach (var converter in engine.Options.GetObjectConverters())
+            foreach (var converter in engine.Options._ObjectConverters)
             {
             {
                 JsValue result;
                 JsValue result;
                 if (converter.TryConvert(value, out result))
                 if (converter.TryConvert(value, out result))

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

@@ -73,7 +73,7 @@ namespace Jint.Native.Number
                 return "-Infinity";
                 return "-Infinity";
             }
             }
 
 
-            return m.ToString("n", Engine.Options.GetCulture());
+            return m.ToString("n", Engine.Options._Culture);
         }
         }
 
 
         private JsValue ValueOf(JsValue thisObj, JsValue[] arguments)
         private JsValue ValueOf(JsValue thisObj, JsValue[] arguments)

+ 12 - 49
Jint/Options.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
-using Jint.Native;
 using Jint.Runtime.Interop;
 using Jint.Runtime.Interop;
 
 
 namespace Jint
 namespace Jint
@@ -123,64 +122,28 @@ namespace Jint
             return this;
             return this;
         }
         }
 
 
-        internal bool GetDiscardGlobal()
-        {
-            return _discardGlobal;
-        }
+        internal bool _IsGlobalDiscarded => _discardGlobal;
 
 
-        internal bool IsStrict()
-        {
-            return _strict;
-        }
+        internal bool _IsStrict => _strict;
 
 
-        internal bool IsDebuggerStatementAllowed()
-        {
-            return _allowDebuggerStatement;
-        }
+        internal bool _IsDebuggerStatementAllowed => _allowDebuggerStatement;
 
 
-        internal bool IsDebugMode()
-        {
-            return _debugMode;
-        }
+        internal bool _IsDebugMode => _debugMode;
 
 
-        internal bool IsClrAllowed()
-        {
-            return _allowClr;
-        }
+        internal bool _IsClrAllowed => _allowClr;
         
         
-        internal IList<Assembly> GetLookupAssemblies()
-        {
-            return _lookupAssemblies;
-        }
+        internal IList<Assembly> _LookupAssemblies => _lookupAssemblies;
 
 
-        internal IEnumerable<IObjectConverter> GetObjectConverters()
-        {
-            return _objectConverters;
-        }
+        internal IEnumerable<IObjectConverter> _ObjectConverters => _objectConverters;
 
 
-        internal int GetMaxStatements()
-        {
-            return _maxStatements;
-        }
+        internal int _MaxStatements => _maxStatements;
 
 
-        internal int GetMaxRecursionDepth()
-        {
-            return _maxRecursionDepth;
-        }
+        internal int _MaxRecursionDepth => _maxRecursionDepth;
 
 
-        internal TimeSpan GetTimeoutInterval()
-        {
-            return _timeoutInterval;
-        }
+        internal TimeSpan _TimeoutInterval => _timeoutInterval;
 
 
-        internal CultureInfo GetCulture()
-        {
-            return _culture;
-        }
+        internal CultureInfo _Culture => _culture;
 
 
-        internal TimeZoneInfo GetLocalTimeZone()
-        {
-            return _localTimeZone;
-        }
+        internal TimeZoneInfo _LocalTimeZone => _localTimeZone;
     }
     }
 }
 }

+ 5 - 6
Jint/Runtime/ExpressionIntepreter.cs

@@ -791,7 +791,7 @@ namespace Jint.Runtime
         {
         {
             var callee = EvaluateExpression(callExpression.Callee);
             var callee = EvaluateExpression(callExpression.Callee);
 
 
-            if (_engine.Options.IsDebugMode())
+            if (_engine.Options._IsDebugMode)
             {
             {
                 _engine.DebugHandler.AddToDebugCallStack(callExpression);
                 _engine.DebugHandler.AddToDebugCallStack(callExpression);
             }
             }
@@ -805,14 +805,13 @@ namespace Jint.Runtime
             
             
             var r = callee as Reference;
             var r = callee as Reference;
 
 
-            var isRecursionHandled = _engine.Options.GetMaxRecursionDepth() >= 0;
-            if (isRecursionHandled)
+            if (_engine.Options._MaxRecursionDepth >= 0)
             {
             {
                 var stackItem = new CallStackElement(callExpression, func, r != null ? r.GetReferencedName() : "anonymous function");
                 var stackItem = new CallStackElement(callExpression, func, r != null ? r.GetReferencedName() : "anonymous function");
 
 
                 var recursionDepth = _engine.CallStack.Push(stackItem);
                 var recursionDepth = _engine.CallStack.Push(stackItem);
 
 
-                if (recursionDepth > _engine.Options.GetMaxRecursionDepth())
+                if (recursionDepth > _engine.Options._MaxRecursionDepth)
                 {
                 {
                     _engine.CallStack.Pop();
                     _engine.CallStack.Pop();
                     throw new RecursionDepthOverflowException(_engine.CallStack, stackItem.ToString());
                     throw new RecursionDepthOverflowException(_engine.CallStack, stackItem.ToString());
@@ -860,12 +859,12 @@ namespace Jint.Runtime
             
             
             var result = callable.Call(thisObject, arguments);
             var result = callable.Call(thisObject, arguments);
 
 
-            if (_engine.Options.IsDebugMode())
+            if (_engine.Options._IsDebugMode)
             {
             {
                 _engine.DebugHandler.PopDebugCallStack();
                 _engine.DebugHandler.PopDebugCallStack();
             }
             }
 
 
-            if (isRecursionHandled)
+            if (_engine.Options._MaxRecursionDepth >= 0)
             {
             {
                 _engine.CallStack.Pop();
                 _engine.CallStack.Pop();
             }
             }

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

@@ -112,7 +112,7 @@ namespace Jint.Runtime.Interop
             }
             }
 
 
             // search in lookup assemblies
             // search in lookup assemblies
-            foreach (var assembly in Engine.Options.GetLookupAssemblies())
+            foreach (var assembly in Engine.Options._LookupAssemblies)
             {
             {
                 type = assembly.GetType(path);
                 type = assembly.GetType(path);
                 if (type != null)
                 if (type != null)

+ 1 - 1
Jint/Runtime/StatementInterpreter.cs

@@ -533,7 +533,7 @@ namespace Jint.Runtime
 
 
         public Completion ExecuteDebuggerStatement(DebuggerStatement debuggerStatement)
         public Completion ExecuteDebuggerStatement(DebuggerStatement debuggerStatement)
         {
         {
-            if (_engine.Options.IsDebuggerStatementAllowed())
+            if (_engine.Options._IsDebuggerStatementAllowed)
             {
             {
                 if (!System.Diagnostics.Debugger.IsAttached)
                 if (!System.Diagnostics.Debugger.IsAttached)
                 {
                 {