Wild Life: copy.c File Reference

Wild Life 2.29

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
Functions | Variables
copy.c File Reference

Go to the source code of this file.

## Functions
void | init_copy ()
void | clear_copy ()
void | insert_translation (ptr_psi_term a, ptr_psi_term b, long info)
ptr_psi_term | translate (ptr_psi_term a, long **infoptr)
static ptr_node | copy_tree (ptr_node t, long copy_flag, long heap_flag)
ptr_psi_term | exact_copy (ptr_psi_term t, long heap_flag)
ptr_psi_term | quote_copy (ptr_psi_term t, long heap_flag)
ptr_psi_term | eval_copy (ptr_psi_term t, long heap_flag)
ptr_psi_term | inc_heap_copy (ptr_psi_term t)
ptr_psi_term | copy (ptr_psi_term t, long copy_flag, long heap_flag)
ptr_node | distinct_tree (ptr_node t)
ptr_psi_term | distinct_copy (ptr_psi_term t)
void | mark_quote_c (ptr_psi_term t, long heap_flag)
void | mark_quote_tree_c (ptr_node n, long heap_flag)
void | mark_eval (ptr_psi_term t)
void | mark_nonstrict (ptr_psi_term t)
void | mark_quote_new2 (ptr_psi_term t)
void | mark_eval_new (ptr_psi_term t)
void | mark_eval_tree_new (ptr_node n)
void | mark_quote_new (ptr_psi_term t)
void | mark_quote_tree_new (ptr_node n)
void | mark_quote_tree ()
void | mark_quote (ptr_psi_term t)
void | mark_quote_tree (ptr_node t)
void | bk_mark_quote (ptr_psi_term t)
void | bk_mark_quote_tree (ptr_node t)

## Variables
static struct hashentry | hashtable [HASHSIZE]
static struct hashbucket * | hashbuckets
static long | hashtime
static long | hashfree
static long | numbuckets
static long | curr_status
static long | mark_nonstrict_flag

## Function Documentation

void bk_mark_quote | ( | ptr_psi_term | t | ) |

Definition at line 630 of file copy.c.

References bk_mark_quote(), bk_mark_quote_tree(), heap_pointer, int_ptr, push_ptr_value(), QUOTED_TRUE, and RMASK.

632 {
633 // ptr_list l;
634
635 if (t && !(t->status&RMASK)) {
636 if(t->status!=4 && (GENERIC)t<heap_pointer)/* RM: Jul 16 1993 */
637 push_ptr_value(int_ptr,(GENERIC *)&(t->status));
638 t->status = 4;
639 t->flags=QUOTED_TRUE; /* 14.9 */
640 t->status |= RMASK;
641 bk_mark_quote(t->coref);
642 bk_mark_quote_tree(t->attr_list);
643 t->status &= ~RMASK;
644 }
645 }
push_ptr_value
void push_ptr_value(type_ptr t, GENERIC *p)
Definition: login.c:360
bk_mark_quote_tree
void bk_mark_quote_tree(ptr_node t)
Definition: copy.c:647
bk_mark_quote
void bk_mark_quote(ptr_psi_term t)
Definition: copy.c:630
RMASK
#define RMASK
Definition: def_const.h:159
wl_psi_term::coref
ptr_psi_term coref
Definition: def_struct.h:172
heap_pointer
GENERIC heap_pointer
Definition: def_glob.h:12
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171
int_ptr
#define int_ptr
Definition: def_const.h:172

void bk_mark_quote_tree | ( | ptr_node | t | ) |

Definition at line 647 of file copy.c.

References bk_mark_quote(), and bk_mark_quote_tree().

649 {
650 if (t) {
651 bk_mark_quote_tree(t->left);
652 bk_mark_quote((ptr_psi_term) (t->data));
653 bk_mark_quote_tree(t->right);
654 }
655 }
bk_mark_quote_tree
void bk_mark_quote_tree(ptr_node t)
Definition: copy.c:647
wl_psi_term
Definition: def_struct.h:161
wl_node::data
GENERIC data
Definition: def_struct.h:185
wl_node::left
ptr_node left
Definition: def_struct.h:183
bk_mark_quote
void bk_mark_quote(ptr_psi_term t)
Definition: copy.c:630
wl_node::right
ptr_node right
Definition: def_struct.h:184

void clear_copy | ( |  | ) |

Definition at line 52 of file copy.c.

References hashfree, and hashtime.

