Branch: Tag:

2020-09-16

2020-09-16 14:02:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Use PIKE_T_MASK.

175:      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";
343:    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:
449:   #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
527:    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:
641:    }      #ifdef DEBUG_MALLOC -  switch(type & 0xff) { +  switch(type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:
894:   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
911:    }       /* 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:
992:   {    /* 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. */
1025:   {    /* 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. */
1156:    /* 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:
1257:   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:
1407:    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;
2208:   {    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');
2827:       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);
2920:    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;
3930:    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);
4070:    }    }    -  switch(b->type & 0xff) +  switch(b->type & PIKE_T_MASK)    {    case T_AND:    ret = low_match_types(a, b->car, flags);
4611:    }   #endif    -  switch(b->type & 0xff) +  switch(b->type & PIKE_T_MASK)    {    case T_AND:    /* OK, if a is a subset of both parts. */
4796:    }   #endif    -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case T_AND:    /* OK if either of the parts is a subset. */
5449:    struct pike_type *t;    int tmp;    CHECK_COMPILER(); -  switch(a->type & 0xff) +  switch(a->type & PIKE_T_MASK)    {    case T_OR:    {
5524:    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;
6289:   {    int num=0, num2;    -  switch(q->type & 0xff) +  switch(q->type & PIKE_T_MASK)    {    case T_OR:    num = low_count_arguments(q->car);
6464:    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),
6769:    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;
7427:    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:
8008:    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:
8329:    }   #endif    -  switch(fun_type->type & 0xff) { +  switch(fun_type->type & PIKE_T_MASK) {    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:
8791:    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);
9636:    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
10058:    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:
10137:    break;    }    -  switch (t->type & 0xff) { +  switch (t->type & PIKE_T_MASK) {    case T_FUNCTION:    case T_MANY:    case T_TUPLE:
10214:   {    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:
10316:    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: