Skip to content

Commit f8d9ec7

Browse files
committed
Some dict instances are replaced with collections.OrderedDict.
1 parent 7ca6eb7 commit f8d9ec7

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

dataflow/subset.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import sys
1111
import os
12+
import collections
1213

1314
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) )
1415

@@ -47,7 +48,7 @@ def getBindSubset(self, termname, visited_sources=set()):
4748
if term is None: raise verror.DefinitionError('No such signal')
4849
bindlist = self.getBindlist(termname)
4950
nextsources = visited_sources.copy()
50-
ret_binds = {}
51+
ret_binds = collections.OrderedDict()
5152
for bind in bindlist:
5253
if not termname in ret_binds:
5354
ret_binds[termname] = []
@@ -70,7 +71,7 @@ def getBindSubset(self, termname, visited_sources=set()):
7071

7172
############################################################################
7273
def getBindSourceSubset(self, targets):
73-
visited_binddict = {}
74+
visited_binddict = collections.OrderedDict()
7475
visited_sources = set()
7576
for target in targets:
7677
termname = util.toTermname(target)
@@ -90,11 +91,11 @@ def getSubset(self, targets):
9091
return self._discretion(visited_binddict, visited_sources)
9192

9293
def _discretion(self, visited_binddict, visited_sources):
93-
terms = {}
94-
parameter = {}
95-
assign = {}
96-
always_clockedge = {}
97-
always_combination = {}
94+
terms = collections.OrderedDict()
95+
parameter = collections.OrderedDict()
96+
assign = collections.OrderedDict()
97+
always_clockedge = collections.OrderedDict()
98+
always_combination = collections.OrderedDict()
9899

99100
# discretion the signal desclaration
100101
for source in visited_sources:

dataflow/visit.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def getParamNames(self):
179179

180180
class DefinitionInfoTable(object):
181181
def __init__(self):
182-
self.dict = {}
182+
self.dict = collections.OrderedDict()
183183
self.current = None
184184
def addDefinition(self, name, definition):
185185
if name in self.dict:
@@ -264,8 +264,8 @@ def __init__(self, name, previous, frametype='none',
264264
self.variables = Variables()
265265
self.functions = FunctionInfoTable()
266266
self.tasks = TaskInfoTable()
267-
self.blockingassign = {}
268-
self.nonblockingassign = {}
267+
self.blockingassign = collections.OrderedDict()
268+
self.nonblockingassign = collections.OrderedDict()
269269

270270
self.modulename = modulename
271271

@@ -541,28 +541,28 @@ def getAllInstances(self):
541541
return tuple(ret)
542542

543543
def getAllSignals(self):
544-
ret = {}
544+
ret = collections.OrderedDict()
545545
for dk, dv in self.dict.items():
546546
ret.update(
547547
map_key((lambda x: dk+ScopeLabel(x,'signal')), dv.getSignals()))
548548
return ret
549549

550550
def getAllConsts(self):
551-
ret = {}
551+
ret = collections.OrderedDict()
552552
for dk, dv in self.dict.items():
553553
ret.update(
554554
map_key((lambda x: dk+ScopeLabel(x,'signal')), dv.getConsts()))
555555
return ret
556556

557557
def getAllFunctions(self):
558-
ret = {}
558+
ret = collections.OrderedDict()
559559
for dk, dv in self.dict.items():
560560
ret.update(
561561
map_key((lambda x: dk+ScopeLabel(x,'function')), dv.getFunctions()))
562562
return ret
563563

564564
def getAllTasks(self):
565-
ret = {}
565+
ret = collections.OrderedDict()
566566
for dk, dv in self.dict.items():
567567
ret.update(
568568
map_key((lambda x: dk+ScopeLabel(x,'task')), dv.getTasks()))
@@ -640,9 +640,9 @@ def getNonblockingAssigns(self):
640640

641641
def getPreviousNonblockingAssign(self):
642642
previous = self.dict[self.current].previous
643-
if len(previous) == 0: return {}
643+
if len(previous) == 0: return collections.OrderedDict()
644644
previous_frame = self.dict[previous]
645-
if not previous_frame.isAlways(): return {}
645+
if not previous_frame.isAlways(): return collections.OrderedDict()
646646
return previous_frame.getNonblockingAssigns()
647647

648648
def searchConstantDefinition(self, key, name):

0 commit comments

Comments
 (0)