pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:2275:    break;    }    if (s->flags) {    fprintf(stderr, "[%06x]", s->flags);    }    } else {    fprintf(stderr, "NULL");    }   }    + static void low_describe_int_range(struct string_builder *s, +  struct pike_type *t) + { +  if (!t || (t == int_type_string)) return; +  loop: +  switch(t->type) { +  case T_ZERO: +  string_builder_strcat(s, "zero"); +  break; +  case T_INT: +  { +  INT32 min=CAR_TO_INT(t); +  INT32 max=CDR_TO_INT(t); +  +  if (min == max) { +  string_builder_sprintf(s, "%ld", (long) min); +  } else if (!min && (max != MAX_INT32) && !(max & (max + 1))) { +  int j = 0; +  while (max) { +  max >>= 1; +  j++; +  } +  string_builder_sprintf(s, "%dbit", j); +  } else { +  if (min != MIN_INT32) { +  string_builder_sprintf(s, "%ld..", (long)min); +  } else { +  string_builder_strcat(s, ".."); +  } +  if (max != MAX_INT32) { +  string_builder_sprintf(s, "%ld", (long)max); +  } +  } +  } +  break; +  case T_ASSIGN: +  t = t->cdr; +  goto loop; +  case T_OR: +  low_describe_int_range(s, t->car); +  string_builder_strcat(s, " | "); +  t = t->cdr; +  goto loop; +  default: +  low_describe_type(s, t); +  break; +  } + } +    void low_describe_type(struct string_builder *s, struct pike_type *t)   {    check_c_stack(1024);    switch(t->type)    {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    string_builder_putchar(s, t->type);    break;   
pike.git/src/pike_types.cmod:2301:    break;       case T_TUPLE:    string_builder_sprintf(s, "[%T,%T]", t->car, t->cdr);    break;       case T_VOID: string_builder_strcat(s, "void"); break;    case T_ZERO: string_builder_strcat(s, "zero"); break;    case T_MIXED: string_builder_strcat(s, "mixed"); break;    case PIKE_T_UNKNOWN: string_builder_strcat(s, "unknown"); break; -  case T_INT: -  { -  INT32 min=CAR_TO_INT(t); -  INT32 max=CDR_TO_INT(t); +     -  if (!min && max && max != MAX_INT32 && !(max & (max+1))) { -  int j = 0; -  while (max) { -  max >>= 1; -  j++; -  } -  string_builder_sprintf(s, "int(%dbit)", j); -  } else if (min == max) { -  string_builder_sprintf(s, "int(%ld)", (long)min); -  } else if(min!=MIN_INT32 || max!=MAX_INT32) { -  string_builder_sprintf(s, "int(%ld..%ld)", (long)min, (long)max); -  } else { +  case T_INT:    string_builder_strcat(s, "int"); -  } +  +  if (t == int_type_string) break; +  +  string_builder_putchar(s, '('); +  low_describe_int_range(s, t); +  string_builder_putchar(s, ')');    break; -  } +     case T_FLOAT: string_builder_strcat(s, "float"); break;    case T_PROGRAM:    if ((t->car->type == T_OBJECT) &&    (!t->car->cdr)) {    string_builder_strcat(s, "program");    } else {    string_builder_sprintf(s, "program(%T)", t->car);    }    break;    case T_OBJECT:
pike.git/src/pike_types.cmod:2357:    } else {    string_builder_sprintf(s, "%"PRINTPTRDIFFT"d)", CDR_TO_INT(t));    }    }else{    string_builder_strcat(s, "object");    }    break;       case T_STRING:    { -  INT32 min; -  INT32 max; -  t = t->cdr; -  if (t->type == T_ZERO) { -  string_builder_strcat(s, "string(zero)"); -  } else if (t != int_type_string) { -  string_builder_strcat(s, "string("); -  while (t->type == T_OR) { -  struct pike_type *char_type = t->car; -  while(char_type->type == T_ASSIGN) { -  char_type = char_type->cdr; -  } -  if (char_type->type != T_INT) { -  low_describe_type(s, char_type); -  } else { -  min = CAR_TO_INT(char_type); -  max = CDR_TO_INT(char_type); -  if (!min && max && max != MAX_INT32 && !(max & (max+1))) { -  int j = 0; -  while (max) { -  max >>= 1; -  j++; -  } -  string_builder_sprintf(s, "%dbit", j); -  } else { -  if ((min != MIN_INT32) || (min == max)) { -  string_builder_sprintf(s, "%d", min); -  } -  if (min != max) { -  string_builder_strcat(s, ".."); -  if (max != MAX_INT32) { -  string_builder_sprintf(s, "%d", max); -  } -  } -  } -  } -  string_builder_strcat(s, " | "); -  t = t->cdr; -  } -  while(t->type == T_ASSIGN) { -  t = t->cdr; -  } -  if (t->type != T_INT) { -  low_describe_type(s, t); -  } else { -  min = CAR_TO_INT(t); -  max = CDR_TO_INT(t); -  if (!min && max && max != MAX_INT32 && !(max & (max+1))) { -  int j = 0; -  while (max) { -  max >>= 1; -  j++; -  } -  string_builder_sprintf(s, "%dbit", j); -  } else { -  if ((min != MIN_INT32) || (min == max)) { -  string_builder_sprintf(s, "%d", min); -  } -  if (min != max) { -  string_builder_strcat(s, ".."); -  if (max != MAX_INT32) { -  string_builder_sprintf(s, "%d", max); -  } -  } -  } -  } -  string_builder_putchar(s, ')'); -  } else { +     string_builder_strcat(s, "string"); -  +  if (t->cdr == int_type_string) { +  break;    } -  +  string_builder_putchar(s, '('); +  low_describe_int_range(s, t->cdr); +  string_builder_putchar(s, ')');    break;    }    case T_TYPE:    string_builder_sprintf(s, "type(%T)", t->car);    break;       case PIKE_T_NAME:    string_builder_sprintf(s, "{ %S = %T }",    (struct pike_string *)t->car, t->cdr);    break;
pike.git/src/pike_types.cmod:2498:    if(arg++) string_builder_strcat(s, ", ");    low_describe_type(s, t->car);    string_builder_strcat(s, " ...");    }    string_builder_sprintf(s, " : %T)", t->cdr);    }    break;    }       case T_ARRAY: -  if(t->cdr->type != T_MIXED) { -  string_builder_sprintf(s, "array(%T)", t->cdr); -  } else { +     string_builder_strcat(s, "array"); -  +  if(t->cdr->type == T_MIXED) { +  break;    } -  +  string_builder_putchar(s, '('); +  string_builder_sprintf(s, "%T", t->cdr); +  string_builder_putchar(s, ')');    break;       case T_MULTISET:    if(t->car->type != T_MIXED) {    string_builder_sprintf(s, "multiset(%T)", t->car);    } else {    string_builder_strcat(s, "multiset");    }    break;