Branch: Tag:

2015-05-15

2015-05-15 08:24:10 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Don't reference inherited prototypes.

Having local references to inherited prototype functions is not
useful, as they can never become anything else than a prototype.

It also confuses code that uses mixins and attempts to use the
anonymous inherit specifier to access the base implementation
in one inherited class when there's a corresponding prototype
in another inherited class, in which case both functions were
returned. This typically caused "Calling undefined function.".

As a bonus this also improves code generation somewhat.

4520:    *    * @return    * Returns an equivalent reference that is INLINE|HIDDEN. +  * +  * Returns -1 if the referenced identifier is -1 or a prototype.    */   PMOD_EXPORT int really_low_reference_inherited_identifier(struct program_state *q,    int i,
4534:       p = np->inherits[i].prog;    +  if ((q?q:Pike_compiler)->compiler_pass == 2) { +  struct identifier *id = ID_FROM_INT(p, i); +  if (((id->identifier_flags & IDENTIFIER_TYPE_MASK) == +  IDENTIFIER_PIKE_FUNCTION) && (id->func.offset == -1)) { +  /* Prototype. */ +  return -1; +  } +  } +     funp = p->identifier_references[f];    funp.inherit_offset += i;    funp.id_flags = (funp.id_flags & ~ID_INHERITED) | ID_INLINE|ID_HIDDEN;