pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:6706:
{ struct pike_frame *fp = Pike_fp; struct program *prog = fp->context->prog; struct reference *funp = PTR_FROM_INT(fp->current_program, fp->fun); struct identifier *id = ID_FROM_PTR(fp->current_program, funp); struct pike_string *name = id->name; int fun_num = prog->num_identifier_references; int flags = 0; int best = -1; struct pike_type *t;
-
struct
pike_type *
expected =
NULL
;
+
int
expected =
0
;
/* NB: The following is mostly to support a potential future * case where a mixed set of protections would cause * multiple dispatchers with the same name to be added * (but different protection (and types)). */ if (funp->id_flags & ID_PRIVATE) { flags = SEE_PRIVATE|SEE_PROTECTED; } else if (funp->id_flags & ID_PROTECTED) { flags = SEE_PROTECTED;
pike.git/src/program.c:6729:
while ((fun_num = really_low_find_variant_identifier(name, prog, NULL, fun_num, flags)) != -1) { int i; struct pike_type *ret; id = ID_FROM_INT(prog, fun_num); add_ref(t = id->type); /* Check whether the type is compatible with our arguments. */ for (i = 0; i < args; i++) {
-
struct pike_type *cont = check_call_svalue(t, 0, Pike_sp+i - args);
-
if (!cont && (i > best)) {
-
if (expected)
free
_
type
(expected);
+
struct pike_type *cont =
+
check_call_svalue(t, 0, Pike_sp+i -
(
args
+ expected
)
)
;
+
if (!cont && (i >
=
best)) {
+
if (
(i > best) &&
expected)
{
+
pop
_
n_elems
(expected);
+
expected = 0;
+
}
best = i;
-
expected
=
t
;
+
push_type_value(t);
+
expected++
;
t = NULL; break; } else { free_type(t); } if (!(t = cont)) break; } if (!t) continue; ret = new_get_return_type(t, 0);
-
if (!ret && (i+1 > best)) {
-
if (expected)
free
_
type
(expected);
+
+
if (!ret && (i+1 >
=
best)) {
+
if (
((i+1) > best) &&
expected)
{
+
pop
_
n_elems
(expected);
+
expected = 0;
+
}
best = i+1;
-
expected
=
t
;
+
push_type_value(t);
+
expected++
;
continue; } free_type(t); if (!ret) continue; free_type(ret);
-
if (expected)
free
_
type
(expected);
+
if (expected)
{
+
pop
_
n_elems
(expected);
+
}
/* Found a function to call! */ apply_current(fun_num, args); return; } if (!expected) { /* No variants listed? */ Pike_error("No variants of %S() to dispatch to!\n", name); }
-
t
= get_first_arg_type
(expected
,
0
)
;
-
free
_
type
(expected);
-
if
(
t
)
{
-
push
_
type
_
value
(
t
)
;
+
if
(expected
> 1
)
{
+
f
_
or
(expected);
+
}
+
f___get_first_arg_type
(
1
)
;
+
if
(!UNSAFE
_
IS
_
ZERO
(
Pike_sp-1
)
) {
if (best < args) { Pike_error("Bad argument %d to %S(). Expected %O.\n", best + 1, name, Pike_sp-1); } else { Pike_error("Too few arguments to %S(). Expected %O.\n", name, Pike_sp-1); } } else { Pike_error("Too many arguments to %S().\n", name); }