Subj : Re: javascript function To : netscape.public.mozilla.jseng From : Matthew Mondor Date : Fri Mar 25 2005 05:22 am On Thu, 24 Mar 2005 13:22:56 +0100 "Béatrice Philippe" wrote: > in jsapi, is there any function to enumerate each statement (one by > one) of a javascript function ? > for example, we have the following function : > "function fun1() { > var i = 'mozilla.org'; > var b = document.location.href = 'http://www.'+i; > return b; > }" > i'd like to get the first statement "var i = ....", then the > second > statement "var b = ...." etc...in my array. JS_DecompileFunction() might help, but it returns a string representation rather than providing iteration function... Its internals (js_DecompileFunction() code) might help understanding how it works, but it seems to only be dealing with private parts of the API. toSource() from javascript code, similarily returns a string (invokes internal toString code). I guess that possibly an iterator function could be derived with string parsing to work on each element one by one, however it then is very possible that a rather complex javascript custom parser become necessary if any code analysis is required. Maybe that through debugging API functions it would be possible in a more elegant manner, but I personally have no experience with this API yet and will let others (dis)confirm this... Matt .