53 {
54 hashtime++;
55 hashfree=0;
56 }
hashfree
static long hashfree
Definition: copy.c:23
hashtime
static long hashtime
Definition: copy.c:22

ptr_psi_term copy | ( | ptr_psi_term | t,
|  | long | copy_flag,
|  | long | heap_flag
| ) |  |

Definition at line 219 of file copy.c.

References abort_life(), wl_psi_term::attr_list, choice_stack, COPY_THRESHOLD, copy_tree(), curr_status, cut, deref_ptr, env, Errorline(), EVAL_FLAG, FALSE, wl_psi_term::flags, function_it, global, global_time_stamp, HEAP, heap_pointer, HEAPDONE, insert_translation(), mark_quote_c(), NEW, NULL, QUOTE_FLAG, QUOTE_STUB, QUOTED_TRUE, wl_psi_term::resid, stack_pointer, wl_psi_term::status, traceline(), translate(), TRUE, type_it, and wl_psi_term::value_3.

222 {
223 ptr_psi_term u;
224 long old_status;
225 long local_copy_flag;
226 long *infoptr;
227
228
229 if ((u=t)) {
230 deref_ptr(t); /* Always dereference when copying */
231
232 if (HEAPDONE(t)) return t;
233 u = translate(t,&infoptr);
234
235 if (u && *infoptr!=QUOTE_STUB) { /* 24.8 */
236 /* If it was eval-copied before, then quote it now. */
237 if (*infoptr==EVAL_FLAG && copy_flag==QUOTE_FLAG) { /* 24.8 25.8 */
238 mark_quote_c(t,heap_flag);
239 *infoptr=QUOTE_FLAG; /* I.e. don't touch this term any more */
240 }
241 if (copy_flag==EVAL_FLAG) { /* PVR 14.2.94 */
242 /* If any subterm has zero curr_status (i.e., if u->status==0),
243 then so does the whole term: */
244 old_status=curr_status;
245 curr_status=u->status;
246 if (curr_status) curr_status=old_status;
247 }
248 }
249 else {
250 if (heap_pointer-stack_pointer < COPY_THRESHOLD) {
251 Errorline("psi-term too large -- get a bigger Life!\n");
252 (void)abort_life(TRUE);
253 longjmp(env,FALSE); /* Back to main loop */ /* RM: Feb 15 1993 */
254 }
255 if (copy_flag==EVAL_FLAG && !t->type->evaluate_args) /* 24.8 25.8 */
256 local_copy_flag=QUOTE_FLAG; /* All arguments will be quoted 24.8 */
257 else /* 24.8 */
258 local_copy_flag=copy_flag;
259 if (copy_flag==EVAL_FLAG) {
260 old_status = curr_status;
261 curr_status = 4;
262 }
263 if (u) { /* 15.9 */
264 *infoptr=QUOTE_FLAG;
265 local_copy_flag=QUOTE_FLAG;
266 copy_flag=QUOTE_FLAG;
267 }
268 else {
269 u=NEW(t,psi_term);
270 insert_translation(t,u,local_copy_flag); /* 24.8 */
271 }
272 *u = *t;
273 u->resid=NULL; /* 24.8 Don't copy residuations */
274 #ifdef TS
275 u->time_stamp=global_time_stamp; /* 9.6 */
276 #endif
277
278 if (t->attr_list)
279 u->attr_list=copy_tree(t->attr_list, local_copy_flag, heap_flag);
280
281 if (copy_flag==EVAL_FLAG) {
282 switch((long)t->type->type_def) {
283 case (long)type_it:
284 if (t->type->properties)
285 curr_status=0;
286 break;
287
288 case (long)function_it:
289 curr_status=0;
290 break;
291
292 case (long)global: /* RM: Feb 8 1993 */
293 curr_status=0;
294 break;
295
296 default:
297 break;
298 }
299 u->status=curr_status;
300 u->flags=curr_status?QUOTED_TRUE:FALSE; /* 14.9 */
301 /* If any subterm has zero curr_status,
302 then so does the whole term: */
303 if (curr_status) curr_status=old_status;
304 } else if (copy_flag==QUOTE_FLAG) {
305 u->status=4;
306 u->flags=QUOTED_TRUE; /* 14.9 */
307 }
308 /* else copy_flag==EXACT_FLAG & u->status=t->status */
309
310 if (heap_flag==HEAP) {
311 if (t->type==cut) u->value_3=NULL;
312 } else {
313 if (t->type==cut) {
314 u->value_3=(GENERIC)choice_stack;
315 traceline("current choice point is %x\n",choice_stack);
316 }
317 }
318 }
319 }
320
321 return u;
322 }
COPY_THRESHOLD
#define COPY_THRESHOLD
Definition: def_const.h:68
wl_psi_term::resid
ptr_residuation resid
Definition: def_struct.h:173
function_it
#define function_it
Definition: def_const.h:362
translate
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
HEAP
#define HEAP
Definition: def_const.h:147
wl_definition::evaluate_args
char evaluate_args
Definition: def_struct.h:136
global
#define global
Definition: def_const.h:364
QUOTE_STUB
#define QUOTE_STUB
Definition: def_const.h:329
wl_definition::type_def
def_type type_def
Definition: def_struct.h:133
wl_psi_term
Definition: def_struct.h:161
insert_translation
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
NULL
#define NULL
Definition: def_const.h:203
NEW
#define NEW(A, TYPE)
Definition: def_macro.h:279
abort_life
long abort_life(int nlflag)
Definition: built_ins.c:2124
traceline
void traceline(char *format,...)
Definition: error.c:157
type_it
#define type_it
Definition: def_const.h:363
EVAL_FLAG
#define EVAL_FLAG
Definition: def_const.h:327
Errorline
void Errorline(char *format,...)
Definition: error.c:414
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
copy_tree
static ptr_node copy_tree(ptr_node t, long copy_flag, long heap_flag)
Definition: copy.c:139
curr_status
static long curr_status
Definition: copy.c:215
FALSE
#define FALSE
Definition: def_const.h:128
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:170
mark_quote_c
void mark_quote_c(ptr_psi_term t, long heap_flag)
Definition: copy.c:396
heap_pointer
GENERIC heap_pointer
Definition: def_glob.h:12
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
env
jmp_buf env
Definition: def_glob.h:236
cut
ptr_definition cut
Definition: def_glob.h:83
global_time_stamp
unsigned long global_time_stamp
Definition: login.c:19
HEAPDONE
#define HEAPDONE(R)
Definition: def_macro.h:291
stack_pointer
GENERIC stack_pointer
Definition: def_glob.h:14
QUOTE_FLAG
#define QUOTE_FLAG
Definition: def_const.h:326
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
wl_definition::properties
ptr_triple_list properties
Definition: def_struct.h:127
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171
choice_stack
ptr_choice_point choice_stack
Definition: def_glob.h:51

