363 |
fun condCons (true, x, xs) = x::xs |
fun condCons (true, x, xs) = x::xs |
364 |
| condCons (false, _, xs) = xs |
| condCons (false, _, xs) = xs |
365 |
|
|
366 |
|
fun verbFrag (tgt : target_desc, parFrag, seqFrag, subs) = |
367 |
|
CL.verbatim [if (#parallel tgt) then parFrag else seqFrag] subs |
368 |
|
|
369 |
fun compile (tgt : target_desc, basename) = let |
fun compile (tgt : target_desc, basename) = let |
370 |
(* generate the C compiler flags *) |
(* generate the C compiler flags *) |
371 |
val cflags = ["-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude] |
val cflags = ["-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude] |
439 |
(CL.T_Ptr(CL.T_Ptr(CL.T_Named tyName)), "inState"), |
(CL.T_Ptr(CL.T_Ptr(CL.T_Named tyName)), "inState"), |
440 |
(CL.T_Ptr(CL.T_Ptr(CL.T_Named tyName)), "outState") |
(CL.T_Ptr(CL.T_Ptr(CL.T_Named tyName)), "outState") |
441 |
] |
] |
442 |
|
val body = if #parallel tgt |
443 |
|
then body @ [ |
444 |
|
(CL.T_Ptr(CL.T_Named "Diderot_Sched_t"), "sched") |
445 |
|
] |
446 |
|
else body |
447 |
in |
in |
448 |
if isTypedef |
if isTypedef |
449 |
then CL.D_StructDef(NONE, body, SOME(ns ^ "World_t")) |
then CL.D_StructDef(NONE, body, SOME(ns ^ "World_t")) |
478 |
val ppStrm = PrintAsC.new outS |
val ppStrm = PrintAsC.new outS |
479 |
fun ppDecl dcl = PrintAsC.output(ppStrm, dcl) |
fun ppDecl dcl = PrintAsC.output(ppStrm, dcl) |
480 |
in |
in |
481 |
(* FIXME: use a fragment for this part of the file *) |
ppDecl (verbFrag (tgt, ParHeadFrag.text, SeqHeadFrag.text, substitutions)); |
|
ppDecl (CL.verbatim [CHeadFrag.text] substitutions); |
|
482 |
ppDecl (genGlobalStruct (tgt, List.rev(!globals))); |
ppDecl (genGlobalStruct (tgt, List.rev(!globals))); |
483 |
ppDecl (genWorldStruct(false, tgt, strand)); |
ppDecl (genWorldStruct(false, tgt, strand)); |
484 |
List.app ppDecl (List.rev (!topDecls)); |
List.app ppDecl (List.rev (!topDecls)); |
491 |
(* FIXME: the XXX_Init function needs to include code to initialize the globals with defaults *) |
(* FIXME: the XXX_Init function needs to include code to initialize the globals with defaults *) |
492 |
ppDecl (CL.verbatim [AllocFrag.text] substitutions); |
ppDecl (CL.verbatim [AllocFrag.text] substitutions); |
493 |
ppDecl (!initially); |
ppDecl (!initially); |
494 |
ppDecl (CL.verbatim [RunFrag.text] substitutions); |
ppDecl (verbFrag (tgt, ParRunFrag.text, SeqRunFrag.text, substitutions)); |
495 |
ppDecl (CL.verbatim [ShutdownFrag.text] substitutions); |
ppDecl (CL.verbatim [ShutdownFrag.text] substitutions); |
496 |
PrintAsC.close ppStrm; |
PrintAsC.close ppStrm; |
497 |
TextIO.closeOut outS |
TextIO.closeOut outS |
528 |
val outS = TextIO.openOut fileName |
val outS = TextIO.openOut fileName |
529 |
val ppStrm = PrintAsC.new outS |
val ppStrm = PrintAsC.new outS |
530 |
fun ppDecl dcl = PrintAsC.output(ppStrm, dcl) |
fun ppDecl dcl = PrintAsC.output(ppStrm, dcl) |
|
val mainFrag = if (#parallel tgt) |
|
|
then ParMainFrag.text |
|
|
else SeqMainFrag.text |
|
531 |
in |
in |
532 |
ppDecl (CL.verbatim [ExecHdr.text] substitutions); |
ppDecl (CL.verbatim [ExecHdr.text] substitutions); |
533 |
ppDecl (genGlobalStruct (tgt, List.rev(!globals))); |
ppDecl (genGlobalStruct (tgt, List.rev(!globals))); |
541 |
(* FIXME: the XXX_Init function needs to include code to initialize the globals with defaults *) |
(* FIXME: the XXX_Init function needs to include code to initialize the globals with defaults *) |
542 |
ppDecl (CL.verbatim [AllocFrag.text] substitutions); |
ppDecl (CL.verbatim [AllocFrag.text] substitutions); |
543 |
ppDecl (!initially); |
ppDecl (!initially); |
544 |
ppDecl (CL.verbatim [RunFrag.text] substitutions); |
ppDecl (verbFrag (tgt, ParRunFrag.text, SeqRunFrag.text, substitutions)); |
545 |
ppDecl (CL.verbatim [ShutdownFrag.text] substitutions); |
ppDecl (CL.verbatim [ShutdownFrag.text] substitutions); |
546 |
ppDecl (CL.verbatim [mainFrag] substitutions); |
ppDecl (verbFrag (tgt, ParMainFrag.text, SeqMainFrag.text, substitutions)); |
547 |
PrintAsC.close ppStrm; |
PrintAsC.close ppStrm; |
548 |
TextIO.closeOut outS |
TextIO.closeOut outS |
549 |
end |
end |