pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:1078:    Pike_compiler->type_stackp[0] = Pike_compiler->type_stackp[-1];    Pike_compiler->type_stackp[-1] = tmp;    break;    }    }    push_type(type);       TYPE_STACK_DEBUG("push_reverse_type");   }    + static int is_int_type(struct pike_type *t) + { +  loop: +  switch(t->type) { +  case T_INT: +  case T_ZERO: +  case T_VOID: +  case '0': case '1': case '2': case '3': case '4': +  case '5': case '6': case '7': case '8': case '9': +  return 1; +  case T_OR: +  case T_AND: +  return is_int_type(t->car) && is_int_type(t->cdr); +  case PIKE_T_NAME: +  case PIKE_T_ATTRIBUTE: +  case PIKE_T_SCOPE: +  case T_ASSIGN: +  t = t->cdr; +  goto loop; +  default: +  return 0; +  } + } +    /* The marker_set is used as follows:    *    * PT_FLAG_MARKER_n Indicates that marker #n should be kept after    * expansion.    *    * PT_FLAG_ASSIGN_n Indicates that the assign to marker #n should    * NOT be removed.    */   static void debug_push_finished_type_with_markers(struct pike_type *type,    struct pike_type **markers,
pike.git/src/pike_types.c:1111:    */    if (!(type->flags & (~marker_set | PT_FLAG_MARKER) & PT_FLAG_MARK_ASSIGN)) {    /* Nothing to replace in this subtree. */   #ifdef PIKE_TYPE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "Nothing to replace in this subtree.\n");    simple_describe_type(type);    fprintf(stderr, "\n");    }   #endif /* PIKE_TYPE_DEBUG */ +  if ((marker_set & PT_FLAG_INT_ONLY) && !is_int_type(type)) { +  push_finished_type(int_type_string); +  } else {    push_finished_type(type); -  +  }    return;    }    if ((type->type >= '0') && (type->type <= '9')) {    /* Marker. */    unsigned int m = type->type - '0';   #ifdef PIKE_TYPE_DEBUG    if ((l_flag > 2) && m) {    fprintf(stderr, "Marker %d: %p.\n", m, markers[m]);    }   #endif /* PIKE_TYPE_DEBUG */    if (markers[m]) {    /* The marker has a value. */    struct pike_type *type = dmalloc_touch(struct pike_type *, markers[m]);   #ifdef PIKE_TYPE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "Marker value.\n");    }   #endif    /* FIXME: We probably ought to switch to the other marker set here. */    markers[m] = NULL; -  push_finished_type_with_markers(type, markers, 0); +  push_finished_type_with_markers(type, markers, +  marker_set & PT_FLAG_INT_ONLY);    if (type->flags & (PT_FLAG_MARKER|PT_FLAG_ASSIGN)) {    push_scope_type(0);    }    if (markers[m]) free_type(markers[m]);    markers[m] = dmalloc_touch(struct pike_type *, type);    } else {    /* The marker has not been set. */   #ifdef PIKE_TYPE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "No marker value.\n");
pike.git/src/pike_types.c:1258:    pop_stack_mark();    pop_stack_mark();    push_type(T_AND);    }    }    } else {    if (type->cdr) {    /* In all other cases type->cdr will be a valid node if is not NULL. */    push_finished_type_with_markers(type->cdr, markers, cdr_set);    } +  /* Make sure to filter invalid nodes from the marker in case +  * it is a string type. +  */ +  if (type->type == PIKE_T_STRING) car_set |= PT_FLAG_INT_ONLY;    /* In all other cases type->car will be a valid node. */    push_finished_type_with_markers(type->car, markers, car_set);    /* push_type has sufficient magic to recreate the type. */    push_type(type->type);    }    done:    TYPE_STACK_DEBUG("push_finished_type_with_markers");   }      static void push_type_field(TYPE_FIELD field)