Changed the names of generated tock files to have ".tock" before the extension
This helps avoid collisions with pre-existing files, especially .inc files (but also .c and .h)
This commit is contained in:
parent
ea14f568fa
commit
f69030df34
4
Main.hs
4
Main.hs
|
@ -244,7 +244,7 @@ compileFull inputFile moutputFile
|
|||
-- using a stem (input file minus known extension).
|
||||
-- If the extension isn't known, the user must specify
|
||||
-- the output file
|
||||
("-", Just file) -> return file
|
||||
("-", Just file) -> return $ file ++ ".tock"
|
||||
("-", Nothing) -> dieReport (Nothing, "Must specify an output file when using full-compile mode")
|
||||
(file, _) -> return file
|
||||
|
||||
|
@ -287,7 +287,7 @@ compileFull inputFile moutputFile
|
|||
exec $ cCommand postCFile postOFile (csCompilerFlags optsPS)
|
||||
|
||||
cs <- lift getCompState
|
||||
let otherOFiles = [usedFile ++ ".o"
|
||||
let otherOFiles = [usedFile ++ ".tock.o"
|
||||
| usedFile <- Set.toList $ csUsedFiles cs]
|
||||
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ cgenTopLevel headerName s
|
|||
|
||||
tell ["#include \"", dropPath headerName, "\"\n"]
|
||||
|
||||
sequence_ [tell ["#include \"", usedFile, ".h\"\n"]
|
||||
sequence_ [tell ["#include \"", usedFile, ".tock.h\"\n"]
|
||||
| usedFile <- Set.toList $ csUsedFiles cs]
|
||||
|
||||
sequence_ [tell ["extern int "] >> genName n >> tell ["_stack_size;\n"]
|
||||
|
|
|
@ -6,15 +6,15 @@ tests = $(patsubst %.occ,%,$(wildcard cgtests/cgtest??.occ))
|
|||
all: $(tests)
|
||||
|
||||
clean:
|
||||
rm -f $(tests) cgtests/cglib.inc
|
||||
rm -f $(tests) cgtests/cglib.tock.inc
|
||||
|
||||
checkout:
|
||||
svn co http://projects.cs.kent.ac.uk/projects/kroc/svn/kroc/trunk/tests/cgtests
|
||||
|
||||
%: %.occ cgtests/cglib.inc
|
||||
./tock -vk --backend=$(BACKEND) --usage-checking=off --run-indent -o $@ $<
|
||||
%: %.occ cgtests/cglib.tock.inc
|
||||
./tock -vk --backend=$(BACKEND) --usage-checking=off --run-indent $<
|
||||
|
||||
cgtests/cglib.inc: cgtests/cglib.occ
|
||||
cgtests/cglib.tock.inc: cgtests/cglib.occ
|
||||
./tock -vk --backend=$(BACKEND) --usage-checking=off --run-indent --no-main $<
|
||||
|
||||
run: $(tests)
|
||||
|
|
|
@ -65,9 +65,9 @@ preprocessFile m filename
|
|||
= do (handle, realFilename) <- searchFile m filename
|
||||
progress $ "Loading source file " ++ realFilename
|
||||
origCS <- get
|
||||
let modFunc = if drop4 filename `Set.member` csUsedFiles origCS
|
||||
then Set.insert (drop4 realFilename)
|
||||
. Set.delete (drop4 filename)
|
||||
let modFunc = if drop9 filename `Set.member` csUsedFiles origCS
|
||||
then Set.insert (drop9 realFilename)
|
||||
. Set.delete (drop9 filename)
|
||||
else id
|
||||
modify (\cs -> cs { csCurrentFile = realFilename
|
||||
, csUsedFiles = modFunc $ csUsedFiles cs })
|
||||
|
@ -76,8 +76,8 @@ preprocessFile m filename
|
|||
modify (\cs -> cs { csCurrentFile = csCurrentFile origCS })
|
||||
return toks
|
||||
where
|
||||
-- drops 4 from the end:
|
||||
drop4 = reverse . drop 4 . reverse
|
||||
-- drops 9 (i.e. length ".tock.inc") from the end:
|
||||
drop9 = reverse . drop 9 . reverse
|
||||
|
||||
-- | Preprocesses source directly and returns its tokenised form ready for parsing.
|
||||
preprocessSource :: Meta -> String -> String -> PassM [Token]
|
||||
|
@ -199,7 +199,7 @@ handleUse m [modName]
|
|||
put $ cs { csUsedFiles = Set.insert incName (csUsedFiles cs) }
|
||||
if Set.member incName (csUsedFiles cs)
|
||||
then return return
|
||||
else handleInclude m [incName ++ ".inc"]
|
||||
else handleInclude m [incName ++ ".tock.inc"]
|
||||
where
|
||||
-- | If a module name has a suffix, strip it
|
||||
mangleModName :: String -> String
|
||||
|
|
Loading…
Reference in New Issue
Block a user