On Mar 5, 12:37 pm, Kris Zyp <[email protected]> wrote:
> On Mar 4, 5:29 am, Norris Boyd <[email protected]> wrote:
>
>
>
> > On Feb 27, 8:19 am, Kris Zyp <[email protected]> wrote:
>
> > > On Oct 8 2008, 6:15 am, Kris Zyp <[email protected]> wrote:
>
> > > > What is the best way to get the AST representation
> > > > (org.mozilla.javascript.Node or appropriate subclass) of an existing
> > > > function (one that was created by evaluation)? Currently I am calling
> > > > JS toString for the function and then creating a new Parser and
> > > > parsing that string, but seems pretty awkward. Is there a better way?
>
> > > Will 1.7R2 with it's new AST API provide any assistance in getting at
> > > the AST of a function from a live function instance?
>
> > > Thanks,
> > > Kris
>
> > 1.7R2 doesn't have the new AST API. That feature is still being
> > developed and is targeted at 1.7R3.
>
> Sorry, that was a typo, I knew it was R3.
>
> > There are currently no plans to retain the AST after compilation,
> > since to do so would likely result in a substantial memory cost.
>
> Clearly the memory cost would prohibit this from being the default
> behavior, but couldn't this be a configuration option? It seems like
> the new AST API would have much broader opportunities for use if it
> could be accessed from within JavaScript by accessing the AST from a
> live function.
> For example, I could get parameter names:
>
> function add(a, b){
>   return a + b;}
>
> foo.ast.getParams().get(0).getName() -> "a"
>
> Wouldn't that be cool! Would it be better to talk to Steve about this?
> Kris

+1

It would be a shame not to have the option to access this information
at runtime.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to