df743204810ceb156faef8f45ea33b08e22e98d2
[ghc-hetmet.git] / ghc / interpreter / storage.h
1
2 /* --------------------------------------------------------------------------
3  * Defines storage datatypes: Text, Name, Module, Tycon, Cell, List, Pair,
4  * Triple, ...
5  *
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.
11  *
12  * $RCSfile: storage.h,v $
13  * $Revision: 1.25 $
14  * $Date: 2000/01/11 15:40:57 $
15  * ------------------------------------------------------------------------*/
16
17 /* --------------------------------------------------------------------------
18  * Typedefs for main data types:
19  * Many of these type names are used to indicate the intended us of a data
20  * item, rather than for type checking purposes.  Sadly (although sometimes,
21  * fortunately), the C compiler cannot distinguish between the use of two
22  * different names defined to be synonyms for the same types.
23  * ------------------------------------------------------------------------*/
24
25 typedef Int          Text;                       /* text string            */
26 typedef Unsigned     Syntax;                     /* syntax (assoc,preced)  */
27 typedef Int          Cell;                       /* general cell value     */
28 typedef Cell far     *Heap;                      /* storage of heap        */
29 typedef Cell         Pair;                       /* pair cell              */
30 typedef Int          StackPtr;                   /* stack pointer          */
31 typedef Cell         Offset;                     /* offset/generic variable*/
32 typedef Int          Script;                     /* script file number     */
33 typedef Int          Module;                     /* module                 */
34 typedef Cell         Tycon;                      /* type constructor       */
35 typedef Cell         Type;                       /* type expression        */
36 typedef Cell         Kind;                       /* kind expression        */
37 typedef Cell         Kinds;                      /* list of kinds          */
38 typedef Cell         Constr;                     /* constructor expression */
39 typedef Cell         Name;                       /* named value            */
40 typedef Cell         Class;                      /* type class             */
41 typedef Cell         Inst;                       /* instance of type class */
42 typedef Cell         Triple;                     /* triple of cell values  */
43 typedef Cell         List;                       /* list of cells          */
44 typedef Cell         Bignum;                     /* bignum integer         */
45 typedef Cell         Float;                      /* floating pt literal    */
46 #if TREX
47 typedef Cell         Ext;                        /* extension label        */
48 #endif
49
50 typedef Cell         ConId;
51 typedef Cell         VarId;
52 typedef Cell         QualId;
53 typedef Cell         ConVarId;
54
55 /* --------------------------------------------------------------------------
56  * Text storage:
57  * provides storage for the characters making up identifier and symbol
58  * names, string literals, character constants etc...
59  * ------------------------------------------------------------------------*/
60
61 extern  String       textToStr            Args((Text));
62 extern  Text         findText             Args((String));
63 extern  Text         inventText           Args((Void));
64 extern  Text         inventDictText       Args((Void));
65 extern  Bool         inventedText         Args((Text));
66 extern  Text         enZcodeThenFindText  Args((String));
67 extern  Text         unZcodeThenFindText  Args((String));
68
69 /* Variants of textToStr and syntaxOf which work for idents, ops whether
70  * qualified or unqualified.
71  */
72 extern  String       identToStr         Args((Cell));
73 extern  Text         fixLitText         Args((Text));
74 extern  Syntax       identSyntax        Args((Cell));
75 extern  Syntax       defaultSyntax      Args((Text));
76
77 /* --------------------------------------------------------------------------
78  * Specification of syntax (i.e. default written form of application)
79  * ------------------------------------------------------------------------*/
80
81 #define MIN_PREC  0                    /* weakest binding operator         */
82 #define MAX_PREC  9                    /* strongest binding operator       */
83 #define FUN_PREC  (MAX_PREC+2)         /* binding of function symbols      */
84 #define DEF_PREC  MAX_PREC
85 #define APPLIC    0                    /* written applicatively            */
86 #define LEFT_ASS  1                    /* left associative infix           */
87 #define RIGHT_ASS 2                    /* right associative infix          */
88 #define NON_ASS   3                    /* non associative infix            */
89 #define DEF_ASS   LEFT_ASS
90
91 #define UMINUS_PREC  6                  /* Change these settings at your   */
92 #define UMINUS_ASSOC LEFT_ASS           /* own risk; they may not work!    */
93
94 #define assocOf(x)      ((x)&NON_ASS)
95 #define precOf(x)       ((x)>>2)
96 #define mkSyntax(a,p)   ((a)|((p)<<2))
97 #define DEF_OPSYNTAX    mkSyntax(DEF_ASS,DEF_PREC)
98 #define NO_SYNTAX       (-1)
99
100 extern  Void   addSyntax  Args((Int,Text,Syntax));
101 extern  Syntax syntaxOf   Args((Text));
102
103 /* --------------------------------------------------------------------------
104  * Heap storage:
105  * Provides a garbage collectable heap for storage of expressions etc.
106  * ------------------------------------------------------------------------*/
107
108 #define heapAlloc(s) (Heap)(farCalloc(s,sizeof(Cell)))
109 #define heapBuilt()  (heapFst)
110 extern  Int          heapSize;
111 extern  Heap         heapFst, heapSnd;
112 extern  Heap         heapTopFst;
113 extern  Heap         heapTopSnd;
114 extern  Bool         consGC;            /* Set to FALSE to turn off gc from*/
115                                         /* C stack; use with extreme care! */
116 extern Int   cellsRecovered;            /* cells recovered by last gc      */
117
118 #define fst(c)       heapTopFst[c]
119 #define snd(c)       heapTopSnd[c]
120
121 extern  Pair         pair            Args((Cell,Cell));
122 extern  Void         garbageCollect  Args((Void));
123
124 extern  Void         overwrite       Args((Pair,Pair));
125 extern  Void         overwrite2      Args((Pair,Cell,Cell));
126 extern  Cell         markExpr        Args((Cell));
127 extern  Void         markWithoutMove Args((Cell));
128
129 #define mark(v)      v=markExpr(v)
130
131 #define isPair(c)    ((c)<0)
132 #define isGenPair(c) ((c)<0 && -heapSize<=(c))
133
134 extern  Cell         whatIs    Args((Cell));
135
136 /* --------------------------------------------------------------------------
137  * Box cell tags are used as the fst element of a pair to indicate that
138  * the snd element of the pair is to be treated in some special way, other
139  * than as a Cell.  Examples include holding integer values, variable name
140  * and string text etc.
141  * ------------------------------------------------------------------------*/
142
143 #define TAGMIN       1            /* Box and constructor cell tag values   */
144 #define BCSTAG       30           /* Box=TAGMIN..BCSTAG-1                  */
145 #define isTag(c)     (TAGMIN<=(c) && (c)<SPECMIN) /* Tag cell values       */
146 #define isBoxTag(c)  (TAGMIN<=(c) && (c)<BCSTAG)  /* Box cell tag values   */
147 #define isConTag(c)  (BCSTAG<=(c) && (c)<SPECMIN) /* Constr cell tag values*/
148
149 #define FREECELL     3            /* Free list cell:          snd :: Cell  */
150 #define VARIDCELL    4            /* Identifier variable:     snd :: Text  */
151 #define VAROPCELL    5            /* Operator variable:       snd :: Text  */
152 #define DICTVAR      6            /* Dictionary variable:     snd :: Text  */
153 #define CONIDCELL    7            /* Identifier constructor:  snd :: Text  */
154 #define CONOPCELL    8            /* Operator constructor:    snd :: Text  */
155 #define STRCELL      9            /* String literal:          snd :: Text  */
156 #define INTCELL      10           /* Int literal:             snd :: Int   */
157 #define ADDPAT       11           /* (_+k) pattern discr:     snd :: Int   */
158 #define FLOATCELL    15           /* Floating Pt literal:     snd :: Text  */
159 #define BIGCELL      16           /* Integer literal:         snd :: Text  */
160 #if PTR_ON_HEAP
161 #define PTRCELL      17           /* C Heap Pointer           snd :: Ptr   */
162 #if IPARAM
163 #define IPCELL       19           /* Imp Param Cell:          snd :: Text  */
164 #define IPVAR        20           /* ?x:                      snd :: Text  */
165 #endif
166 #define CPTRCELL     21           /* Native code pointer      snd :: Ptr   */
167 #endif
168 #if TREX
169 #define EXTCOPY      22           /* Copy of an Ext:          snd :: Text  */
170 #endif
171
172 #define qmodOf(c)       (textOf(fst(snd(c))))    /* c ::  QUALIDENT        */
173 #define qtextOf(c)      (textOf(snd(snd(c))))    /* c ::  QUALIDENT        */
174 #define mkVar(t)        ap(VARIDCELL,t)
175 #define mkVarop(t)      ap(VAROPCELL,t)
176 #define mkCon(t)        ap(CONIDCELL,t)
177 #define mkConop(t)      ap(CONOPCELL,t)
178 #define mkQVar(m,t)     ap(QUALIDENT,pair(mkCon(m),mkVar(t)))
179 #define mkQCon(m,t)     ap(QUALIDENT,pair(mkCon(m),mkCon(t)))
180 #define mkQVarOp(m,t)   ap(QUALIDENT,pair(mkCon(m),mkVarop(t)))
181 #define mkQConOp(m,t)   ap(QUALIDENT,pair(mkCon(m),mkConop(t)))
182 #define mkQualId(m,t)   ap(QUALIDENT,pair(m,t))
183 #define intValOf(c)     (snd(c))
184 #define inventVar()     mkVar(inventText())
185 #define mkDictVar(t)    ap(DICTVAR,t)
186 #define inventDictVar() mkDictVar(inventDictText())
187 #define mkStr(t)        ap(STRCELL,t)
188 #if IPARAM
189 #define mkIParam(c)     ap(IPCELL,snd(c))
190 #define isIP(p)         (whatIs(p) == IPCELL)
191 #define ipMatch(pi, t)  (isIP(fun(pi)) && textOf(fun(pi)) == t)
192 #define ipVar(pi)       textOf(fun(pi))
193 #else
194 #define isIP(p)         FALSE
195 #endif
196
197 extern  Bool            isVar        Args((Cell));
198 extern  Bool            isCon        Args((Cell));
199 extern  Bool            isQVar       Args((Cell));
200 extern  Bool            isQCon       Args((Cell));
201 extern  Bool            isQualIdent  Args((Cell));
202 extern  Bool            eqQualIdent ( QualId c1, QualId c2 );
203 extern  Bool            isIdent      Args((Cell));
204 extern  String          stringNegate Args((String));
205 extern  Text            textOf       Args((Cell));
206
207 #define isFloat(c)       (isPair(c) && fst(c)==FLOATCELL)
208 #define stringToFloat(s) pair(FLOATCELL,findText(s))
209 #define floatToString(f) textToStr(snd(f))
210 #define floatOf(f)       atof(floatToString(f))
211 #define mkFloat(f)       (f)  /* ToDo: is this right? */
212 #define floatNegate(f)   stringToFloat(stringNegate(floatToString(f)))
213
214 #define stringToBignum(s) pair(BIGCELL,findText(s))
215 #define bignumToString(b) textToStr(snd(b))
216
217 #if PTR_ON_HEAP
218 #define isPtr(c)        (isPair(c) && fst(c)==PTRCELL)
219 extern  Cell            mkPtr           Args((Ptr));
220 extern  Ptr             ptrOf           Args((Cell));
221 #define isCPtr(c)       (isPair(c) && fst(c)==CPTRCELL)
222 extern  Cell            mkCPtr          Args((Ptr));
223 extern  Ptr             cptrOf          Args((Cell));
224 #endif
225
226 /* --------------------------------------------------------------------------
227  * Constructor cell tags are used as the fst element of a pair to indicate
228  * a particular syntactic construct described by the snd element of the
229  * pair.
230  * Note that a cell c will not be treated as an application (AP/isAp) node
231  * if its first element is a constructor cell tag, whereas a cell whose fst
232  * element is a special cell will be treated as an application node.
233  * ------------------------------------------------------------------------*/
234
235 #define LETREC       30           /* LETREC     snd :: ([Decl],Exp)        */
236 #define COND         31           /* COND       snd :: (Exp,Exp,Exp)       */
237 #define LAMBDA       32           /* LAMBDA     snd :: Alt                 */
238 #define FINLIST      33           /* FINLIST    snd :: [Exp]               */
239 #define DOCOMP       34           /* DOCOMP     snd :: (Exp,[Qual])        */
240 #define BANG         35           /* BANG       snd :: Type                */
241 #define COMP         36           /* COMP       snd :: (Exp,[Qual])        */
242 #define ASPAT        37           /* ASPAT      snd :: (Var,Exp)           */
243 #define ESIGN        38           /* ESIGN      snd :: (Exp,Type)          */
244 #define RSIGN        39           /* RSIGN      snd :: (Rhs,Type)          */
245 #define CASE         40           /* CASE       snd :: (Exp,[Alt])         */
246 #define NUMCASE      41           /* NUMCASE    snd :: (Exp,Disc,Rhs)      */
247 #define FATBAR       42           /* FATBAR     snd :: (Exp,Exp)           */
248 #define LAZYPAT      43           /* LAZYPAT    snd :: Exp                 */
249 #define DERIVE       45           /* DERIVE     snd :: Cell                */
250 #if BREAK_FLOATS
251 #define FLOATCELL    46           /* FLOATCELL  snd :: (Int,Int)           */
252 #endif
253
254 #define BOOLQUAL     49           /* BOOLQUAL   snd :: Exp                 */
255 #define QWHERE       50           /* QWHERE     snd :: [Decl]              */
256 #define FROMQUAL     51           /* FROMQUAL   snd :: (Exp,Exp)           */
257 #define DOQUAL       52           /* DOQUAL     snd :: Exp                 */
258 #define MONADCOMP    53           /* MONADCOMP  snd :: ((m,m0),(Exp,[Qual])*/
259
260 #define GUARDED      54           /* GUARDED    snd :: [guarded exprs]     */
261
262 #define ARRAY        55           /* Array      snd :: (Bounds,[Values])   */
263 #define MUTVAR       56           /* Mutvar     snd :: Cell                */
264 #if INTERNAL_PRIMS
265 #define HUGSOBJECT   57           /* HUGSOBJECT snd :: Cell                */
266 #endif
267
268 #if IPARAM
269 #define WITHEXP      58           /* WITHEXP    snd :: [(Var,Exp)]         */
270 #endif
271
272
273 #define POLYTYPE     60           /* POLYTYPE   snd :: (Kind,Type)         */
274 #define QUAL         61           /* QUAL       snd :: ([Classes],Type)    */
275 #define RANK2        62           /* RANK2      snd :: (Int,Type)          */
276 #define EXIST        63           /* EXIST      snd :: (Int,Type)          */
277 #define POLYREC      64           /* POLYREC    snd :: (Int,Type)          */
278 #define BIGLAM       65           /* BIGLAM     snd :: (vars,patterns)     */
279 #define CDICTS       66           /* CDICTS     snd :: ([Pred],Type)       */
280
281 #define LABC         67           /* LABC       snd :: (con,[(Vars,Type)]) */
282 #define CONFLDS      68           /* CONFLDS    snd :: (con,[Field])       */
283 #define UPDFLDS      69           /* UPDFLDS    snd :: (Exp,[con],[Field]) */
284 #if TREX
285 #define RECORD       70           /* RECORD     snd :: [Val]               */
286 #define EXTCASE      71           /* EXTCASE    snd :: (Exp,Disc,Rhs)      */
287 #define RECSEL       72           /* RECSEL     snd :: Ext                 */
288 #endif
289 #define IMPDEPS      73           /* IMPDEPS    snd :: [Binding]           */
290
291 #define QUALIDENT    74           /* Qualified identifier  snd :: (Id,Id)  */
292 #define HIDDEN       75           /* hiding import list    snd :: [Entity] */
293 #define MODULEENT    76           /* module in export list snd :: con      */
294
295 #define INFIX        77           /* INFIX      snd :: (see tidyInfix)     */
296 #define ONLY         78           /* ONLY       snd :: Exp                 */
297 #define NEG          79           /* NEG        snd :: Exp                 */
298
299 /* Used when parsing GHC interface files */
300 #define DICTAP       80           /* DICTAP     snd :: (QClassId,[Type])   */
301 #define UNBOXEDTUP   81           /* UNBOXEDTUP snd :: [Type]              */
302
303 #if SIZEOF_INTP != SIZEOF_INT
304 #define PTRCELL      82           /* C Heap Pointer snd :: (Int,Int)       */
305 #endif
306
307 /* STG syntax */
308 #define STGVAR       92           /* STGVAR     snd :: (StgRhs,info)       */
309 #define STGAPP       93           /* STGAPP     snd :: (StgVar,[Arg])      */
310 #define STGPRIM      94           /* STGPRIM    snd :: (PrimOp,[Arg])      */
311 #define STGCON       95           /* STGCON     snd :: (StgCon,[Arg])      */
312 #define PRIMCASE     96           /* PRIMCASE   snd :: (Expr,[PrimAlt])    */
313 #define DEEFALT      97           /* DEEFALT    snd :: (Var,Expr)          */
314 #define CASEALT      98           /* CASEALT    snd :: (Con,[Var],Expr)    */
315 #define PRIMALT      99           /* PRIMALT    snd :: ([Var],Expr)        */
316
317
318 /* 
319    Top-level interface entities 
320    type Line             = Int  -- a line number 
321    type ConVarId         = CONIDCELL | VARIDCELL
322    type <a>              = ZList a
323    type ExportListEntry  = ConVarId | (ConId, <ConVarId>) 
324    type Associativity    = mkInt of LEFT_ASS | RIGHT_ASS | NON_ASS
325    type Constr           = ((ConId, [((Type,VarId,Int))]))
326                ((constr name, [((type, field name if any, strictness))]))
327                strictness: 0 => none, 1 => !, 2 => !! (unpacked)
328    All 2/3/4/5 tuples in the interface abstract syntax are done with
329    z-tuples.
330 */
331
332 #define I_INTERFACE  109  /* snd :: ((ConId, [I_IMPORT..I_VALUE])) 
333                                     interface name, list of iface entities */
334
335 #define I_IMPORT     110  /* snd :: ((ConId, [ConVarId]))
336                                     module name, list of entities          */
337
338 #define I_INSTIMPORT 111  /* snd :: NIL    -- not used at present          */
339
340 #define I_EXPORT     112  /* snd :: ((ConId, [ExportListEntry]))
341                                     this module name?, entities to export  */
342
343 #define I_FIXDECL    113  /* snd :: ((NIL|Int, Associativity, ConVarId))   
344                                     fixity, associativity, name            */
345
346 #define I_INSTANCE   114 /* snd :: ((Line, 
347                                      [((VarId,Kind))], 
348                                      Type, VarId, Inst))
349                    lineno, 
350                    forall-y bit (eg __forall [a b] =>),
351                    other bit, eg { C a1 } -> { C2 a2 } -> ... -> { Cn an },
352                    name of dictionary builder,
353                    (after startGHCInstance) the instance table location    */
354
355 #define I_TYPE       115 /* snd :: ((Line, ConId, [((VarId,Kind))], Type))
356                             lineno, tycon, kinded tyvars, the type expr    */
357
358 #define I_DATA       116 /* snd :: ((Line, [((QConId,VarId))], ConId, 
359                                           [((VarId,Kind))], [Constr]) 
360                             lineno, context, tycon, kinded tyvars, constrs 
361                            An empty constr list means exported abstractly. */
362
363 #define I_NEWTYPE    117 /* snd :: ((Line, [((QConId,VarId))], ConId,
364                                     [((VarId,Kind))], ((ConId,Type)) ))
365                              lineno, context, tycon, kinded tyvars, constr 
366                                     constr==NIL means exported abstractly. */
367
368 #define I_CLASS      118 /* snd :: ((Line, [((QConId,VarId))], ConId,
369                                     [((VarId,Kind))], [((VarId,Type))]))
370                             lineno, context, classname, 
371                                       kinded tyvars, method sigs           */
372
373 #define I_VALUE      119 /* snd :: ((Line, VarId, Type))                   */
374
375
376
377 /* Generic syntax */
378 #if 0
379 #define ZCONS        190          /* snd :: (Cell,Cell)                    */
380 #endif
381
382
383 #define ZTUP2        192          /* snd :: (Cell,Cell)                    */
384 #define ZTUP3        193          /* snd :: (Cell,(Cell,Cell))             */
385 #define ZTUP4        194          /* snd :: (Cell,(Cell,(Cell,Cell)))      */
386 #define ZTUP5        195       /* snd :: (Cell,(Cell,(Cell,(Cell,Cell))))  */
387
388 /* Last constructor tag must be less than SPECMIN */
389
390 /* --------------------------------------------------------------------------
391  * Special cell values:
392  * ------------------------------------------------------------------------*/
393
394 #define SPECMIN      201
395
396 #if TREX
397 #define isSpec(c)    (SPECMIN<=(c) && (c)<EXTMIN)/* Special cell values    */
398 #else
399 #define isSpec(c)    (SPECMIN<=(c) && (c)<OFFMIN)
400 #endif
401
402 #define NONE         201          /* Dummy stub                            */
403 #define STAR         202          /* Representing the kind of types        */
404 #if TREX
405 #define ROW          203          /* Representing the kind of rows         */
406 #endif
407 #define WILDCARD     204          /* Wildcard pattern                      */
408 #define SKOLEM       205          /* Skolem constant                       */
409
410 #define DOTDOT       206          /* ".." in import/export list            */
411
412 #define NAME         210          /* whatIs code for isName                */
413 #define TYCON        211          /* whatIs code for isTycon               */
414 #define CLASS        212          /* whatIs code for isClass               */
415 #define MODULE       213          /* whatIs code for isModule              */
416 #define INSTANCE     214          /* whatIs code for isInst                */
417 #define TUPLE        215          /* whatIs code for tuple constructor     */
418 #define OFFSET       216          /* whatis code for offset                */
419 #define AP           217          /* whatIs code for application node      */
420 #define CHARCELL     218          /* whatIs code for isChar                */
421 #if TREX
422 #define EXT          219          /* whatIs code for isExt                 */
423 #endif
424
425 #define SIGDECL      220          /* Signature declaration                 */
426 #define FIXDECL      221          /* Fixity declaration                    */
427 #define FUNBIND      222          /* Function binding                      */
428 #define PATBIND      223          /* Pattern binding                       */
429
430 #define DATATYPE     230          /* Datatype type constructor             */
431 #define NEWTYPE      231          /* Newtype type constructor              */
432 #define SYNONYM      232          /* Synonym type constructor              */
433 #define RESTRICTSYN  233          /* Synonym with restricted scope         */
434
435 #define NODEPENDS    235          /* Stop calculation of deps in type check*/
436 #define PREDEFINED   236          /* Predefined name, not yet filled       */
437
438 /* --------------------------------------------------------------------------
439  * Tuple data/type constructors:
440  * ------------------------------------------------------------------------*/
441
442 extern Text ghcTupleText    Args((Tycon));
443 extern Text ghcTupleText_n  Args((Int));
444
445
446
447 #if TREX
448 #define EXTMIN       301
449 #define isExt(c)     (EXTMIN<=(c) && (c)<OFFMIN)
450 #define extText(e)   tabExt[(e)-EXTMIN]
451 #define extField(c)  arg(fun(c))
452 #define extRow(c)    arg(c)
453
454 extern Text          DECTABLE(tabExt);
455 extern Ext           mkExt Args((Text));
456 #else
457 #define mkExt(t) NIL
458 #endif
459
460 extern Module findFakeModule ( Text t );
461 extern Tycon addTupleTycon ( Int n );
462 extern Name addWiredInBoxingTycon
463                ( String modNm, String typeNm, String constrNm,
464                  Int rep, Kind kind );
465 Tycon addWiredInEnumTycon ( String modNm, String typeNm, 
466                             List /*of Text*/ constrs );
467
468 /* --------------------------------------------------------------------------
469  * Offsets: (generic types/stack offsets)
470  * ------------------------------------------------------------------------*/
471
472 #if TREX
473 #define OFFMIN       (EXTMIN+NUM_EXT)
474 #else
475 #define OFFMIN       301
476 #endif
477 #define isOffset(c)  (OFFMIN<=(c) && (c)<MODMIN)
478 #define offsetOf(c)  ((c)-OFFMIN)
479 #define mkOffset(o)  (OFFMIN+(o))
480
481
482 /* --------------------------------------------------------------------------
483  * Modules:
484  * ------------------------------------------------------------------------*/
485
486 #define MODMIN        (OFFMIN+NUM_OFFSETS)
487
488 #define isModule(c)   (MODMIN<=(c) && (c)<TYCMIN)
489 #define mkModule(n)   (MODMIN+(n))
490 #define module(n)     tabModule[(n)-MODMIN]
491
492 /* Import defns for the ObjectCode struct in Module. */
493 #include "object.h"
494
495 /* Under Haskell 1.3, the list of qualified imports is always a subset
496  * of the list of unqualified imports.  For simplicity and flexibility,
497  * we do not attempt to exploit this fact - when a module is imported
498  * unqualified, it is added to both the qualified and unqualified
499  * import lists.
500  * Similarily, Haskell 1.3 does not allow a constructor to be imported
501  * or exported without exporting the type it belongs to but the export
502  * list is just a flat list of Texts (before static analysis) or
503  * Tycons, Names and Classes (after static analysis).
504  */
505 struct Module {
506     Text  text;
507     /* Lists of top level objects (local defns + imports)                  */
508     List  tycons;
509     List  names;
510     List  classes;
511     List  exports; /* [ Entity | (Entity, NIL|DOTDOT) ] */
512     /* List of qualified imports.  Used both during compilation and when
513      * evaluating an expression in the context of the current module.
514      */
515     List  qualImports;
516
517     /* TRUE if module exists only via GHC primop defn; usually FALSE */
518     Bool  fake; 
519
520     /* The primary object file for this module. */
521     ObjectCode* object;
522
523     /* And any extras it might need. */
524     ObjectCode* objectExtras;
525     List        objectExtraNames;   /* :: [Text] -- names of extras */
526 };
527
528
529 extern Module currentModule;           /* Module currently being processed */
530 extern struct Module DECTABLE(tabModule);
531
532 extern Bool   isValidModule Args((Module));
533 extern Module newModule     Args((Text));
534 extern Module findModule    Args((Text));
535 extern Module findModid     Args((Cell));
536 extern Void   setCurrModule Args((Module));
537
538 extern void      addOTabName     Args((Module,char*,void*));
539 extern void*     lookupOTabName  Args((Module,char*));
540 extern char*     nameFromOPtr    Args((void*));
541
542 extern void          addSection    Args((Module,void*,void*,OSectionKind));
543 extern OSectionKind  lookupSection Args((void*));
544 extern void* lookupOExtraTabName ( char* sym );
545
546 #define isPrelude(m) (m==modulePrelude)
547
548 /* --------------------------------------------------------------------------
549  * Type constructor names:
550  * ------------------------------------------------------------------------*/
551
552 #define TYCMIN       (MODMIN+NUM_MODULE)
553 #define isTycon(c)   (TYCMIN<=(c) && (c)<NAMEMIN && tabTycon[(c)-TYCMIN].tuple==-1)
554 #define tycon(n)     tabTycon[(n)-TYCMIN]
555
556 #define isTuple(c)   (TYCMIN<=(c) && (c)<NAMEMIN && tabTycon[(c)-TYCMIN].tuple>=0)
557 #define tupleOf(n)   (tabTycon[(n)-TYCMIN].tuple)
558 extern Tycon mkTuple ( Int );
559
560
561 struct strTycon {
562     Text   text;
563     Int    line;
564     Module mod;                         /* module that defines it          */
565     Int    tuple;                      /* tuple number, or -1 if not tuple */
566     Int    arity;
567     Kind   kind;                        /* kind (includes arity) of Tycon  */
568     Cell   what;                        /* DATATYPE/SYNONYM/RESTRICTSYN... */
569     Cell   defn;
570     Name   conToTag;                    /* used in derived code            */
571     Name   tagToCon;
572     void*  itbl;                       /* For tuples, the info tbl pointer */
573     Tycon  nextTyconHash;
574 };
575
576 extern struct strTycon DECTABLE(tabTycon);
577
578 extern Tycon newTycon     Args((Text));
579 extern Tycon findTycon    Args((Text));
580 extern Tycon addTycon     Args((Tycon));
581 extern Tycon findQualTycon Args((Cell));
582 extern Tycon addPrimTycon Args((Text,Kind,Int,Cell,Cell));
583
584 #define isSynonym(h)    (isTycon(h) && tycon(h).what==SYNONYM)
585 #define isQualType(t)   (isPair(t) && fst(t)==QUAL)
586 #define mkPolyType(n,t) pair(POLYTYPE,pair(n,t))
587 #define isPolyType(t)   (isPair(t) && fst(t)==POLYTYPE)
588 #define isPolyOrQualType(t) (isPair(t) && (fst(t)==POLYTYPE || fst(t)==QUAL))
589 #define polySigOf(t)    fst(snd(t))
590 #define monotypeOf(t)   snd(snd(t))
591
592 #define bang(t)         ap(BANG,t)
593 extern Tycon findQualTyconWithoutConsultingExportList ( QualId q );
594
595 /* --------------------------------------------------------------------------
596  * Globally defined name values:
597  * ------------------------------------------------------------------------*/
598
599 #define NAMEMIN      (TYCMIN+NUM_TYCON)
600 #define isName(c)    (NAMEMIN<=(c) && (c)<INSTMIN)
601 #define mkName(n)    (NAMEMIN+(n))
602 #define name(n)      tabName[(n)-NAMEMIN]
603
604 struct strName {
605     Text   text;
606     Int    line;
607     Module mod;                         /* module that defines it          */
608     Syntax syntax;
609     Cell   parent; 
610     Int    arity;
611     Int    number;
612     Cell   type;
613     Cell   defn;
614     Cell   stgVar;                                      /* really StgVar   */
615     Text   callconv;                          /* for foreign import/export */
616     void*  primop;                                      /* really StgPrim* */
617     void*  itbl;                 /* For constructors, the info tbl pointer */
618     Name   nextNameHash;
619 };
620
621 extern int numNames Args(( Void ));
622
623 extern struct strName DECTABLE(tabName);
624
625 /* The number field in a name is used to distinguish various kinds of name:
626  *   mfunNo(i) = code for member function, offset i
627  *               members that are sole elements of dict use mfunNo(0)
628  *               members of dicts with more than one elem use mfunNo(n), n>=1
629  *   EXECNAME  = code for executable name (bytecodes or primitive)
630  *   SELNAME   = code for selector function
631  *   DFUNNAME  = code for dictionary builder or selector
632  *   cfunNo(i) = code for data constructor
633  *               datatypes with only one constructor uses cfunNo(0)
634  *               datatypes with multiple constructors use cfunNo(n), n>=1
635  */
636
637 #define EXECNAME        0
638 #define SELNAME         1
639 #define DFUNNAME        2
640 #define CFUNNAME        3
641
642 #define isSfun(n)       (name(n).number==SELNAME)
643 #define isDfun(n)       (name(n).number==DFUNNAME)
644
645 #define isCfun(n)       (name(n).number>=CFUNNAME)
646 #define cfunOf(n)       (name(n).number-CFUNNAME)
647 #define cfunNo(i)       ((i)+CFUNNAME)
648 #define hasCfun(cs)     (nonNull(cs) && isCfun(hd(cs)))
649
650 #define isMfun(n)       (name(n).number<0)
651 #define mfunOf(n)       ((-1)-name(n).number)
652 #define mfunNo(i)       ((-1)-(i))
653
654 extern Name   newName         Args((Text,Cell));
655 extern Name   findName        Args((Text));
656 extern Name   addName         Args((Name));
657 extern Name   findQualName    Args((Cell));
658 extern Name   addPrimCfun     Args((Text,Int,Int,Cell));
659 extern Name   addPrimCfunREP  Args((Text,Int,Int,Int));
660 extern Int    sfunPos         Args((Name,Name));
661 extern Name   nameFromStgVar  Args((Cell));
662 extern Name   jrsFindQualName Args((Text,Text));
663
664 extern Name findQualNameWithoutConsultingExportList ( QualId q );
665
666 /* --------------------------------------------------------------------------
667  * Type class values:
668  * ------------------------------------------------------------------------*/
669
670 #define INSTMIN      (NAMEMIN+NUM_NAME) /* instances                       */
671 #define isInst(c)    (INSTMIN<=(c) && (c)<CLASSMIN)
672 #define mkInst(n)    (INSTMIN+(n))
673 #define instOf(c)    ((Int)((c)-INSTMIN))
674 #define inst(in)     tabInst[(in)-INSTMIN]
675
676 struct strInst {
677     Class  c;                           /* class C                         */
678     Int    line;
679     Module mod;                         /* module that defines it          */
680     Kinds  kinds;                       /* Kinds of variables in head      */
681     Cell   head;                        /* :: Pred                         */
682     List   specifics;                   /* :: [Pred]                       */
683     Int    numSpecifics;                /* length(specifics)               */
684     List   implements;
685     Name   builder;                     /* Dictionary constructor function */
686 };
687
688 /* a predicate (an element :: Pred) is an application of a Class to one or
689  * more type expressions
690  */
691
692 #define CLASSMIN     (INSTMIN+NUM_INSTS)
693 #define isClass(c)   (CLASSMIN<=(c) && (c)<CHARMIN)
694 #define mkClass(n)   (CLASSMIN+(n))
695 #define cclass(n)    tabClass[(n)-CLASSMIN]
696
697 struct strClass {
698     Text   text;                        /* Name of class                   */
699     Int    line;                        /* Line where declaration begins   */
700     Module mod;                         /* module that declares it         */
701     Int    level;                       /* Level in class hierarchy        */
702     Int    arity;                       /* Number of arguments             */
703     Kinds  kinds;                       /* Kinds of constructors in class  */
704     List   fds;                         /* Functional Dependencies         */
705     List   xfds;                        /* Xpanded Functional Dependencies */
706     Cell   head;                        /* Head of class                   */
707     Name   dcon;                        /* Dictionary constructor function */
708     List   supers;                      /* :: [Pred]                       */
709     Int    numSupers;                   /* length(supers)                  */
710     List   dsels;                       /* Superclass dictionary selectors */
711     List   members;                     /* :: [Name]                       */
712     Int    numMembers;                  /* length(members)                 */
713     List   defaults;                    /* :: [Name]                       */
714     List   instances;                   /* :: [Inst]                       */
715 };
716
717 extern struct strClass    DECTABLE(tabClass);
718 extern struct strInst far *tabInst;
719
720 extern Class newClass      Args((Text));
721 extern Class classMax      Args((Void));
722 extern Class findClass     Args((Text));
723 extern Class addClass      Args((Class));
724 extern Class findQualClass Args((Cell));
725 extern Inst  newInst       Args((Void));
726 extern Inst  findFirstInst Args((Tycon));
727 extern Inst  findNextInst  Args((Tycon,Inst));
728 extern List getAllKnownTyconsAndClasses ( void );
729 extern Class findQualClassWithoutConsultingExportList ( QualId q );
730
731 /* --------------------------------------------------------------------------
732  * Character values:
733  * ------------------------------------------------------------------------*/
734
735 #define CHARMIN      (CLASSMIN+NUM_CLASSES)
736 #define MAXCHARVAL   (NUM_CHARS-1)
737 #define isChar(c)    (CHARMIN<=(c) && (c)<INTMIN)
738 #define charOf(c)    ((Char)(c-CHARMIN))
739 #define mkChar(c)    ((Cell)(CHARMIN+(((unsigned)(c))%NUM_CHARS)))
740
741 /* --------------------------------------------------------------------------
742  * Small Integer values:
743  * ------------------------------------------------------------------------*/
744
745 #define INTMIN       (CHARMIN+NUM_CHARS)
746 #define INTMAX       (MAXPOSINT)
747 #define isSmall(c)   (INTMIN<=(c))
748 #define INTZERO      (INTMIN/2 + INTMAX/2)
749 #define MINSMALLINT  (INTMIN - INTZERO)
750 #define MAXSMALLINT  (INTMAX - INTZERO)
751 #define mkDigit(c)   ((Cell)((c)+INTMIN))
752 #define digitOf(c)   ((Int)((c)-INTMIN))
753
754 extern  Bool isInt    Args((Cell));
755 extern  Int  intOf    Args((Cell));
756 extern  Cell mkInt    Args((Int));
757
758 /* --------------------------------------------------------------------------
759  * Implementation of triples:
760  * ------------------------------------------------------------------------*/
761
762 #define triple(x,y,z) pair(x,pair(y,z))
763 #define fst3(c)      fst(c)
764 #define snd3(c)      fst(snd(c))
765 #define thd3(c)      snd(snd(c))
766
767 /* --------------------------------------------------------------------------
768  * Implementation of lists:
769  * ------------------------------------------------------------------------*/
770
771 #define NIL          0
772 #define isNull(c)    ((c)==NIL)
773 #define nonNull(c)   (c)
774 #define cons(x,xs)   pair(x,xs)
775 #define singleton(x)     cons(x,NIL)
776 #define doubleton(x,y)   cons(x,cons(y,NIL))
777 #define tripleton(x,y,z) cons(x,cons(y,cons(z,NIL)))
778 #define hd(c)        fst(c)
779 #define tl(c)        snd(c)
780
781 extern  Int          length       Args((List));
782 extern  List         appendOnto   Args((List,List));    /* destructive     */
783 extern  List         dupOnto      Args((List,List));
784 extern  List         dupList      Args((List));
785 extern  List         revOnto      Args((List, List));   /* destructive     */
786 #define rev(xs)      revOnto((xs),NIL)                  /* destructive     */
787 #define reverse(xs)  revOnto(dupList(xs),NIL)           /* non-destructive */
788 extern  Cell         cellIsMember Args((Cell,List));
789 extern  Cell         cellAssoc    Args((Cell,List));
790 extern  Cell         cellRevAssoc Args((Cell,List));
791 extern  Bool         eqList       Args((List,List));
792 extern  Cell         varIsMember  Args((Text,List));
793 extern  Name         nameIsMember Args((Text,List));
794 extern  QualId       qualidIsMember ( QualId, List );
795 extern  Cell         intIsMember  Args((Int,List));
796 extern  List         replicate    Args((Int,Cell));
797 extern  List         diffList     Args((List,List));    /* destructive     */
798 extern  List         deleteCell   Args((List,Cell));    /* non-destructive */
799 extern  List         take         Args((Int,List));     /* destructive     */
800 extern  List         splitAt      Args((Int,List));     /* non-destructive */
801 extern  Cell         nth          Args((Int,List));
802 extern  List         removeCell   Args((Cell,List));    /* destructive     */
803 extern  List         dupListOnto  Args((List,List));    /* non-destructive */ 
804 extern  List         nubList      Args((List));         /* non-destructive */
805
806 /* The following macros provide `inline expansion' of some common ways of
807  * traversing, using and modifying lists:
808  *
809  * N.B. We use the names _f, _a, _xs, Zs, in an attempt to avoid clashes
810  *      with identifiers used elsewhere.
811  */
812
813 #define mapBasic(_init,_step)           {List Zs=(_init);\
814                                          for(;nonNull(Zs);Zs=tl(Zs))  \
815                                          _step;}
816 #define mapModify(_init,_step)          mapBasic(_init,hd(Zs)=_step)
817
818 #define mapProc(_f,_xs)                 mapBasic(_xs,_f(hd(Zs)))
819 #define map1Proc(_f,_a,_xs)             mapBasic(_xs,_f(_a,hd(Zs)))
820 #define map2Proc(_f,_a,_b,_xs)          mapBasic(_xs,_f(_a,_b,hd(Zs)))
821 #define map3Proc(_f,_a,_b,_c,_xs)       mapBasic(_xs,_f(_a,_b,_c,hd(Zs)))
822 #define map4Proc(_f,_a,_b,_c,_d,_xs)    mapBasic(_xs,_f(_a,_b,_c,_d,hd(Zs)))
823
824 #define mapOver(_f,_xs)                 mapModify(_xs,_f(hd(Zs)))
825 #define map1Over(_f,_a,_xs)             mapModify(_xs,_f(_a,hd(Zs)))
826 #define map2Over(_f,_a,_b,_xs)          mapModify(_xs,_f(_a,_b,hd(Zs)))
827 #define map3Over(_f,_a,_b,_c,_xs)       mapModify(_xs,_f(_a,_b,_c,hd(Zs)))
828 #define map4Over(_f,_a,_b,_c,_d,_xs)    mapModify(_xs,_f(_a,_b,_c,_d,hd(Zs)))
829
830 /* This is just what you want for functions with accumulating parameters */
831 #define mapAccum(_f,_acc,_xs)           mapBasic(_xs,_acc=_f(_acc,hd(Zs)))
832 #define map1Accum(_f,_acc,_a,_xs)       mapBasic(_xs,_acc=_f(_acc,_a,hd(Zs)))
833 #define map2Accum(_f,_acc,_a,_b,_xs)    mapBasic(_xs,_acc=_f(_acc,_a,_b,hd(Zs)))
834 #define map3Accum(_f,_acc,_a,_b,_c,_xs) mapBasic(_xs,_acc=_f(_acc,_a,_b,_c,hd(Zs)))
835
836
837 /* --------------------------------------------------------------------------
838  * Strongly-typed lists (z-lists) and tuples (experimental)
839  * ------------------------------------------------------------------------*/
840
841 typedef Cell ZPair;
842 typedef Cell ZTriple;
843 typedef Cell Z4Ble;
844 typedef Cell Z5Ble;
845
846 #if 0
847 typedef Cell ZList;
848 extern Cell  zcons ( Cell x, Cell xs );
849 extern Cell  zhd ( Cell xs );
850 extern Cell  ztl ( Cell xs );
851 extern Cell  zsingleton ( Cell x );
852 extern Cell  zdoubleton ( Cell x, Cell y );
853 extern Int   zlength ( ZList xs );
854 extern ZList zreverse ( ZList xs );
855 #endif
856
857 extern Cell zpair ( Cell x1, Cell x2 );
858 extern Cell zfst ( Cell zpair );
859 extern Cell zsnd ( Cell zpair );
860
861 extern Cell ztriple ( Cell x1, Cell x2, Cell x3 );
862 extern Cell zfst3 ( Cell zpair );
863 extern Cell zsnd3 ( Cell zpair );
864 extern Cell zthd3 ( Cell zpair );
865
866 extern Cell z4ble ( Cell x1, Cell x2, Cell x3, Cell x4 );
867 extern Cell zsel14 ( Cell zpair );
868 extern Cell zsel24 ( Cell zpair );
869 extern Cell zsel34 ( Cell zpair );
870 extern Cell zsel44 ( Cell zpair );
871
872 extern Cell z5ble ( Cell x1, Cell x2, Cell x3, Cell x4, Cell x5 );
873 extern Cell zsel15 ( Cell zpair );
874 extern Cell zsel25 ( Cell zpair );
875 extern Cell zsel35 ( Cell zpair );
876 extern Cell zsel45 ( Cell zpair );
877 extern Cell zsel55 ( Cell zpair );
878
879 extern Cell unap ( int tag, Cell c );
880 #define isZPair(c) (whatIs((c))==ZTUP2)
881
882 /* --------------------------------------------------------------------------
883  * Implementation of function application nodes:
884  * ------------------------------------------------------------------------*/
885
886 #define ap(f,x)      pair(f,x)
887 #define ap1(f,x)     ap(f,x)
888 #define ap2(f,x,y)   ap(ap(f,x),y)
889 #define ap3(f,x,y,z) ap(ap(ap(f,x),y),z)
890 #define fun(c)       fst(c)
891 #define arg(c)       snd(c)
892 #define isAp(c)      (isPair(c) && !isTag(fst(c)))
893 extern  Cell         getHead     Args((Cell));
894 extern  List         getArgs     Args((Cell));
895 extern  Int          argCount;
896 extern  Cell         nthArg      Args((Int,Cell));
897 extern  Int          numArgs     Args((Cell));
898 extern  Cell         applyToArgs Args((Cell,List));
899
900 /* --------------------------------------------------------------------------
901  * Stack implementation:
902  *
903  * NB: Use of macros makes order of evaluation hard to predict.
904  *     For example, "push(1+pop());" doesn't increment TOS.
905  * ------------------------------------------------------------------------*/
906
907 extern  Cell DECTABLE(cellStack);
908 extern  StackPtr sp;
909
910 #define clearStack() sp=(-1)
911 #define stackEmpty() (sp==(-1))
912 #define stack(p)     cellStack[p]
913 #define chkStack(n)  if (sp>=NUM_STACK-(n)) hugsStackOverflow()
914 #define push(c)      \
915   do {               \
916     chkStack(1);     \
917     onto(c);         \
918   } while (0)
919 #define onto(c)      stack(++sp)=(c);
920 #define pop()        stack(sp--)
921 #define drop()       sp--
922 #define top()        stack(sp)
923 #define pushed(n)    stack(sp-(n))
924 #define topfun(f)    top()=ap((f),top())
925 #define toparg(x)    top()=ap(top(),(x))
926
927 extern  Void hugsStackOverflow Args((Void));
928
929 #if SYMANTEC_C
930 #include <Memory.h>
931 #define STACK_HEADROOM 16384
932 #define STACK_CHECK if (StackSpace() <= STACK_HEADROOM) \
933                       internal("Macintosh function parameter stack overflow.");
934 #else
935 #define STACK_CHECK
936 #endif
937
938 /* --------------------------------------------------------------------------
939  * Script file control:
940  * The implementation of script file storage is hidden.
941  * ------------------------------------------------------------------------*/
942
943 extern Script      startNewScript   Args((String));
944 extern Bool        moduleThisScript Args((Module));
945 extern Module      moduleOfScript   Args((Script));
946 extern Bool        isPreludeScript  Args((Void));
947 extern Module      lastModule       Args((Void));
948 extern Script      scriptThisFile   Args((Text));
949 extern Script      scriptThisName   Args((Name));
950 extern Script      scriptThisTycon  Args((Tycon));
951 extern Script      scriptThisInst   Args((Inst));
952 extern Script      scriptThisClass  Args((Class));
953 extern String      fileOfModule     Args((Module));
954 extern Void        dropScriptsFrom  Args((Script));
955
956
957 /* --------------------------------------------------------------------------
958  * Plugins
959  * ------------------------------------------------------------------------*/
960
961 #if PLUGINS
962 /* This is an exact copy of the declaration found in GreenCard.h */
963
964 typedef int     HugsStackPtr;
965 typedef int     HugsStablePtr;
966 typedef Pointer HugsForeign;
967
968 typedef struct {
969
970   /* evaluate next argument */
971   int            (*getInt   )     Args(());  
972   unsigned int   (*getWord  )     Args(());
973   void*          (*getAddr  )     Args(());
974   float          (*getFloat )     Args(());
975   double         (*getDouble)     Args(());
976   char           (*getChar  )     Args(());
977   HugsForeign    (*getForeign)    Args(());
978   HugsStablePtr  (*getStablePtr)  Args(());
979
980   /* push part of result   */
981   void           (*putInt   )     Args((int));           
982   void           (*putWord  )     Args((unsigned int));
983   void           (*putAddr  )     Args((void*));
984   void           (*putFloat )     Args((double));
985   void           (*putDouble)     Args((double));
986   void           (*putChar  )     Args((char));
987   void           (*putForeign)    Args((HugsForeign, void (*)(HugsForeign)));
988   void           (*putStablePtr)  Args((HugsStablePtr));
989
990   /* return n values in IO monad or Id monad */
991   void           (*returnIO)      Args((HugsStackPtr, int));
992   void           (*returnId)      Args((HugsStackPtr, int));
993   int            (*runIO)         Args((int));
994
995   /* free a stable pointer */                            
996   void           (*freeStablePtr) Args((HugsStablePtr));
997
998   /* register the prim table */                          
999   void           (*registerPrims) Args((struct primInfo*));
1000                            
1001   /* garbage collect */
1002   void           (*garbageCollect) Args(());
1003
1004 } HugsAPI2;
1005
1006 extern  HugsAPI2* hugsAPI2     Args((Void));
1007 typedef Void (*InitModuleFun2) Args((HugsAPI2*));
1008
1009 typedef struct {
1010   Name  nameTrue, nameFalse;
1011   Name  nameNil,  nameCons;
1012   Name  nameJust, nameNothing;
1013   Name  nameLeft, nameRight;
1014   Name  nameUnit;
1015   Name  nameIORun;
1016
1017   Cell  (*makeInt)         Args((Int));
1018                            
1019   Cell  (*makeChar)        Args((Char));
1020   Char  (*CharOf)          Args((Cell));
1021                            
1022   Cell  (*makeFloat)       Args((FloatPro));
1023   Cell  (*makeTuple)       Args((Int));
1024   Pair  (*pair)            Args((Cell,Cell));
1025                            
1026   Cell  (*mkMallocPtr)     Args((Void *, Void (*)(Void *)));
1027   Void *(*derefMallocPtr)  Args((Cell));
1028                            
1029   Int   (*mkStablePtr)     Args((Cell));
1030   Cell  (*derefStablePtr)  Args((Int));
1031   Void  (*freeStablePtr)   Args((Int));
1032                            
1033   Void  (*eval)            Args((Cell));
1034   Cell  (*evalWithNoError) Args((Cell));
1035   Void  (*evalFails)       Args((StackPtr));
1036   Int   *whnfArgs;         
1037   Cell  *whnfHead;         
1038   Int   *whnfInt;          
1039   Float *whnfFloat;        
1040                            
1041   Void  (*garbageCollect)  Args(());
1042   Void  (*stackOverflow)   Args(());
1043   Void  (*internal)        Args((String)) HUGS_noreturn;
1044
1045   Void  (*registerPrims)   Args((struct primInfo*));
1046   Name  (*addPrimCfun)     Args((Text,Int,Int,Cell));
1047   Text  (*inventText)      Args(());
1048
1049   Cell *(*Fst)             Args((Cell));
1050   Cell *(*Snd)             Args((Cell));
1051
1052   Cell  *cellStack;
1053   StackPtr *sp;
1054 } HugsAPI1;
1055
1056 extern  HugsAPI1* hugsAPI1     Args((Void));
1057 typedef Void (*InitModuleFun1) Args((HugsAPI1*));
1058 #endif /* PLUGINS */
1059
1060
1061 /* --------------------------------------------------------------------------
1062  * Misc:
1063  * ------------------------------------------------------------------------*/
1064
1065 extern  Void   setLastExpr       Args((Cell));
1066 extern  Cell   getLastExpr       Args((Void));
1067 extern  List   addTyconsMatching Args((String,List));
1068 extern  List   addNamesMatching  Args((String,List));
1069
1070 /*-------------------------------------------------------------------------*/