PageRenderTime 23ms CodeModel.GetById 17ms app.highlight 4ms 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
  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
 16using System;
 17using System.Collections.Generic;
 18using System.Collections.ObjectModel;
 19using System.Threading;
 20using IronRuby.Builtins;
 21using Microsoft.Scripting;
 22using Microsoft.Scripting.Utils;
 23
 24namespace IronRuby.Runtime {
 25
 26    [Serializable]
 27    public sealed class RubyOptions : LanguageOptions {
 28        private readonly ReadOnlyCollection<string>/*!*/ _arguments;
 29        private readonly RubyEncoding/*!*/ _localeEncoding;
 30        private readonly RubyEncoding _defaultEncoding;
 31        private readonly ReadOnlyCollection<string>/*!*/ _libraryPaths;
 32        private readonly ReadOnlyCollection<string> _requirePaths;
 33        private readonly string _mainFile;
 34        private readonly bool _enableTracing;
 35        private readonly int _verbosity;
 36        private readonly bool _debugVariable;
 37        private readonly string _savePath;
 38        private readonly bool _loadFromDisk;
 39        private readonly bool _profile;
 40        private readonly bool _hasSearchPaths;
 41        private readonly bool _noAssemblyResolveHook;
 42
 43#if DEBUG
 44        public static bool UseThreadAbortForSyncRaise;
 45        public static bool CompileRegexps;
 46        public static bool ShowRules;
 47#endif
 48
 49        public ReadOnlyCollection<string>/*!*/ Arguments {
 50            get { return _arguments; }
 51        }
 52
 53        public RubyEncoding/*!*/ LocaleEncoding {
 54            get { return _localeEncoding; }
 55        }
 56
 57        public RubyEncoding DefaultEncoding {
 58            get { return _defaultEncoding; }
 59        }
 60
 61        public string MainFile {
 62            get { return _mainFile; }
 63        }
 64        
 65        public int Verbosity {
 66            get { return _verbosity; }
 67        }
 68
 69        public bool EnableTracing {
 70            get { return _enableTracing; }
 71        }
 72
 73        public string SavePath {
 74            get { return _savePath; }
 75        }
 76
 77        public bool LoadFromDisk {
 78            get { return _loadFromDisk; }
 79        }
 80
 81        public bool Profile {
 82            get { return _profile; }
 83        }
 84
 85        public bool NoAssemblyResolveHook {
 86            get { return _noAssemblyResolveHook; }
 87        }
 88
 89        public ReadOnlyCollection<string> LibraryPaths {
 90            get { return _libraryPaths; }
 91        }
 92
 93        public ReadOnlyCollection<string> RequirePaths {
 94            get { return _requirePaths; }
 95        }
 96
 97        public bool HasSearchPaths {
 98            get { return _hasSearchPaths; }
 99        }
100
101        public RubyCompatibility Compatibility {
102            get { return RubyCompatibility.Default; }
103        }
104
105        /// <summary>
106        /// The initial value of $DEBUG variable.
107        /// </summary>
108        public bool DebugVariable {
109            get { return _debugVariable; }
110        }
111
112        public RubyOptions(IDictionary<string, object>/*!*/ options)
113            : base(options) {
114            _arguments = GetStringCollectionOption(options, "Arguments") ?? EmptyStringCollection;
115            _localeEncoding = GetOption(options, "LocaleEncoding", RubyEncoding.UTF8);
116            _defaultEncoding = GetOption<RubyEncoding>(options, "DefaultEncoding", null);
117
118            _mainFile = GetOption(options, "MainFile", (string)null);
119            _verbosity = GetOption(options, "Verbosity", 1);
120            _debugVariable = GetOption(options, "DebugVariable", false);
121            _enableTracing = GetOption(options, "EnableTracing", false);
122            _savePath = GetOption(options, "SavePath", (string)null);
123            _loadFromDisk = GetOption(options, "LoadFromDisk", false);
124            _profile = GetOption(options, "Profile", false);
125            _noAssemblyResolveHook = GetOption(options, "NoAssemblyResolveHook", false);
126            _requirePaths = GetStringCollectionOption(options, "RequiredPaths", ';', ',');
127            _hasSearchPaths = GetOption<object>(options, "SearchPaths", null) != null;
128            _libraryPaths = GetStringCollectionOption(options, "LibraryPaths", ';', ',');
129        }
130    }
131}