YAP 7.1.0
computils.c
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: computils.c *
12* comments: some useful routines for YAP's compiler *
13* *
14* Last rev: $Date: 2007-11-26 23:43:08 $ *
15* $Log: not supported by cvs2svn $
16* Revision 1.31 2007/11/06 17:02:12 vsc
17* compile ground terms away.
18*
19* Revision 1.30 2006/09/20 20:03:51 vsc
20* improve indexing on floats
21* fix sending large lists to DB
22*
23* Revision 1.29 2005/12/05 17:16:10 vsc
24* write_depth/3
25* overflow handlings and garbage collection
26* Several ipdates to CLPBN
27* dif/2 could be broken in the presence of attributed variables.
28*
29* Revision 1.28 2005/09/08 22:06:44 rslopes
30* BEAM for YAP update...
31*
32* Revision 1.27 2005/07/06 15:10:04 vsc
33* improvements to compiler: merged instructions and fixes for ->
34*
35* Revision 1.26 2005/01/04 02:50:21 vsc
36* - allow MegaClauses with blobs
37* - change Diffs to be thread specific
38* - include Christian's updates
39*
40* Revision 1.25 2004/11/19 17:14:13 vsc
41* a few fixes for 64 bit compiling.
42*
43* Revision 1.24 2004/04/16 19:27:31 vsc
44* more bug fixes
45*
46* Revision 1.23 2004/03/10 14:59:55 vsc
47* optimise -> for type tests
48* *
49* *
50*************************************************************************/
51#ifdef SCCS
52static char SccsId[] = "%W% %G%";
53#endif
54
55/*
56 * This file includes a set of utilities, useful to the several compilation
57 * modules
58 */
59
60#include "Yap.h"
61#include "Yatom.h"
62#include "YapHeap.h"
63#define COMPILER_NAMES 1
64#include "YapCompile.h"
65#undef COMPILER_NAMES
66#include "YapCompile.h"
67#include "yapio.h"
68#if HAVE_STRING_H
69#include <string.h>
70#endif
71
72/*
73 * The compiler creates an instruction chain which will be assembled after
74 * afterwards
75 */
76
77
78
79typedef struct mem_blk {
80 union {
81 struct mem_blk *next;
82 double fill;
83 } ublock;
84 char contents[1];
85} MemBlk;
86
87#define CMEM_BLK_SIZE (4*4096)
88#define FIRST_CMEM_BLK_SIZE (16*4096)
89
90static char *
91AllocCMem (UInt size, struct intermediates *cip)
92{
93#if SIZEOF_INT_P==8
94 size = (size + 7) & ((UInt)-8);
95#else
96 size = (size + 3) & ((UInt)0xfffffffc);
97#endif
98#if USE_SYSTEM_MALLOC
99 if (!cip->blks || cip->blk_cur+size > cip->blk_top) {
100 UInt blksz;
101 struct mem_blk *p;
102
103 if (size > CMEM_BLK_SIZE)
104 blksz = size+sizeof(struct mem_blk);
105 else
106 blksz = CMEM_BLK_SIZE;
107 if (!cip->blks) {
108 CACHE_REGS
109 if (LOCAL_CMemFirstBlock) {
110 p = LOCAL_CMemFirstBlock;
111 blksz = LOCAL_CMemFirstBlockSz;
112 p->ublock.next = NULL;
113 } else {
114 if (blksz < FIRST_CMEM_BLK_SIZE)
115 blksz = FIRST_CMEM_BLK_SIZE;
116 p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
117 if (!p) {
118 LOCAL_Error_Size = size;
119 save_machine_regs();
120 siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
121 }
122 LOCAL_CMemFirstBlock = p;
123 LOCAL_CMemFirstBlockSz = blksz;
124 }
125 } else {
126 p = (struct mem_blk *)Yap_AllocCodeSpace(blksz);
127 if (!p) {
128 CACHE_REGS
129 LOCAL_Error_Size = size;
130 save_machine_regs();
131 siglongjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
132 }
133 }
134 p->ublock.next = cip->blks;
135 cip->blks = p;
136 cip->blk_cur = p->contents;
137 cip->blk_top = (char *)p+blksz;
138 }
139 {
140 char *out = cip->blk_cur;
141 cip->blk_cur += size;
142 return out;
143 }
144#else
145 char *p;
146 if (ASP <= CellPtr (cip->freep) + 256) {
147 CACHE_REGS
148 LOCAL_Error_Size = 256+((char *)cip->freep - (char *)HR);
149 save_machine_regs();
150 siglongjmp(cip->CompilerBotch, OUT_OF_STACK_BOTCH);
151 }
152 p = cip->freep;
153 cip->freep += size;
154 return p;
155#endif
156}
157
158void
159Yap_ReleaseCMem (struct intermediates *cip)
160{
161#if USE_SYSTEM_MALLOC
162 CACHE_REGS
163 struct mem_blk *p = cip->blks;
164 while (p) {
165 struct mem_blk *nextp = p->ublock.next;
166 if (p != LOCAL_CMemFirstBlock)
167 Yap_FreeCodeSpace((ADDR)p);
168 p = nextp;
169 }
170 cip->blks = NULL;
171 if (cip->label_offset &&
172 cip->label_offset != LOCAL_LabelFirstArray) {
173 Yap_FreeCodeSpace((ADDR)cip->label_offset);
174 }
175#endif
176 cip->label_offset = NULL;
177}
178
179char *
180Yap_AllocCMem (UInt size, struct intermediates *cip)
181{
182 return AllocCMem(size, cip);
183}
184
185static int
186is_a_test(Term arg, Term mod)
187{
188 if (IsVarTerm (arg)) {
189 return FALSE;
190 }
191 if (IsVarTerm (arg) || !IsAtomTerm(mod)) {
192 return FALSE;
193 }
194 if (IsAtomTerm (arg)) {
195 Atom At = AtomOfTerm (arg);
196 PredEntry *pe = RepPredProp(PredPropByAtom(At, mod));
197 if (EndOfPAEntr(pe))
198 return FALSE;
199 return pe->PredFlags & TestPredFlag;
200 }
201 if (IsApplTerm (arg)) {
202 Functor f = FunctorOfTerm (arg);
203
204 if (f == FunctorModule) {
205 return is_a_test(ArgOfTerm(2,arg), ArgOfTerm(1,arg));
206 } else if (f == FunctorComma) {
207 return
208 is_a_test(ArgOfTerm(1,arg), mod) &&
209 is_a_test(ArgOfTerm(2,arg), mod);
210 } else {
211 PredEntry *pe = RepPredProp(PredPropByFunc(f, mod));
212
213 if (EndOfPAEntr(pe))
214 return FALSE;
215 if (pe->PredFlags & AsmPredFlag) {
216 int op = pe->PredFlags & 0x7f;
217 if (op >= _atom && op <= _eq) {
218 return TRUE;
219 }
220 return FALSE;
221 }
222 return pe->PredFlags & (TestPredFlag|BinaryPredFlag);
223 }
224 }
225 return FALSE;
226}
227
228int
229Yap_is_a_test_pred (Term arg, Term mod)
230{
231 return is_a_test(arg, mod);
232}
233
234void
235Yap_emit (compiler_vm_op o, Int r1, CELL r2, struct intermediates *cip)
236{
237 PInstr *p;
238 p = (PInstr *) AllocCMem (sizeof (*p), cip);
239 p->op = o;
240 p->rnd1 = r1;
241 p->rnd2 = r2;
242 p->nextInst = NULL;
243 if (cip->cpc == NIL) {
244 cip->cpc = cip->CodeStart = p;
245 } else {
246 cip->cpc->nextInst = p;
247 cip->cpc = p;
248 }
249}
250
251void
252Yap_emit_3ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, struct intermediates *cip)
253{
254 PInstr *p;
255 p = (PInstr *) AllocCMem (sizeof (*p)+sizeof(CELL), cip);
256 p->op = o;
257 p->rnd1 = r1;
258 p->rnd2 = r2;
259 p->rnd3 = r3;
260 p->nextInst = NIL;
261 if (cip->cpc == NIL)
262 cip->cpc = cip->CodeStart = p;
263 else
264 {
265 cip->cpc->nextInst = p;
266 cip->cpc = p;
267 }
268}
269
270void
271Yap_emit_4ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, CELL r4, struct intermediates *cip)
272{
273 PInstr *p;
274 p = (PInstr *) AllocCMem (sizeof (*p)+2*sizeof(CELL), cip);
275 p->op = o;
276 p->rnd1 = r1;
277 p->rnd2 = r2;
278 p->rnd3 = r3;
279 p->rnd4 = r4;
280 p->nextInst = NIL;
281 if (cip->cpc == NIL)
282 cip->cpc = cip->CodeStart = p;
283 else
284 {
285 cip->cpc->nextInst = p;
286 cip->cpc = p;
287 }
288}
289
290void
291Yap_emit_5ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, CELL r4, CELL r5, struct intermediates *cip)
292{
293 PInstr *p;
294 p = (PInstr *) AllocCMem (sizeof (*p)+3*sizeof(CELL), cip);
295 p->op = o;
296 p->rnd1 = r1;
297 p->rnd2 = r2;
298 p->rnd3 = r3;
299 p->rnd4 = r4;
300 p->rnd5 = r5;
301 p->nextInst = NIL;
302 if (cip->cpc == NIL)
303 cip->cpc = cip->CodeStart = p;
304 else
305 {
306 cip->cpc->nextInst = p;
307 cip->cpc = p;
308 }
309}
310
311void
312Yap_emit_6ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, CELL r4, CELL r5, CELL r6, struct intermediates *cip)
313{
314 PInstr *p;
315 p = (PInstr *) AllocCMem (sizeof (*p)+4*sizeof(CELL), cip);
316 p->op = o;
317 p->rnd1 = r1;
318 p->rnd2 = r2;
319 p->rnd3 = r3;
320 p->rnd4 = r4;
321 p->rnd5 = r5;
322 p->rnd6 = r6;
323 p->nextInst = NIL;
324 if (cip->cpc == NIL)
325 cip->cpc = cip->CodeStart = p;
326 else
327 {
328 cip->cpc->nextInst = p;
329 cip->cpc = p;
330 }
331}
332
333void
334Yap_emit_7ops (compiler_vm_op o, CELL r1, CELL r2, CELL r3, CELL r4, CELL r5, CELL r6, CELL r7, struct intermediates *cip)
335{
336 PInstr *p;
337 p = (PInstr *) AllocCMem (sizeof (*p)+5*sizeof(CELL), cip);
338 p->op = o;
339 p->rnd1 = r1;
340 p->rnd2 = r2;
341 p->rnd3 = r3;
342 p->rnd4 = r4;
343 p->rnd5 = r5;
344 p->rnd6 = r6;
345 p->rnd7 = r7;
346 p->nextInst = NIL;
347 if (cip->cpc == NIL)
348 cip->cpc = cip->CodeStart = p;
349 else
350 {
351 cip->cpc->nextInst = p;
352 cip->cpc = p;
353 }
354}
355
356CELL *
357Yap_emit_extra_size (compiler_vm_op o, CELL r1, int size, struct intermediates *cip)
358{
359 PInstr *p;
360 p = (PInstr *) AllocCMem (sizeof (*p) + size - CellSize, cip);
361 p->op = o;
362 p->rnd1 = r1;
363 p->nextInst = NIL;
364 if (cip->cpc == NIL)
365 cip->cpc = cip->CodeStart = p;
366 else
367 {
368 cip->cpc->nextInst = p;
369 cip->cpc = p;
370 }
371 return p->arnds;
372}
373
374static void
375bip_name(Int op, char *s)
376{
377 switch (op) {
378 case _atom:
379 strcpy(s,"atom");
380 break;
381 case _atomic:
382 strcpy(s,"atomic");
383 break;
384 case _integer:
385 strcpy(s,"integer");
386 break;
387 case _nonvar:
388 strcpy(s,"nonvar");
389 break;
390 case _number:
391 strcpy(s,"number");
392 break;
393 case _var:
394 strcpy(s,"var");
395 break;
396 case _cut_by:
397 strcpy(s,"cut_by");
398 break;
399 case _save_by:
400 strcpy(s,"save_by");
401 break;
402 case _db_ref:
403 strcpy(s,"db_ref");
404 break;
405 case _compound:
406 strcpy(s,"compound");
407 break;
408 case _float:
409 strcpy(s,"float");
410 break;
411 case _primitive:
412 strcpy(s,"primitive");
413 break;
414 case _equal:
415 strcpy(s,"equal");
416 break;
417 case _dif:
418 strcpy(s,"dif");
419 break;
420 case _eq:
421 strcpy(s,"eq");
422 break;
423 case _functor:
424 strcpy(s,"functor");
425 break;
426 case _plus:
427 strcpy(s,"plus");
428 break;
429 case _minus:
430 strcpy(s,"minus");
431 break;
432 case _times:
433 strcpy(s,"times");
434 break;
435 case _div:
436 strcpy(s,"div");
437 break;
438 case _and:
439 strcpy(s,"and");
440 break;
441 case _or:
442 strcpy(s,"or");
443 break;
444 case _sll:
445 strcpy(s,"sll");
446 break;
447 case _slr:
448 strcpy(s,"slr");
449 break;
450 case _arg:
451 strcpy(s,"arg");
452 break;
453 default:
454 strcpy(s,"");
455 break;
456 }
457}
458
459void
460Yap_bip_name(Int op, char *s) {
461 bip_name(op,s);
462}
463
464#ifdef DEBUG
465
466static void
467write_address(CELL address)
468{
469 if (address < (CELL)AtomBase) {
470 Yap_DebugErrorPutc('L');
471 Yap_DebugPlWrite(MkIntTerm (address));
472 } else if (address == (CELL) FAILCODE) {
473 Yap_DebugPlWrite (MkAtomTerm (AtomFail));
474 } else {
475 char buf[32], *p = buf;
476
477#if HAVE_SNPRINTF
478 snprintf(buf,32,"%p",(void *)address);
479#else
480 sprintf(buf,"%p",(void *)address);
481#endif
482 p[31] = '\0'; /* so that I don't have to worry */
483 //Yap_DebugErrorPutc('0');
484 //Yap_DebugErrorPutc('x');
485 while (*p != '\0') {
486 Yap_DebugErrorPutc(*p++);
487 }
488 }
489}
490
491static void
492write_special_label(special_label_op arg, special_label_id rn, UInt lab)
493{
494 switch (arg) {
495 case SPECIAL_LABEL_INIT:
496 Yap_DebugErrorPuts("init,");
497 switch (rn) {
498 case SPECIAL_LABEL_EXCEPTION:
499 Yap_DebugErrorPuts("exception,");
500 break;
501 case SPECIAL_LABEL_SUCCESS:
502 Yap_DebugErrorPuts("success,");
503 break;
504 case SPECIAL_LABEL_FAILURE:
505 Yap_DebugErrorPuts("fail,");
506 break;
507 }
508 write_address(lab);
509 case SPECIAL_LABEL_SET:
510 Yap_DebugErrorPuts("set,");
511 break;
512 case SPECIAL_LABEL_CLEAR:
513 Yap_DebugErrorPuts("clear,");
514 switch (rn) {
515 case SPECIAL_LABEL_EXCEPTION:
516 Yap_DebugErrorPuts("exception");
517 break;
518 case SPECIAL_LABEL_SUCCESS:
519 Yap_DebugErrorPuts("success");
520 break;
521 case SPECIAL_LABEL_FAILURE:
522 Yap_DebugErrorPuts("fail");
523 break;
524 }
525 }
526}
527
528static void
529write_functor(Functor f)
530{
531 if (IsExtensionFunctor(f)) {
532 if (f == FunctorDBRef) {
533 Yap_DebugPlWrite(MkAtomTerm(AtomDBREF));
534 } else if (f == FunctorLongInt) {
535 Yap_DebugPlWrite(MkAtomTerm(AtomLONGINT));
536 } else if (f == FunctorBigInt) {
537 Yap_DebugPlWrite(MkAtomTerm(AtomLONGINT));
538 } else if (f == FunctorDouble) {
539 Yap_DebugPlWrite(MkAtomTerm(AtomDOUBLE));
540 } else if (f == FunctorString) {
541 Yap_DebugPlWrite(MkAtomTerm(AtomSTRING));
542 }
543 } else {
544 Yap_DebugPlWrite(MkAtomTerm(NameOfFunctor (f)));
545 Yap_DebugErrorPutc ('/');
546 Yap_DebugPlWrite(MkIntTerm(ArityOfFunctor (f)));
547 }
548}
549
550
551static void send_pred(PredEntry *p)
552{
553 Functor f = p->FunctorOfPred;
554 UInt arity = p->ArityOfPE;
555 Term mod = TermProlog;
556
557 if (p->ModuleOfPred) mod = p->ModuleOfPred;
558 Yap_DebugPlWrite (mod);
559 Yap_DebugErrorPutc (':');
560 if (arity == 0)
561 Yap_DebugPlWrite (MkAtomTerm ((Atom)f));
562 else
563 Yap_DebugPlWrite (MkAtomTerm (NameOfFunctor (f)));
564 Yap_DebugErrorPutc ('/');
565 Yap_DebugPlWrite (MkIntTerm (arity));
566}
567
568
569static void
570ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc)
571{
572 CACHE_REGS
573 char ch;
574 Int arg = cpc->rnd1;
575 Int rn = cpc->rnd2;
576 CELL *cptr = cpc->arnds;
577
578 if (ic != label_op && ic != label_ctl_op && ic != name_op) {
579 Yap_DebugErrorPutc ('\t');
580 }
581 while ((ch = *f++) != 0)
582 {
583 if (ch == '%')
584 switch (ch = *f++)
585 {
586#ifdef BEAM
587 case '1':
588 Yap_DebugPlWrite(MkIntTerm(rn));
589 break;
590 case '4':
591 Yap_DebugPlWrite(MkIntTerm(arg));
592 break;
593#endif
594 case '2':
595 {
596 Ventry *v = (Ventry *) cpc->rnd3;
597 Yap_DebugErrorPutc (v->KindOfVE == PermVar ? 'Y' : 'X');
598 Yap_DebugPlWrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs));
599 Yap_DebugErrorPutc (',');
600 Yap_DebugErrorPutc ('A');
601 Yap_DebugPlWrite (MkIntegerTerm (cpc->rnd4));
602 Yap_DebugErrorPutc (',');
603 send_pred( RepPredProp((Prop)(cpc->rnd5)) );
604 }
605 break;
606
607 case 'a':
608 case 'n':
609 Yap_DebugPlWrite ((Term) arg);
610 break;
611 case 'b':
612 /* write a variable bitmap for a call */
613 {
614 int max = arg/(8*sizeof(CELL)), i;
615 CELL *ptr = cptr;
616 for (i = 0; i <= max; i++) {
617 Yap_DebugPlWrite(MkIntegerTerm((Int)(*ptr++)));
618 }
619 }
620 break;
621 case 'l':
622 write_address (arg);
623 break;
624 case 'L':
625 write_special_label (arg, rn, cpc->rnd3);
626 break;
627 case 'B':
628 {
629 char s[32];
630
631 bip_name(rn,s);
632 Yap_DebugPlWrite (MkAtomTerm(Yap_LookupAtom(s)));
633 }
634 break;
635 case 'd':
636 Yap_DebugPlWrite (MkIntegerTerm (arg));
637 break;
638 case 'z':
639 Yap_DebugPlWrite (MkIntTerm (cpc->rnd3));
640 break;
641 case 'v':
642 {
643 Ventry *v = (Ventry *) arg;
644 if (v) {
645 Yap_DebugErrorPutc (v->KindOfVE == PermVar ? 'Y' : 'X');
646 Yap_DebugPlWrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs));
647 }
648 }
649 break;
650 case 'N':
651 {
652 Ventry *v;
653
654 cpc = cpc->nextInst;
655 arg = cpc->rnd1;
656 v = (Ventry *) arg;
657 Yap_DebugErrorPutc (v->KindOfVE == PermVar ? 'Y' : 'X');
658 Yap_DebugPlWrite (MkIntTerm ((v->NoOfVE) & MaskVarAdrs));
659 }
660 break;
661 case 'm':
662 Yap_DebugPlWrite (MkAtomTerm ((Atom) arg));
663 Yap_DebugErrorPutc ('/');
664 Yap_DebugPlWrite (MkIntTerm (rn));
665 break;
666 case 'p':
667 send_pred( RepPredProp((Prop)(arg) ));
668 break;
669 case 'P':
670 send_pred( RepPredProp((Prop)(rn) ));
671 break;
672 case 'f':
673 write_functor((Functor)arg);
674 break;
675 case 'r':
676 Yap_DebugErrorPutc ('A');
677 Yap_DebugPlWrite (MkIntTerm (rn));
678 break;
679 case 'S':
680 Yap_DebugErrorPutc ('S');
681 Yap_DebugPlWrite (MkIntTerm (rn));
682 break;
683 case 'h':
684 {
685 CELL my_arg = *cptr++;
686 write_address(my_arg);
687 }
688 break;
689 case 'g':
690 write_address(arg);
691 break;
692 case 'i':
693 write_address (arg);
694 break;
695 case 'j':
696 {
697 Functor fun = (Functor)*cptr++;
698 if (IsExtensionFunctor(fun)) {
699 if (fun == FunctorDBRef) {
700 Yap_DebugPlWrite(MkAtomTerm(AtomDBREF));
701 } else if (fun == FunctorLongInt) {
702 Yap_DebugPlWrite(MkAtomTerm(AtomLONGINT));
703 } else if (fun == FunctorDouble) {
704 Yap_DebugPlWrite(MkAtomTerm(AtomDOUBLE));
705 } else if (fun == FunctorString) {
706 Yap_DebugPlWrite(MkAtomTerm(AtomSTRING));
707 }
708 } else {
709 Yap_DebugPlWrite (MkAtomTerm(NameOfFunctor(fun)));
710 Yap_DebugErrorPutc ('/');
711 Yap_DebugPlWrite (MkIntTerm(ArityOfFunctor(fun)));
712 }
713 }
714 break;
715 case 'O':
716 Yap_DebugPlWrite(AbsAppl(cptr));
717 break;
718 case 'x':
719 Yap_DebugPlWrite (MkIntTerm (rn >> 1));
720 Yap_DebugErrorPutc ('\t');
721 Yap_DebugPlWrite (MkIntTerm (rn & 1));
722 break;
723 case 'w':
724 Yap_DebugPlWrite (arg);
725 break;
726 case 'o':
727 Yap_DebugPlWrite ((Term) * cptr++);
728 case 'c':
729 {
730 int i;
731 CELL *ptr = (CELL *)cptr[0];
732 for (i = 0; i < arg; ++i) {
733 CELL my_arg;
734 Yap_DebugErrorPutc('\t');
735 if (*ptr) {
736 Yap_DebugPlWrite ((Term) *ptr++);
737 } else {
738 Yap_DebugPlWrite (MkIntTerm (0));
739 ptr++;
740 }
741 Yap_DebugErrorPutc ('\t');
742 my_arg = *ptr++;
743 write_address (my_arg);
744 if (i+1 < arg)
745 Yap_DebugErrorPutc ('\n');
746 }
747 }
748 break;
749 case 'e':
750 {
751 int i;
752 CELL *ptr = (CELL *)cptr[0];
753 for (i = 0; i < arg; ++i) {
754 CELL my_arg = ptr[0], lbl = ptr[1];
755 Yap_DebugErrorPutc('\t');
756 if (my_arg) {
757 write_functor((Functor)my_arg);
758 } else {
759 Yap_DebugPlWrite(MkIntTerm (0));
760 }
761 Yap_DebugErrorPutc('\t');
762 write_address(lbl);
763 ptr += 2;
764 if (i+1 < arg)
765 Yap_DebugErrorPutc('\n');
766 }
767 }
768 break;
769 default:
770 Yap_DebugErrorPutc ('%');
771 Yap_DebugErrorPutc (ch);
772 }
773 else
774 Yap_DebugErrorPutc (ch);
775 }
776 Yap_DebugErrorPutc ('\n');
777}
778
779void
780Yap_ShowCode (struct intermediates *cint)
781{
782 CACHE_REGS
783 struct PSEUDO *cpc;
784
785 cpc = cint->CodeStart;
786 /* MkIntTerm and friends may build terms in the global stack */
787 HR = (CELL *)cint->freep;
788 while (cpc) {
789 compiler_vm_op ic = cpc->op;
790 if (ic != nop_op) {
791 ShowOp (ic, opDesc[ic], cpc);
792 }
793 cpc = cpc->nextInst;
794 }
795 Yap_DebugErrorPutc ('\n');
796}
797
798#endif /* DEBUG */
Main definitions.
Definition: Yatom.h:544