@@ -81,45 +81,6 @@ def to_ast(*filelist, **opt):
8181 return ast
8282
8383#-------------------------------------------------------------------------------
84- def str_to_signed (s ):
85- targ = s .replace ('_' ,'' )
86- match = re .search (r's(.+)' , targ )
87- if match is not None :
88- return True
89- return False
90-
91- def str_to_value (s ):
92- targ = s .replace ('_' ,'' )
93- match = re .search (r'h(.+)' , targ )
94- if match is not None :
95- return int (match .group (1 ), 16 ), 16
96- match = re .search (r'd(.+)' , targ )
97- if match is not None :
98- return int (match .group (1 ), 10 ), 10
99- match = re .search (r'o(.+)' , targ )
100- if match is not None :
101- return int (match .group (1 ), 8 ), 8
102- match = re .search (r'b(.+)' , targ )
103- if match is not None :
104- return int (match .group (1 ), 2 ), 2
105- return int (targ , 10 ), None
106-
107- def str_to_width (s ):
108- targ = s .replace ('_' ,'' )
109- match = re .search (r'(.+)\'h.+' , targ )
110- if match is not None :
111- return int (match .group (1 ), 10 )
112- match = re .search (r'(.+)\'d.+' , targ )
113- if match is not None :
114- return int (match .group (1 ), 10 )
115- match = re .search (r'(.+)\'o.+' , targ )
116- if match is not None :
117- return int (match .group (1 ), 10 )
118- match = re .search (r'(.+)\'b.+' , targ )
119- if match is not None :
120- return int (match .group (1 ), 10 )
121- return None
122-
12384def to_tuple (s ):
12485 if not isinstance (s , (list , tuple )):
12586 return tuple ([s ])
@@ -205,9 +166,9 @@ def visit_Identifier(self, node):
205166 return self .m .find_identifier (node .name )
206167
207168 def visit_IntConst (self , node ):
208- value , base = str_to_value (node .value )
209- width = str_to_width (node .value )
210- signed = str_to_signed (node .value )
169+ value , base = vtypes . str_to_value (node .value )
170+ width = vtypes . str_to_width (node .value )
171+ signed = vtypes . str_to_signed (node .value )
211172 return vtypes .Int (value , width , base , signed )
212173
213174 def visit_FloatConst (self , node ):
0 commit comments