static ptr_node copy_tree | ( | ptr_node | t,
|  | long | copy_flag,
|  | long | heap_flag
| ) |  |
| static

Definition at line 139 of file copy.c.

References copy(), wl_node::data, HEAPDONE, wl_node::key, wl_node::left, NEW, NULL, and wl_node::right.

142 {
143 ptr_node r;
144 ptr_psi_term t1,t2;
145
146 /* if (t) { RM: Dec 15 1992 this test is useless */
147
148 if (HEAPDONE(t)) return t;
149 r=NEW(t,node);
150 r->key = t->key;
151 r->left = (t->left) ? copy_tree(t->left,copy_flag,heap_flag) : NULL;
152 t1 = (ptr_psi_term)(t->data);
153 t2 = copy(t1,copy_flag,heap_flag);
154 r->data = (GENERIC) t2;
155 r->right = (t->right) ? copy_tree(t->right,copy_flag,heap_flag) : NULL;
156
157 /* } else r=NULL; */
158
159 return r;
160 }
wl_psi_term
Definition: def_struct.h:161
wl_node::data
GENERIC data
Definition: def_struct.h:185
NULL
#define NULL
Definition: def_const.h:203
NEW
#define NEW(A, TYPE)
Definition: def_macro.h:279
wl_node::left
ptr_node left
Definition: def_struct.h:183
wl_node::key
char * key
Definition: def_struct.h:182
copy
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
copy_tree
static ptr_node copy_tree(ptr_node t, long copy_flag, long heap_flag)
Definition: copy.c:139
ptr_psi_term
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
HEAPDONE
#define HEAPDONE(R)
Definition: def_macro.h:291
wl_node
Definition: def_struct.h:181
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
wl_node::right
ptr_node right
Definition: def_struct.h:184

ptr_psi_term distinct_copy | ( | ptr_psi_term | t | ) |

Definition at line 358 of file copy.c.

References wl_psi_term::attr_list, distinct_tree(), global_time_stamp, and STACK_ALLOC.

