@@ -22,10 +22,11 @@ codegenC :: [(Name, SDecl)] ->
22 String -> -- output file name
22 String -> -- output file name
23 Bool -> -- generate executable if True, only .o if False
23 Bool -> -- generate executable if True, only .o if False
24 [FilePath] -> -- include files
24 [FilePath] -> -- include files
25+ String -> -- extra object files
25 String -> -- extra compiler flags
26 String -> -- extra compiler flags
26 DbgLevel ->
27 DbgLevel ->
28−codegenC defs out exec incs libs dbg
29+codegenC defs out exec incs objs libs dbg
29 = do -- print defs
30 = do -- print defs
30 let bc = map toBC defs
31 let bc = map toBC defs
31 let h = concatMap toDecl (map fst bc)
32 let h = concatMap toDecl (map fst bc)
@@ -38,7 +39,9 @@ codegenC defs out exec incs libs dbg
38 hPutStr tmph cout
39 hPutStr tmph cout
39 hFlush tmph
40 hFlush tmph
40 hClose tmph
41 hClose tmph
41− let gcc = "gcc -x c " ++
42+ let useclang = False
43+ let comp = if useclang then "clang" else "gcc"
44+ let gcc = comp ++ " -I. " ++ objs ++ " -x c " ++
42 (if exec then "" else " - c ") ++
45 (if exec then "" else " - c ") ++
43 gccDbg dbg ++
46 gccDbg dbg ++
44 " " ++ tmpn ++
47 " " ++ tmpn ++
@@ -150,7 +153,7 @@ bcc i (ERROR str) = indent i ++ "fprintf(stderr, " ++ show str ++ "); assert(0);
151c_irts FInt l x = l ++ "MKINT((i_int)(" ++ x ++ "))"
154c_irts FInt l x = l ++ "MKINT((i_int)(" ++ x ++ "))"
152c_irts FChar l x = l ++ "MKINT((i_int)(" ++ x ++ "))"
155c_irts FChar l x = l ++ "MKINT((i_int)(" ++ x ++ "))"
153−c_irts FString l x = l ++ "MKSTR(" ++ x ++ ")"
156+c_irts FString l x = l ++ "MKSTR(vm, " ++ x ++ ")"
154c_irts FUnit l x = x
157c_irts FUnit l x = x
155c_irts FPtr l x = l ++ "MKPTR(vm, " ++ x ++ ")"
158c_irts FPtr l x = l ++ "MKPTR(vm, " ++ x ++ ")"
156c_irts FDouble l x = l ++ "MKFLOAT(vm, " ++ x ++ ")"
159c_irts FDouble l x = l ++ "MKFLOAT(vm, " ++ x ++ ")"