zemu 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zemu/debug.rb +35 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0542a6b70d68a1ea2de55fb02802f487ec2ff06f00d824d8113dd8d0b40da40b
4
- data.tar.gz: d806954f2a981777e57b2dcd3d8e1ba4946ce62c6ef440d63ceb2993ab1cd82c
3
+ metadata.gz: b7ab3a65fd7f45896cac4297f3715d138a1753def97266f78dd1af1b30e0f012
4
+ data.tar.gz: 6d33e40e95a4add449616e6793b2817d2a9c5113f7fcc6fe0f7bf075d0d9dec2
5
5
  SHA512:
6
- metadata.gz: 45a3ca398596119e345dd6b146c571c7f635f5067b2ea58ecc9a2ebb6808ea3c60db327dbb0027c7d75ee1a73a79f41dc334cc9eea0e4bd7b3d634752c5047af
7
- data.tar.gz: b580177e4823c0ecb5b54268c3820f32345560a8199054dc8754f855554ef74d38f15895d337a43fc3b7d6363e5e5ed148d479b6106db9673904765736693611
6
+ metadata.gz: 4551b92671a66d326ec426cbfd240427d93d181ef000c47bda8505185f9ac865b51411bfc35222d097f79e810af9cb9337a50473c7ef80c5b0a63c7d98fa550f
7
+ data.tar.gz: aeb983650f57cbb5a7e76b6caffbf81a0ccef919133754fae2608d1a8b04708b329ae5d75e2f5606e8409808b8b456d26b776c28c0ee9a7c39f6f4c1b1ddf038
data/lib/zemu/debug.rb CHANGED
@@ -5,22 +5,50 @@ module Zemu
5
5
  # Loads a map file at the given path, and returns a hash of address => Symbol
6
6
  # for the symbols defined within.
7
7
  def self.load_map(path)
8
- symbols = {}
8
+ symbols = []
9
9
 
10
10
  File.open(path, "r") do |f|
11
11
  f.each_line do |l|
12
12
  s = Symbol.parse(l)
13
13
 
14
- if symbols[s.address].nil?
15
- symbols[s.address] = []
16
- end
14
+ symbols << s
15
+ end
16
+ end
17
17
 
18
- symbols[s.address] << s
19
- symbols[s.address].sort_by!(&:label)
18
+ return Symbols.new(symbols)
19
+ end
20
+
21
+ # Contains a set of symbols.
22
+ # Allows for various lookup operations.
23
+ class Symbols
24
+ # Constructor.
25
+ def initialize(syms)
26
+ @syms = []
27
+ syms.each do |s|
28
+ @syms << s
20
29
  end
21
30
  end
22
31
 
23
- return symbols
32
+ # Access all symbols with a given address.
33
+ def [](address)
34
+ at_address = []
35
+ @syms.each do |s|
36
+ if s.address == address
37
+ at_address << s
38
+ end
39
+ end
40
+
41
+ return at_address.sort_by(&:label)
42
+ end
43
+
44
+ # Find a symbol with a given name.
45
+ def find_by_name(name)
46
+ @syms.each do |s|
47
+ return s if s.label == name
48
+ end
49
+
50
+ return nil
51
+ end
24
52
  end
25
53
 
26
54
  # Represents a symbol definition, of the form `label = address`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zemu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Valentine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zemu is a gem which allows the user to configure a Z80-based system