360 {
361 ptr_psi_term res;
362
363 res=STACK_ALLOC(psi_term);
364 *res= *t;
365 #ifdef TS
366 res->time_stamp=global_time_stamp; /* 9.6 */
367 #endif
368 /* res->coref=distinct_copy(t->coref); */
369 res->attr_list=distinct_tree(t->attr_list);
370
371 return res;
372 }
wl_psi_term
Definition: def_struct.h:161
distinct_tree
ptr_node distinct_tree(ptr_node t)
Definition: copy.c:334
STACK_ALLOC
#define STACK_ALLOC(A)
Definition: def_macro.h:16
global_time_stamp
unsigned long global_time_stamp
Definition: login.c:19
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

ptr_node distinct_tree | ( | ptr_node | t | ) |

Definition at line 334 of file copy.c.

References wl_node::data, distinct_tree(), wl_node::key, wl_node::left, NULL, wl_node::right, and STACK_ALLOC.

336 {
337 ptr_node n;
338
339 n=NULL;
340 if (t) {
341 n=STACK_ALLOC(node);
342 n->key=t->key;
343 n->data=t->data;
344 n->left=distinct_tree(t->left);
345 n->right=distinct_tree(t->right);
346 }
347
348 return n;
349 }
wl_node::data
GENERIC data
Definition: def_struct.h:185
NULL
#define NULL
Definition: def_const.h:203
distinct_tree
ptr_node distinct_tree(ptr_node t)
Definition: copy.c:334
wl_node::left
ptr_node left
Definition: def_struct.h:183
wl_node::key
char * key
Definition: def_struct.h:182
STACK_ALLOC
#define STACK_ALLOC(A)
Definition: def_macro.h:16
wl_node
Definition: def_struct.h:181
wl_node::right
ptr_node right
Definition: def_struct.h:184

ptr_psi_term eval_copy | ( | ptr_psi_term | t,
|  | long | heap_flag
| ) |  |

Definition at line 205 of file copy.c.

References copy(), EVAL_FLAG, FALSE, and to_heap.

208 { to_heap=FALSE; return (copy(t, EVAL_FLAG, heap_flag)); }
EVAL_FLAG
#define EVAL_FLAG
Definition: def_const.h:327
copy
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
to_heap
long to_heap
Definition: def_glob.h:264
FALSE
#define FALSE
Definition: def_const.h:128

ptr_psi_term exact_copy | ( | ptr_psi_term | t,
|  | long | heap_flag
| ) |  |

Definition at line 195 of file copy.c.

References copy(), EXACT_FLAG, FALSE, and to_heap.

198 { to_heap=FALSE; return (copy(t, EXACT_FLAG, heap_flag)); }
EXACT_FLAG
#define EXACT_FLAG
Definition: def_const.h:325
copy
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
to_heap
long to_heap
Definition: def_glob.h:264
FALSE
#define FALSE
Definition: def_const.h:128

ptr_psi_term inc_heap_copy | ( | ptr_psi_term | t | ) |

Definition at line 211 of file copy.c.

References copy(), EXACT_FLAG, to_heap, and TRUE.

213 { to_heap=TRUE; return (copy(t, EXACT_FLAG, TRUE)); }
EXACT_FLAG
#define EXACT_FLAG
Definition: def_const.h:325
TRUE
#define TRUE
Definition: def_const.h:127
copy
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
to_heap
long to_heap
Definition: def_glob.h:264

void init_copy | ( |  | ) |

Definition at line 34 of file copy.c.

References HASHSIZE, hashtable, hashtime, numbuckets, and NUMBUCKETS.

35 {
36 long i;
37
38 /* for(i=0; i<HASHSTATS; i++) hashstats[i]=0; 20.8 */
39
40 for(i=0; i<HASHSIZE; i++) hashtable[i].timestamp = 0;
41 hashtime = 0;
42 numbuckets = NUMBUCKETS;
43 hashbuckets = (struct hashbucket *)
44 malloc(NUMBUCKETS * sizeof(struct hashbucket));
45 }
hashtable
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:20
NUMBUCKETS
#define NUMBUCKETS
Definition: def_const.h:319
numbuckets
static long numbuckets
Definition: copy.c:24
hashtime
static long hashtime
Definition: copy.c:22
hashbuckets
static struct hashbucket * hashbuckets
Definition: copy.c:21
hashbucket
Definition: def_struct.h:384
HASHSIZE
#define HASHSIZE
Definition: def_const.h:315

