7
7
"""
8
8
import uuid
9
9
from collections import defaultdict
10
- from typing import TYPE_CHECKING , Dict , Set , Optional
10
+ from typing import TYPE_CHECKING , Dict , List , Set , Optional
11
11
12
12
from crytic_compile .compiler .compiler import CompilerVersion
13
13
from crytic_compile .source_unit import SourceUnit
@@ -36,7 +36,7 @@ def __init__(self, crytic_compile: "CryticCompile", unique_id: str):
36
36
self ._source_units : Dict [Filename , SourceUnit ] = {}
37
37
38
38
# set containing all the filenames of this compilation unit
39
- self ._filenames : Set [Filename ] = set ()
39
+ self ._filenames : List [Filename ] = []
40
40
41
41
# mapping from absolute/relative/used to filename
42
42
self ._filenames_lookup : Optional [Dict [str , Filename ]] = None
@@ -114,6 +114,8 @@ def create_source_unit(self, filename: Filename) -> SourceUnit:
114
114
Create the source unit associated with the filename
115
115
Add the relevant info in the compilation unit/crytic compile
116
116
If the source unit already exist, return it
117
+ Also appends filename to the end of filenames, if not already present
118
+ So this function should be called in the order you want filenames to have
117
119
118
120
Args:
119
121
filename (Filename): filename of the source unit
@@ -123,8 +125,9 @@ def create_source_unit(self, filename: Filename) -> SourceUnit:
123
125
"""
124
126
if not filename in self ._source_units :
125
127
source_unit = SourceUnit (self , filename ) # type: ignore
126
- self .filenames .add (filename )
127
128
self ._source_units [filename ] = source_unit
129
+ if filename not in self .filenames :
130
+ self .filenames .append (filename )
128
131
return self ._source_units [filename ]
129
132
130
133
# endregion
@@ -135,20 +138,20 @@ def create_source_unit(self, filename: Filename) -> SourceUnit:
135
138
###################################################################################
136
139
137
140
@property
138
- def filenames (self ) -> Set [Filename ]:
141
+ def filenames (self ) -> List [Filename ]:
139
142
"""Return the filenames used by the compilation unit
140
143
141
144
Returns:
142
- Set [Filename]: Filenames used by the compilation units
145
+ list [Filename]: Filenames used by the compilation units
143
146
"""
144
147
return self ._filenames
145
148
146
149
@filenames .setter
147
- def filenames (self , all_filenames : Set [Filename ]) -> None :
150
+ def filenames (self , all_filenames : List [Filename ]) -> None :
148
151
"""Set the filenames
149
152
150
153
Args:
151
- all_filenames (Set [Filename]): new filenames
154
+ all_filenames (List [Filename]): new filenames
152
155
"""
153
156
self ._filenames = all_filenames
154
157
0 commit comments