|
19 | 19 | from . import options |
20 | 20 | from . import global_ |
21 | 21 |
|
22 | | -from .options import ANYTYPE, Actions |
| 22 | +from .options import ANYTYPE, Action |
23 | 23 |
|
24 | 24 |
|
25 | 25 | # ------------------------------------------------------ |
@@ -86,7 +86,7 @@ class OPTION: |
86 | 86 |
|
87 | 87 | def load_config_from_file(filename: str, section: str, options_: options.Options = None, stop_on_error=True) -> bool: |
88 | 88 | """ Opens file and read options from the given section. If stop_on_error is set, |
89 | | - the program stop. Otherwise the result of the operation will be |
| 89 | + the program stop if any error is found. Otherwise the result of the operation will be |
90 | 90 | returned (True on success, False on failure) |
91 | 91 | """ |
92 | 92 | if options_ is None: |
@@ -166,63 +166,55 @@ def save_config_into_file(filename: str, section: str, options_: options.Options |
166 | 166 |
|
167 | 167 |
|
168 | 168 | def init(): |
| 169 | + """ Default Options and Compilation Flags |
169 | 170 | """ |
170 | | - Default Options and Compilation Flags |
171 | | -
|
172 | | - optimization -- Optimization level. Use -O flag to change. |
173 | | - case_insensitive -- Whether user identifiers are case insensitive |
174 | | - or not |
175 | | - array_base -- Default array lower bound |
176 | | - param_byref --Default parameter passing. TRUE => By Reference |
177 | | - """ |
178 | | - |
179 | | - OPTIONS(Actions.CLEAR) |
| 171 | + OPTIONS(Action.CLEAR) |
180 | 172 |
|
181 | | - OPTIONS(Actions.ADD, name=OPTION.OUTPUT_FILENAME, type=str) |
182 | | - OPTIONS(Actions.ADD, name=OPTION.INPUT_FILENAME, type=str) |
183 | | - OPTIONS(Actions.ADD, name=OPTION.STDERR_FILENAME, type=str) |
184 | | - OPTIONS(Actions.ADD, name=OPTION.DEBUG, type=int, default=0) |
| 173 | + OPTIONS(Action.ADD, name=OPTION.OUTPUT_FILENAME, type=str) |
| 174 | + OPTIONS(Action.ADD, name=OPTION.INPUT_FILENAME, type=str) |
| 175 | + OPTIONS(Action.ADD, name=OPTION.STDERR_FILENAME, type=str, ignore_none=True) |
| 176 | + OPTIONS(Action.ADD, name=OPTION.DEBUG, type=int, default=0, ignore_none=True) |
185 | 177 |
|
186 | 178 | # Default console redirections |
187 | | - OPTIONS(Actions.ADD, name=OPTION.STDIN, type=ANYTYPE, default=sys.stdin) |
188 | | - OPTIONS(Actions.ADD, name=OPTION.STDOUT, type=ANYTYPE, default=sys.stdout) |
189 | | - OPTIONS(Actions.ADD, name=OPTION.STDERR, type=ANYTYPE, default=sys.stderr) |
| 179 | + OPTIONS(Action.ADD, name=OPTION.STDIN, type=ANYTYPE, default=sys.stdin) |
| 180 | + OPTIONS(Action.ADD, name=OPTION.STDOUT, type=ANYTYPE, default=sys.stdout) |
| 181 | + OPTIONS(Action.ADD, name=OPTION.STDERR, type=ANYTYPE, default=sys.stderr) |
190 | 182 |
|
191 | | - OPTIONS(Actions.ADD, name=OPTION.O_LEVEL, type=int, default=global_.DEFAULT_OPTIMIZATION_LEVEL) |
192 | | - OPTIONS(Actions.ADD, name=OPTION.CASE_INS, type=bool, default=False) |
193 | | - OPTIONS(Actions.ADD, name=OPTION.ARRAY_BASE, type=int, default=0) |
194 | | - OPTIONS(Actions.ADD, name=OPTION.DEFAULT_BYREF, type=bool, default=False) |
195 | | - OPTIONS(Actions.ADD, name=OPTION.MAX_SYN_ERRORS, type=int, default=global_.DEFAULT_MAX_SYNTAX_ERRORS) |
196 | | - OPTIONS(Actions.ADD, name=OPTION.STR_BASE, type=int, default=0) |
197 | | - OPTIONS(Actions.ADD, name=OPTION.MEMORY_MAP, type=str, default=None) |
198 | | - OPTIONS(Actions.ADD, name=OPTION.FORCE_ASM_BRACKET, type=bool, default=False) |
| 183 | + OPTIONS(Action.ADD, name=OPTION.O_LEVEL, type=int, default=global_.DEFAULT_OPTIMIZATION_LEVEL, ignore_none=True) |
| 184 | + OPTIONS(Action.ADD, name=OPTION.CASE_INS, type=bool, default=False, ignore_none=True) |
| 185 | + OPTIONS(Action.ADD, name=OPTION.ARRAY_BASE, type=int, default=0, ignore_none=True) |
| 186 | + OPTIONS(Action.ADD, name=OPTION.DEFAULT_BYREF, type=bool, default=False, ignore_none=True) |
| 187 | + OPTIONS(Action.ADD, name=OPTION.MAX_SYN_ERRORS, type=int, default=global_.DEFAULT_MAX_SYNTAX_ERRORS) |
| 188 | + OPTIONS(Action.ADD, name=OPTION.STR_BASE, type=int, default=0, ignore_none=True) |
| 189 | + OPTIONS(Action.ADD, name=OPTION.MEMORY_MAP, type=str, default=None, ignore_none=True) |
| 190 | + OPTIONS(Action.ADD, name=OPTION.FORCE_ASM_BRACKET, type=bool, default=False, ignore_none=True) |
199 | 191 |
|
200 | | - OPTIONS(Actions.ADD, name=OPTION.USE_BASIC_LOADER, type=bool, default=False) # Whether to use a loader |
| 192 | + OPTIONS(Action.ADD, name=OPTION.USE_BASIC_LOADER, type=bool, default=False) # Whether to use a loader |
201 | 193 |
|
202 | 194 | # Whether to add autostart code (needs basic loader = true) |
203 | | - OPTIONS(Actions.ADD, name=OPTION.AUTORUN, type=bool, default=False) |
204 | | - OPTIONS(Actions.ADD, name=OPTION.OUTPUT_FILE_TYPE, type=str, default='bin') # bin, tap, tzx etc... |
205 | | - OPTIONS(Actions.ADD, name=OPTION.INCLUDE_PATH, type=str, default='') # Include path, like '/var/lib:/var/include' |
206 | | - |
207 | | - OPTIONS(Actions.ADD, name=OPTION.CHECK_MEMORY, type=bool, default=False) |
208 | | - OPTIONS(Actions.ADD, name=OPTION.STRICT_BOOL, type=bool, default=False) |
209 | | - OPTIONS(Actions.ADD, name=OPTION.CHECK_ARRAYS, type=bool, default=False) |
210 | | - |
211 | | - OPTIONS(Actions.ADD, name=OPTION.ENABLE_BREAK, type=bool, default=False) |
212 | | - OPTIONS(Actions.ADD, name=OPTION.EMIT_BACKEND, type=bool, default=False) |
213 | | - OPTIONS(Actions.ADD, name='__DEFINES', type=dict, default={}) |
214 | | - OPTIONS(Actions.ADD, name=OPTION.EXPLICIT, type=bool, default=False) |
215 | | - OPTIONS(Actions.ADD, name='sinclair', type=bool, default=False) |
216 | | - OPTIONS(Actions.ADD, name=OPTION.STRICT, type=bool, default=False) # True to force type checking |
217 | | - OPTIONS(Actions.ADD, name=OPTION.ASM_ZXNEXT, type=bool, default=False) # True to enable ZX Next ASM opcodes |
218 | | - OPTIONS(Actions.ADD, name=OPTION.ARCH, type=str, default=None) # Architecture |
219 | | - OPTIONS(Actions.ADD, name=OPTION.EXPECTED_WARNINGS, type=int, default=0) # Expected Warnings that will be silenced |
| 195 | + OPTIONS(Action.ADD, name=OPTION.AUTORUN, type=bool, default=False) |
| 196 | + OPTIONS(Action.ADD, name=OPTION.OUTPUT_FILE_TYPE, type=str, default='bin') # bin, tap, tzx etc... |
| 197 | + OPTIONS(Action.ADD, name=OPTION.INCLUDE_PATH, type=str, default='') # Include path, like '/var/lib:/var/include' |
| 198 | + |
| 199 | + OPTIONS(Action.ADD, name=OPTION.CHECK_MEMORY, type=bool, default=False, ignore_none=True) |
| 200 | + OPTIONS(Action.ADD, name=OPTION.STRICT_BOOL, type=bool, default=False, ignore_none=True) |
| 201 | + OPTIONS(Action.ADD, name=OPTION.CHECK_ARRAYS, type=bool, default=False, ignore_none=True) |
| 202 | + |
| 203 | + OPTIONS(Action.ADD, name=OPTION.ENABLE_BREAK, type=bool, default=False, ignore_none=True) |
| 204 | + OPTIONS(Action.ADD, name=OPTION.EMIT_BACKEND, type=bool, default=False) |
| 205 | + OPTIONS(Action.ADD, name='__DEFINES', type=dict, default={}) |
| 206 | + OPTIONS(Action.ADD, name=OPTION.EXPLICIT, type=bool, default=False, ignore_none=True) |
| 207 | + OPTIONS(Action.ADD, name='sinclair', type=bool, default=False) |
| 208 | + OPTIONS(Action.ADD, name=OPTION.STRICT, type=bool, default=False, ignore_none=True) # True to force type checking |
| 209 | + OPTIONS(Action.ADD, name=OPTION.ASM_ZXNEXT, type=bool, default=False, ignore_none=True) # Enable ZX Next ASM |
| 210 | + OPTIONS(Action.ADD, name=OPTION.ARCH, type=str, default=None, ignore_none=True) # Architecture |
| 211 | + OPTIONS(Action.ADD, name=OPTION.EXPECTED_WARNINGS, type=int, default=0, ignore_none=True) |
220 | 212 |
|
221 | 213 | # Whether to show WXXX warning codes or not |
222 | | - OPTIONS(Actions.ADD, name=OPTION.HIDE_WARNING_CODES, type=bool, default=False) |
| 214 | + OPTIONS(Action.ADD, name=OPTION.HIDE_WARNING_CODES, type=bool, default=False, ignore_none=True) |
223 | 215 |
|
224 | | - OPTIONS(Actions.ADD, name=OPTION.PROJECT_FILENAME, type=str, default=os.path.join(os.path.abspath(os.path.curdir), |
225 | | - 'project.ini')) |
| 216 | + OPTIONS(Action.ADD, name=OPTION.PROJECT_FILENAME, type=str, default=os.path.join(os.path.abspath(os.path.curdir), |
| 217 | + 'project.ini')) |
226 | 218 |
|
227 | 219 |
|
228 | 220 | init() |
0 commit comments