Skip to content

Commit ff08a15

Browse files
committed
Fix #713, actually delete old generated files
1 parent 824ee27 commit ff08a15

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

grammars/silver/compiler/translation/java/driver/BuildProcess.sv

+2-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ IO<()> ::= silverGen::String keepFiles::[String] r::Decorated RootSpec
246246
exit(-5);
247247
});
248248
});
249-
oldSrcFiles::[String] <- listContents(srcPath);
249+
srcDirContents::[String] <- listContents(srcPath);
250+
oldSrcFiles::[String] <- filterM(isFile, map(append(srcPath, _), srcDirContents));
250251
deleteFiles(removeAll(keepFiles, oldSrcFiles));
251252
deleteDirFiles(binPath);
252253
writeFiles(srcPath, r.genFiles);

grammars/silver/core/List.sv

+23
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,29 @@ function filter
172172
else filter(f, tail(lst));
173173
}
174174

175+
@{--
176+
- Monadic (actually Applicative) version of filter
177+
-
178+
- @param f The filter function
179+
- @param lst The input list to filter
180+
- @return Only those elements of 'lst' that 'f' returns true for, in the
181+
- same order as they appeared in 'lst'
182+
-}
183+
function filterM
184+
Applicative m =>
185+
m<[a]> ::= f::(m<Boolean> ::= a) lst::[a]
186+
{
187+
return
188+
case lst of
189+
| [] -> pure([])
190+
| h :: t -> do {
191+
cond::Boolean <- f(h);
192+
rest::[a] <- filterM(f, t);
193+
return if cond then h :: rest else rest;
194+
}
195+
end;
196+
}
197+
175198
@{--
176199
- Partition a list in two
177200
-

0 commit comments

Comments
 (0)