Subj : Re: Compacting JS source via ParseTree or Decompile To : netscape.public.mozilla.jseng From : Dan Libby Date : Sun Jun 06 2004 02:24 am Brendan, thanks for the example. I got the JS_DecompileScript API working, stripping out all unnecessary whitespace. Perfect. This is just what I need right now. You guys rock! I'll be doing some additional cleanup/testing over the next few days, and will likely release something to SourceForge this week. In which case I'll post the link here. Looking towards a more general purpose JS source tuneup tool, I think the following features would be quite nice, but they seem to require additional support from the JS library: - ability to pretty print source *with comments*. This doesn't seem to be possible decompiling from bytecode, correct? From JSParseNode? - Finer grained control over formatting: more indentation and newline options, positioning of curly braces and parens, braces ommitted for IF with single statement. Rather than hard-code this type of logic into the JS library JSPrinter, it seems like these behaviors could be controlled by the calling application via callbacks. - auto-generation of comment templates (stubs) for functions/methods, including function name and params. For this, the app would need to be able to introspect the function/class and insert the comments into the string at approprate places. I am still interested in the "walk pn and check sanity" approach, which seems like it might enable some of the features listed above. However, I'm having trouble making sense of the JSParseNode struct. And looking at the function js_EmitTree() is quite intimidating. Do you see a simple way for me to walk the PN and emit the [possibly modified] source code, or am I getting in too deep for a weekend project? Dan .