@@ -14,7 +14,13 @@ use resolver::{
14
14
} ;
15
15
use static_analyzer:: context:: AnalysisContext ;
16
16
use std:: {
17
- cell:: RefCell , env, io:: { self , Write } , path:: Path , process:: exit, rc:: Rc , sync:: { Arc , Mutex }
17
+ cell:: RefCell ,
18
+ env,
19
+ io:: { self , Write } ,
20
+ path:: Path ,
21
+ process:: exit,
22
+ rc:: Rc ,
23
+ sync:: { Arc , Mutex } ,
18
24
} ;
19
25
use typed_ast:: { ModuleID , TypedProgramTree } ;
20
26
use utils:: fs:: { ensure_output_dir, get_directory_of_file} ;
@@ -64,8 +70,13 @@ fn get_program_trees(
64
70
{
65
71
for ( _, _, module_id, typed_program_tree) in program_trees. iter ( ) {
66
72
{
67
- let mut analyzer =
68
- AnalysisContext :: new ( & resolver, * module_id, typed_program_tree. clone ( ) , entry_points. clone ( ) , options. disable_warnings ) ;
73
+ let mut analyzer = AnalysisContext :: new (
74
+ & resolver,
75
+ * module_id,
76
+ typed_program_tree. clone ( ) ,
77
+ entry_points. clone ( ) ,
78
+ options. disable_warnings ,
79
+ ) ;
69
80
analyzer. analyze ( ) ;
70
81
DiagReporter :: display ( & analyzer. reporter ) ;
71
82
if analyzer. reporter . has_errors ( ) {
@@ -92,7 +103,10 @@ fn prepare_compilation(
92
103
Vec < ( String , ModuleFilePath , ModuleID , Rc < RefCell < TypedProgramTree > > ) > ,
93
104
Rc < Resolver > ,
94
105
) {
95
- let opts = options. to_compiler_options ( ) ;
106
+ let mut opts = options. to_compiler_options ( ) ;
107
+ if file_path. is_some ( ) {
108
+ opts. disable_modulefs_cache = true ;
109
+ }
96
110
let file_path = get_entry_source_code_path ( options. base_path . clone ( ) , file_path) ;
97
111
let final_build_dir = get_final_build_directory_path ( options. base_path . clone ( ) , opts. build_dir . clone ( ) ) ;
98
112
ensure_build_dir_subs ( options. base_path . clone ( ) , final_build_dir. clone ( ) ) ;
@@ -103,9 +117,7 @@ fn prepare_compilation(
103
117
}
104
118
105
119
pub ( crate ) fn command_run ( mut options : CompilerOptions , file_path : Option < String > ) {
106
- let ( mut opts, file_path, final_build_dir, program_trees, resolver_rc) =
107
- prepare_compilation ( & mut options, file_path) ;
108
- opts. disable_modulefs_cache = true ;
120
+ let ( opts, file_path, final_build_dir, program_trees, resolver_rc) = prepare_compilation ( & mut options, file_path) ;
109
121
110
122
let mut temp = env:: temp_dir ( ) ;
111
123
temp. push ( "path" ) ;
@@ -131,7 +143,6 @@ pub(crate) fn command_run(mut options: CompilerOptions, file_path: Option<String
131
143
}
132
144
133
145
pub ( crate ) fn command_emit_llvm ( mut options : CompilerOptions , file_path : Option < String > , output_path : Option < String > ) {
134
- options. disable_modulefs_cache = true ;
135
146
let ( opts, file_path, final_build_dir, program_trees, resolver_rc) = prepare_compilation ( & mut options, file_path) ;
136
147
137
148
let output_path = output_path. unwrap_or_else ( || {
@@ -154,7 +165,6 @@ pub(crate) fn command_emit_bytecode(
154
165
file_path : Option < String > ,
155
166
output_path : Option < String > ,
156
167
) {
157
- options. disable_modulefs_cache = true ;
158
168
let ( opts, file_path, final_build_dir, program_trees, resolver_rc) = prepare_compilation ( & mut options, file_path) ;
159
169
160
170
let output_path = output_path. unwrap_or_else ( || {
@@ -177,7 +187,6 @@ pub(crate) fn command_emit_bytecode(
177
187
}
178
188
179
189
pub ( crate ) fn command_emit_asm ( mut options : CompilerOptions , file_path : Option < String > , output_path : Option < String > ) {
180
- options. disable_modulefs_cache = true ;
181
190
let ( opts, file_path, final_build_dir, program_trees, resolver_rc) = prepare_compilation ( & mut options, file_path) ;
182
191
183
192
let output_path = output_path. unwrap_or_else ( || {
@@ -217,7 +226,6 @@ pub(crate) fn command_build(mut options: CompilerOptions, file_path: Option<Stri
217
226
}
218
227
219
228
pub ( crate ) fn command_object ( mut options : CompilerOptions , file_path : Option < String > , output_path : Option < String > ) {
220
- options. disable_modulefs_cache = true ;
221
229
let ( opts, file_path, final_build_dir, program_trees, resolver_rc) = prepare_compilation ( & mut options, file_path) ;
222
230
223
231
let output_path = output_path. unwrap_or_else ( || {
@@ -236,7 +244,6 @@ pub(crate) fn command_object(mut options: CompilerOptions, file_path: Option<Str
236
244
}
237
245
238
246
pub ( crate ) fn command_dylib ( mut options : CompilerOptions , file_path : Option < String > , output_path : Option < String > ) {
239
- options. disable_modulefs_cache = true ;
240
247
let ( opts, file_path, final_build_dir, program_trees, resolver_rc) = prepare_compilation ( & mut options, file_path) ;
241
248
242
249
let output_path = output_path. unwrap_or_else ( || {
0 commit comments