修复了大量存在的问题,增加了假鸭子类型等等机制

This commit is contained in:
2026-06-25 14:49:46 +08:00
parent 19f2787db0
commit d88d11b646
827 changed files with 32617 additions and 18316 deletions

View File

@@ -1,11 +1,12 @@
# 常量定义
from __future__ import annotations
DEFAULT_INPUT_FILE = 'test.py'
DEFAULT_OUTPUT_FILE = 'test.ll'
DEFAULT_INPUT_FILE: str = 'test.py'
DEFAULT_OUTPUT_FILE: str = 'test.ll'
SLICE_THRESHOLD = 50
SLICE_LEVEL_DEFAULT = 3
SLICE_LEVELS = {
SLICE_THRESHOLD: int = 50
SLICE_LEVEL_DEFAULT: int = 3
SLICE_LEVELS: dict[int | str, str] = {
0: 'no_optimize',
1: 'conservative',
2: 'moderate',
@@ -13,10 +14,10 @@ SLICE_LEVELS = {
's': 'size',
}
DEFAULT_COMPILE_COMMAND = 'gcc'
DEFAULT_COMPILE_FLAGS = ''
DEFAULT_COMPILE_COMMAND: str = 'gcc'
DEFAULT_COMPILE_FLAGS: str = ''
DEFAULT_METADATA = {
DEFAULT_METADATA: dict[str, str] = {
'PROJECT_NAME': 'TransPyC Project',
'AUTHOR': 'TransPyC Team',
'VERSION': '1.0.0',
@@ -25,7 +26,7 @@ DEFAULT_METADATA = {
'COPYRIGHT_HOLDER': 'Galactic Vorpal Software Development Studio (e.g. GVSDS Inc.)'
}
ERROR_MESSAGES = {
ERROR_MESSAGES: dict[str, str] = {
'MISSING_ARGS': 'Missing required arguments -f and/or -o',
'UNKNOWN_ARG': 'Unknown argument',
'UNSUPPORTED_TYPE': 'Unsupported file type',
@@ -33,10 +34,10 @@ ERROR_MESSAGES = {
'COMPILE_FAILED': 'Compilation or execution failed'
}
HELP_MESSAGE = '''
HELP_MESSAGE: str = '''
Usage: python TransPyC.py -f InputFile -o OutputFile [-wh header_files] [-debug DebugFile]
[-cc compile_command] [-cflags CompileFlags] [-run] [-args RunArgs] [-h HelperFiles]
-h: Specify helper files (C or Python) to help identify structs, functions, variables, and ptrs
'''
mode = "strict"
mode: str = "strict"