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/22 17:18:02 $
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;
581 case THREADID_REP: return nameMkThreadId;
582 case MVAR_REP: return nameMkPrimMVar;
584 case WEAK_REP: return nameMkWeak;
586 #ifdef PROVIDE_FOREIGN
587 case FOREIGN_REP: return nameMkForeign;
593 static StgPrimAlt boxResults( String reps, StgVar state )
595 List rs = NIL; /* possibly unboxed results */
596 List bs = NIL; /* boxed results of wrapper */
597 List rbinds = NIL; /* bindings used to box results */
600 for(i=0; reps[i] != '\0'; ++i) {
601 StgRep k = mkStgRep(reps[i]);
602 Cell v = mkStgPrimVar(NIL,k,NIL);
603 Name box = repToBox(reps[i]);
607 StgRhs rhs = mkStgCon(box,singleton(v));
608 StgVar bv = mkStgVar(rhs,NIL); /* boxed */
610 rbinds = cons(bv,rbinds);
615 /* Construct tuple of results */
622 StgVar r = mkStgVar(mkStgCon(mkTuple(i),rev(bs)),NIL);
623 rbinds = cons(r,rbinds);
626 /* construct result pair if needed */
627 if (nonNull(state)) {
628 /* Note that this builds a tuple directly - we know it's
631 StgVar r = mkStgVar(mkStgCon(mkTuple(2),doubleton(e,state)),NIL);
632 rbinds = cons(r,rbinds);
633 rs = cons(state,rs); /* last result is a state */
636 return mkStgPrimAlt(rev(rs),makeStgLet(rbinds,e));
639 static List mkUnboxedVars( String reps )
643 for(i=0; reps[i] != '\0'; ++i) {
644 Cell v = mkStgPrimVar(NIL,mkStgRep(reps[i]),NIL);
650 static List mkBoxedVars( String reps )
654 for(i=0; reps[i] != '\0'; ++i) {
655 as = cons(mkStgVar(NIL,NIL),as);
660 static StgRhs unboxVars( String reps, List b_args, List u_args, StgExpr e )
662 if (nonNull(b_args)) {
663 StgVar b_arg = hd(b_args); /* boxed arg */
664 StgVar u_arg = hd(u_args); /* unboxed arg */
665 Name box = repToBox(*reps);
666 e = unboxVars(reps+1,tl(b_args),tl(u_args),e);
668 /* Use a trivial let-binding */
669 stgVarBody(u_arg) = b_arg;
670 return mkStgLet(singleton(u_arg),e);
672 StgCaseAlt alt = mkStgCaseAlt(box,singleton(u_arg),e);
673 return mkStgCase(b_arg,singleton(alt));
680 /* Generate wrapper for primop based on list of arg types and result types:
682 * makeStgPrim op# False "II" "II" =
683 * \ x y -> "case x of { I# x# ->
684 * case y of { I# y# ->
685 * case op#{x#,y#} of { r1# r2# ->
686 * let r1 = I# r1#; r2 = I# r2# in
690 static StgRhs local makeStgPrim(op,addState,extra_args,a_reps,r_reps)
696 List b_args = NIL; /* boxed args to primop */
697 List u_args = NIL; /* possibly unboxed args to primop */
699 StgVar s0 = addState ? mkStgVar(NIL,NIL) : NIL;
700 StgVar s1 = addState ? mkStgVar(NIL,NIL) : NIL;
703 if (strcmp(r_reps,"B") == 0) {
705 = mkStgPrimAlt(singleton(
706 mkStgPrimVar(mkInt(0),
707 mkStgRep(INT_REP),NIL)
712 singleton(mkStgPrimVar(NIL,mkStgRep(INT_REP),NIL)),
714 alts = doubleton(altF,altT);
715 assert(nonNull(nameTrue));
718 alts = singleton(boxResults(r_reps,s1));
720 b_args = mkBoxedVars(a_reps);
721 u_args = mkUnboxedVars(a_reps);
724 = appendOnto(extra_args,dupListOnto(u_args,singleton(s0)));
726 = makeStgLambda(singleton(s0),
727 unboxVars(a_reps,b_args,u_args,
728 mkStgPrimCase(mkStgPrim(op,actual_args),
730 StgVar m = mkStgVar(rhs,NIL);
731 return makeStgLambda(b_args,
732 mkStgLet(singleton(m),
733 mkStgApp(nameMkIO,singleton(m))));
735 List actual_args = appendOnto(extra_args,u_args);
736 return makeStgLambda(
738 unboxVars(a_reps,b_args,u_args,
739 mkStgPrimCase(mkStgPrim(op,actual_args),alts))
744 Void implementPrim ( n )
746 const AsmPrim* p = name(n).primop;
747 StgRhs rhs = makeStgPrim(n,p->monad!=MONAD_Id,NIL,p->args,p->results);
748 StgVar v = mkStgVar(rhs,NIL);
750 stgGlobals=cons(pair(n,v),stgGlobals); /* so it will get codegened */
753 /* Generate wrapper code from (in,out) type lists.
757 * inTypes = [Int,Float]
758 * outTypes = [Char,Addr]
762 * case a1 of { I# a1# ->
763 * case s2 of { F# a2# ->
764 * case ccall# "IF" "CA" fun a1# a2# s0 of { r1# r2# s1 ->
772 * Addr -> (Int -> Float -> IO (Char,Addr))
774 Void implementForeignImport ( Name n )
776 Type t = name(n).type;
778 List resultTys = NIL;
779 CFunDescriptor* descriptor = 0;
780 Bool addState = TRUE;
781 while (getHead(t)==typeArrow && argCount==2) {
782 Type ta = fullExpand(arg(fun(t)));
784 argTys = cons(ta,argTys);
787 argTys = rev(argTys);
788 if (getHead(t) == typeIO) {
789 resultTys = getArgs(t);
790 assert(length(resultTys) == 1);
791 resultTys = hd(resultTys);
797 resultTys = fullExpand(resultTys);
798 if (isTuple(getHead(resultTys))) {
799 resultTys = getArgs(resultTys);
800 } else if (getHead(resultTys) == typeUnit) {
803 resultTys = singleton(resultTys);
805 mapOver(foreignOutboundTy,argTys); /* allows foreignObj, byteArrays, etc */
806 mapOver(foreignInboundTy,resultTys); /* doesn't */
807 descriptor = mkDescriptor(charListToString(argTys),
808 charListToString(resultTys));
810 ERRMSG(name(n).line) "Can't allocate memory for call descriptor"
814 /* ccall is the default convention, if it wasn't specified */
815 if (isNull(name(n).callconv)
816 || name(n).callconv == textCcall) {
817 name(n).primop = addState ? &ccall_ccall_IO : &ccall_ccall_Id;
819 else if (name(n).callconv == textStdcall) {
820 if (!stdcallAllowed()) {
821 ERRMSG(name(n).line) "stdcall is not supported on this platform"
824 name(n).primop = addState ? &ccall_stdcall_IO : &ccall_stdcall_Id;
827 internal ( "implementForeignImport: unknown calling convention");
830 Pair extName = name(n).defn;
831 void* funPtr = getDLLSymbol(name(n).line,
832 textToStr(textOf(fst(extName))),
833 textToStr(textOf(snd(extName))));
834 List extra_args = doubleton(mkPtr(descriptor),mkPtr(funPtr));
835 StgRhs rhs = makeStgPrim(n,addState,extra_args,descriptor->arg_tys,
836 descriptor->result_tys);
837 StgVar v = mkStgVar(rhs,NIL);
839 ERRMSG(name(n).line) "Could not find foreign function \"%s\" in \"%s\"",
840 textToStr(textOf(snd(extName))),
841 textToStr(textOf(fst(extName)))
846 stgGlobals=cons(pair(n,v),stgGlobals);/*so it will get codegen'd */
855 e3 = C# 'c' -- (ccall), or 's' (stdcall)
856 in primMkAdjThunk fun e1 e3 s0
858 we require, and check that,
859 fun :: prim_arg* -> IO prim_result
861 Void implementForeignExport ( Name n )
863 Type t = name(n).type;
865 List resultTys = NIL;
868 if (getHead(t)==typeArrow && argCount==2) {
871 ERRMSG(name(n).line) "foreign export has illegal type" ETHEN
872 ERRTEXT " \"" ETHEN ERRTYPE(t);
877 while (getHead(t)==typeArrow && argCount==2) {
878 Type ta = fullExpand(arg(fun(t)));
880 argTys = cons(ta,argTys);
883 argTys = rev(argTys);
884 if (getHead(t) == typeIO) {
885 resultTys = getArgs(t);
886 assert(length(resultTys) == 1);
887 resultTys = hd(resultTys);
889 ERRMSG(name(n).line) "foreign export doesn't return an IO type" ETHEN
890 ERRTEXT " \"" ETHEN ERRTYPE(t);
894 resultTys = fullExpand(resultTys);
896 mapOver(foreignInboundTy,argTys);
898 /* ccall is the default convention, if it wasn't specified */
899 if (isNull(name(n).callconv)
900 || name(n).callconv == textCcall) {
903 else if (name(n).callconv == textStdcall) {
904 if (!stdcallAllowed()) {
905 ERRMSG(name(n).line) "stdcall is not supported on this platform"
911 internal ( "implementForeignExport: unknown calling convention");
918 StgVar e1, e2, e3, v;
921 tdList = cons(mkChar(':'),argTys);
922 if (resultTys != typeUnit)
923 tdList = cons(foreignOutboundTy(resultTys),tdList);
925 tdText = findText(charListToString ( tdList ));
928 mkStgCon(nameMkA,singleton(ap(STRCELL,tdText))),
932 mkStgApp(nameUnpackString,singleton(e1)),
936 mkStgCon(nameMkC,singleton(mkChar(cc_char))),
945 cons(hd(args),cons(e2,cons(e3,cons(hd(tl(args)),NIL))))
950 v = mkStgVar(fun,NIL);
954 stgGlobals = cons(pair(n,v),stgGlobals);
958 // ToDo: figure out how to set inlineMe for these (non-Name) things
959 Void implementTuple(size)
962 Cell t = mkTuple(size);
963 List args = makeArgs(size);
964 StgVar tv = mkStgVar(mkStgCon(t,args),NIL);
965 StgExpr e = mkStgLet(singleton(tv),tv);
966 StgVar v = mkStgVar(mkStgLambda(args,e),NIL);
967 stgGlobals = cons(pair(t,v),stgGlobals); /* so we can see it */
969 StgVar tv = mkStgVar(mkStgCon(nameUnit,NIL),NIL);
970 stgGlobals = cons(pair(nameUnit,tv),stgGlobals); /* ditto */
974 /* --------------------------------------------------------------------------
976 * ------------------------------------------------------------------------*/
978 Void translateControl(what)
983 /* deliberate fall through */
994 /*-------------------------------------------------------------------------*/