1/* BEGIN LICENSE BLOCK
2 * Version: CMPL 1.1
3 *
4 * The contents of this file are subject to the Cisco-style Mozilla Public
5 * License Version 1.1 (the "License"); you may not use this file except
6 * in compliance with the License.  You may obtain a copy of the License
7 * at www.eclipse-clp.org/license.
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
11 * the License for the specific language governing rights and limitations
12 * under the License.
13 *
14 * The Original Code is  The ECLiPSe Constraint Logic Programming System.
15 * The Initial Developer of the Original Code is  Cisco Systems, Inc.
16 * Portions created by the Initial Developer are
17 * Copyright (C) 1989-2006 Cisco Systems, Inc.  All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * END LICENSE BLOCK */
22
23/*
24 * SEPIA INCLUDE FILE
25 *
26 * VERSION	$Id: dict.h,v 1.5 2009/03/09 05:29:48 jschimpf Exp $
27 *
28 * IDENTIFICATION:	dict.h
29 *
30 * DESCRIPTION:		Types and macro definitions related to
31 *
32 *				- dictionary
33 *				- procedure table
34 *				- properties
35 *
36 * AUTHORS:		Joachim Schimpf, Emmanuel van Rossum, Micha Meier
37 *
38 */
39
40
41/*
42 *	DICTIONARY PARAMETERS AND DATA TYPE DEFS
43 */
44
45/* Dictionary Related Definitions */
46#define		D_UNKNOWN	0L	/* unknown did */
47
48/* values for the stability field */
49#define		DICT_VOLATILE	0	/* has only stack & property references	*/
50#define		DICT_HEAP_REF	1	/* (unused)				*/
51#define		DICT_CODE_REF	2	/* may have code references		*/
52#define		DICT_PERMANENT	3	/* do never remove from dictionary	*/
53
54/* In unused (e.g. garbage collected) dict_items, we set the arity
55** field to this value in order to catch bugs */
56#define		UNUSED_DID_ARITY	(-3)
57
58
59
60/* dictionary definitions */
61#define		DidPtr(D)	((dident) (D))
62#define		DidAttainable(D) DidPtr(D)->attainable
63#define		DidMacro(D)	DidPtr(D)->macro
64#define		DidModule(D)	DidPtr(D)->module
65#define		DidIsOp(D)	DidPtr(D)->isop
66#define		DidProc(D)	DidPtr(D)->procedure
67#define 	DidProperties(D) DidPtr(D)->properties
68#define 	DidBitField(D)	DidPtr(D)->bitfield
69#define 	DidStability(D)	DidPtr(D)->stability
70#define 	DidNext(D)	DidPtr(D)->next
71
72#define Set_Did_Stability(D, NewStability) \
73	{ if ((NewStability) > (int) DidPtr(D)->stability) \
74		DidPtr(D)->stability = (NewStability); }
75
76/* marking for dictionary GC */
77#define	Mark_Did(D)	DidAttainable(D) = 1
78#define	Mark_VarName(t)	DidAttainable(TagDid(t)) = 1
79
80/* convert a given functor to another arity */
81#define Add_Dict(d, new_arity) 	d = add_dict(d, new_arity)
82
83
84/* ------------------------ PROCEDURE DESCRIPTOR ---------------------	*/
85
86/*
87 * A procedure descriptor (pri) describes a predicate visible in a module.
88 * It stores all predicate properties, visibility information, and code.
89 *
90 * Every predicate has:
91 * - a descriptor in the module where it is defined (LOCAL,EXPORT),
92 *	this is called the "home" or "definition" descriptor.
93 * - a descriptor in every module where it is visible (IMPORT,IMPEXP).
94 * - a qualified access descriptor (QUALI) in every module where
95 *     there is a compiled qualified access to it via :/2.
96 * - a DEFAULT descriptor in every module where it is referenced but the
97 *     source of the corresponding definition is not yet known.
98 *
99 * Procedure descriptors may be referenced from
100 * - other procedure descriptors
101 * - wam code (but only code in the same module as the descriptor!)
102 * - certain stack data (suspensions, trace frames)
103 * Procedure descriptors are only freed when their module is erased.
104 *
105 * Procedure descriptors are usually looked up via predicate functor and
106 * module name. Related code and further description is in proc_desc.c.
107 */
108
109
110/*
111 * Option values for calls to visible_procedure()
112 */
113
114#define PRI_CREATE	1	/* create pri if none exists */
115#define PRI_REFER	2	/* mark pri as referenced */
116#define PRI_DONTIMPORT	4	/* don't try to import if none exists */
117#define PRI_DONTWARN	8	/* don't issue redefinition warnings */
118#define PRI_EXPORTEDONLY 16	/* hide module internals */
119
120
121/*
122 * Generic pointer to the code that implements a procedure
123 */
124
125typedef union
126{
127    vmcode	*vmc;		/* pointer to virtual machine code	*/
128    word	cint;		/* builtin number in emulator		*/
129    int		(*func)();	/* address of C function		*/
130} pri_code_t;
131
132
133/*
134 * The actual procedure descriptor (pri)
135 */
136
137#define PRIMODEBITS	24		/* bits used for storing mode	*/
138
139typedef struct pri
140{
141    pri_code_t		code;		/* code (multiple types)	*/
142    struct pri		*nextproc;	/* next pri with same functor	*/
143    struct pri		*next_in_mod;	/* next pri in same module	*/
144    dident		module_def;	/* module of this descriptor	*/
145    dident		module_ref;	/* home module of the procedure	*/
146    dident		did;		/* this procedure's functor	*/
147    uint32		flags;		/* various flags, see below	*/
148    unsigned		prio:4;		/* the schedule priority	*/
149    unsigned		run_prio:4;	/* the run priority		*/
150    unsigned		mode:PRIMODEBITS;	/* the mode declaration	*/
151    dident		trans_function;	/* did of the transformation procedure*/
152} pri;
153
154
155/*
156 * Access macros for procedure descriptor
157 */
158
159#define	PriCode(pd)		(pd)->code.vmc
160#define	PriCint(pd)		(pd)->code.cint
161#define	PriFunc(pd)		(pd)->code.func
162#define	PriNext(pd)		(pd)->nextproc
163#define	PriModule(pd)		(pd)->module_def
164#define	PriHomeModule(pd)	(pd)->module_ref
165#define	PriFlags(pd)		(pd)->flags
166#define PriDid(pd)		(pd)->did
167#define PriMode(pd)		(pd)->mode
168#define PriPriority(pd)		(pd)->prio
169#define PriRunPriority(pd)	(pd)->run_prio
170#define PriScope(pd)		(PriFlags(pd) & PREDSCOPE)
171#define	PriCodeType(pd)		(PriFlags(pd) & CODETYPE)
172#define	PriArgPassing(pd)	(PriFlags(pd) & ARGPASSING)
173#define UnifType(pd)		(PriFlags(pd) & UNIFTYPE)
174#define StaticProc(pd)		(!DynamicProc(pd))
175#define DynamicProc(pd)		(PriFlags(pd) & PROC_DYNAMIC)
176#define SystemProc(pd)		(PriFlags(pd) & SYSTEM)
177#define ToolProc(pd)		(PriFlags(pd) & TOOL)
178#define DebugProc(pd)		(PriFlags(pd) & DEBUG_DB)
179#define ParallelProc(pd)	(PriFlags(pd) & PROC_PARALLEL)
180#define InvisibleProc(pd)	(PriFlags(pd) & DEBUG_INVISIBLE)
181
182#define Pri_Set_Scope(pd,newscope) \
183 	PriFlags(pd) = (PriFlags(pd) & ~PREDSCOPE) | (newscope);
184
185#define PriReferenced(pd) \
186 	(!(PriFlags(pd) & NOREFERENCE))
187#define Pri_Set_Reference(pd) \
188 	PriFlags(pd) &= ~NOREFERENCE;
189
190#define IsVisibilityPri(pd)	((pd)  &&  PriScope(pd) != QUALI)
191#define PriIsProxy(pd) \
192 	(PriScope(pd) == IMPORT || PriScope(pd) == QUALI || PriScope(pd) == IMPEXP)
193#define PriAnyExp(pd) \
194 	(PriScope(pd) == EXPORT || PriScope(pd) == IMPEXP)
195#define PriExported(pd) \
196 	(PriScope(pd) == EXPORT)
197#define PriExportedFrom(pd, module) \
198 	(PriExported(pd)  &&  (module) == (pd)->module_ref)
199#define PriWillExport(pd) \
200 	(PriFlags(pd) & TO_EXPORT)
201
202
203/* ---------------- GROUPS OF PROCEDURE FLAGS -----------------------	*/
204
205/* Every flag must be either in COMMON_FLAGS or in DESCRIPTOR_FLAGS.
206 * The COMMON_FLAGS belong to the procedure and have to be kept consistent
207 * over all the linked descriptors for the same actual procedure.
208 * The DESCRIPTOR_FLAGS belong to the descriptor only.
209 */
210#define COMMON_FLAGS	(~DESCRIPTOR_FLAGS)
211#define DESCRIPTOR_FLAGS (NOREFERENCE|PREDSCOPE|TO_EXPORT|DONT_REEXPORT)
212
213
214/* Flags that can't be changed once the procedure has been referenced,
215 * i.e. all the information that might have been exploited in compiling
216 * a call to the predicate (calling convention, etc).
217 */
218#define PF_DONT_CHANGE_WHEN_REFERENCED	\
219	(TOOL|CODETYPE|ARGPASSING|UNIFTYPE)
220
221/* Flags that can't be changed once the procedure has been defined.
222 * This is basically the information that may be used when compiling
223 * the code for the predicate.
224 */
225#define PF_DONT_CHANGE_WHEN_DEFINED	\
226	(PF_DONT_CHANGE_WHEN_REFERENCED|PROC_PARALLEL|PROC_DEMON\
227	|PROC_DYNAMIC|EXTERN)
228
229/* Flags that can be changed even when not in the home module */
230#define PF_CHANGE_FROM_ANYWHERE \
231	(DEBUG_TR|DEBUG_SP|DEBUG_SK|DEBUG_ST)
232
233
234/* The flags that must be stored along with the code in .eco files
235 * (the ones that are set by compiler pragmas rather than proper queries)
236 */
237#define ECO_FLAGS	(SYSTEM|DEBUG_DB|DEBUG_SK|PROC_AUXILIARY)
238
239
240/* ------------------------- PROCEDURE FLAGS ------------------------	*/
241
242/* The descriptor was not yet referenced (from code, or equivalent).
243 * This implies that it can still be changed rather freely.
244 */
245#define NOREFERENCE	0x20000000
246
247
248/* Procedure visibility */
249#define PREDSCOPE	0x07000000
250#define QUALI		0x00000000
251#define LOCAL		0x01000000
252#define EXPORT		0x02000000
253#define IMPORT		0x03000000
254#define DEFAULT		0x04000000
255#define IMPEXP		0x05000000
256
257#define TO_EXPORT	0X10000000	/* always together with LOCAL */
258#define DONT_REEXPORT	0X10000000	/* together with EXPORT/IMPEXP */
259
260
261/* Various predicate properties (set via declarations or by the compiler) */
262#define SYSTEM		0x40000000	/* was compiled with system-pragma */
263#define PROC_PARALLEL	0x00400000	/* has been declared parallel	*/
264#define PROC_DEMON	0x00200000	/* has been declared a demon	*/
265#define PROC_DYNAMIC	0x80000000	/* has been declared dynamic	*/
266#define EXTERN		0X00000080	/* has been declared external	*/
267#define TOOL		0x00000040	/* it is a tool interface */
268#define AUTOLOAD	0X00000400	/* autoload flag, causes autoload
269					 * event rather than undefined
270					 * procedure event */
271#define PROC_AUXILIARY	0X00000800	/* it is a compiler auxiliary, ie. it
272					   needs to be saved in .eco files */
273#define PROC_DEPRECATED	0x00000020	/* deprecated, warn if used	*/
274
275
276/* Debugger flags */
277#define DEBUG_TYPES	0X081F0100
278#define DEBUG_TR	0X00010000	/* traceable 		*/
279#define DEBUG_SP	0X00020000	/* has a spy point	*/
280#define DEBUG_SK	0X00040000	/* skipped		*/
281#define DEBUG_DB	0x00080000	/* in debugging mode	*/
282#define DEBUG_ST	0x00100000	/* start debugger	*/
283#define DEBUG_INVISIBLE	0x08000000	/* not even a box	*/
284#define DEBUG_TRMETA	0X00000100	/* always trace metacalled subgoals */
285/* default flags for a traceable procedure */
286#define DEBUG_DF	DEBUG_TR
287
288/* the debugger flags occur also in the TRACE_MODE register
289 * They are also defined in tracer.pl!
290 */
291#define TR_TRACING	DEBUG_TR	/* must match, see OfInterest() */
292#define TR_LEAPING	DEBUG_SP	/* must match, see OfInterest() */
293#define TR_STARTED	DEBUG_ST	/* arbitrary */
294
295/*
296#define UNUSED_BITS	0X0000F000
297*/
298
299
300/*
301 * Different predicate implementations. Combinations currently used:
302 *
303 * CODETYPE	ARGPASSING	other
304 *
305 * VMCODE	ARGFIXEDWAM	-		static Prolog predicate
306 * VMCODE	ARGFIXEDWAM	PROC_DYNAMIC	dynamic Prolog predicate
307 * VMCODE	ARGFIXEDWAM	EXTERN		C external with WAM wrapper
308 * VMCODE	ARGFLEXWAM	EXTERN		C external (in emulator)
309 */
310
311/* CODETYPE describes the contents of the .code field (a union) */
312#define CODETYPE	0X00000200
313#define	VMCODE		0X00000200	/* virtual machine code		*/
314#define	FUNPTR		0X00000000	/* function pointer		*/
315
316#define B_SAFE		VMCODE		/* obsolete built-in classification */
317#define B_UNSAFE	VMCODE		/* obsolete built-in classification */
318
319#define CODE_DEFINED	0x00800000	/* has non-default code		*/
320
321
322/* ARGPASSING describes the calling convention of the predicate */
323#define ARGPASSING	0X00000001
324#define ARGFIXEDWAM	0X00000000	/* Args in A[1]..A[n]		*/
325#define ARGFLEXWAM 	0X00000001	/* various regs and immediate args */
326/* #define ARGSTACK	0X00000002	Args on local stack (obsolete)	*/
327/* #define ARGSTRUCT	0X00000003	future extension */
328
329
330
331/* Unification types: used in the compiler (conditions),
332   in the occur check etc. Currently only for builtins, but can hold also
333   for Prolog ones.
334   ***The order is important!
335 */
336#define UNIFTYPE	0X0000001c /* Unification type field */
337
338#define U_NONE		0x00000000 /* no unification at all, must be 0!      */
339#define U_SIMPLE	0x00000004 /* unify 1 arg with a simple term	      */
340#define U_GROUND	0x00000008 /* unify args with ground terms+functor/3 */
341#define U_FRESH		0x0000000c /* unify to a term with fresh variables   */
342#define U_UNIFY		0x0000000c /* general unification		      */
343#define U_GLOBAL	0x00000010 /* binds to a term with other variables   */
344#define U_DELAY		0x00000014 /* a delay condition */
345
346
347
348/*
349 * The mode declarations are stored in a bitfield of PRIMODEBITS,
350 * the mode specification for one argument consists of PMODEBITS bits.
351 * This means that up to arity MAX_MODES the declaration
352 * can be taken into account, higher arguments are ignored.
353 */
354
355#undef EXTENDED_MODES		/* set this to allow -+ and +- modes */
356
357#define ANY			0		/* (?)	must be 0!	    */
358#define OUTPUT                  1		/* (-)	actually uninit	    */
359#define NONVAR                  2		/* (+)	nonground structure */
360#define GROUND                  3		/* (++)			    */
361#ifdef EXTENDED_MODES
362#define NOALIAS                 5		/* (-+) term without aliases*/
363#define NOALIAS_INST            7		/* (+-) no aliases, inst.   */
364#endif
365
366/* simulate an array of n-bit elements */
367#ifdef EXTENDED_MODES
368#define PMODEBITS		3
369#define PMODEMASK		7
370#else
371#define PMODEBITS		2
372#define PMODEMASK		3
373#endif
374#define MAX_MODES		(PRIMODEBITS/PMODEBITS)
375
376/* Mode() and Next_Mode() must work even for arities bigger than MAX_MODES */
377#define Mode(i, mode_decl)	\
378        ((i) > MAX_MODES ? ANY :        \
379	    (((mode_decl) >> (((i) - 1) * PMODEBITS)) & PMODEMASK))
380#define Next_Mode(part_mode, next)	(next) = (part_mode) & PMODEMASK;    \
381					(part_mode) >>= PMODEBITS;
382#define Set_Mode(i, mode_decl, val)	\
383	    {if ((i) <= MAX_MODES) (mode_decl) = \
384		((mode_decl) & ~(PMODEMASK << (((i) - 1) * PMODEBITS))) | \
385		    (val) << (((i) - 1) * PMODEBITS);\
386	    }
387
388
389/* Obsolete built-in binding information - being phased out */
390#define CONSTANT                1
391#define BoundArg(i, val)	0
392
393
394/* ------------------------- PROPERTIES TABLE -----------------------	*/
395
396typedef struct property			/* property descriptor */
397{
398    int			name;		/* the property name resp. number    */
399    dident		module;		/* the definition module / D_UNKNOWN */
400    pword 		property_value; /* prop value / TEND if undefined   */
401    struct property	*next_prop,	/* next same module / next global    */
402    			*next_mod;	/* same property in other module     */
403} property;
404
405
406#define EOI_SYMBOL	256		/* end of input pseudo character */
407
408typedef struct syntax_desc
409{
410    unsigned char	char_class[EOI_SYMBOL+1]; /* 256 ASCII + 1 EOI symbol */
411    int			options;
412    unsigned char	current_sq_char;
413    unsigned char	current_aq_char;
414    unsigned char	current_ul_char;
415    int			current_escape;
416} syntax_desc;
417
418extern syntax_desc	*default_syntax;
419
420typedef struct didlist
421{
422    dident		 name;
423    struct didlist	*next;
424} didlist;
425
426/* module descriptor	*/
427typedef struct module_item
428{
429    syntax_desc		*syntax;	/* module syntax descriptor	     */
430    char		*lock;		/* the module password		     */
431    pri			*procedures;	/* list of procedures in this module */
432    property		*properties;	/* list of properties in this module */
433    didlist		*imports;	/* list of imported modules (import/1)*/
434} module_item;
435
436
437/* macro transformation descriptor	*/
438typedef struct macro_desc
439{
440	int		flags;		/* transformation options	     */
441	dident		trans_function;	/* did of the transformation procedure*/
442	dident		module;		/* did of the transformation module  */
443} macro_desc;
444
445/* flags */
446#define TR_FLAGS	0x00003f00
447#define TR_TYPE		0x00000f00	/* mandatory flags in caller	*/
448#define TR_TOP		0x00000100
449#define TR_CLAUSE	0x00000200
450#define TR_GOAL		0x00000400
451#define TR_WRITE	0x00000800
452#define TR_PROTECT	0x00001000
453#define TR_GLOBAL	0x00002000
454
455
456/* ---------------------------- OPERATORS -----------------------------	*/
457
458/* an operator item is put in a pword: the tag part contains the prolog
459   tag (8 bits), the associativity (3 bits), the precedence (11 bits)
460   and bits for the garbage collector; the value part stores the did
461   needed by the parser							*/
462typedef pword opi;
463
464/* access thru *opi							*/
465#define		ASSOC_MASK	0X00000F00 /* mask the assoc bits	*/
466#define		PRECED_MASK	0X07FF0000 /* mask the preced bits	*/
467#define		ASSOC_SHIFT	8
468#define		PRECED_SHIFT	16
469#define		SHIFTED_ASSOC_MASK	(ASSOC_MASK >> ASSOC_SHIFT)
470#define		SHIFTED_PRECED_MASK	(PRECED_MASK >> PRECED_SHIFT)
471
472#define		OpiDid(O)	(O)->val.did
473#define		GetOpiAssoc(O) \
474    (((O)->tag.kernel >> ASSOC_SHIFT) & SHIFTED_ASSOC_MASK)
475#define		GetOpiPreced(O)	\
476    (((O)->tag.kernel >> PRECED_SHIFT) & SHIFTED_PRECED_MASK)
477#define		Set_Opi_Assoc(O, V) \
478    (O)->tag.kernel = ((O)->tag.kernel & ~ASSOC_MASK) | ((V) << ASSOC_SHIFT)
479#define		Set_Opi_Preced(O, V) \
480    (O)->tag.kernel = ((O)->tag.kernel & ~PRECED_MASK) | ((V) << PRECED_SHIFT)
481
482/* Operator Associativities						*/
483#define		NIL_OP		0
484#define		FX		1
485#define		FY		2
486#define		XF		3
487#define		YF		4
488#define		XFX		5
489#define		XFY		6
490#define		YFX		7
491#define		FXX		8
492#define		FXY		9
493#define		MAX_ASSOC	9
494
495/* Tests for Associativity */
496
497#define IsPrefix2(op)		(GetOpiAssoc(op) >= FXX)
498#define IsPostfixAss(ass)	((ass) == XF || (ass) == YF)
499
500/* Get precedences */
501
502#define Get_Prefix_Prec(op_desc, oprec, rprec) \
503	oprec = GetOpiPreced(op_desc); \
504	rprec = GetOpiAssoc(op_desc) == FY ? oprec : oprec - 1;
505
506#define Get_Postfix_Prec(op_desc, lprec, oprec) \
507	oprec = GetOpiPreced(op_desc); \
508	lprec = GetOpiAssoc(op_desc) == YF ? oprec : oprec - 1;
509
510#define Get_Infix_Prec(op_desc, lprec, oprec, rprec) \
511	oprec = GetOpiPreced(op_desc); \
512	lprec = GetOpiAssoc(op_desc) == YFX ? oprec : oprec - 1; \
513	rprec = GetOpiAssoc(op_desc) == XFY ? oprec : oprec - 1;
514
515#define Get_Prefix2_Prec(op_desc, oprec, lprec, rprec) \
516	oprec = GetOpiPreced(op_desc); \
517	lprec = oprec - 1; \
518	rprec = GetOpiAssoc(op_desc) == FXY ? oprec : oprec - 1;
519
520#define InfixLeftPrecedence(op_desc) \
521	( GetOpiAssoc(op_desc) == YFX ? GetOpiPreced(op_desc) : GetOpiPreced(op_desc) - 1 )
522
523#define PostfixLeftPrecedence(op_desc) \
524	( GetOpiAssoc(op_desc) == YF  ? GetOpiPreced(op_desc) : GetOpiPreced(op_desc) - 1 )
525
526
527
528/*-------------------- function declarations --------------------*/
529
530/* dictionary */
531Extern dident	in_dict ARGS((char*,int));
532Extern dident	enter_dict ARGS((char*,int));
533Extern dident	enter_dict_n ARGS((char*,word,int));
534Extern dident	add_dict ARGS((dident,int));
535Extern dident	check_did ARGS((dident,int));
536Extern dident	check_did_n ARGS((char*,word,int));
537Extern dident	bitfield_did ARGS((word));
538
539Extern int	next_functor ARGS((int *index, dident *did));
540Extern int	ec_gc_dictionary ARGS((void));
541Extern int	ec_dict_param ARGS((value,type,value,type));
542
543Extern pword	*enter_string_n ARGS((char*,word,int));
544
545Extern int	ec_constant_table_enter ARGS((value,type,pword*));
546
547/* procedure descriptor handling */
548Extern pri	*local_procedure ARGS((dident,dident,type,int));
549Extern pri	*export_procedure ARGS((dident,dident,type));
550Extern pri	*reexport_procedure ARGS((dident,dident,type,dident));
551Extern pri	*global_procedure ARGS((dident,dident,type));
552Extern pri	*import_procedure ARGS((dident,dident,type,dident));
553Extern pri	*visible_procedure ARGS((dident,dident,type,int));
554Extern pri	*qualified_procedure ARGS((dident,dident,dident,type));
555Extern pri	*pri_home ARGS((pri*));
556Extern int	pri_compatible_flags ARGS((pri*,uint32,uint32));
557Extern void	pri_change_flags ARGS((pri*,uint32,uint32));
558Extern void	pri_init_code ARGS((pri*,int));
559Extern void	pri_define_code ARGS((pri*,int,pri_code_t));
560Extern int	pri_change_trans_function ARGS((pri*,dident));
561Extern int	pri_change_mode ARGS((pri*,uint32));
562Extern int	pri_change_prio ARGS((pri*,int));
563Extern int	pri_change_run_prio ARGS((pri*,int));
564
565Extern pri *	built_in(dident did1, int (*func) (/* ??? */), word flags);
566Extern pri *	local_built_in(dident did1, int (*func) (/* ??? */), word flags);
567Extern pri *	exported_built_in(dident did1, int (*func) (/* ??? */), word flags);
568Extern pri *	b_built_in(dident did1, int (*func) (/* ??? */), dident module);
569Extern word	ec_getaddress ARGS((char*));
570
571/*
572 * Pointers to some compiler-expanded builtin descriptors (in particular
573 * those which have an emulator instruction and can delay or raise events)
574 */
575Extern pri
576	*fail_proc_,
577	*true_proc_,
578	*softcut_proc_,
579	*cut_to_proc_,
580	*cut_to_stamp_proc_,
581	*minus_proc_,
582	*add_proc_,
583	*sub_proc_,
584	*mul_proc_,
585	*quot_proc_,
586	*div_proc_,
587	*rem_proc_,
588	*fdiv_proc_,
589	*mod_proc_,
590	*and_proc_,
591	*or_proc_,
592	*xor_proc_,
593	*bitnot_proc_,
594	*lt_proc3_,
595	*le_proc3_,
596	*eq_proc3_,
597	*ne_proc3_,
598	*ge_proc3_,
599	*gt_proc3_,
600	*identical_proc_,
601	*not_identical_proc_,
602	*inequality_proc_,
603	*not_ident_list_proc_,
604	*arg_proc_,
605	*arity_proc_,
606	*make_suspension_proc_;
607
608/* operator lookup */
609Extern opi *	visible_op ARGS((dident atom, dident module, type mod_tag, int *res));
610Extern opi *	visible_prefix_op ARGS((dident atom, dident module, type mod_tag, int *res));
611Extern opi *	visible_infix_op ARGS((dident atom, dident module, type mod_tag, int *res));
612Extern opi *	visible_postfix_op ARGS((dident atom, dident module, type mod_tag, int *res));
613
614/* ------------------------- STORE TABLE -----------------------*/
615
616typedef struct htable_elem {
617    struct htable_elem	*next;
618    uword		hash;
619    pword		key;
620    pword		value;
621} t_htable_elem;
622
623typedef struct {
624    uword		ref_ctr;
625    uword		size;
626    uword		nentries;
627    uword		internal;
628    t_htable_elem	**htable;
629} t_heap_htable;
630
631#define HTABLE_INTERNAL 1
632
633/*-------------------- function declarations --------------------*/
634
635Extern t_heap_htable	*htable_new ARGS((int));
636Extern void		htable_free ARGS((t_heap_htable *));
637Extern int		store_set ARGS((t_heap_htable*,value,type,pword*));
638Extern int		store_get ARGS((t_heap_htable*,value,type,pword*));
639Extern int		store_get_else_set ARGS((t_heap_htable*,value,type,pword*));
640
641