Strengthening Function.prototype.toString

Yuh-Ruey Chen maian330 at gmail.com
Fri Oct 10 19:52:20 PDT 2008


Hallvord R. M. Steen wrote:
> On Fri, 26 Sep 2008 19:58:27 +0200, liorean <liorean at gmail.com> wrote:
>
> > 2008/9/26 Erik Arvidsson <erik.arvidsson at gmail.com>:
> >> I know that Opera on mobile phones used to return a string
> >> representation that did not reflect the original.
> >
> > Yeah. Opera Mobile returned "[ECMAScript code]" or "[ecmascript
> > code]". This was contrary to the ES3 spec (must be parsable as a
> > function definition, IIRC) and also breaks the eval roundtripping by
> > throwing a parse error.
> > Anybody know if those issues have been fixed in more modern versions?
>
> No, not consistently across "modern versions". It's not likely to be  
> properly "fixed" for a while yet. The reason is that on many platforms  
> where memory is scarce, not enabling JS decompilation helps reduce memory  
> requirements.
>   

Do you keep the original source code of the whole script in memory, or
at least somewhere cached? If so, you could store offsets to the
function's source within memory/cache in defined functions, and get the
function source as a string on demand. It would be slow, but it would
fix compatibility, and I hardly think the speed of a relatively
little-used feature matters for mobile.


More information about the Es-discuss mailing list