Subj : Re: Using Rhino to report on JS variable/function scoping To : netscape.public.mozilla.jseng From : mark@umii.co.uk (Mark__e) Date : Wed Sep 03 2003 03:55 am Brendan Eich wrote in message news:... > Mark__e wrote: > What about variables or functions created using eval? Is it ok if those > are not included? They really need to be included as this is a likely scenario, the information I will be checking is a precursor for the application being approved for use in a portal environment. Part of the pre-processing of the http response that the portal makes to the portlet involves changes to the original javascript returned with regard to location.href window.open etc. (it just uses basic regex for this by the look of it) Some developers do not want this behaviour and will use eval to split the script up so the regex can't match it (horrible I know, but it's what I have to work with). > In SpiderMonkey, you could parse the source and walk the parse tree > yourself, using a "friend" API (subject to change, not frozen but not > likely to change in a huge way; no binary compatibility). I was really trying to keep it all Java, but I will have a look at this as well. > Or you could > compile to a script and then execute the script's prolog bytecodes, > which process var, const, and function declarations. > Thanks I will look at that, although I suspect I will run into too many problems actually getting the script to compile given the way most people write client side javascript + I assume I would have to simulate the dom objects etc. as well which woul dnot be trivial. I really wanted to catch it before the compilation stage if that was possible, but I could well be misunderstanding exactly the process it goes through, I have not worked with compilers before. The process does not have to be 100% bomb proof, there will be human review as well, what I want to do is handle as much as I can automatically to alleviate everything having to be reviewed by hand, just the exceptions. .