PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Ruby/Runtime/RubyOptions.cs

#
C# | 131 lines | 93 code | 21 blank | 17 comment | 1 complexity | 0e9205305c684f9a522134903c399e24 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Collections.ObjectModel;
  18. using System.Threading;
  19. using IronRuby.Builtins;
  20. using Microsoft.Scripting;
  21. using Microsoft.Scripting.Utils;
  22. namespace IronRuby.Runtime {
  23. [Serializable]
  24. public sealed class RubyOptions : LanguageOptions {
  25. private readonly ReadOnlyCollection<string>/*!*/ _arguments;
  26. private readonly RubyEncoding/*!*/ _localeEncoding;
  27. private readonly RubyEncoding _defaultEncoding;
  28. private readonly ReadOnlyCollection<string>/*!*/ _libraryPaths;
  29. private readonly ReadOnlyCollection<string> _requirePaths;
  30. private readonly string _mainFile;
  31. private readonly bool _enableTracing;
  32. private readonly int _verbosity;
  33. private readonly bool _debugVariable;
  34. private readonly string _savePath;
  35. private readonly bool _loadFromDisk;
  36. private readonly bool _profile;
  37. private readonly bool _hasSearchPaths;
  38. private readonly bool _noAssemblyResolveHook;
  39. #if DEBUG
  40. public static bool UseThreadAbortForSyncRaise;
  41. public static bool CompileRegexps;
  42. public static bool ShowRules;
  43. #endif
  44. public ReadOnlyCollection<string>/*!*/ Arguments {
  45. get { return _arguments; }
  46. }
  47. public RubyEncoding/*!*/ LocaleEncoding {
  48. get { return _localeEncoding; }
  49. }
  50. public RubyEncoding DefaultEncoding {
  51. get { return _defaultEncoding; }
  52. }
  53. public string MainFile {
  54. get { return _mainFile; }
  55. }
  56. public int Verbosity {
  57. get { return _verbosity; }
  58. }
  59. public bool EnableTracing {
  60. get { return _enableTracing; }
  61. }
  62. public string SavePath {
  63. get { return _savePath; }
  64. }
  65. public bool LoadFromDisk {
  66. get { return _loadFromDisk; }
  67. }
  68. public bool Profile {
  69. get { return _profile; }
  70. }
  71. public bool NoAssemblyResolveHook {
  72. get { return _noAssemblyResolveHook; }
  73. }
  74. public ReadOnlyCollection<string> LibraryPaths {
  75. get { return _libraryPaths; }
  76. }
  77. public ReadOnlyCollection<string> RequirePaths {
  78. get { return _requirePaths; }
  79. }
  80. public bool HasSearchPaths {
  81. get { return _hasSearchPaths; }
  82. }
  83. public RubyCompatibility Compatibility {
  84. get { return RubyCompatibility.Default; }
  85. }
  86. /// <summary>
  87. /// The initial value of $DEBUG variable.
  88. /// </summary>
  89. public bool DebugVariable {
  90. get { return _debugVariable; }
  91. }
  92. public RubyOptions(IDictionary<string, object>/*!*/ options)
  93. : base(options) {
  94. _arguments = GetStringCollectionOption(options, "Arguments") ?? EmptyStringCollection;
  95. _localeEncoding = GetOption(options, "LocaleEncoding", RubyEncoding.UTF8);
  96. _defaultEncoding = GetOption<RubyEncoding>(options, "DefaultEncoding", null);
  97. _mainFile = GetOption(options, "MainFile", (string)null);
  98. _verbosity = GetOption(options, "Verbosity", 1);
  99. _debugVariable = GetOption(options, "DebugVariable", false);
  100. _enableTracing = GetOption(options, "EnableTracing", false);
  101. _savePath = GetOption(options, "SavePath", (string)null);
  102. _loadFromDisk = GetOption(options, "LoadFromDisk", false);
  103. _profile = GetOption(options, "Profile", false);
  104. _noAssemblyResolveHook = GetOption(options, "NoAssemblyResolveHook", false);
  105. _requirePaths = GetStringCollectionOption(options, "RequiredPaths", ';', ',');
  106. _hasSearchPaths = GetOption<object>(options, "SearchPaths", null) != null;
  107. _libraryPaths = GetStringCollectionOption(options, "LibraryPaths", ';', ',');
  108. }
  109. }
  110. }