-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsym.rb
More file actions
40 lines (31 loc) · 757 Bytes
/
sym.rb
File metadata and controls
40 lines (31 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$NSYMBOLS = 1024
class GlobalSymTab
attr_reader :names
def initialize
@globs = 0
@names = {}
end
def findglob(s)
@names.each do |i, props|
if props["name"] == s
return i
end
end
return -1
end
def newglob
if (p = (@globs += 1)) > $NSYMBOLS
puts "too many globals"
exit(1)
end
p
end
def addglob(name, type=nil, s_type=nil, endlabel=nil)
if ((y = findglob(name)) != -1)
return y
end
y = newglob
@names[y] = {"name" => name, "type" => type, "s_type" => s_type, "endlabel" => endlabel}
y
end
end