void insert_translation | ( | ptr_psi_term | a,
|  | ptr_psi_term | b,
|  | long | info
| ) |  |

Definition at line 63 of file copy.c.

References hashentry::bucketindex, HASH, hashbuckets, HASHEND, hashfree, hashtable, hashtime, hashbucket::info, hashbucket::new_value, hashbucket::next, numbuckets, hashbucket::old_value, hashentry::timestamp, and traceline().

67 {
68 long index;
69 long lastbucket;
70
71 /* Ensure there are free buckets by doubling their number if necessary */
72 if (hashfree >= numbuckets) {
73 numbuckets *= 2;
74 hashbuckets = (struct hashbucket *)
75 realloc((void *) hashbuckets, numbuckets * sizeof(struct hashbucket));
76 /* *** Do error handling here *** */
77 traceline("doubled the number of hashbuckets to %d\n", numbuckets);
78 }
79
80 /* Add a bucket to the beginning of the list */
81 index = HASH(a);
82 if (hashtable[index].timestamp == hashtime)
83 lastbucket = hashtable[index].bucketindex;
84 else {
85 lastbucket = HASHEND;
86 hashtable[index].timestamp = hashtime;
87 }
88 hashtable[index].bucketindex = hashfree;
89 hashbuckets[hashfree].old_value = a;
90 hashbuckets[hashfree].new_value = b;
91 hashbuckets[hashfree].info = info;
92 hashbuckets[hashfree].next = lastbucket;
93 hashfree++;
94 }
hashtable
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:20
hashfree
static long hashfree
Definition: copy.c:23
numbuckets
static long numbuckets
Definition: copy.c:24
HASHEND
#define HASHEND
Definition: def_const.h:322
hashbucket::old_value
ptr_psi_term old_value
Definition: def_struct.h:385
hashtime
static long hashtime
Definition: copy.c:22
traceline
void traceline(char *format,...)
Definition: error.c:157
hashbucket::new_value
ptr_psi_term new_value
Definition: def_struct.h:386
hashbucket::next
long next
Definition: def_struct.h:388
hashentry::timestamp
long timestamp
Definition: def_struct.h:392
hashbuckets
static struct hashbucket * hashbuckets
Definition: copy.c:21
hashentry::bucketindex
long bucketindex
Definition: def_struct.h:393
hashbucket::info
long info
Definition: def_struct.h:387
HASH
#define HASH(A)
Definition: def_macro.h:273
hashbucket
Definition: def_struct.h:384

void mark_eval | ( | ptr_psi_term | t | ) |

Definition at line 452 of file copy.c.

References clear_copy(), FALSE, mark_eval_new(), and mark_nonstrict_flag.

454 {
455 clear_copy();
456 mark_nonstrict_flag=FALSE;
457 mark_eval_new(t);
458 }
mark_eval_new
void mark_eval_new(ptr_psi_term t)
Definition: copy.c:479
clear_copy
void clear_copy()
Definition: copy.c:52
FALSE
#define FALSE
Definition: def_const.h:128
mark_nonstrict_flag
static long mark_nonstrict_flag
Definition: copy.c:442

void mark_eval_new | ( | ptr_psi_term | t | ) |

Definition at line 479 of file copy.c.

References curr_status, deref_ptr, FALSE, function_it, global, insert_translation(), mark_eval_tree_new(), mark_nonstrict_flag, mark_quote_new(), mark_quote_tree_new(), QUOTED_TRUE, translate(), TRUE, and type_it.

