Skip to content

Commit a1fee33

Browse files
authored
Merge pull request #153 from Decompollaborate/develop
1.22.0
2 parents e9e0779 + f35a8f0 commit a1fee33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+347
-207
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v2
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
1314

1415
- name: Install build module
15-
run: pip install build
16+
run: pip install -U build
1617

1718
- name: Build wheel and source
1819
run: python -m build --sdist --wheel --outdir dist/ .
1920

20-
- uses: actions/upload-artifact@v2
21+
- uses: actions/upload-artifact@v4.3.1
2122
with:
2223
path: dist/*
2324

@@ -26,12 +27,12 @@ jobs:
2627
runs-on: ubuntu-latest
2728
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
2829
steps:
29-
- uses: actions/download-artifact@v2
30+
- uses: actions/download-artifact@v4.1.2
3031
with:
3132
name: artifact
3233
path: dist
3334

34-
- uses: pypa/gh-action-pypi-publish@v1.4.2
35+
- uses: pypa/gh-action-pypi-publish@v1.8.11
3536
with:
3637
user: __token__
3738
password: ${{ secrets.pypi_password }}

.github/workflows/mypy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ jobs:
88
runs-on: ubuntu-latest
99
name: mypy
1010
steps:
11-
- uses: actions/checkout@v1
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
1214
- name: Set up Python 3.7
1315
uses: actions/setup-python@v1
1416
with:
1517
python-version: 3.7
18+
1619
- name: Install Dependencies
1720
run: |
1821
pip install -r requirements.txt
1922
pip install mypy -U
23+
2024
- name: mypy
2125
run: mypy --show-column-numbers --hide-error-context .

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.22.0] - 2024-03-08
11+
12+
### Added
13+
14+
- New options:
15+
- Add `ASM_GLOBALIZE_TEXT_LABELS_REFERENCED_BY_NON_JUMPTABLE`.
16+
- Forces the use of `ASM_JTBL_LABEL` on text labels that are referenced by
17+
non jumptables.
18+
- Turned off by default.
19+
- Not enabled by default since this may be a symptom of something
20+
misconfigured or fake refences, since nothing besides jumptables should
21+
be able to reference labels inside a function.
22+
- Add libleo (64DD) hardware registers to the list of known N64 hardware
23+
registers.
24+
25+
### Changed
26+
27+
- Change the logic for emitting the alignment directives.
28+
- Now the address of the symbol must be aligned relative to the file where
29+
the symbol is, instead of requiring both the symbol and the file to be
30+
aligned independently.
31+
- This should be specially useful for PSX projects, since the compiler aligns
32+
jumptables to 8, but it doesn't impose alignment restrictions on files,
33+
meaning the files (and those jumptables) may end up aligned to a lower
34+
alignment.
35+
- Avoid filtering out user declared symbols when they are outside the valid
36+
address space.
37+
38+
### Fixed
39+
40+
- Fix missing type hints
41+
1042
## [1.21.0] - 2024-02-08
1143

1244
### Added
@@ -1390,6 +1422,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13901422
- Version 1.0.0
13911423

13921424
[unreleased]: https://github.com/Decompollaborate/spimdisasm/compare/master...develop
1425+
[1.22.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.21.1...1.22.0
13931426
[1.21.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.20.1...1.21.0
13941427
[1.20.1]: https://github.com/Decompollaborate/spimdisasm/compare/1.20.0...1.20.1
13951428
[1.20.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.19.0...1.20.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If you use a `requirements.txt` file in your repository, then you can add
6868
this library with the following line:
6969

7070
```txt
71-
spimdisasm>=1.21.0,<2.0.0
71+
spimdisasm>=1.22.0,<2.0.0
7272
```
7373

7474
### Development version

mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[mypy]
22
python_version = 3.7
33
check_untyped_defs = True
4+
disallow_untyped_defs = True
5+
disallow_any_unimported = True
6+
no_implicit_optional = True
7+
warn_return_any = True
8+
show_error_codes = True
9+
warn_unused_ignores = True

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[project]
55
name = "spimdisasm"
66
# Version should be synced with spimdisasm/__init__.py
7-
version = "1.21.0"
7+
version = "1.22.0"
88
description = "MIPS disassembler"
99
readme = "README.md"
1010
license = {file = "LICENSE"}

spimdisasm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from __future__ import annotations
77

8-
__version_info__: tuple[int, int, int] = (1, 21, 0)
8+
__version_info__: tuple[int, int, int] = (1, 22, 0)
99
__version__ = ".".join(map(str, __version_info__))
1010
__author__ = "Decompollaborate"
1111

spimdisasm/common/Context.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ def increaseEnd(self, address: int) -> None:
3434
self.end = address
3535
return None
3636

37+
def __str__(self) -> str:
38+
return f"AddressRange(0x{self.start:08X}, 0x{self.end:08X})"
39+
40+
def __repr__(self) -> str:
41+
return self.__str__()
42+
3743
class SymbolsRanges:
38-
def __init__(self, start: int, end: int):
44+
def __init__(self, start: int, end: int) -> None:
3945
self.mainAddressRange = AddressRange(start, end)
4046
self.specialRanges: list[AddressRange] = list()
4147

@@ -63,6 +69,12 @@ def addSpecialRange(self, start: int, end: int) -> AddressRange|None:
6369
self.specialRanges.append(addrRange)
6470
return addrRange
6571

72+
def __str__(self) -> str:
73+
ret = f"MainRange: {self.mainAddressRange}\n"
74+
for i, spRange in enumerate(self.specialRanges):
75+
ret += f" {i}'th special: {spRange}\n"
76+
return ret
77+
6678
class Context:
6779
N64DefaultBanned = {
6880
0x7FFFFFE0, # osInvalICache
@@ -72,7 +84,7 @@ class Context:
7284
0x80000020,
7385
}
7486

75-
def __init__(self):
87+
def __init__(self) -> None:
7688
# Arbitrary initial range
7789
self.globalSegment = SymbolsSegment(self, 0x0, 0x1000, 0x80000000, 0x80001000, overlayCategory=None)
7890
# For symbols that we don't know where they come from
@@ -95,7 +107,7 @@ def __init__(self):
95107
self.gpAccesses = GpAccessContainer()
96108

97109

98-
def changeGlobalSegmentRanges(self, vromStart: int, vromEnd: int, vramStart: int, vramEnd: int):
110+
def changeGlobalSegmentRanges(self, vromStart: int, vromEnd: int, vramStart: int, vramEnd: int) -> None:
99111
if vromStart == vromEnd:
100112
Utils.eprint(f"Warning: globalSegment's will has its vromStart equal to the vromEnd (0x{vromStart:X})")
101113
if vramStart == vramEnd:
@@ -130,33 +142,33 @@ def addSpecialVramRange(self, start: int, end: int) -> AddressRange|None:
130142
return self.totalVramRange.addSpecialRange(start, end)
131143

132144

133-
def initGotTable(self, pltGot: int, localsTable: list[int], globalsTable: list[int]):
145+
def initGotTable(self, pltGot: int, localsTable: list[int], globalsTable: list[int]) -> None:
134146
self.gpAccesses.initGotTable(pltGot, localsTable, globalsTable)
135147

136148
for gotEntry in self.gpAccesses.got.globalsTable:
137149
contextSym = self.globalSegment.addSymbol(gotEntry)
138150
contextSym.isUserDeclared = True
139151
contextSym.isGotGlobal = True
140152

141-
def addSmallSection(self, address: int, size: int):
153+
def addSmallSection(self, address: int, size: int) -> None:
142154
self.gpAccesses.addSmallSection(address, size)
143155

144156

145-
def fillDefaultBannedSymbols(self):
157+
def fillDefaultBannedSymbols(self) -> None:
146158
self.bannedSymbols |= self.N64DefaultBanned
147159

148160

149161
def isAddressInGlobalRange(self, address: int) -> bool:
150162
return self.totalVramRange.isInRange(address)
151163

152164

153-
def addBannedSymbol(self, address: int):
165+
def addBannedSymbol(self, address: int) -> None:
154166
self.bannedSymbols.add(address)
155167

156-
def addBannedSymbolRange(self, rangeStart: int, rangeEnd: int):
168+
def addBannedSymbolRange(self, rangeStart: int, rangeEnd: int) -> None:
157169
self.bannedRangedSymbols.append(AddressRange(rangeStart, rangeEnd))
158170

159-
def addBannedSymbolRangeBySize(self, rangeStart: int, size: int):
171+
def addBannedSymbolRangeBySize(self, rangeStart: int, size: int) -> None:
160172
self.bannedRangedSymbols.append(AddressRange(rangeStart, rangeStart + size))
161173

162174
def isAddressBanned(self, address: int) -> bool:
@@ -172,7 +184,7 @@ def addGlobalReloc(self, vromAddres: int, relocType: RelocType, symbol: ContextS
172184
self.globalRelocationOverrides[vromAddres] = reloc
173185
return reloc
174186

175-
def saveContextToFile(self, contextPath: Path):
187+
def saveContextToFile(self, contextPath: Path) -> None:
176188
with contextPath.open("w") as f:
177189
self.globalSegment.saveContextToFile(f)
178190

@@ -191,7 +203,7 @@ def saveContextToFile(self, contextPath: Path):
191203

192204

193205
@staticmethod
194-
def addParametersToArgParse(parser: argparse.ArgumentParser):
206+
def addParametersToArgParse(parser: argparse.ArgumentParser) -> None:
195207
contextParser = parser.add_argument_group("Context configuration")
196208

197209
contextParser.add_argument("--save-context", help="Saves the context to a file", metavar="FILENAME")
@@ -214,7 +226,7 @@ def addParametersToArgParse(parser: argparse.ArgumentParser):
214226
symbolsConfig.add_argument("--named-hardware-regs", help="Use actual names for the hardware registers", action=Utils.BooleanOptionalAction)
215227

216228

217-
def parseArgs(self, args: argparse.Namespace):
229+
def parseArgs(self, args: argparse.Namespace) -> None:
218230
if args.default_banned != False:
219231
self.fillDefaultBannedSymbols()
220232
if args.libultra_syms != False:

spimdisasm/common/ContextSymbols.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AccessTypeInfo:
5858
typeUnsigned: str|None
5959
typeNameAliases: set[str] = dataclasses.field(default_factory=set)
6060

61-
def typeMatchesAccess(self, typename) -> bool:
61+
def typeMatchesAccess(self, typename: SymbolSpecialType|str|None) -> bool:
6262
if typename is None:
6363
return False
6464
if typename == self.typeSigned:
@@ -222,7 +222,7 @@ def size(self) -> int|None:
222222

223223
#! @deprecated
224224
@size.setter
225-
def size(self, value: int|None):
225+
def size(self, value: int|None) -> None:
226226
self.userDeclaredSize = value
227227

228228
#! @deprecated
@@ -232,7 +232,7 @@ def type(self) -> SymbolSpecialType|str|None:
232232

233233
#! @deprecated
234234
@type.setter
235-
def type(self, value: SymbolSpecialType|str|None):
235+
def type(self, value: SymbolSpecialType|str|None) -> None:
236236
self.setTypeSpecial(value, self.isAutogenerated)
237237

238238
def hasNoType(self) -> bool:
@@ -574,7 +574,7 @@ def getType(self) -> str:
574574
return currentType.toStr()
575575
return currentType
576576

577-
def setTypeSpecial(self, newType: SymbolSpecialType|str|None, isAutogenerated: bool):
577+
def setTypeSpecial(self, newType: SymbolSpecialType|str|None, isAutogenerated: bool) -> None:
578578
if isAutogenerated:
579579
self.autodetectedType = newType
580580
else:
@@ -727,5 +727,5 @@ def __eq__(self, other: object) -> bool:
727727
return self.address == other.address and self.vromAddress == other.vromAddress
728728

729729
# https://stackoverflow.com/a/56915493/6292472
730-
def __hash__(self):
730+
def __hash__(self) -> int:
731731
return hash((self.address, self.vromAddress))

spimdisasm/common/ElementBase.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ElementBase:
1818
"""Represents the base class used for most file sections and symbols.
1919
"""
2020

21-
def __init__(self, context: Context, vromStart: int, vromEnd: int, inFileOffset: int, vram: int, name: str, words: list[int], sectionType: FileSectionType, segmentVromStart: int, overlayCategory: str|None):
21+
def __init__(self, context: Context, vromStart: int, vromEnd: int, inFileOffset: int, vram: int, name: str, words: list[int], sectionType: FileSectionType, segmentVromStart: int, overlayCategory: str|None) -> None:
2222
"""Constructor
2323
2424
Args:
@@ -68,10 +68,10 @@ def vramEnd(self) -> int:
6868
return self.vram + self.sizew * 4
6969

7070

71-
def setVram(self, vram: int):
71+
def setVram(self, vram: int) -> None:
7272
self.vram = vram
7373

74-
def setCommentOffset(self, commentOffset: int):
74+
def setCommentOffset(self, commentOffset: int) -> None:
7575
self.commentOffset = commentOffset
7676

7777
def getName(self) -> str:
@@ -106,7 +106,7 @@ def getLabelFromSymbol(self, sym: ContextSymbol|None, symName: str|None) -> str:
106106
return ""
107107

108108

109-
def analyze(self):
109+
def analyze(self) -> None:
110110
"""Scans the words of this element, gathering as much info as possible.
111111
112112
This method should be called only once for each element.
@@ -306,7 +306,7 @@ def addJumpTableLabel(self, vramAddress: int, *, isAutogenerated: bool=False, sy
306306
return segment.addJumpTableLabel(vramAddress, isAutogenerated=isAutogenerated, vromAddress=symbolVrom)
307307

308308

309-
def removeSymbol(self, vramAddress: int, *, symbolVrom: int|None=None):
309+
def removeSymbol(self, vramAddress: int, *, symbolVrom: int|None=None) -> None:
310310
if symbolVrom is not None:
311311
segment = self.getSegmentForVrom(symbolVrom)
312312
else:

spimdisasm/common/FileSplitFormat.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
from __future__ import annotations
77

88
from pathlib import Path
9+
from typing import Generator
910

1011
from . import Utils
1112
from .FileSectionType import FileSectionType
1213

1314

1415
class FileSplitEntry:
15-
def __init__(self, offset: int, vram: int, fileName: str, section: FileSectionType, nextOffset: int, isHandwritten: bool, isRsp: bool):
16+
def __init__(self, offset: int, vram: int, fileName: str, section: FileSectionType, nextOffset: int, isHandwritten: bool, isRsp: bool) -> None:
1617
self.offset: int = offset
1718
self.vram: int = vram
1819
self.fileName: str = fileName
@@ -23,16 +24,16 @@ def __init__(self, offset: int, vram: int, fileName: str, section: FileSectionTy
2324

2425

2526
class FileSplitFormat:
26-
def __init__(self, csvPath: Path|None = None):
27+
def __init__(self, csvPath: Path|None = None) -> None:
2728
self.splits: list[list[str]] = list()
2829

2930
if csvPath is not None:
3031
self.readCsvFile(csvPath)
3132

32-
def __len__(self):
33+
def __len__(self) -> int:
3334
return len(self.splits)
3435

35-
def __iter__(self):
36+
def __iter__(self) -> Generator[FileSplitEntry, None, None]:
3637
section = FileSectionType.Invalid
3738

3839
for i, row in enumerate(self.splits):
@@ -72,11 +73,11 @@ def __iter__(self):
7273

7374
yield FileSplitEntry(offset, vram, fileName, section, nextOffset, isHandwritten, isRsp)
7475

75-
def readCsvFile(self, csvPath: Path):
76+
def readCsvFile(self, csvPath: Path) -> None:
7677
self.splits = Utils.readCsv(csvPath)
7778
self.splits = [x for x in self.splits if len(x) > 0]
7879

79-
def append(self, element: FileSplitEntry | list[str]):
80+
def append(self, element: FileSplitEntry | list[str]) -> None:
8081
if isinstance(element, FileSplitEntry):
8182

8283
offset = f"{element.offset:X}"
@@ -108,5 +109,5 @@ def append(self, element: FileSplitEntry | list[str]):
108109
# TODO: error message
109110
raise TypeError()
110111

111-
def appendEndSection(self, offset: int, vram: int):
112+
def appendEndSection(self, offset: int, vram: int) -> None:
112113
self.splits.append([f"{offset:X}", f"{vram:X}", ".end"])

0 commit comments

Comments
 (0)