pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:3819:
int id_flags; int j; if (prog->identifier_references[e].inherit_offset) continue; if (!((id_flags = prog->identifier_references[e].id_flags) & ID_VARIANT)) { /* Not a variant function. */ continue; } id = ID_FROM_INT(prog, e); name = id->name; type = id->type;
+
/* NB: The dispatcher needs the variant references to not
+
* get overloaded for the ::-operator to work.
+
*/
+
prog->identifier_references[e].id_flags |= ID_LOCAL;
CDFPRINTF((stderr, "Collecting variants of \"%s\"...\n", name->str)); /* Check whether we've added a dispatcher for this function already. */ j = isidentifier(name); if ((j >= 0) && (!prog->identifier_references[j].inherit_offset)) { /* Already handled. */ CDFPRINTF((stderr, "Dispatcher present!\n")); goto next_ref; }
pike.git/src/program.c:3843:
fprintf(stderr, "\n"); #endif /* Collect the other variants of the function. */ for (j = e+1; j < num_refs; j++) { if (prog->identifier_references[j].inherit_offset) continue; if (!(prog->identifier_references[j].id_flags & ID_VARIANT)) continue; id = ID_FROM_INT(prog, j); if (name != id->name) continue; id_flags |= prog->identifier_references[j].id_flags;
+
prog->identifier_references[j].id_flags |= ID_LOCAL;
type = or_pike_types(type, id->type, 1); #ifdef COMPILER_DEBUG fprintf(stderr, "type: "); simple_describe_type(id->type); fprintf(stderr, "\n"); #endif } /* Include the directly inherited variants as well. */ for (j = 1; j < prog->num_inherits; j++) { struct inherit *inh = &prog->inherits[j];
pike.git/src/program.c:6550:
} /** * This is the dispatcher function for variant functions. * * cf end_first_pass(). */ static void f_dispatch_variant(INT32 args) { struct pike_frame *fp = Pike_fp;
-
int fun_num = fp->fun;
+
struct program *prog = fp->context->prog;
-
struct
identifier
*
id
=
ID
_FROM_INT(
prog
, fun_
num
);
+
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;
-
while (fun_num-
-
) {
+
int fun_num = prog->num_identifier_references;
+
int flags = 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;
+
}
+
+
while (
(
fun_num
= really_low_find_variant_identifier(name, prog, NULL,
+
fun_num, flags)) !=
-
1
) {
int i; struct pike_type *t; struct pike_type *ret;
-
if (!(prog->identifier_references[fun_num].id_flags & ID_VARIANT)) {
-
continue;
-
}
+
id = ID_FROM_INT(prog, fun_num);
-
if (id->name != name) continue;
-
+
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); free_type(t); if (!(t = cont)) break; } if (!t) continue; ret = new_get_return_type(t, 0);