pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:209:   #ifdef PIKE_DEBUG    /* Let's make it able to describe any type constant in debug mode. */    case T_UNFINISHED: return "T_UNFINISHED";    case T_MANY: return "T_MANY";    case PIKE_T_INT_UNTYPED: return "PIKE_T_INT_UNTYPED";    case PIKE_T_GET_SET: return "PIKE_T_GET_SET";    case PIKE_T_FREE: return "PIKE_T_FREE";    case PIKE_T_FUNCTION_ARG: return "PIKE_T_FUNCTION_ARG";       case PIKE_T_FIND_LFUN: return "PIKE_T_FIND_LFUN"; +  case PIKE_T_SET_CAR: return "PIKE_T_SET_CAR"; +  case PIKE_T_SET_CDR: return "PIKE_T_SET_CDR";       case PIKE_T_ATTRIBUTE: return "PIKE_T_ATTRIBUTE";    case PIKE_T_NSTRING: return "PIKE_T_NSTRING";    case PIKE_T_LSTRING: return "PIKE_T_LSTRING";    case PIKE_T_LARRAY: return "PIKE_T_LARRAY";    case PIKE_T_RING: return "PIKE_T_RING";    case PIKE_T_NAME: return "PIKE_T_NAME";    case PIKE_T_SCOPE: return "PIKE_T_SCOPE";    case PIKE_T_TUPLE: return "PIKE_T_TUPLE";    case T_ASSIGN: return "T_ASSIGN";
pike.git/src/pike_types.cmod:281:    * TYPE type -    * PROGRAM type -    * MIXED - -    * VOID - -    * ZERO - -    * UNKNOWN - -    * INT min (int) max (int)    * OBJECT implements/is object id(int)    * OPERATOR type Depends on bit #15. Added in 8.1    * FIND_LFUN object type lfun (int) Added in 8.1 +  * SET_CAR type type Added in 8.1 +  * SET_CDR type type Added in 8.1    * TRANSITIVE fun_type fun_type Added in 8.1    *    * Note that the cdr of a FUNCTION is a valid FUNCTION for the rest of    * the arguments.    *    * Note also that functions that don't take any arguments, or just    * a many argument just have a MANY node, and no FUNCTION node.    *    * TRANSITIVE has a car with the current state, and a cdr with the    * function type to apply.
pike.git/src/pike_types.cmod:2283:    case T_NOT: fprintf(stderr, "not"); break;    case T_VOID: fprintf(stderr, "void"); break;    case T_ZERO: fprintf(stderr, "zero"); break;    case T_MIXED: fprintf(stderr, "mixed"); break;       case PIKE_T_OPERATOR:    fprintf(stderr, "operator ");    e++;    switch(EXTRACT_UCHAR(a+e)<<8 | PIKE_T_OPERATOR) {    case PIKE_T_FIND_LFUN: fprintf(stderr, "find_lfun"); break; +  case PIKE_T_SET_CAR: fprintf(stderr, "set_car"); break; +  case PIKE_T_SET_CDR: fprintf(stderr, "set_cdr"); break;    default:    fprintf(stderr, "unknown<0x%04x>",    EXTRACT_UCHAR(a+e)<<8 | PIKE_T_OPERATOR);    break;    }    break;       case PIKE_T_TRANSITIVE:    fprintf(stderr, "transitive");    break;
pike.git/src/pike_types.cmod:2938:    t->car, lfun_strings[CDR_TO_INT(t)]);    break;       case PIKE_T_TRANSITIVE:    string_builder_sprintf(s, "transitive(%T, %T)", t->car, t->cdr);    break;       default:    {    if ((t->type & PIKE_T_MASK) == PIKE_T_OPERATOR) { -  string_builder_sprintf(s, "operator(0x%04x)(%T", t->type, t->car); +  switch(t->type) { +  case PIKE_T_SET_CAR: +  string_builder_strcat(s, "set_car"); +  break; +  case PIKE_T_SET_CDR: +  string_builder_strcat(s, "set_cdr"); +  break; +  default: +  string_builder_sprintf(s, "operator(0x%04x)", t->type); +  break; +  } +  string_builder_sprintf(s, "(%T", t->car);    if (t->type & 0x8000) {    string_builder_sprintf(s, ",%T)", t->cdr);    } else if (t->cdr) {    string_builder_sprintf(s, ",0x%08lx)", CDR_TO_INT(t));    } else {    string_builder_strcat(s, ")");    }    } else {    string_builder_sprintf(s, "unknown code(%d)", t->type);    }
pike.git/src/pike_types.cmod:2974:   }         /******/      static TYPE_T low_compile_type_to_runtime_type(struct pike_type *t)   {    switch(t?t->type:PIKE_T_UNKNOWN) /* Note: No masking here. */    {    case PIKE_T_RING: +  case PIKE_T_SET_CAR: +  case PIKE_T_SET_CDR:    return low_compile_type_to_runtime_type(t->car);       case T_OR:    {    TYPE_T car_t = low_compile_type_to_runtime_type(t->car);    TYPE_T cdr_t = low_compile_type_to_runtime_type(t->cdr);    if (car_t == cdr_t)    return car_t;    if (car_t == PIKE_T_VOID) {    car_t = PIKE_T_ZERO;
pike.git/src/pike_types.cmod:12497:      struct pike_type *apply_type_operator(enum PIKE_TYPE op,    struct pike_type *arg1,    struct pike_type *arg2)   {    struct pike_type *res = NULL;    switch(op) {    case PIKE_T_FIND_LFUN:    res = find_lfun_type(arg1, (ptrdiff_t)(void*)arg2);    break; +  case PIKE_T_SET_CAR: +  if (!arg1) return NULL; +  switch(arg1->type) { +  case PIKE_T_FUNCTION: +  case PIKE_T_MANY: +  case PIKE_T_RING: +  case PIKE_T_TUPLE: +  case PIKE_T_MAPPING: +  case PIKE_T_ARRAY: +  case PIKE_T_STRING: +  case PIKE_T_MULTISET: +  type_stack_mark(); +  push_finished_type(arg2); +  push_finished_type(arg1->cdr); +  push_reverse_type(arg1->type); +  return pop_unfinished_type(); +  } +  break; +  case PIKE_T_SET_CDR: +  if (!arg1) return NULL; +  switch(arg1->type) { +  case PIKE_T_FUNCTION: +  case PIKE_T_MANY: +  case PIKE_T_RING: +  case PIKE_T_TUPLE: +  case PIKE_T_MAPPING: +  case PIKE_T_ARRAY: +  case PIKE_T_STRING: +  type_stack_mark(); +  push_finished_type(arg2); +  push_finished_type(arg1->car); +  push_type(arg1->type); +  return pop_unfinished_type(); +  } +  break;    default:    Pike_fatal("apply_type_operator(): Unknown operator: 0x%04x\n", op);    break;    }    if (!res) {    res = mixed_type_string;    add_ref(res);    }    return res;   }
pike.git/src/pike_types.cmod:13845:    case PIKE_T_TRANSITIVE:    if (t->cdr) gc_mark_type_as_referenced(t->cdr);    /* FALLTHROUGH */    case PIKE_T_MULTISET:    case T_NOT:    case PIKE_T_TYPE:    case PIKE_T_PROGRAM:    if (t->car) gc_mark_type_as_referenced(t->car);    break;    case PIKE_T_OPERATOR: -  if (t->type & 0x8000) { +  if ((t->type & 0x8000) && t->cdr) {    gc_mark_type_as_referenced(t->cdr);    }    gc_mark_type_as_referenced(t->car);    break;    }    } GC_LEAVE;    }   }      #ifdef PIKE_DEBUG
pike.git/src/pike_types.cmod:13965:    debug_gc_check (t->car, " as car in a type");    }    break;    case T_SCOPE:    case T_ASSIGN:    if (t->cdr) {    debug_gc_check (t->cdr, " as cdr in a type");    }    break;    case PIKE_T_OPERATOR: -  if (t->type & 0x8000) { +  if ((t->type & 0x8000) && t->cdr) {    debug_gc_check (t->cdr, " as cdr in a type");    }    if (t->car) {    debug_gc_check (t->car, " as car in a type");    }    break;   #ifdef PIKE_DEBUG    case '0':    case '1':    case '2':