Branch: Tag:

2020-01-02

2020-01-02 13:38:20 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Added push_unlimited_array_type().

This is in preparation for adding support for
length-limited array types.

729:    TYPE_STACK_DEBUG("push_int_type");   }    + /** +  * Used with arrays and strings. +  * +  * On entry the type stack contains the value type. +  * +  * Generates an array or string type with no length limits. +  */ + void debug_push_unlimited_array_type(enum PIKE_TYPE t) + { +  struct compilation * c = MAYBE_THIS_COMPILATION; + #ifdef PIKE_DEBUG +  if ((t != PIKE_T_ARRAY) && (t != PIKE_T_STRING)) { +  Pike_fatal("Invalid type for push_array_type(): %s (%d)\n", +  get_name_of_type(t), t); +  } + #endif +  /* FIXME: Set car to unlimited length. */ +  push_type(t); + } +    static int (*program_id_to_id)(int) = NULL;      PMOD_EXPORT void set_program_id_to_id( int (*to)(int) )
1301:    if (field & BIT_COMPLEX) {    if (field & BIT_ARRAY) {    push_type(T_MIXED); -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    push_type(T_OR);    }    if (field & BIT_MAPPING) {
1336:    if (field & BIT_BASIC) {    if (field & BIT_STRING) {    push_int_type(MIN_INT32, MAX_INT32); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    push_type(T_OR);    }    if (field & BIT_TYPE) {
1638:    } else {    push_finished_type(int_type_string);    } -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    break;    }    goto bad_type;
1732:    }else{    push_type(T_MIXED);    } -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    break;    }    goto bad_type;
1850:    {    ++*s;    while(isspace(EXTRACT_UCHAR(*s))) ++*s; -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    }   }   
2753:    case T_STRING:    {    low_or_pike_types(t1->cdr, t2->cdr, 1); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    return 0;    }    break;
2928:    {    Pike_compiler->type_stackp--;    low_or_pike_types(t->cdr, top->cdr, 1); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    free_type(top);    }    break;
2940:    case T_ARRAY:    Pike_compiler->type_stackp--;    low_or_pike_types(t->cdr, top->cdr, zero_implied); -  push_type(t->type); +  push_unlimited_array_type(t->type);    free_type(top);    break;    case T_MULTISET:
3120:    } else if (t1->type == T_STRING) {    push_type(T_ZERO);    even_lower_and_pike_types(t1->cdr, t2->cdr); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    push_type(T_OR);    } else {    push_finished_type(t1);
3249:    }    else if ((t1->type == T_STRING) && (t2->type == T_STRING)) {    low_and_pike_types(t1->cdr, t2->cdr); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    }    else if((t1->type == T_FLOAT) && (t2->type == T_FLOAT))    {
4110:    type_stack_mark();    push_finished_type_with_markers(b, bb_markers, 0);    for(i=array_cnt; i > 0; i--) -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    tmp=pop_unfinished_type();       type_stack_mark();
4273:    type_stack_mark();    push_finished_type_with_markers(a, aa_markers, 0);    for(i = array_cnt; i < 0; i++) -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    tmp=pop_unfinished_type();       type_stack_mark();
4785:    case T_ARRAY:    tmp = low_get_return_type(a->cdr, b);    if(!tmp) return 0; -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    return 1;    }   
5013:    type_stack_mark();    push_finished_type(a);    free_type(a); -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);       if (low_match_types(int_type_string, index_type, 0)) {    /* Also possible to index the array with an int. */
5715:    if (arg_no < 0) {    type_stack_mark();    push_finished_type(fun = get_argument_type(fun->cdr, arg_no)); -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    free_type(fun);    return pop_unfinished_type();    }
6030:    push_finished_type(tmp2);    free_type(tmp2);    tmp2 = NULL; -  while(array_cnt--) push_type(T_ARRAY); +  while(array_cnt--) push_unlimited_array_type(T_ARRAY);    push_reverse_type(T_MANY);    while(loop_cnt--) push_reverse_type(T_FUNCTION);    res = pop_unfinished_type();
6084:    } else {    push_finished_type(zero_type_string);    } -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    res = pop_unfinished_type();    break;    case T_STRING:
6093:    type_stack_mark();    push_finished_type(res);    free_type(res); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    res = pop_unfinished_type();    break;    case T_INT:
6544:    push_finished_type(res);    free_type(res);    while(array_cnt--) { -  push_type(PIKE_T_ARRAY); +  push_unlimited_array_type(PIKE_T_ARRAY);    }    res = pop_type();   
6918:    push_finished_type(res);    free_type(res);    while(array_cnt--) { -  push_type(PIKE_T_ARRAY); +  push_unlimited_array_type(PIKE_T_ARRAY);    }    res = pop_unfinished_type();   
7287:    free_type(res);       while(array_cnt--) { -  push_type(PIKE_T_ARRAY); +  push_unlimited_array_type(PIKE_T_ARRAY);    }      #ifdef PIKE_DEBUG
7377:    type_stack_mark();    push_finished_type(tmp);    free_type(tmp); -  push_type(arg_type->type); +  push_unlimited_array_type(arg_type->type);    return pop_unfinished_type();       case T_MAPPING:
8021:    }else    push_finished_type(zero_type_string);   #endif /* 0 */ -  push_type(T_ARRAY); +  push_unlimited_array_type(T_ARRAY);    return pop_unfinished_type();    }   
8148:    } else {    push_type(T_ZERO);    } -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    return pop_unfinished_type();       default:
8411:    case T_FUNCTION:    low_make_function_type(type_string+1, cont);    break; -  case T_ARRAY: +     case T_MULTISET:    case T_TYPE:    case T_NOT:
8444:    case T_STRING:    *cont = type_string + 1;    push_finished_type(int_type_string); -  push_type(T_STRING); +  push_unlimited_array_type(T_STRING);    break;       case PIKE_T_NSTRING: -  +  type = T_STRING; +  /* FALLTHRU */ +  case T_ARRAY:    low_make_pike_type(type_string + 1, cont); -  /* FIXME: Add check for valid subtype. */ -  push_type(T_STRING); +  /* FIXME: Add check for valid subtype in the string case. */ +  push_unlimited_array_type(type);    break;       case T_INT: