Skip to content

Commit 70c1d79

Browse files
Looks like I found a bug in the csr_field type_cache. It was barfing if a different design was passed to it which seems bizzare since it goes out of its way to support having a different type for different designs. So, I modified it to work like the type cache in ast and do what I think it wanted to do in the first place.
1 parent e8465dd commit 70c1d79

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.vscode/launch.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
"args": [],
2020
"askParameters": false
2121
},
22+
{
23+
"type": "rdbg",
24+
"name": "portfolios",
25+
"request": "launch",
26+
"command": "bundle exec rake",
27+
"script": "portfolios",
28+
"args": [],
29+
"askParameters": false
30+
},
2231
{
2332
"type": "rdbg",
2433
"name": "RVA20",

lib/arch_obj_models/csr_field.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def initialize(parent_csr, field_name, field_data)
2727
super(field_data, parent_csr.data_path, parent_csr.arch)
2828
@name = field_name
2929
@parent = parent_csr
30+
@type_cache = {}
3031
end
3132

3233
# @param possible_xlens [Array<Integer>] List of xlens that be used in any implemented mode
@@ -161,11 +162,7 @@ def pruned_type_ast(symtab)
161162
def type(symtab)
162163
raise ArgumentError, "Argument 1 should be a symtab" unless symtab.is_a?(Idl::SymbolTable)
163164

164-
unless @type_cache.nil?
165-
raise "Different design for type #{@type_cache.keys}, #{symtab.design}" unless @type_cache.key?(symtab.design)
166-
167-
return @type_cache[symtab.design]
168-
end
165+
return @type_cache[symtab.design] if @type_cache.key?(symtab.design)
169166

170167
type =
171168
if @data.key?("type")
@@ -210,7 +207,6 @@ def type(symtab)
210207
# end
211208
end
212209

213-
@type_cache ||= {}
214210
@type_cache[symtab.design] = type
215211
end
216212

0 commit comments

Comments
 (0)