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