481 {
482 // ptr_list l;
483 long *infoptr,flag;
484 ptr_psi_term u;
485 long old_status;
486
487 if (t) {
488 deref_ptr(t);
489 flag = t->type->evaluate_args;
490 u=translate(t,&infoptr);
491 if (u) {
492 /* Quote the subgraph if it was already copied as to be evaluated. */
493 if (!flag && *infoptr) {
494 mark_quote_new(t);
495 *infoptr=FALSE;
496 }
497 /* If any subterm has zero curr_status (i.e., if t->status==0),
498 then so does the whole term: PVR 14.2.94 */
499 old_status=curr_status;
500 curr_status=(long)t->status;
501 if (curr_status) curr_status=old_status;
502 }
503 else {
504 insert_translation(t,(ptr_psi_term)TRUE,flag);
505 old_status=curr_status;
506 curr_status=4;
507
508 if (flag) /* 16.9 */
509 mark_eval_tree_new(t->attr_list);
510 else
511 mark_quote_tree_new(t->attr_list);
512
513 switch((long)t->type->type_def) {
514 case type_it:
515 if (t->type->properties)
516 curr_status=0;
517 break;
518
519 case function_it:
520 curr_status=0;
521 break;
522
523 case global: /* RM: Feb 8 1993 */
524 curr_status=0;
525 break;
526
527 default:
528 break;
529 }
530 if (mark_nonstrict_flag) { /* 25.8 */
531 if (curr_status) {
532 /* Only increase the status, never decrease it: */
533 t->status=curr_status;
534 }
535 }
536 else {
537 t->status=curr_status;
538 t->flags=curr_status?QUOTED_TRUE:FALSE; /* 14.9 */
539 }
540 /* If any subterm has zero curr_status, then so does the whole term: */
541 if (curr_status) curr_status=old_status;
542 }
543 }
544 }
function_it
#define function_it
Definition: def_const.h:362
translate
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
wl_definition::evaluate_args
char evaluate_args
Definition: def_struct.h:136
global
#define global
Definition: def_const.h:364
wl_definition::type_def
def_type type_def
Definition: def_struct.h:133
wl_psi_term
Definition: def_struct.h:161
insert_translation
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
mark_eval_tree_new
void mark_eval_tree_new(ptr_node n)
Definition: copy.c:546
type_it
#define type_it
Definition: def_const.h:363
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
mark_quote_tree_new
void mark_quote_tree_new(ptr_node n)
Definition: copy.c:581
curr_status
static long curr_status
Definition: copy.c:215
FALSE
#define FALSE
Definition: def_const.h:128
mark_quote_new
void mark_quote_new(ptr_psi_term t)
Definition: copy.c:557
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
mark_nonstrict_flag
static long mark_nonstrict_flag
Definition: copy.c:442
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_definition::properties
ptr_triple_list properties
Definition: def_struct.h:127
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

void mark_eval_tree_new | ( | ptr_node | n | ) |

Definition at line 546 of file copy.c.

References mark_eval_new(), and mark_eval_tree_new().

548 {
549 if (n) {
550 mark_eval_tree_new(n->left);
551 mark_eval_new((ptr_psi_term) (n->data));
552 mark_eval_tree_new(n->right);
553 }
554 }
mark_eval_new
void mark_eval_new(ptr_psi_term t)
Definition: copy.c:479
wl_psi_term
Definition: def_struct.h:161
wl_node::data
GENERIC data
Definition: def_struct.h:185
mark_eval_tree_new
void mark_eval_tree_new(ptr_node n)
Definition: copy.c:546
wl_node::left
ptr_node left
Definition: def_struct.h:183
wl_node::right
ptr_node right
Definition: def_struct.h:184

void mark_nonstrict | ( | ptr_psi_term | t | ) |

Definition at line 462 of file copy.c.

References clear_copy(), mark_eval_new(), mark_nonstrict_flag, and TRUE.

464 {
465 clear_copy();
466 mark_nonstrict_flag=TRUE;
467 mark_eval_new(t);
468 }
mark_eval_new
void mark_eval_new(ptr_psi_term t)
Definition: copy.c:479
clear_copy
void clear_copy()
Definition: copy.c:52
TRUE
#define TRUE
Definition: def_const.h:127
mark_nonstrict_flag
static long mark_nonstrict_flag
Definition: copy.c:442

void mark_quote | ( | ptr_psi_term | t | ) |

Definition at line 601 of file copy.c.

References mark_quote(), mark_quote_tree(), QUOTED_TRUE, RMASK, and wl_psi_term::status.

603 {
604 // ptr_list l;
605
606 if (t && !(t->status&RMASK)) {
607 t->status = 4;
608 t->flags=QUOTED_TRUE; /* 14.9 */
609 t->status |= RMASK;
610 mark_quote(t->coref);
611 mark_quote_tree(t->attr_list);
612 t->status &= ~RMASK;
613 }
614 }
RMASK
#define RMASK
Definition: def_const.h:159
wl_psi_term::coref
ptr_psi_term coref
Definition: def_struct.h:172
mark_quote
void mark_quote(ptr_psi_term t)
Definition: copy.c:601
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171
mark_quote_tree
void mark_quote_tree()

void mark_quote_c | ( | ptr_psi_term | t,
|  | long | heap_flag
| ) |  |

Definition at line 396 of file copy.c.

References deref_ptr, EVAL_FLAG, wl_psi_term::flags, insert_translation(), mark_quote_tree_c(), NEW, QUOTE_FLAG, QUOTE_STUB, QUOTED_TRUE, wl_psi_term::status, and translate().

