pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:1475:    code_number(id->func.const_info.offset, data);       /* run-time type */    code_number(id->run_time_type, data);       /* opt flags */    code_number(id->opt_flags, data);    break;       case IDENTIFIER_PIKE_FUNCTION: +  encode_pike_function:    EDB(3,    fprintf(stderr, "%*sencode: encoding function\n",    data->depth, ""));       code_number(ID_ENTRY_FUNCTION, data);    if (gs_flags >= 0) {    code_number(gs_flags, data);    } else {    code_number(ref->id_flags, data);    }
pike.git/src/encode.c:1526:   #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. */ +  int k; +  int j; +  struct identifier *other = NULL; +  /* This is handled by end_first_pass() et al. */    /* NB: This can be reached even though id_dumped    * for it gets set by the variant functions,    * if it is overriding an old definition.    *    * Note that this means that even the first local    * function must have the variant modifier (since    * otherwise it would have overridden the old def    * and not the dispatcher). This is handled    * automatically by the use of id_dumped for the    * dispatcher as marker for whether the first    * variant has been added or not.    */ -  continue; +  EDB(3, +  fprintf(stderr, "%*sencode: encoding variant dispatcher\n", +  data->depth, "")); +  +  for(k = 0; k < p->num_identifiers; k++) { +  other = p->identifiers + k; +  if (other->name == id->name) break;    } -  +  if (other >= id) { +  /* variant before termination function. */ +  break; +  } +  if ((other->identifier_flags & IDENTIFIER_TYPE_MASK) == +  IDENTIFIER_PIKE_FUNCTION) { +  struct reference *r = NULL; +  for (j = 0; j < p->num_identifier_references; j++) { +  r = p->identifier_references + j; +  if (!r->inherit_offset && (r->identifier_offset == k)) { +  /* Found the override. */ +  break; +  } +  } +  if ((j != p->num_identifier_references) && (j > d)) { +  /* We have a termination function at identifier k, +  * that was overridden by the variant dispatcher. +  * +  * We need to encode it here at its original place. +  */ +  id_dumped[k] = 1; +  gs_flags = r->id_flags & ref->id_flags; +  id = other; +  ref = r; +  goto encode_pike_function; +  } +  } +  }    /* 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",
pike.git/src/encode.c:3654:    id_flags, func_flags,    &func, opt_flags);    if ((no < 0 || no >= p->num_identifier_references) ||    (no != n &&    (p->identifier_references[no].id_flags != id_flags ||    p->identifier_references[no].identifier_offset !=    p->identifier_references[n].identifier_offset ||    p->identifier_references[no].inherit_offset != 0))) {    ref_push_program (p);    decode_error(data, Pike_sp - 1, -  "Bad function identifier offset: %d\n", no); +  "Bad function identifier offset for %S:%T: %d != %d\n", +  Pike_sp[-3].u.string, Pike_sp[-2].u.type, n, no);    }       pop_n_elems(2);    }    break;    case ID_ENTRY_CONSTANT:    {    struct identifier id;    struct reference ref;    int no;