* Injects labels into the assembly where addresses are referred to * if an address doesn't have a mapped name, it is called
()
| 228 | * if an address doesn't have a mapped name, it is called <Laddress> |
| 229 | */ |
| 230 | insertLabels() { |
| 231 | let currentSegment: Segment | undefined; |
| 232 | let segmentChanged = false; |
| 233 | |
| 234 | let lineIdx = 0; |
| 235 | while (lineIdx < this.asmLines.length) { |
| 236 | const line = this.asmLines[lineIdx]; |
| 237 | |
| 238 | const matches = line.match(this.addressRegex); |
| 239 | if (matches) { |
| 240 | const addressStr = matches[1]; |
| 241 | const address = Number.parseInt(addressStr, 16); |
| 242 | |
| 243 | const segmentInfo = this.mapFileReader.getSegmentInfoByStartingAddress(undefined, address); |
| 244 | if (segmentInfo) { |
| 245 | currentSegment = segmentInfo; |
| 246 | segmentChanged = true; |
| 247 | } |
| 248 | |
| 249 | let namedAddr: Segment | undefined; |
| 250 | let labelLine: string | undefined; |
| 251 | |
| 252 | const isReferenced = this.addressesToLabel.indexOf(addressStr); |
| 253 | if (isReferenced === -1) { |
| 254 | // we might have missed the reference to this address, |
| 255 | // but if it's listed as a symbol, we should still label it. |
| 256 | // todo: the call might be in <.itext>, should we include that part of the assembly? |
| 257 | namedAddr = this.mapFileReader.getSymbolAt(undefined, address); |
| 258 | if (namedAddr) { |
| 259 | labelLine = matches[1] + ' <' + namedAddr.displayName + '>:'; |
| 260 | |
| 261 | this.asmLines.splice(lineIdx, 0, labelLine); |
| 262 | lineIdx++; |
| 263 | } |
| 264 | } else { |
| 265 | labelLine = matches[1] + ' <L' + addressStr + '>:'; |
| 266 | |
| 267 | namedAddr = this.mapFileReader.getSymbolAt(undefined, address); |
| 268 | if (namedAddr) { |
| 269 | labelLine = matches[1] + ' <' + namedAddr.displayName + '>:'; |
| 270 | } |
| 271 | |
| 272 | if (!this.dontLabelUnmappedAddresses || namedAddr) { |
| 273 | this.asmLines.splice(lineIdx, 0, labelLine); |
| 274 | lineIdx++; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | const lineInfo = this.mapFileReader.getLineInfoByAddress(undefined, address); |
| 279 | if (lineInfo && currentSegment?.unitName) { |
| 280 | this.asmLines.splice(lineIdx, 0, '/app/' + currentSegment.unitName + ':' + lineInfo.lineNumber); |
| 281 | lineIdx++; |
| 282 | } else if (segmentChanged && currentSegment) { |
| 283 | this.asmLines.splice(lineIdx, 0, '/app/' + currentSegment.unitName + ':0'); |
| 284 | lineIdx++; |
| 285 | } |
| 286 | } |
| 287 |
no test coverage detected