399 {
400 // ptr_list l;
401 long *infoptr;
402 ptr_psi_term u;
403
404 if (t) {
405 deref_ptr(t);
406 u=translate(t,&infoptr);
407 /* assert(u!=NULL); 15.9 */
408 if (u) {
409 if (*infoptr==EVAL_FLAG) {
410 *infoptr=QUOTE_FLAG;
411 u->status=4;
412 u->flags=QUOTED_TRUE; /* 14.9 */
413 mark_quote_tree_c(t->attr_list,heap_flag);
414 }
415 }
416 else { /* u does not exist yet */ /* 15.9 */
417 /* Create a stub & mark it as to-be-quoted. */
418 u=NEW(t,psi_term);
419 insert_translation(t,u,QUOTE_STUB);
420 }
421 }
422 }
translate
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
mark_quote_tree_c
void mark_quote_tree_c(ptr_node n, long heap_flag)
Definition: copy.c:424
QUOTE_STUB
#define QUOTE_STUB
Definition: def_const.h:329
wl_psi_term
Definition: def_struct.h:161
insert_translation
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
NEW
#define NEW(A, TYPE)
Definition: def_macro.h:279
EVAL_FLAG
#define EVAL_FLAG
Definition: def_const.h:327
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
QUOTE_FLAG
#define QUOTE_FLAG
Definition: def_const.h:326
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

void mark_quote_new | ( | ptr_psi_term | t | ) |

Definition at line 557 of file copy.c.

References deref_ptr, FALSE, insert_translation(), mark_quote_tree_new(), QUOTED_TRUE, translate(), and TRUE.

559 {
560 // ptr_list l;
561 long *infoptr;
562 ptr_psi_term u;
563
564 if (t) {
565 deref_ptr(t);
566 u=translate(t,&infoptr);
567
568 /* Return if the subgraph is already quoted. */
569 if (u && !*infoptr) return;
570
571 /* Otherwise quote the subgraph */
572 if (!u) insert_translation(t,(ptr_psi_term)TRUE,FALSE);
573 else *infoptr = FALSE; /* sanjay */
574 t->status= 4;
575 t->flags=QUOTED_TRUE; /* 14.9 */
576 mark_quote_tree_new(t->attr_list);
577 }
578 }
translate
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
wl_psi_term
Definition: def_struct.h:161
insert_translation
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
mark_quote_tree_new
void mark_quote_tree_new(ptr_node n)
Definition: copy.c:581
FALSE
#define FALSE
Definition: def_const.h:128
wl_psi_term::status
long status
Definition: def_struct.h:166
wl_psi_term::flags
long flags
Definition: def_struct.h:169
QUOTED_TRUE
#define QUOTED_TRUE
Definition: def_const.h:123
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

void mark_quote_new2 | ( | ptr_psi_term | t | ) |

Definition at line 471 of file copy.c.

References clear_copy(), FALSE, mark_nonstrict_flag, and mark_quote_new().

473 {
474 clear_copy();
475 mark_nonstrict_flag=FALSE;
476 mark_quote_new(t);
477 }
clear_copy
void clear_copy()
Definition: copy.c:52
FALSE
#define FALSE
Definition: def_const.h:128
mark_quote_new
void mark_quote_new(ptr_psi_term t)
Definition: copy.c:557
mark_nonstrict_flag
static long mark_nonstrict_flag
Definition: copy.c:442

void mark_quote_tree | ( |  | ) |

void mark_quote_tree | ( | ptr_node | t | ) |

Definition at line 616 of file copy.c.

References mark_quote(), and mark_quote_tree().

618 {
619 if (t) {
620 mark_quote_tree(t->left);
621 mark_quote((ptr_psi_term) (t->data));
622 mark_quote_tree(t->right);
623 }
624 }
wl_psi_term
Definition: def_struct.h:161
wl_node::data
GENERIC data
Definition: def_struct.h:185
wl_node::left
ptr_node left
Definition: def_struct.h:183
mark_quote
void mark_quote(ptr_psi_term t)
Definition: copy.c:601
mark_quote_tree
void mark_quote_tree()
wl_node::right
ptr_node right
Definition: def_struct.h:184

void mark_quote_tree_c | ( | ptr_node | n,
|  | long | heap_flag
| ) |  |

Definition at line 424 of file copy.c.

References mark_quote_c(), and mark_quote_tree_c().

