Subj : Re: Rhino: Obtaining a list of script functions To : netscape.public.mozilla.jseng From : Attila Szegedi Date : Fri Oct 15 2004 09:06 pm Actually, I have since found a way to enumerate DebuggableScript objects through Debugger.handleCompilationDone() (I'm talking about 1.6 codebase here). My problem is that the object behind the DebuggableScript is not the InterpretedFunction object, but rather its InterpretedData. I have a script execution engine that serializes lots of script execution contexts when they are inactive for a period of time - this is used in conjunction with continuation support in 1.6 - then later loads them and continues execution. The ability to stub the InterpretedFunction instances in serialization would allow me to eliminate redundancy at runtime - if I have 2000 deserialized states executing the same script, each InterpetedFunction is deserialized and duplicated in memory 2000 times. Now granted, stubbing InterpetedData (which is the only thing I can enumerate through debugger.handleCompilationDone()) does help eliminate some of the redundancy - all the deserialized states can use single instance/function, but if I could enumerate (and therfore stub) InterpretedFunction instances, that'd be the real deal. TIA for any help. Attila. On Fri, 15 Oct 2004 19:13:30 +0200, Attila Szegedi wrote: > Hi folks, > > is there a way to obtain a list of all functions that a particular > script declares via the "function" keyword? > > Right now, I can execute the script into an empty NativeObject as a > scope and then get the property ids and pick those that implement > InterpretedFunction, however the approach has two drawbacks: > > - if there's a top level statement in the script other than a function > declaration, it will likely throw an org.mozilla.javascript.EcmaError: > ReferenceError: "" is not defined. Actually, I might > circumvent this with a clever Scriptable implementation as the scope... > > - the approach only returns top-level functions. > > Ideally, I want to have a map of functions to strings (in case of > embedded functions some nice hierarchical naming) and vice versa so I > can replace as many functions as possible in serialization with stubs. > > Any idea appreciated. > > Cheers, > Attila. > _______________________________________________ > mozilla-jseng mailing list > mozilla-jseng@mozilla.org > http://mail.mozilla.org/listinfo/mozilla-jseng > -- home: http://www.szegedi.org Visit Szegedi Butterfly fractals at: http://www.szegedi.org/fractals/butterfly/index.html .