Skip to content

Commit 3643b1b

Browse files
committed
Implement SymbolTable
1 parent 61936df commit 3643b1b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/symbol_table.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
module SymbolTable
1+
class SymbolTable
2+
def initialize
3+
@symbols = Hash.new
4+
end
5+
6+
def contains?(symbol)
7+
symbols.key?(symbol)
8+
end
9+
10+
def add_entry(symbol, address)
11+
symbols[symbol] = address
12+
end
13+
14+
def get_address(symbol)
15+
symbols.fetch(symbol)
16+
end
17+
18+
private
19+
20+
attr_reader :symbols
221
end

0 commit comments

Comments
 (0)