427 {
428 if (n) {
429 mark_quote_tree_c(n->left,heap_flag);
430 mark_quote_c((ptr_psi_term) (n->data),heap_flag);
431 mark_quote_tree_c(n->right,heap_flag);
432 }
433 }
mark_quote_tree_c
void mark_quote_tree_c(ptr_node n, long heap_flag)
Definition: copy.c:424
wl_psi_term
Definition: def_struct.h:161
wl_node::data
GENERIC data
Definition: def_struct.h:185
wl_node::left
ptr_node left
Definition: def_struct.h:183
mark_quote_c
void mark_quote_c(ptr_psi_term t, long heap_flag)
Definition: copy.c:396
wl_node::right
ptr_node right
Definition: def_struct.h:184

void mark_quote_tree_new | ( | ptr_node | n | ) |

Definition at line 581 of file copy.c.

References mark_quote_new(), and mark_quote_tree_new().

583 {
584 if (n) {
585 mark_quote_tree_new(n->left);
586 mark_quote_new((ptr_psi_term) (n->data));
587 mark_quote_tree_new(n->right);
588 }
589 }
wl_psi_term
Definition: def_struct.h:161
wl_node::data
GENERIC data
Definition: def_struct.h:185
wl_node::left
ptr_node left
Definition: def_struct.h:183
mark_quote_tree_new
void mark_quote_tree_new(ptr_node n)
Definition: copy.c:581
mark_quote_new
void mark_quote_new(ptr_psi_term t)
Definition: copy.c:557
wl_node::right
ptr_node right
Definition: def_struct.h:184

ptr_psi_term quote_copy | ( | ptr_psi_term | t,
|  | long | heap_flag
| ) |  |

Definition at line 200 of file copy.c.

References copy(), FALSE, QUOTE_FLAG, and to_heap.

203 { to_heap=FALSE; return (copy(t, QUOTE_FLAG, heap_flag)); }
copy
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
to_heap
long to_heap
Definition: def_glob.h:264
FALSE
#define FALSE
Definition: def_const.h:128
QUOTE_FLAG
#define QUOTE_FLAG
Definition: def_const.h:326

ptr_psi_term translate | ( | ptr_psi_term | a,
|  | long ** | infoptr
| ) |  |

Definition at line 101 of file copy.c.

References hashentry::bucketindex, HASH, HASHEND, hashtable, hashtime, hashbucket::info, hashbucket::new_value, hashbucket::next, NULL, and hashbucket::old_value.

104 {
105 long index;
106 /* long i; 20.8 */
107 long bucket;
108
109 index = HASH(a);
110 if (hashtable[index].timestamp != hashtime) return NULL;
111 bucket = hashtable[index].bucketindex;
112 /* i=0; 20.8 */
113 while (bucket != HASHEND && hashbuckets[bucket].old_value != a) {
114 /* i++; 20.8 */
115 bucket = hashbuckets[bucket].next;
116 }
117 /* hashstats[i]++; 20.8 */
118 if (bucket != HASHEND) {
119 *infoptr = &hashbuckets[bucket].info;
120 return (hashbuckets[bucket].new_value);
121 }
122 else
123 return NULL;
124 }
hashtable
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:20
HASHEND
#define HASHEND
Definition: def_const.h:322
NULL
#define NULL
Definition: def_const.h:203
hashbucket::old_value
ptr_psi_term old_value
Definition: def_struct.h:385
hashtime
static long hashtime
Definition: copy.c:22
hashbucket::new_value
ptr_psi_term new_value
Definition: def_struct.h:386
hashbucket::next
long next
Definition: def_struct.h:388
hashbuckets
static struct hashbucket * hashbuckets
Definition: copy.c:21
hashentry::bucketindex
long bucketindex
Definition: def_struct.h:393
hashbucket::info
long info
Definition: def_struct.h:387
HASH
#define HASH(A)
Definition: def_macro.h:273

## Variable Documentation

long curr_status
| static

Definition at line 215 of file copy.c.

struct hashbucket* hashbuckets
| static

Definition at line 21 of file copy.c.

long hashfree
| static

Definition at line 23 of file copy.c.

struct hashentry hashtable[HASHSIZE]
| static

Definition at line 20 of file copy.c.

long hashtime
| static

Definition at line 22 of file copy.c.

long mark_nonstrict_flag
| static

Definition at line 442 of file copy.c.

long numbuckets
| static

Definition at line 24 of file copy.c.