pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:1075:    /* We have to remove ourselves from the cache for now */    struct svalue tmp = entry_id;    map_delete(data->encoded, val);       code_entry(TAG_PROGRAM, 2, data);    ref_push_program(p->parent);    encode_value2(Pike_sp-1, data, 0);       ref_push_program(p);    f_function_name(1); + #if 0    if(TYPEOF(Pike_sp[-1]) == PIKE_T_INT)    Pike_error("Cannot encode C programs.\n"); -  + #endif    encode_value2(Pike_sp-1, data, 0);       pop_n_elems(2);       /* Put value back in cache */    mapping_insert(data->encoded, val, &tmp);    goto encode_done;    }    if( p->event_handler )    Pike_error("Cannot encode programs with event handlers.\n"); -  + #if 0    Pike_error("Cannot encode C programs.\n"); -  + #endif    }      #ifdef OLD_PIKE_ENCODE_PROGRAM       EDB(1,    fprintf(stderr, "%*sencode: encoding program in old style\n",    data->depth, ""));       /* Type 1 -- Old-style encoding. */   
pike.git/src/encode.c:1407:    EDB (4, fprintf (stderr, "%*sencode: inherit_num: %d, d_max: %d\n",    data->depth, "", inherit_num, d_max););       /* Fix locally defined identifiers. */    for (; d < d_max; d++) {    struct reference *ref = p->identifier_references + d;    struct inherit *inh = INHERIT_FROM_PTR(p, ref);    struct identifier *id = ID_FROM_PTR(p, ref);       /* Skip identifiers that haven't been overloaded. */ -  if (ref->id_flags & ID_INHERITED) continue; +  if (ref->id_flags & ID_INHERITED) { +  if ((ref->id_flags & (ID_VARIANT|ID_HIDDEN)) == ID_VARIANT) { +  /* Find the dispatcher. */ +  int i = really_low_find_shared_string_identifier(id->name, p, +  SEE_PROTECTED|SEE_PRIVATE); +  /* NB: We use the id_dumped flag for the +  * dispatcher to mark whether we have +  * dumped the first variant of this +  * name in this program. +  */ +  if ((i >= 0) && !is_variant_dispatcher(p, i) && +  !PTR_FROM_INT(p, i)->inherit_offset) { +  /* Overloaded in this program. +  * +  * Make sure later variants don't clear this one. +  */ +  id_dumped[PTR_FROM_INT(p, i)->identifier_offset] = 1; +  } +  } +  continue; +  }       /* Skip getter/setter variables; they get pulled in    * by their respective functions.    */    if (!IDENTIFIER_IS_ALIAS(id->identifier_flags) &&    IDENTIFIER_IS_VARIABLE(id->identifier_flags) &&    (id->run_time_type == PIKE_T_GET_SET))    continue;       EDB(3,
pike.git/src/encode.c:1522:    }    if (symbol) {    int i = really_low_find_shared_string_identifier(symbol, p,    SEE_PROTECTED|SEE_PRIVATE);    if (i >= 0) {    /* Found the symbol. */    gs_flags = PTR_FROM_INT(p, i)->id_flags;    }    free_string(symbol);    } +  } else if (ref->id_flags & ID_VARIANT) { +  /* Find the dispatcher. */ +  int i = really_low_find_shared_string_identifier(id->name, p, +  SEE_PROTECTED|SEE_PRIVATE); +  /* NB: We use the id_dumped flag for the +  * dispatcher to mark whether we have +  * dumped the first variant of this +  * name in this program. +  */ +  if ((i < 0) || !is_variant_dispatcher(p, i)) { +  Pike_error("Failed to find dispatcher for inherited " +  "variant function: %S\n", id->name);    } -  +  if (PTR_FROM_INT(p, i)->inherit_offset) { +  Pike_error("Dispatcher for variant function %S " +  "is inherited.\n", id->name); +  } +  gs_flags = ref->id_flags & PTR_FROM_INT(p, i)->id_flags; +  if (id_dumped[PTR_FROM_INT(p, i)->identifier_offset]) { +  gs_flags |= ID_VARIANT; +  } else { +  /* First variant. */ +  id_dumped[PTR_FROM_INT(p, i)->identifier_offset] = 1; +  } +  }       if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {    if ((!id->func.ext_ref.depth) &&    IDENTIFIER_IS_VARIABLE(id->identifier_flags)) {    struct identifier *other =    ID_FROM_INT(p, id->func.ext_ref.id);    if (other->name == id->name) {    /* Let define_variable() handle the decoding. */    EDB(3, fprintf(stderr,    "%*sencode: encoding aliased variable\n",
pike.git/src/encode.c:1655:    }   #else /* !PIKE_PORTABLE_BYTECODE */    code_number(id->func.offset, data);   #endif /* PIKE_PORTABLE_BYTECODE */       /* opt_flags */    code_number(id->opt_flags, data);    break;       case IDENTIFIER_C_FUNCTION: +  if (is_variant_dispatcher(p, d)) { +  /* This is handled by end_first_pass() et all. */ +  /* NB: This can be reached even though id_dumped +  * for it gets set by the variant functions, +  * if it is overriding an old definition. +  * +  * We thus need to make sure id_dumped stays cleared. +  */ +  id_dumped[ref->identifier_offset] = 0; +  continue; +  }    /* Not supported. */    Pike_error("Cannot encode functions implemented in C "    "(identifier=\"%S\").\n",    id->name);    break;       case IDENTIFIER_VARIABLE:    if (d < d_min) {    EDB(3,    fprintf(stderr, "%*sencode: Skipping overloaded variable \"%s\"\n",