| 1 | package com.rox.cpu.mos6502.assembler; | |
| 2 | ||
| 3 | import java.util.LinkedHashMap; | |
| 4 | import java.util.Map; | |
| 5 | ||
| 6 | /** Maps label names to their resolved addresses, built during assembly's first pass. */ | |
| 7 | final class SymbolTable { | |
| 8 | private final Map<String, Integer> addresses = new LinkedHashMap<>(); | |
| 9 | ||
| 10 | void define(final String label, final int address, final int lineNumber) { | |
| 11 |
1
1. define : negated conditional → KILLED |
if (addresses.containsKey(label)) { |
| 12 | throw new AssemblyException(lineNumber, "Duplicate label: " + label); | |
| 13 | } | |
| 14 | addresses.put(label, address); | |
| 15 | } | |
| 16 | ||
| 17 | int resolve(final String label, final int lineNumber) { | |
| 18 | final Integer address = addresses.get(label); | |
| 19 |
1
1. resolve : negated conditional → KILLED |
if (address == null) { |
| 20 | throw new AssemblyException(lineNumber, "Undefined label: " + label); | |
| 21 | } | |
| 22 |
1
1. resolve : replaced int return with 0 for com/rox/cpu/mos6502/assembler/SymbolTable::resolve → KILLED |
return address; |
| 23 | } | |
| 24 | ||
| 25 | Map<String, Integer> asMap() { | |
| 26 |
1
1. asMap : replaced return value with Collections.emptyMap for com/rox/cpu/mos6502/assembler/SymbolTable::asMap → KILLED |
return Map.copyOf(addresses); |
| 27 | } | |
| 28 | } | |
Mutations | ||
| 11 |
1.1 |
|
| 19 |
1.1 |
|
| 22 |
1.1 |
|
| 26 |
1.1 |