Wild Life  2.29
 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 hashbuckethashbuckets
 
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 */
638  t->status = 4;
639  t->flags=QUOTED_TRUE; /* 14.9 */
640  t->status |= RMASK;
641  bk_mark_quote(t->coref);
643  t->status &= ~RMASK;
644  }
645 }
void push_ptr_value(type_ptr t, GENERIC *p)
Definition: login.c:360
void bk_mark_quote_tree(ptr_node t)
Definition: copy.c:647
void bk_mark_quote(ptr_psi_term t)
Definition: copy.c:630
#define RMASK
Definition: def_const.h:159
ptr_psi_term coref
Definition: def_struct.h:172
GENERIC heap_pointer
Definition: def_glob.h:12
unsigned long * GENERIC
Definition: def_struct.h:17
#define QUOTED_TRUE
Definition: def_const.h:123
ptr_node attr_list
Definition: def_struct.h:171
#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) {
654  }
655 }
void bk_mark_quote_tree(ptr_node t)
Definition: copy.c:647
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
void bk_mark_quote(ptr_psi_term t)
Definition: copy.c:630
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 }
static long hashfree
Definition: copy.c:23
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 {
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) {
315  traceline("current choice point is %x\n",choice_stack);
316  }
317  }
318  }
319  }
320 
321  return u;
322 }
#define COPY_THRESHOLD
Definition: def_const.h:68
ptr_residuation resid
Definition: def_struct.h:173
#define function_it
Definition: def_const.h:362
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
#define HEAP
Definition: def_const.h:147
char evaluate_args
Definition: def_struct.h:136
#define global
Definition: def_const.h:364
#define QUOTE_STUB
Definition: def_const.h:329
def_type type_def
Definition: def_struct.h:133
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
#define NULL
Definition: def_const.h:203
#define NEW(A, TYPE)
Definition: def_macro.h:279
long abort_life(int nlflag)
Definition: built_ins.c:2124
void traceline(char *format,...)
Definition: error.c:157
#define type_it
Definition: def_const.h:363
#define EVAL_FLAG
Definition: def_const.h:327
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
static ptr_node copy_tree(ptr_node t, long copy_flag, long heap_flag)
Definition: copy.c:139
static long curr_status
Definition: copy.c:215
#define FALSE
Definition: def_const.h:128
GENERIC value_3
Definition: def_struct.h:170
void mark_quote_c(ptr_psi_term t, long heap_flag)
Definition: copy.c:396
GENERIC heap_pointer
Definition: def_glob.h:12
jmp_buf env
Definition: def_glob.h:236
ptr_definition cut
Definition: def_glob.h:83
unsigned long global_time_stamp
Definition: login.c:19
#define HEAPDONE(R)
Definition: def_macro.h:291
GENERIC stack_pointer
Definition: def_glob.h:14
#define QUOTE_FLAG
Definition: def_const.h:326
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_triple_list properties
Definition: def_struct.h:127
#define QUOTED_TRUE
Definition: def_const.h:123
ptr_node attr_list
Definition: def_struct.h:171
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 }
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
#define NEW(A, TYPE)
Definition: def_macro.h:279
ptr_node left
Definition: def_struct.h:183
char * key
Definition: def_struct.h:182
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
static ptr_node copy_tree(ptr_node t, long copy_flag, long heap_flag)
Definition: copy.c:139
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
#define HEAPDONE(R)
Definition: def_macro.h:291
unsigned long * GENERIC
Definition: def_struct.h:17
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); */
370 
371  return res;
372 }
ptr_node distinct_tree(ptr_node t)
Definition: copy.c:334
#define STACK_ALLOC(A)
Definition: def_macro.h:16
unsigned long global_time_stamp
Definition: login.c:19
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 }
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
ptr_node distinct_tree(ptr_node t)
Definition: copy.c:334
ptr_node left
Definition: def_struct.h:183
char * key
Definition: def_struct.h:182
#define STACK_ALLOC(A)
Definition: def_macro.h:16
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)); }
#define EVAL_FLAG
Definition: def_const.h:327
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
long to_heap
Definition: def_glob.h:264
#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)); }
#define EXACT_FLAG
Definition: def_const.h:325
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
long to_heap
Definition: def_glob.h:264
#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)); }
#define EXACT_FLAG
Definition: def_const.h:325
#define TRUE
Definition: def_const.h:127
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
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;
43  hashbuckets = (struct hashbucket *)
44  malloc(NUMBUCKETS * sizeof(struct hashbucket));
45 }
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:20
#define NUMBUCKETS
Definition: def_const.h:319
static long numbuckets
Definition: copy.c:24
static long hashtime
Definition: copy.c:22
static struct hashbucket * hashbuckets
Definition: copy.c:21
#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  }
92  hashbuckets[hashfree].next = lastbucket;
93  hashfree++;
94 }
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:20
static long hashfree
Definition: copy.c:23
static long numbuckets
Definition: copy.c:24
#define HASHEND
Definition: def_const.h:322
ptr_psi_term old_value
Definition: def_struct.h:385
static long hashtime
Definition: copy.c:22
void traceline(char *format,...)
Definition: error.c:157
ptr_psi_term new_value
Definition: def_struct.h:386
long timestamp
Definition: def_struct.h:392
static struct hashbucket * hashbuckets
Definition: copy.c:21
long bucketindex
Definition: def_struct.h:393
#define HASH(A)
Definition: def_macro.h:273
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();
457  mark_eval_new(t);
458 }
void mark_eval_new(ptr_psi_term t)
Definition: copy.c:479
void clear_copy()
Definition: copy.c:52
#define FALSE
Definition: def_const.h:128
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 {
505  old_status=curr_status;
506  curr_status=4;
507 
508  if (flag) /* 16.9 */
510  else
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 }
#define function_it
Definition: def_const.h:362
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
char evaluate_args
Definition: def_struct.h:136
#define global
Definition: def_const.h:364
def_type type_def
Definition: def_struct.h:133
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
void mark_eval_tree_new(ptr_node n)
Definition: copy.c:546
#define type_it
Definition: def_const.h:363
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
void mark_quote_tree_new(ptr_node n)
Definition: copy.c:581
static long curr_status
Definition: copy.c:215
#define FALSE
Definition: def_const.h:128
void mark_quote_new(ptr_psi_term t)
Definition: copy.c:557
static long mark_nonstrict_flag
Definition: copy.c:442
ptr_definition type
Definition: def_struct.h:165
ptr_triple_list properties
Definition: def_struct.h:127
#define QUOTED_TRUE
Definition: def_const.h:123
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) {
553  }
554 }
void mark_eval_new(ptr_psi_term t)
Definition: copy.c:479
GENERIC data
Definition: def_struct.h:185
void mark_eval_tree_new(ptr_node n)
Definition: copy.c:546
ptr_node left
Definition: def_struct.h:183
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();
467  mark_eval_new(t);
468 }
void mark_eval_new(ptr_psi_term t)
Definition: copy.c:479
void clear_copy()
Definition: copy.c:52
#define TRUE
Definition: def_const.h:127
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);
612  t->status &= ~RMASK;
613  }
614 }
#define RMASK
Definition: def_const.h:159
ptr_psi_term coref
Definition: def_struct.h:172
void mark_quote(ptr_psi_term t)
Definition: copy.c:601
#define QUOTED_TRUE
Definition: def_const.h:123
ptr_node attr_list
Definition: def_struct.h:171
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);
420  }
421  }
422 }
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
void mark_quote_tree_c(ptr_node n, long heap_flag)
Definition: copy.c:424
#define QUOTE_STUB
Definition: def_const.h:329
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
#define NEW(A, TYPE)
Definition: def_macro.h:279
#define EVAL_FLAG
Definition: def_const.h:327
#define deref_ptr(P)
Definition: def_macro.h:95
#define QUOTE_FLAG
Definition: def_const.h:326
#define QUOTED_TRUE
Definition: def_const.h:123
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 */
573  else *infoptr = FALSE; /* sanjay */
574  t->status= 4;
575  t->flags=QUOTED_TRUE; /* 14.9 */
577  }
578 }
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
void mark_quote_tree_new(ptr_node n)
Definition: copy.c:581
#define FALSE
Definition: def_const.h:128
#define QUOTED_TRUE
Definition: def_const.h:123
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();
476  mark_quote_new(t);
477 }
void clear_copy()
Definition: copy.c:52
#define FALSE
Definition: def_const.h:128
void mark_quote_new(ptr_psi_term t)
Definition: copy.c:557
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));
623  }
624 }
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
void mark_quote(ptr_psi_term t)
Definition: copy.c:601
void mark_quote_tree()
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 }
void mark_quote_tree_c(ptr_node n, long heap_flag)
Definition: copy.c:424
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
void mark_quote_c(ptr_psi_term t, long heap_flag)
Definition: copy.c:396
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) {
588  }
589 }
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
void mark_quote_tree_new(ptr_node n)
Definition: copy.c:581
void mark_quote_new(ptr_psi_term t)
Definition: copy.c:557
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)); }
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
Definition: copy.c:219
long to_heap
Definition: def_glob.h:264
#define FALSE
Definition: def_const.h:128
#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 }
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:20
#define HASHEND
Definition: def_const.h:322
#define NULL
Definition: def_const.h:203
ptr_psi_term old_value
Definition: def_struct.h:385
static long hashtime
Definition: copy.c:22
ptr_psi_term new_value
Definition: def_struct.h:386
static struct hashbucket * hashbuckets
Definition: copy.c:21
long bucketindex
Definition: def_struct.h:393
#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.