pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:168:    add_ref(res = mixed_type_string);    type_stack_mark();    return res;    }else{    return debug_pop_type();    }   }      PMOD_EXPORT char *get_name_of_type(TYPE_T t)   { -  switch(t & 0xff) +  switch(t & PIKE_T_MASK)    {    case T_ARRAY: return "array";    case T_MAPPING: return "mapping";    case T_MULTISET: return "multiset";    case T_OBJECT: return "object";    case T_FUNCTION: return "function";    case T_PROGRAM: return "program";    case T_STRING: return "string";    case T_TYPE: return "type";    case T_INT: return "int";
pike.git/src/pike_types.cmod:336:    t2 = &((*t2)->next);    }       car = t->car;    cdr = t->cdr;    type = t->type;       really_free_pike_type((struct pike_type*)debug_malloc_pass(t));       /* FIXME: Recursion: Should we use a stack? */ -  switch(type & 0xff) { +  switch(type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case T_ARRAY:    case T_STRING:    case PIKE_T_TRANSITIVE:
pike.git/src/pike_types.cmod:442:       hash ^= (hash >> 20) ^ (hash >> 12);    hash ^= (hash >> 7) ^ (hash >> 4);       index = hash & pike_type_hash_size;   #ifdef PIKE_EXTRA_DEBUG    static unsigned INT32 extra_debug_index = (unsigned INT32)~0;   #endif /* PIKE_EXTRA_DEBUG */   #ifdef PIKE_DEBUG    /* PIKE_DEBUG code */ -  if ((type & ~255) && ((type & 0xff) != PIKE_T_OPERATOR)) { +  if ((type & ~PIKE_T_MASK) && ((type & PIKE_T_MASK) != PIKE_T_OPERATOR)) {    /* The bad type node on OSF/1 seems to be:    *    * type: 0xffff    * car: valid pointer.    * cdr: 0x400000000    * next: 0x100000000    */    Pike_fatal("Attempt to create an invalid type node: %d(%s)\n"    " car: %p\n"    " cdr: %p\n",
pike.git/src/pike_types.cmod:520:    " t->next:%p\n",    t->type, get_name_of_type(t->type),    t->car, car,    t->cdr, cdr,    t->next);    }   #endif /* PIKE_EXTRA_DEBUG */    if ((t->hash == hash) && (t->type == type) &&    (t->car == car) && (t->cdr == cdr)) {    /* Free car & cdr as appropriate. */ -  switch(type & 0xff) { +  switch(type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case T_ARRAY:    case T_STRING:    case PIKE_T_TRANSITIVE:
pike.git/src/pike_types.cmod:634:    if (car && (flag_method & PT_COPY_CAR)) {    t->flags |= car->flags;    }    if (cdr && (flag_method & PT_COPY_CDR)) {    t->flags |= cdr->flags;    }    }    }      #ifdef DEBUG_MALLOC -  switch(type & 0xff) { +  switch(type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case T_ARRAY:    case T_STRING:    case PIKE_T_TRANSITIVE:
pike.git/src/pike_types.cmod:887:    TYPE_STACK_DEBUG("push_type_name");   }      static struct pike_type *apply_type_operator(enum PIKE_TYPE op,    struct pike_type *arg1,    struct pike_type *arg2);      void debug_push_type_operator(enum PIKE_TYPE op, struct pike_type *arg)   {    struct pike_type *t = *Pike_compiler->type_stackp; +  struct pike_type *tmp;    int free_arg = 0;      #ifdef PIKE_DEBUG -  if ((op & 0xff) != 0x80) { +  if ((op & PIKE_T_MASK) != 0x80) {    Pike_fatal("Invalid operator for push_operator: 0x%04x\n", op);    }   #endif    if (op & 0x8000) {    if (!arg) {    Pike_compiler->type_stackp--;    arg = *Pike_compiler->type_stackp;    free_arg = 1;    *Pike_compiler->type_stackp = t;    }    }       /* Attempt to propagate the operator towards the leaf nodes. */ -  switch(t->type & 0xff) { +  switch(t->type & PIKE_T_MASK) {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    case T_ASSIGN:    case PIKE_T_OPERATOR:    case PIKE_T_SCOPE:    /* Deferred evaluation. */    if (op & 0x8000) {    *Pike_compiler->type_stackp = mk_type(op,    *Pike_compiler->type_stackp,    arg,
pike.git/src/pike_types.cmod:985:   {    copy_pike_type(*(++Pike_compiler->type_stackp), t);       TYPE_STACK_DEBUG("push_finished_type");   }      static void push_reverse_joiner_type(unsigned int type)   {    /* fprintf(stderr, "push_reverse_joiner_type(%d)\n", type); */    -  switch(type & 0xff) { +  switch(type & PIKE_T_MASK) {    case T_OR:    case T_AND:    /* Special case: Check if the two top elements are equal. */    if (Pike_compiler->type_stackp[-1] == Pike_compiler->type_stackp[0]) {    free_type(*(Pike_compiler->type_stackp--));    return;    }    /* Make a new type of the top two types. */    --Pike_compiler->type_stackp;   #ifdef PIKE_DEBUG
pike.git/src/pike_types.cmod:1018:   }      static void low_or_pike_types(struct pike_type *t1,    struct pike_type *t2,    int zero_implied);      void debug_push_type(unsigned int type)   {    /* fprintf(stderr, "push_type(%d)\n", type); */    -  switch(type & 0xff) { +  switch(type & PIKE_T_MASK) {    case T_OR:    case T_AND:    /* Special case: Check if the two top elements are equal. */    if (Pike_compiler->type_stackp[-1] == Pike_compiler->type_stackp[0]) {    free_type(*(Pike_compiler->type_stackp--));    return;    }    if (Pike_compiler->type_stackp[0]->type == type) {    /* The top type is the same as our type.    * Split it and join the parts with the other type.
pike.git/src/pike_types.cmod:1149:   #ifdef PIKE_DEBUG    if ((top->type != expected) &&    (top->type != PIKE_T_NAME) &&    (top->type != PIKE_T_ATTRIBUTE)) {    Pike_fatal("Unexpected type on stack: %d (expected %d)\n", top->type, expected);    }   #endif /* PIKE_DEBUG */    /* OPTIMIZE: It looks like this function is always called with    * expected == T_ARRAY.    */ -  switch(top->type & 0xff) { +  switch(top->type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case PIKE_T_TRANSITIVE:    /* Both car & cdr. */    push_finished_type(top->cdr);
pike.git/src/pike_types.cmod:1250:    }    }    push_type(type);       TYPE_STACK_DEBUG("push_reverse_type");   }      static int is_int_type(struct pike_type *t)   {    loop: -  switch(t->type & 0xff) { +  switch(t->type & PIKE_T_MASK) {    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':    case PIKE_T_OPERATOR:    return 1;    case T_OR:    case T_AND:    return is_int_type(t->car) && is_int_type(t->cdr);
pike.git/src/pike_types.cmod:1400:    }    } else if (type->type == PIKE_T_NAME) {    /* Strip the name, since it won't be correct anymore. */    type = type->cdr;    goto recurse;    } else if (type->type == PIKE_T_ATTRIBUTE) {    /* Keep the attribute. */    push_finished_type_with_markers(type->cdr, markers, marker_set);    push_type_attribute((struct pike_string *)type->car);    goto done; -  } else if ((type->type & 0xff) == PIKE_T_OPERATOR) { +  } else if ((type->type & PIKE_T_MASK) == PIKE_T_OPERATOR) {    push_finished_type_with_markers(type->car, markers, marker_set);    push_type_operator(type->type, type->cdr);    goto done;    } else if (type->type == PIKE_T_TRANSITIVE) {    push_finished_type(type->cdr);    push_finished_type_with_markers(type->car, markers, marker_set);    push_type(PIKE_T_TRANSITIVE);    goto done;    }    /* FIXME: T_SCOPE */
pike.git/src/pike_types.cmod:2201:    }    }    fprintf(stderr, "\n");   }   #endif      void simple_describe_type(struct pike_type *s)   {    if (s) {    /* fprintf(stderr, "[[[%p]]]", s); */ -  switch(s->type & 0xff) { +  switch(s->type & PIKE_T_MASK) {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    fprintf(stderr, "%d", s->type-'0');    break;       case PIKE_T_NAME:    fprintf(stderr, "{ %s = ", ((struct pike_string *)s->car)->str);    simple_describe_type(s->cdr);    fprintf(stderr, " }");    break;
pike.git/src/pike_types.cmod:2820:    string_builder_sprintf(s, "find_lfun(%T, \"%S\")",    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 & 0xff) == PIKE_T_OPERATOR) { +  if ((t->type & PIKE_T_MASK) == PIKE_T_OPERATOR) {    string_builder_sprintf(s, "operator(0x%04x)(%T", t->type, 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:2913:    *    * @param t    * Type to check.    */   int deprecated_typep(struct pike_type *t)   {    struct pike_string *deprecated_string;    MAKE_CONST_STRING(deprecated_string, "deprecated");       while (t) { -  switch(t->type & 0xff) { +  switch(t->type & PIKE_T_MASK) {    case PIKE_T_ATTRIBUTE:    if (((struct pike_string*)t->car) == deprecated_string) {    return 1;    }    /* FALLTHRU */    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    t = t->cdr;    continue;
pike.git/src/pike_types.cmod:3923:    int flags)   {    int correct_args;    struct pike_type *ret = NULL;    struct pike_type *tmp;      #ifdef PIKE_DEBUG    fatal_check_c_stack(1024);   #endif    -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case T_AND:    ret = low_match_types(a->car, b, flags);    if(!ret) return 0;    free_type(ret);    return low_match_types(a->cdr, b, flags);       case T_OR:    ret = low_match_types(a->car, b, flags);    if(ret && !(flags & NO_SHORTCUTS)) return ret;
pike.git/src/pike_types.cmod:4063:    free_type(t);    return ret;   #else    /* FIXME */    add_ref(a);    return a;   #endif    }    }    -  switch(b->type & 0xff) +  switch(b->type & PIKE_T_MASK)    {    case T_AND:    ret = low_match_types(a, b->car, flags);    if(!ret) return 0;    free_type(ret);    return low_match_types(a, b->cdr, flags);       case T_OR:    ret = low_match_types(a, b->car, flags);    if(ret && !(flags & NO_SHORTCUTS)) return ret;
pike.git/src/pike_types.cmod:4604:   #endif /* 0 */       if(a == b) return 1;      #ifdef TYPE_GROUPING    if (b->type != T_OR) {    flags &= ~LE_B_GROUPED;    }   #endif    -  switch(b->type & 0xff) +  switch(b->type & PIKE_T_MASK)    {    case T_AND:    /* OK, if a is a subset of both parts. */    ret = low_pike_types_le(a, b->car, array_cnt, flags);    if(!ret) return 0;    b = b->cdr;    goto recurse;       case T_OR:    /* OK if a is a subset of either of the parts,
pike.git/src/pike_types.cmod:4789:    return ret;    }    }      #ifdef TYPE_GROUPING    if (a->type != T_OR) {    flags &= ~LE_A_GROUPED;    }   #endif    -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case T_AND:    /* OK if either of the parts is a subset. */    /* FIXME: What if b also contains an AND? */    ret = low_pike_types_le(a->car, b, array_cnt, flags);    if(!ret) {    a = a->cdr;    goto recurse;    }    if ((a->flags | b->flags) & PT_FLAG_ASSIGN) {
pike.git/src/pike_types.cmod:5442:      /*    * Return the return type from a function call.    */   static int low_get_return_type(struct pike_type *a, struct pike_type *b)   {    struct compilation *c = THIS_COMPILATION;    struct pike_type *t;    int tmp;    CHECK_COMPILER(); -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case T_OR:    {    struct pike_type *o1, *o2;    o1=o2=0;       type_stack_mark();    if(low_get_return_type(a->car, b))    {    o1=pop_unfinished_type();
pike.git/src/pike_types.cmod:5517:    t = low_match_types(a, b, NO_SHORTCUTS);    if(t)    {    a = t;   #if 0    if ((c->lex.pragmas & ID_STRICT_TYPES) &&    !low_pike_types_le(a, b, 0, 0)) {    yyreport_type(REPORT_WARNING, NULL, 0, b, NULL, 0, a, 0, "Type mismatch");    }   #endif /* 0 */ -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case PIKE_T_TRANSITIVE:    a = a->car;    if (a->type != T_FUNCTION) {    if (a->type == T_MANY) {    a = a->cdr;    push_finished_type_with_markers(a, a_markers, 0);    free_type(t);    return 1;    }
pike.git/src/pike_types.cmod:6282:    struct pike_type *index_type,    node *n)   {    return low_check_indexing(type, index_type, n);   }      static int low_count_arguments(struct pike_type *q)   {    int num=0, num2;    -  switch(q->type & 0xff) +  switch(q->type & PIKE_T_MASK)    {    case T_OR:    num = low_count_arguments(q->car);    num2 = low_count_arguments(q->cdr);    if(num<0 && num2>0) return num;    if(num2<0 && num>0) return num2;    if(num2<0 && num<0) return ~num>~num2?num:num2;    return num>num2?num:num2;       case T_AND:
pike.git/src/pike_types.cmod:6457:      /* Get the type for the specified argument in a function type.    * Argument number -1 is the return type.    * True arguments are counted from zero.    */   struct pike_type *get_argument_type(struct pike_type *fun, int arg_no)   {    struct pike_type *tmp, *tmp2;       loop: -  switch(fun->type & 0xff) { +  switch(fun->type & PIKE_T_MASK) {    case T_OR:    fun = or_pike_types(tmp = get_argument_type(fun->car, arg_no),    tmp2 = get_argument_type(fun->cdr, arg_no),    1);    free_type(tmp);    free_type(tmp2);    return fun;       case PIKE_T_OPERATOR:    tmp = apply_type_operator(fun->type, fun->car, fun->cdr);
pike.git/src/pike_types.cmod:6762:    } else if (orig_type->type == T_OBJECT) {    if ((tmp = low_object_lfun_type(orig_type, LFUN_CALL))) {    orig_type = tmp;    tmp = NULL;    } else {    /* FIXME: Multiple cases. */    copy_pike_type(res, orig_type);    break;    }    } -  if ((orig_type->type & 0xff) == PIKE_T_OPERATOR) { +  if ((orig_type->type & PIKE_T_MASK) == PIKE_T_OPERATOR) {    /* Assume ok. */    copy_pike_type(res, orig_type);    break;    }    /* FIXME: Loop above until function? */    if ((orig_type->type != T_FUNCTION) &&    (orig_type->type != T_MANY)) {    /* Failure. */    break;    }
pike.git/src/pike_types.cmod:7420:    }   #endif /* PIKE_DEBUG */       loop:    /* Count the number of array levels. */    while(fun_type->type == PIKE_T_ARRAY) {    array_cnt++;    fun_type = fun_type->cdr;    }    -  switch(fun_type->type & 0xff) { +  switch(fun_type->type & PIKE_T_MASK) {    case T_SCOPE:    /* FIXME: Save and restore the corresponding marker set. */    case T_ASSIGN:    case PIKE_T_NAME:    fun_type = fun_type->cdr;    goto loop;       case PIKE_T_ATTRIBUTE:    res = lower_new_check_call(fun_type->cdr, arg_type, flags, sval CHECK_CALL_ARGS);    if (!res) return NULL;
pike.git/src/pike_types.cmod:8001:    }   #endif /* PIKE_DEBUG */       loop:    /* Count the number of array levels. */    while(fun_type->type == PIKE_T_ARRAY) {    array_cnt++;    fun_type = fun_type->cdr;    }    -  switch(fun_type->type & 0xff) { +  switch(fun_type->type & PIKE_T_MASK) {    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    fun_type = fun_type->cdr;    goto loop;       case PIKE_T_ATTRIBUTE:    tmp = new_get_return_type(fun_type->cdr, flags);    if (!tmp) break;    if (c) {
pike.git/src/pike_types.cmod:8322:    }      #ifdef PIKE_DEBUG    if (l_flag > 2) {    fprintf(stderr, "get_first_arg_type(");    simple_describe_type(fun_type);    fprintf(stderr, ", 0x%04x)\n", flags);    }   #endif    -  switch(fun_type->type & 0xff) { +  switch(fun_type->type & PIKE_T_MASK) {    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    case PIKE_T_ATTRIBUTE:    case PIKE_T_RING:    fun_type = fun_type->cdr;    goto loop;       case PIKE_T_OPERATOR:    tmp = apply_type_operator(fun_type->type, fun_type->car, fun_type->cdr);
pike.git/src/pike_types.cmod:8784:    } while(args);    }       return fun_type;   }      struct pike_type *zzap_function_return(struct pike_type *a,    struct pike_type *fun_ret)   {    struct pike_type *ret = NULL; -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case T_SCOPE:    ret = zzap_function_return(a->cdr, fun_ret);    if (!ret) return NULL;    type_stack_mark();    push_finished_type(ret);    free_type(ret);    push_scope_type(CAR_TO_INT(a));    return pop_unfinished_type();   
pike.git/src/pike_types.cmod:9629:    return pop_unfinished_type();   }      int pike_type_allow_premature_toss(struct pike_type *type)   {    again:   #if 0    fprintf(stderr, "pike_type_allow_premature_toss(): Type: %d\n",    type->type);   #endif /* 0 */ -  switch(type->type & 0xff) +  switch(type->type & PIKE_T_MASK)    {    default:   #ifdef PIKE_DEBUG    Pike_fatal("pike_type_allow_premature_toss: Unknown type (code: %d)\n",    type->type);    UNREACHABLE(return 0);   #endif    case T_NOT:    return !pike_type_allow_premature_toss(type->car);   
pike.git/src/pike_types.cmod:10051:      PMOD_EXPORT void *find_type(struct pike_type *t,    void *(*cb)(struct pike_type *))   {    void *res;    if (!t) return NULL;       res = cb(t);    if (res) return res;    -  switch(t->type & 0xff) { +  switch(t->type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case PIKE_T_TRANSITIVE:    res = find_type(t->car, cb);    if (res) return res;
pike.git/src/pike_types.cmod:10130:    break;   #endif    case VISIT_COMPLEX_ONLY:    visit_leave(t, PIKE_T_TYPE, extra);    return;    case VISIT_COUNT_BYTES:    mc_counted_bytes += sizeof (struct pike_type);    break;    }    -  switch (t->type & 0xff) { +  switch (t->type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case T_ARRAY:    case T_STRING:    case PIKE_T_TRANSITIVE:
pike.git/src/pike_types.cmod:10207:      /* This is only enough gc stuff to detect leaking pike_type structs    * and to locate references to them. More is needed if types are    * extended to contain pointers to other memory objects or if they    * might contain cycles. */      void gc_mark_type_as_referenced(struct pike_type *t)   {    if (gc_mark(t, PIKE_T_TYPE)) {    GC_ENTER(t, PIKE_T_TYPE) { -  switch(t->type & 0xff) { +  switch(t->type & PIKE_T_MASK) {    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    case PIKE_T_ATTRIBUTE:    if (t->cdr) gc_mark_type_as_referenced(t->cdr);    break;    case PIKE_T_FUNCTION:    case T_MANY:    case PIKE_T_RING:    case PIKE_T_TUPLE:
pike.git/src/pike_types.cmod:10309:    }   #endif   }   #endif      void gc_check_type (struct pike_type *t)   {    debug_malloc_touch (t);       GC_ENTER (t, T_TYPE) { -  switch (t->type & 0xff) { +  switch (t->type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:    case T_MAPPING:    case T_OR:    case T_AND:    case PIKE_T_RING:    case T_ARRAY:    case T_STRING:    case PIKE_T_TRANSITIVE: