2 /* --------------------------------------------------------------------------
3 * Translator: generates stg code from output of pattern matching
6 * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
7 * Yale Haskell Group, and the Oregon Graduate Institute of Science and
8 * Technology, 1994-1999, All rights reserved. It is distributed as
9 * free software under the license in the file "License", which is
10 * included in the distribution.
12 * $RCSfile: translate.c,v $
14 * $Date: 1999/11/12 17:32:48 $
15 * ------------------------------------------------------------------------*/
24 #include "Assembler.h"
27 /* ---------------------------------------------------------------- */
29 static StgVar local stgOffset Args((Offset,List));
30 static StgVar local stgText Args((Text,List));
31 static StgRhs local stgRhs Args((Cell,Int,List,StgExpr));
32 static StgCaseAlt local stgCaseAlt Args((Cell,Int,List,StgExpr));
33 static StgExpr local stgExpr Args((Cell,Int,List,StgExpr));
35 /* ---------------------------------------------------------------- */
37 /* Association list storing globals assigned to */
38 /* dictionaries, tuples, etc */
39 List stgGlobals = NIL;
41 static StgVar local getSTGTupleVar Args((Cell));
43 static StgVar local getSTGTupleVar( Cell d )
45 Pair p = cellAssoc(d,stgGlobals);
46 /* Yoiks - only the Prelude sees Tuple decls! */
48 implementTuple(tupleOf(d));
49 p = cellAssoc(d,stgGlobals);
55 /* ---------------------------------------------------------------- */
57 static Cell local stgOffset(Offset o, List sc)
59 Cell r = cellAssoc(o,sc);
64 static Cell local stgText(Text t,List sc)
67 for (; nonNull(xs); xs=tl(xs)) {
70 if (!isOffset(v) && t == textOf(v)) {
77 /* ---------------------------------------------------------------- */
79 static StgRhs local stgRhs(e,co,sc,failExpr)
88 return stgOffset(e,sc);
91 return stgText(textOf(e),sc);
93 return getSTGTupleVar(e);
98 return mkStgCon(nameMkC,singleton(e));
100 return mkStgCon(nameMkI,singleton(e));
102 return mkStgCon(nameMkInteger,singleton(e));
104 return mkStgCon(nameMkD,singleton(e));
106 #if USE_ADDR_FOR_STRINGS
108 StgVar v = mkStgVar(mkStgCon(nameMkA,singleton(e)),NIL);
109 return mkStgLet(singleton(v),
110 makeStgApp(nameUnpackString,singleton(v)));
113 return mkStgApp(nameUnpackString,singleton(e));
116 return stgExpr(e,co,sc,namePMFail);
120 return stgExpr(e,co,sc,failExpr/*namePMFail*/);
124 static StgCaseAlt local stgCaseAlt(alt,co,sc,failExpr)
130 StgDiscr d = fst(alt);
131 Int da = discrArity(d);
134 for(i=1; i<=da; ++i) {
135 StgVar nv = mkStgVar(NIL,NIL);
137 sc = cons(pair(mkOffset(co+i),nv),sc);
139 return mkStgCaseAlt(d,vs,stgExpr(snd(alt),co+da,sc,failExpr));
142 static StgExpr local stgExpr(e,co,sc,failExpr)
151 return makeStgIf(stgExpr(fst3(snd(e)),co,sc,namePMFail),
152 stgExpr(snd3(snd(e)),co,sc,failExpr),
153 stgExpr(thd3(snd(e)),co,sc,failExpr));
157 List guards = reverse(snd(e));
159 for(; nonNull(guards); guards=tl(guards)) {
161 Cell c = stgExpr(fst(g),co,sc,namePMFail);
162 Cell rhs = stgExpr(snd(g),co,sc,failExpr);
163 e = makeStgIf(c,rhs,e);
169 StgExpr e2 = stgExpr(snd(snd(e)),co,sc,failExpr);
170 StgVar alt = mkStgVar(e2,NIL);
171 return mkStgLet(singleton(alt),stgExpr(fst(snd(e)),co,sc,alt));
175 List alts = snd(snd(e));
176 Cell scrut = stgExpr(fst(snd(e)),co,sc,namePMFail);
179 } else if (isChar(fst(hd(alts)))) {
181 StgDiscr d = fst(alt);
183 mkStgCon(nameMkC,singleton(d)),NIL);
184 StgExpr test = nameEqChar;
185 /* duplicates scrut but it should be atomic */
187 makeStgLet(singleton(c),
188 makeStgApp(test,doubleton(scrut,c))),
189 stgExpr(snd(alt),co,sc,failExpr),
190 stgExpr(ap(CASE,pair(fst(snd(e)),
191 tl(alts))),co,sc,failExpr));
194 for(; nonNull(alts); alts=tl(alts)) {
195 as = cons(stgCaseAlt(hd(alts),co,sc,failExpr),as);
201 singleton(mkStgDefault(mkStgVar(NIL,NIL),
209 Cell discr = snd3(nc);
211 Cell scrut = stgOffset(o,sc);
212 Cell h = getHead(discr);
213 Int da = discrArity(discr);
216 if (whatIs(h) == ADDPAT && argCount == 1) {
217 /* ADDPAT num dictIntegral
219 * let n = fromInteger num in
220 * if pmLe dictIntegral n scrut
221 * then let v = pmSubtract dictIntegral scrut v
225 Cell dictIntegral = arg(discr); /* Integral dictionary */
228 StgVar dIntegral = NIL;
230 /* bind dictionary */
231 dIntegral = stgRhs(dictIntegral,co,sc,namePMFail);
232 if (!isAtomic(dIntegral)) { /* wasn't atomic */
233 dIntegral = mkStgVar(dIntegral,NIL);
234 binds = cons(dIntegral,binds);
237 n = mkStgVar(mkStgCon(nameMkInteger,singleton(n)),NIL);
238 binds = cons(n,binds);
240 /* coerce number to right type (using Integral dict) */
241 n = mkStgVar(mkStgApp(
242 namePmFromInteger,doubleton(dIntegral,n)),NIL);
243 binds = cons(n,binds);
246 v = mkStgVar(mkStgApp(
247 namePmSubtract,tripleton(dIntegral,scrut,n)),NIL);
252 mkStgApp(namePmLe,tripleton(dIntegral,n,scrut)),
253 mkStgLet(singleton(v),
256 cons(pair(mkOffset(co),v),sc),
262 assert(isName(h) && argCount == 2);
264 /* This code is rather ugly.
265 * We ought to desugar it using one of the following:
266 * if (==) dEq (fromInt dNum pat) scrut
267 * if (==) dEq (fromInteger dNum pat) scrut
268 * if (==) dEq (fromFloat dFractional pat) scrut
269 * But it would be very hard to obtain the Eq dictionary
270 * from the Num or Fractional dictionary we have.
271 * Instead, we rely on the Prelude to supply 3 helper
272 * functions which do the test for us.
273 * primPmInt :: Num a => Int -> a -> Bool
274 * primPmInteger :: Num a => Integer -> a -> Bool
275 * primPmDouble :: Fractional a => Double -> a -> Bool
278 Cell dict = arg(fun(discr));
283 = h == nameFromInt ? nameMkI
284 : h == nameFromInteger ? nameMkInteger
287 = h == nameFromInt ? namePmInt
288 : h == nameFromInteger ? namePmInteger
294 for(i=1; i<=da; ++i) {
295 Cell nv = mkStgVar(NIL,NIL);
297 altsc = cons(pair(mkOffset(co+i),nv),altsc);
299 /* bind dictionary */
300 d = stgRhs(dict,co,sc,namePMFail);
301 if (!isAtomic(d)) { /* wasn't atomic */
303 binds = cons(d,binds);
306 n = mkStgVar(mkStgCon(box,singleton(n)),NIL);
307 binds = cons(n,binds);
312 mkStgApp(testFun,tripleton(d,n,scrut))),
313 stgExpr(r,co+da,altsc,failExpr),
324 /* allocate variables, extend scope */
325 for(bs = snd(fst(snd(e))); nonNull(bs); bs=tl(bs)) {
326 Cell nv = mkStgVar(NIL,NIL);
327 sc = cons(pair(fst3(hd(bs)),nv),sc);
328 binds = cons(nv,binds);
331 for(bs = fst(fst(snd(e))); nonNull(bs); bs=tl(bs)) {
332 Cell nv = mkStgVar(NIL,NIL);
333 sc = cons(pair(mkOffset(++co),nv),sc);
334 binds = cons(nv,binds);
338 /* transform functions */
339 for(bs = snd(fst(snd(e))); nonNull(bs); bs=tl(bs), vs=tl(vs)) {
344 Int arity = intOf(snd3(fun));
346 for(i=1; i<=arity; ++i) {
347 Cell v = mkStgVar(NIL,NIL);
349 funsc = cons(pair(mkOffset(co+i),v),funsc);
354 stgExpr(thd3(thd3(fun)),co+arity,funsc,namePMFail));
356 /* transform expressions */
357 for(bs = fst(fst(snd(e))); nonNull(bs); bs=tl(bs), vs=tl(vs)) {
360 stgVarBody(nv) = stgRhs(rhs,co,sc,namePMFail);
362 return mkStgLet(binds,stgRhs(snd(snd(e)),co,sc,failExpr/*namePMFail*/));
365 default: /* convert to an StgApp or StgVar plus some bindings */
375 args = cons(arg,args);
379 if (e == nameSel && length(args) == 3) {
382 StgVar v = stgOffset(hd(tl(args)),sc);
384 StgExpr v = stgExpr(hd(tl(args)),co,sc,namePMFail);
386 Int ix = intOf(hd(tl(tl(args))));
387 Int da = discrArity(con);
390 for(i=1; i<=da; ++i) {
391 Cell nv = mkStgVar(NIL,NIL);
396 doubleton(mkStgCaseAlt(con,vs,nth(ix-1,vs)),
397 mkStgDefault(mkStgVar(NIL,NIL),namePMFail)));
400 /* Arguments must be StgAtoms */
401 for(as=args; nonNull(as); as=tl(as)) {
402 StgRhs a = stgRhs(hd(as),co,sc,namePMFail);
403 #if 1 /* optional flattening of let bindings */
404 if (whatIs(a) == LETREC) {
405 binds = appendOnto(stgLetBinds(a),binds);
412 binds = cons(a,binds);
417 /* Function must be StgVar or Name */
418 e = stgRhs(e,co,sc,namePMFail);
419 if (!isStgVar(e) && !isName(e)) {
421 binds = cons(e,binds);
424 return makeStgLet(binds,makeStgApp(e,args));
429 #if 0 /* apparently not used */
430 static Void ppExp( Name n, Int arity, Cell e )
432 if (1 || debugCode) {
434 printf("%s", textToStr(name(n).text));
435 for (i = arity; i > 0; i--) {
446 Void stgDefn( Name n, Int arity, Cell e )
451 for (i = 1; i <= arity; ++i) {
452 Cell nv = mkStgVar(NIL,NIL);
454 sc = cons(pair(mkOffset(i),nv),sc);
456 stgVarBody(name(n).stgVar)
457 = makeStgLambda(vs,stgExpr(e,arity,sc,namePMFail));
460 Void implementCfun(c,scs) /* Build implementation for constr */
461 Name c; /* fun c. scs lists integers (1..)*/
462 List scs; { /* in incr order of strict comps. */
463 Int a = name(c).arity;
466 StgVar vcurr, e1, v, vsi;
467 List args = makeArgs(a);
468 StgVar v0 = mkStgVar(mkStgCon(c,args),NIL);
469 List binds = singleton(v0);
472 for (; nonNull(scs); scs=tl(scs)) {
473 vsi = nth(intOf(hd(scs))-1,args);
474 vcurr = mkStgVar(mkStgApp(namePrimSeq,doubleton(vsi,vcurr)), NIL);
475 binds = cons(vcurr,binds);
478 e1 = mkStgLet(binds,vcurr);
479 v = mkStgVar(mkStgLambda(args,e1),NIL);
482 StgVar v = mkStgVar(mkStgCon(c,NIL),NIL);
485 stgGlobals = cons(pair(c,name(c).stgVar),stgGlobals);
486 /* printStg(stderr, name(c).stgVar); fprintf(stderr,"\n\n"); */
489 /* --------------------------------------------------------------------------
490 * Foreign function calls and primops
491 * ------------------------------------------------------------------------*/
493 /* Outbound denotes data moving from Haskell world to elsewhere.
494 Inbound denotes data moving from elsewhere to Haskell world.
496 static String charListToString ( List cs );
497 static Cell foreignTy ( Bool outBound, Type t );
498 static Cell foreignOutboundTy ( Type t );
499 static Cell foreignInboundTy ( Type t );
500 static Name repToBox ( char c );
501 static StgRhs makeStgPrim ( Name,Bool,List,String,String );
503 static String charListToString( List cs )
508 assert( length(cs) < 100 );
509 for(; nonNull(cs); ++i, cs=tl(cs)) {
510 s[i] = charOf(hd(cs));
513 return textToStr(findText(s));
516 static Cell foreignTy ( Bool outBound, Type t )
518 if (t == typeChar) return mkChar(CHAR_REP);
519 else if (t == typeInt) return mkChar(INT_REP);
521 else if (t == typeInteger)return mkChar(INTEGER_REP);
523 else if (t == typeWord) return mkChar(WORD_REP);
524 else if (t == typeAddr) return mkChar(ADDR_REP);
525 else if (t == typeFloat) return mkChar(FLOAT_REP);
526 else if (t == typeDouble) return mkChar(DOUBLE_REP);
527 else if (t == typeStable) return mkChar(STABLE_REP);
528 #ifdef PROVIDE_FOREIGN
529 else if (t == typeForeign)return mkChar(FOREIGN_REP);
530 /* ToDo: argty only! */
533 else if (t == typePrimByteArray) return mkChar(BARR_REP);
534 /* ToDo: argty only! */
535 else if (whatIs(t) == AP) {
537 if (h == typePrimMutableByteArray) return mkChar(MUTBARR_REP);
538 /* ToDo: argty only! */
541 /* ToDo: decent line numbers! */
543 ERRMSG(0) "Illegal outbound (away from Haskell) type" ETHEN
544 ERRTEXT " \"" ETHEN ERRTYPE(t);
548 ERRMSG(0) "Illegal inbound (towards Haskell) type" ETHEN
549 ERRTEXT " \"" ETHEN ERRTYPE(t);
555 static Cell foreignOutboundTy ( Type t )
557 return foreignTy ( TRUE, t );
560 static Cell foreignInboundTy ( Type t )
562 return foreignTy ( FALSE, t );
565 static Name repToBox( char c )
568 case CHAR_REP: return nameMkC;
569 case INT_REP: return nameMkI;
570 case INTEGER_REP: return nameMkInteger;
571 case WORD_REP: return nameMkW;
572 case ADDR_REP: return nameMkA;
573 case FLOAT_REP: return nameMkF;
574 case DOUBLE_REP: return nameMkD;
575 case ARR_REP: return nameMkPrimArray;
576 case BARR_REP: return nameMkPrimByteArray;
577 case REF_REP: return nameMkRef;
578 case MUTARR_REP: return nameMkPrimMutableArray;
579 case MUTBARR_REP: return nameMkPrimMutableByteArray;
580 case STABLE_REP: return nameMkStable;
582 case WEAK_REP: return nameMkWeak;
584 #ifdef PROVIDE_FOREIGN
585 case FOREIGN_REP: return nameMkForeign;
587 #ifdef PROVIDE_CONCURRENT
588 case THREADID_REP: return nameMkThreadId;
589 case MVAR_REP: return nameMkMVar;
595 static StgPrimAlt boxResults( String reps, StgVar state )
597 List rs = NIL; /* possibly unboxed results */
598 List bs = NIL; /* boxed results of wrapper */
599 List rbinds = NIL; /* bindings used to box results */
602 for(i=0; reps[i] != '\0'; ++i) {
603 StgRep k = mkStgRep(reps[i]);
604 Cell v = mkStgPrimVar(NIL,k,NIL);
605 Name box = repToBox(reps[i]);
609 StgRhs rhs = mkStgCon(box,singleton(v));
610 StgVar bv = mkStgVar(rhs,NIL); /* boxed */
612 rbinds = cons(bv,rbinds);
616 /* Construct tuple of results */
619 } else { /* includes i==0 case */
620 StgVar r = mkStgVar(mkStgCon(mkTuple(i),rev(bs)),NIL);
621 rbinds = cons(r,rbinds);
624 /* construct result pair if needed */
625 if (nonNull(state)) {
626 /* Note that this builds a tuple directly - we know it's
629 StgVar r = mkStgVar(mkStgCon(mkTuple(2),doubleton(e,state)),NIL);
630 rbinds = cons(r,rbinds);
631 rs = cons(state,rs); /* last result is a state */
634 return mkStgPrimAlt(rev(rs),makeStgLet(rbinds,e));
637 static List mkUnboxedVars( String reps )
641 for(i=0; reps[i] != '\0'; ++i) {
642 Cell v = mkStgPrimVar(NIL,mkStgRep(reps[i]),NIL);
648 static List mkBoxedVars( String reps )
652 for(i=0; reps[i] != '\0'; ++i) {
653 as = cons(mkStgVar(NIL,NIL),as);
658 static StgRhs unboxVars( String reps, List b_args, List u_args, StgExpr e )
660 if (nonNull(b_args)) {
661 StgVar b_arg = hd(b_args); /* boxed arg */
662 StgVar u_arg = hd(u_args); /* unboxed arg */
663 Name box = repToBox(*reps);
664 e = unboxVars(reps+1,tl(b_args),tl(u_args),e);
666 /* Use a trivial let-binding */
667 stgVarBody(u_arg) = b_arg;
668 return mkStgLet(singleton(u_arg),e);
670 StgCaseAlt alt = mkStgCaseAlt(box,singleton(u_arg),e);
671 return mkStgCase(b_arg,singleton(alt));
678 /* Generate wrapper for primop based on list of arg types and result types:
680 * makeStgPrim op# False "II" "II" =
681 * \ x y -> "case x of { I# x# ->
682 * case y of { I# y# ->
683 * case op#{x#,y#} of { r1# r2# ->
684 * let r1 = I# r1#; r2 = I# r2# in
688 static StgRhs local makeStgPrim(op,addState,extra_args,a_reps,r_reps)
694 List b_args = NIL; /* boxed args to primop */
695 List u_args = NIL; /* possibly unboxed args to primop */
697 StgVar s0 = addState ? mkStgVar(NIL,NIL) : NIL;
698 StgVar s1 = addState ? mkStgVar(NIL,NIL) : NIL;
701 if (strcmp(r_reps,"B") == 0) {
703 = mkStgPrimAlt(singleton(
704 mkStgPrimVar(mkInt(0),
705 mkStgRep(INT_REP),NIL)
710 singleton(mkStgPrimVar(NIL,mkStgRep(INT_REP),NIL)),
712 alts = doubleton(altF,altT);
713 assert(nonNull(nameTrue));
716 alts = singleton(boxResults(r_reps,s1));
718 b_args = mkBoxedVars(a_reps);
719 u_args = mkUnboxedVars(a_reps);
722 = appendOnto(extra_args,dupListOnto(u_args,singleton(s0)));
724 = makeStgLambda(singleton(s0),
725 unboxVars(a_reps,b_args,u_args,
726 mkStgPrimCase(mkStgPrim(op,actual_args),
728 StgVar m = mkStgVar(rhs,NIL);
729 return makeStgLambda(b_args,
730 mkStgLet(singleton(m),
731 mkStgApp(nameMkIO,singleton(m))));
733 List actual_args = appendOnto(extra_args,u_args);
734 return makeStgLambda(
736 unboxVars(a_reps,b_args,u_args,
737 mkStgPrimCase(mkStgPrim(op,actual_args),alts))
742 Void implementPrim ( n )
744 const AsmPrim* p = name(n).primop;
745 StgRhs rhs = makeStgPrim(n,p->monad!=MONAD_Id,NIL,p->args,p->results);
746 StgVar v = mkStgVar(rhs,NIL);
748 stgGlobals=cons(pair(n,v),stgGlobals); /* so it will get codegened */
751 /* Generate wrapper code from (in,out) type lists.
755 * inTypes = [Int,Float]
756 * outTypes = [Char,Addr]
760 * case a1 of { I# a1# ->
761 * case s2 of { F# a2# ->
762 * case ccall# "IF" "CA" fun a1# a2# s0 of { r1# r2# s1 ->
770 * Addr -> (Int -> Float -> IO (Char,Addr))
772 Void implementForeignImport ( Name n )
774 Type t = name(n).type;
776 List resultTys = NIL;
777 CFunDescriptor* descriptor = 0;
778 Bool addState = TRUE;
779 while (getHead(t)==typeArrow && argCount==2) {
780 Type ta = fullExpand(arg(fun(t)));
782 argTys = cons(ta,argTys);
785 argTys = rev(argTys);
786 if (getHead(t) == typeIO) {
787 resultTys = getArgs(t);
788 assert(length(resultTys) == 1);
789 resultTys = hd(resultTys);
795 resultTys = fullExpand(resultTys);
796 if (isTuple(getHead(resultTys))) {
797 resultTys = getArgs(resultTys);
798 } else if (getHead(resultTys) == typeUnit) {
801 resultTys = singleton(resultTys);
803 mapOver(foreignOutboundTy,argTys); /* allows foreignObj, byteArrays, etc */
804 mapOver(foreignInboundTy,resultTys); /* doesn't */
805 descriptor = mkDescriptor(charListToString(argTys),
806 charListToString(resultTys));
808 ERRMSG(name(n).line) "Can't allocate memory for call descriptor"
812 /* ccall is the default convention, if it wasn't specified */
813 if (isNull(name(n).callconv)
814 || name(n).callconv == textCcall) {
815 name(n).primop = addState ? &ccall_ccall_IO : &ccall_ccall_Id;
817 else if (name(n).callconv == textStdcall) {
818 if (!stdcallAllowed()) {
819 ERRMSG(name(n).line) "stdcall is not supported on this platform"
822 name(n).primop = addState ? &ccall_stdcall_IO : &ccall_stdcall_Id;
825 internal ( "implementForeignImport: unknown calling convention");
828 Pair extName = name(n).defn;
829 void* funPtr = getDLLSymbol(name(n).line,
830 textToStr(textOf(fst(extName))),
831 textToStr(textOf(snd(extName))));
832 List extra_args = doubleton(mkPtr(descriptor),mkPtr(funPtr));
833 StgRhs rhs = makeStgPrim(n,addState,extra_args,descriptor->arg_tys,
834 descriptor->result_tys);
835 StgVar v = mkStgVar(rhs,NIL);
837 ERRMSG(name(n).line) "Could not find foreign function \"%s\" in \"%s\"",
838 textToStr(textOf(snd(extName))),
839 textToStr(textOf(fst(extName)))
844 stgGlobals=cons(pair(n,v),stgGlobals);/*so it will get codegen'd */
853 e3 = C# 'c' -- (ccall), or 's' (stdcall)
854 in primMkAdjThunk fun e1 e3 s0
856 we require, and check that,
857 fun :: prim_arg* -> IO prim_result
859 Void implementForeignExport ( Name n )
861 Type t = name(n).type;
863 List resultTys = NIL;
866 if (getHead(t)==typeArrow && argCount==2) {
869 ERRMSG(name(n).line) "foreign export has illegal type" ETHEN
870 ERRTEXT " \"" ETHEN ERRTYPE(t);
875 while (getHead(t)==typeArrow && argCount==2) {
876 Type ta = fullExpand(arg(fun(t)));
878 argTys = cons(ta,argTys);
881 argTys = rev(argTys);
882 if (getHead(t) == typeIO) {
883 resultTys = getArgs(t);
884 assert(length(resultTys) == 1);
885 resultTys = hd(resultTys);
887 ERRMSG(name(n).line) "foreign export doesn't return an IO type" ETHEN
888 ERRTEXT " \"" ETHEN ERRTYPE(t);
892 resultTys = fullExpand(resultTys);
894 mapOver(foreignInboundTy,argTys);
896 /* ccall is the default convention, if it wasn't specified */
897 if (isNull(name(n).callconv)
898 || name(n).callconv == textCcall) {
901 else if (name(n).callconv == textStdcall) {
902 if (!stdcallAllowed()) {
903 ERRMSG(name(n).line) "stdcall is not supported on this platform"
909 internal ( "implementForeignExport: unknown calling convention");
916 StgVar e1, e2, e3, v;
919 tdList = cons(mkChar(':'),argTys);
920 if (resultTys != typeUnit)
921 tdList = cons(foreignOutboundTy(resultTys),tdList);
923 tdText = findText(charListToString ( tdList ));
926 mkStgCon(nameMkA,singleton(ap(STRCELL,tdText))),
930 mkStgApp(nameUnpackString,singleton(e1)),
934 mkStgCon(nameMkC,singleton(mkChar(cc_char))),
943 cons(hd(args),cons(e2,cons(e3,cons(hd(tl(args)),NIL))))
948 v = mkStgVar(fun,NIL);
952 stgGlobals = cons(pair(n,v),stgGlobals);
956 // ToDo: figure out how to set inlineMe for these (non-Name) things
957 Void implementTuple(size)
960 Cell t = mkTuple(size);
961 List args = makeArgs(size);
962 StgVar tv = mkStgVar(mkStgCon(t,args),NIL);
963 StgExpr e = mkStgLet(singleton(tv),tv);
964 StgVar v = mkStgVar(mkStgLambda(args,e),NIL);
965 stgGlobals = cons(pair(t,v),stgGlobals); /* so we can see it */
967 StgVar tv = mkStgVar(mkStgCon(nameUnit,NIL),NIL);
968 stgGlobals = cons(pair(nameUnit,tv),stgGlobals); /* ditto */
972 /* --------------------------------------------------------------------------
974 * ------------------------------------------------------------------------*/
976 Void translateControl(what)
981 /* deliberate fall through */
992 /*-------------------------------------------------------------------------*/