forked from IronLanguages/ironpython3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonCompilerOptions.cs
More file actions
182 lines (162 loc) · 5.67 KB
/
PythonCompilerOptions.cs
File metadata and controls
182 lines (162 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System;
using Microsoft.Scripting;
using IronPython.Runtime;
namespace IronPython.Compiler {
[Serializable]
public sealed class PythonCompilerOptions : CompilerOptions {
private ModuleOptions _module;
private bool _skipFirstLine, _dontImplyIndent;
private string _moduleName;
private int[] _initialIndentation;
private CompilationMode _compilationMode;
/// <summary>
/// Creates a new PythonCompilerOptions with the default language features enabled.
/// </summary>
public PythonCompilerOptions()
: this(ModuleOptions.None) {
}
/// <summary>
/// Creates a new PythonCompilerOptions with the specified language features enabled.
/// </summary>
public PythonCompilerOptions(ModuleOptions features) {
_module = features;
}
/// <summary>
/// Creates a new PythonCompilerOptions and enables or disables true division.
///
/// This overload is obsolete, instead you should use the overload which takes a
/// ModuleOptions.
/// </summary>
[Obsolete("Use the overload that takes ModuleOptions instead")]
public PythonCompilerOptions(bool trueDivision) {
TrueDivision = trueDivision;
}
public bool DontImplyDedent {
get { return _dontImplyIndent; }
set { _dontImplyIndent = value; }
}
/// <summary>
/// Gets or sets the initial indentation. This can be set to allow parsing
/// partial blocks of code that are already indented.
///
/// For each element of the array there is an additional level of indentation.
/// Each integer value represents the number of spaces used for the indentation.
///
/// If this value is null then no indentation level is specified.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
public int[] InitialIndent {
get {
return _initialIndentation;
}
set {
_initialIndentation = value;
}
}
public bool TrueDivision {
get {
return (_module & ModuleOptions.TrueDivision) != 0;
}
set {
if (value) _module |= ModuleOptions.TrueDivision;
else _module &= ~ModuleOptions.TrueDivision;
}
}
public bool AllowWithStatement {
get {
return (_module & ModuleOptions.WithStatement) != 0;
}
set {
if (value) _module |= ModuleOptions.WithStatement;
else _module &= ~ModuleOptions.WithStatement;
}
}
public bool AbsoluteImports {
get {
return (_module & ModuleOptions.AbsoluteImports) != 0;
}
set {
if (value) _module |= ModuleOptions.AbsoluteImports;
else _module &= ~ModuleOptions.AbsoluteImports;
}
}
public bool Verbatim {
get {
return (_module & ModuleOptions.Verbatim) != 0;
}
set {
if (value) _module |= ModuleOptions.Verbatim;
else _module &= ~ModuleOptions.Verbatim;
}
}
public bool UnicodeLiterals {
get {
return (_module & ModuleOptions.UnicodeLiterals) != 0;
}
set {
if (value) _module |= ModuleOptions.UnicodeLiterals;
else _module &= ~ModuleOptions.UnicodeLiterals;
}
}
public bool Interpreted {
get {
return (_module & ModuleOptions.Interpret) != 0;
}
set {
if (value) _module |= ModuleOptions.Interpret;
else _module &= ~ModuleOptions.Interpret;
}
}
public bool Optimized {
get {
return (_module & ModuleOptions.Optimized) != 0;
}
set {
if (value) _module |= ModuleOptions.Optimized;
else _module &= ~ModuleOptions.Optimized;
}
}
public ModuleOptions Module {
get {
return _module;
}
set {
_module = value;
}
}
public string ModuleName {
get {
return _moduleName;
}
set {
_moduleName = value;
}
}
public bool SkipFirstLine {
get { return _skipFirstLine; }
set { _skipFirstLine = value; }
}
internal CompilationMode CompilationMode {
get {
return _compilationMode;
}
set {
_compilationMode = value;
}
}
}
}