pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:10395:    INT32 i;    if(n->token == F_ARROW)    {    if((i=FIND_LFUN(p,LFUN_ARROW))!=-1)    {    struct pike_type *ret = NULL;    struct call_state cs;       INIT_CALL_STATE(cs, lfun_strings[LFUN_ARROW]);    add_ref(tmp = ID_FROM_INT(p, i)->type); -  tmp = new_check_call(lfun_strings[LFUN_ARROW], tmp, CDR(n), &cs, 0); +  tmp = new_check_call(tmp, CDR(n), &cs, 0);    if (tmp) {    ret = new_get_return_type(tmp, &cs, 0);    free_type(tmp);    }    FREE_CALL_STATE(cs);       if (ret) return ret;       /* Invalid type for lfun::`->(). */    add_ref(mixed_type_string);    return mixed_type_string;    }    }else{    if((i=FIND_LFUN(p,LFUN_INDEX)) != -1)    {    struct pike_type *ret = NULL;    struct call_state cs;       INIT_CALL_STATE(cs, lfun_strings[LFUN_INDEX]);    add_ref(tmp = ID_FROM_INT(p, i)->type); -  tmp = new_check_call(lfun_strings[LFUN_INDEX], tmp, CDR(n), &cs, 0); +  tmp = new_check_call(tmp, CDR(n), &cs, 0);    if (tmp) {    ret = new_get_return_type(tmp, &cs, 0);    free_type(tmp);    }    FREE_CALL_STATE(cs);       if (ret) return ret;    /* Invalid type for lfun::`[](). */    add_ref(mixed_type_string);    return mixed_type_string;
pike.git/src/pike_types.cmod:13058:    fprintf(stderr, ", 0x%04x) ==> ", flags);    simple_describe_type(res);    fprintf(stderr, "\n");    }   #endif       return res;   }      /* NOTE: fun_type loses a reference. */ - struct pike_type *check_splice_call(struct pike_string *fun_name, -  struct pike_type *fun_type, + struct pike_type *check_splice_call(struct pike_type *fun_type,    struct call_state *cs,    struct pike_type *args_type,    struct svalue *sval,    INT32 flags)   {    struct compilation *c = THIS_COMPILATION;    struct pike_type *res = NULL;    struct pike_type *arg_type = index_type(args_type, int_type_string, NULL);    struct pike_type *ind_type = key_type(args_type, NULL);    INT_TYPE ind_range[2] = { 256, 0 };
pike.git/src/pike_types.cmod:13090:    /* Mixed or similar range. */    min_cnt = 0;    max_cnt = 256;    }    if (min_cnt < 0) min_cnt = 0;    if (max_cnt > 256) max_cnt = 256;    }      #ifdef PIKE_DEBUG    if (l_flag>4) { -  fprintf(stderr, "check_splice_call(\"%s\", ", fun_name->str); +  fprintf(stderr, "check_splice_call(\"%s\", ", cs->fun_name->str);    simple_describe_type(fun_type);    fprintf(stderr, ",\n %d, ", cs->argno);    simple_describe_type(args_type);    fprintf(stderr, ",\n %p, 0x%04x)", sval, flags);    fprintf(stderr, "\n range: [%d..%d] ", min_cnt, max_cnt);    simple_describe_type(ind_type);    }   #endif /* PIKE_DEBUG */       /* Loop until we get a stable fun_type, or it's an invalid argument. */
pike.git/src/pike_types.cmod:13147:    }    }       if (fun_type || (cnt >= max_cnt)) {    /* Max args reached or stable type. */    free_type(fun_type);    } else if (!(flags & CALL_INHIBIT_WARNINGS)) {    /* The splice values are invalid for later arguments. */    if (!cnt && max_cnt) {    yywarning("In argument %d to %S: The @-operator argument must be an empty array.", -  cs->argno, fun_name); +  cs->argno, cs->fun_name);    } else if (c->lex.pragmas & ID_STRICT_TYPES) {    yywarning("In argument %d to %S: The @-operator argument has a max length of %d.", -  cs->argno, fun_name, cnt); +  cs->argno, cs->fun_name, cnt);    }    }       free_type(ind_type);    free_type(arg_type);      #ifdef PIKE_DEBUG    if (l_flag>4) {    fprintf(stderr, "\ncheck_splice_call(...) ==> ");    simple_describe_type(res);    fprintf(stderr, "\n");    }   #endif /* PIKE_DEBUG */       return res;   }      /* NOTE: fun_type loses a reference. */ - static struct pike_type *new_check_call_arg(struct pike_string *fun_name, -  struct pike_type *fun_type, + static struct pike_type *new_check_call_arg(struct pike_type *fun_type,    node *args, struct call_state *cs,    INT32 flags)   {    struct compilation *c = THIS_COMPILATION;    struct pike_type *tmp = NULL;    struct pike_type *res = NULL;    struct svalue *sval = NULL;       CHECK_COMPILER();   
pike.git/src/pike_types.cmod:13214:    }   #endif /* PIKE_DEBUG */       if (args->token == F_PUSH_ARRAY) {   #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "\n The argument is a splice operator.\n");    }   #endif /* PIKE_DEBUG */    -  res = check_splice_call(fun_name, fun_type, cs, args->type, sval, flags); +  res = check_splice_call(fun_type, cs, args->type, sval, flags);      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "\n result: ");    simple_describe_type(res);    fprintf(stderr, " OK.\n");    }   #endif /* PIKE_DEBUG */       return res;
pike.git/src/pike_types.cmod:13243:    fprintf(stderr, " OK.\n");    }   #endif /* PIKE_DEBUG */    if (c->lex.pragmas & ID_STRICT_TYPES) {    if (!(tmp = low_new_check_call(fun_type, args->type,    flags|CALL_STRICT, cs, sval))) {    tmp = get_first_arg_type(fun_type, flags);    yytype_report(REPORT_WARNING, NULL, 0, tmp,    NULL, 0, args->type,    0, "Type mismatch in argument %d to %S.", -  cs->argno, fun_name); +  cs->argno, cs->fun_name);    if (tmp) free_type(tmp);    } else {    free_type(tmp);    }    }    free_type(fun_type);       return res;    }    }
pike.git/src/pike_types.cmod:13265:    if ((tmp = get_first_arg_type(fun_type, flags|CALL_NOT_LAST_ARG)) &&    (tmp != void_type_string)) {    struct pike_type *tmp2;      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, " Bad argument.\n");    }   #endif /* PIKE_DEBUG */    yytype_report(REPORT_ERROR, NULL, 0, tmp, NULL, 0, args->type, -  0, "Bad argument %d to %S.", cs->argno, fun_name); +  0, "Bad argument %d to %S.", cs->argno, cs->fun_name);       /* Try advancing with the suggested type, so that we can check    * the rest of the arguments.    */    if ((tmp2 = low_new_check_call(fun_type, tmp, flags, cs, NULL))) {    /* Succeeded. */    free_type(fun_type);    free_type(tmp);   #ifdef PIKE_DEBUG    if (l_flag>2) {
pike.git/src/pike_types.cmod:13301:    free_type(tmp);      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, " Too many arguments.\n");    }   #endif /* PIKE_DEBUG */    yytype_report(REPORT_ERROR, NULL, 0, NULL,    NULL, 0, args->type,    0, "Too many arguments to %S (expected %d arguments).", -  fun_name, cs->argno - 1); +  cs->fun_name, cs->argno - 1);    }    free_type(fun_type);       return NULL;   }      /* NOTE: fun_type loses a reference. */ - struct pike_type *new_check_call(struct pike_string *fun_name, -  struct pike_type *fun_type, + struct pike_type *new_check_call(struct pike_type *fun_type,    node *args, struct call_state *cs,    INT32 flags)   {    node *orig_args = args;    node *orig_arg_parent = NULL;    int num_cdr = 0;       if (!args || !fun_type) {    debug_malloc_touch(fun_type);    return fun_type;
pike.git/src/pike_types.cmod:13356:    continue;    } else if (CDR(args)) {    CDR(args)->parent = args;    args = CDR(args);    if (!--num_cdr) {    flags &= ~CALL_NOT_LAST_ARG;    }    continue;    }    } else { -  fun_type = new_check_call_arg(fun_name, fun_type, args, cs, flags); +  fun_type = new_check_call_arg(fun_type, args, cs, flags);    debug_malloc_touch(fun_type);    }       while (args && fun_type) {    node *prev = args;    args = args->parent;    if (!args) {    break;    }    if ((CAR(args) == prev) && CDR(args)) {
pike.git/src/pike_types.cmod:13381:    CDR(args)->parent = args;    args = CDR(args);    break;    }    /* CAR(args) == CDR(args), so we need to recurse    * since we can't differentiate otherwise.    *    * This should be a quite rare case, and the tree is    * most likely very shallow, so this should be safe.    */ -  fun_type = new_check_call(fun_name, fun_type, prev, cs, flags); +  fun_type = new_check_call(fun_type, prev, cs, flags);    debug_malloc_touch(fun_type);    }    }    }       orig_args->parent = orig_arg_parent;       return fun_type;   }