pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pike_types.c,v 1.299 2007/04/26 11:14:53 grubba Exp $ + || $Id: pike_types.c,v 1.300 2007/04/26 15:09:58 grubba Exp $   */      #include "global.h"   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"
pike.git/src/pike_types.c:524:    t->cdr = cdr;       t->hash = hash;    t->next = pike_type_hash[index];    pike_type_hash[index] = t;       if (flag_method) {    if (flag_method == PT_IS_MARKER) {    t->flags = PT_FLAG_MARKER_0 << (type-'0');    } else { +  /* Clear markers that are assigned in the respective subtrees, +  * but copy the rest. +  */    if (car && (flag_method & PT_COPY_CAR)) { -  t->flags |= car->flags; +  t->flags |= car->flags & ~(car->flags >> PT_ASSIGN_SHIFT);    }    if (cdr && (flag_method & PT_COPY_CDR)) { -  t->flags |= cdr->flags; +  t->flags |= cdr->flags & ~(cdr->flags >> PT_ASSIGN_SHIFT);    } -  /* Clear markers that are assigned. */ -  t->flags &= ~(t->flags & (t->flags >> PT_ASSIGN_SHIFT)); +     }    }      #ifdef DEBUG_MALLOC    switch(type) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:
pike.git/src/pike_types.c:1043:    * PT_FLAG_MARKER_n Indicates that marker #n may be replaced.    *    * PT_FLAG_ASSIGN_n Indicates that there's a prior assign to marker #n.    * The marker should thus be kept.    */   static void debug_push_finished_type_with_markers(struct pike_type *type,    struct pike_type **markers,    INT32 marker_set)   {    recurse: - #if 0 -  fprintf(stderr, "push_finished_type_with_markers((%d[%x]),...)...\n", -  type->type, type->flags); - #endif /* 0 */ + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) { +  fprintf(stderr, +  "push_finished_type_with_markers((%d[%x]),..., 0x%08x)...\n", +  type->type, type->flags, marker_set); +  } + #endif /* PIKE_TYPE_DEBUG */    if (!(type->flags & (marker_set /*| (marker_set << PT_ASSIGN_SHIFT)*/))) {    /* No unassigned markers in this sub-tree */ - #if 0 + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) {    fprintf(stderr, "No unassigned markers in this subtree.\n"); - #endif /* 0 */ +  simple_describe_type(type); +  fprintf(stderr, "\n"); +  } + #endif /* PIKE_TYPE_DEBUG */    push_finished_type(type);    return;    }    if ((type->type >= '0') && (type->type <= '9')) {    unsigned int m = type->type - '0'; - #if 0 -  if (m) { + #ifdef PIKE_TYPE_DEBUG +  if ((l_flag > 2) && m) {    fprintf(stderr, "Marker %d: %p.\n", m, markers[m]);    } - #endif /* 0 */ + #endif /* PIKE_TYPE_DEBUG */    if ((marker_set & (PT_FLAG_MARKER_0 << m)) && markers[m]) {    type = dmalloc_touch(struct pike_type *, markers[m]);    if (marker_set & (PT_FLAG_ASSIGN_0 << m)) {    /* There's a corresponding assignment,    * so we need to keep the marker as well.    */ -  + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) { +  fprintf(stderr, "Keep marker or with marker value.\n"); +  } + #endif    markers[m] = NULL;    push_type('0' + m);    push_finished_type_with_markers(type, markers,    marker_set & ~(PT_FLAG_MARKER_0 << m));    push_type(T_OR);    markers[m] = dmalloc_touch(struct pike_type *, type);    } else {    /* It's a marker we're cleared to replace. */ -  + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) { +  fprintf(stderr, "Killed marker.\n"); +  } + #endif    marker_set &= ~(PT_FLAG_MARKER_0 << m);    goto recurse;    }    } else if (marker_set & (PT_FLAG_ASSIGN_0 << m)) {    /* Keep the marker as-is. */ -  + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) { +  fprintf(stderr, "Keep marker and no marker value.\n"); +  } + #endif    push_type(type->type);    } else { -  + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) { +  fprintf(stderr, "Killed marker and no marker value.\n"); +  } + #endif    push_type(T_ZERO);    }    TYPE_STACK_DEBUG("push_finished_type_with_markers");    return;    } else if (type->type == T_ASSIGN) {    int marker = PTR_TO_INT(type->car); - #if 0 + #ifdef PIKE_TYPE_DEBUG +  if (l_flag > 2) {    fprintf(stderr, "Assign to marker %"PRINTPTRDIFFT"d.\n",    CAR_TO_INT(type)); - #endif /* 0 */ +  } + #endif /* PIKE_TYPE_DEBUG */    if ((marker_set & (PT_FLAG_ASSIGN_0 << marker)) && markers[marker])    {    /* The marker has already been set. Remove it. */    type = type->cdr;    goto recurse;    }    /* Remove the corresponding marker from the set to replace. */    marker_set &= ~(PT_FLAG_MARKER_0 << marker);    push_finished_type_with_markers(type->cdr, markers, marker_set);    push_assign_type('0' + marker);