Allow to overwrite the Constant Pool#137
Conversation
|
🤔 |
|
@chitoku-k |
| ->enableWrite(true) | ||
| ->setString((string) $this->object) | ||
| ->setStringObject($this) | ||
| ->enableWrite(false); |
There was a problem hiding this comment.
Why does this set $this->object to a different instance (the one from the constant pool)?
There was a problem hiding this comment.
@chitoku-k
Because $this->object may be a string (on PHP type) or an other object.
$this->object allows being a dynamic generated object, not just a reference to the Constant Pool.
For the above reasons, if the code substitutes a value to $this->object, the $this->object ensures the Constant Pool entry string data. (In this case, it ensures a _Utf8 structure.)
Herewith, if operand stack is stacking _String object, but operations can be proceeded correctly.
There was a problem hiding this comment.
Thanks for your answer but it still does not seem to answer my question, in other words, why does it need to set it?
There was a problem hiding this comment.
Finally, it turned out that $this->object must be equal to the instance already existing in the constant pool because any later comparison might not be guaranteed to treat them equal (such as if_a operation). Although it somewhat looks like String#intern() is affected by the internal object in the constant pool, this implementation is actually derived from the restriction of the way _Utf8 and _String relate to each other.
|
Okay, I merge this PR. |
No description provided.