On 6/6/06, Lukas Felber <[EMAIL PROTECTED]> wrote:
I'm not a JRuby developer, but my understanding is that you won't be
able to get to any AST for core classes - because there's no ruby code
there - it's in Ruby C or in Java. You should be able to get a handle
on JRuby's RubyClass instance for the class, likely. But then there's a
big mismatch between traversing ASTs to get at
things, JRuby's RubyObject -> RubyModule -> RubyClass code which
has methods to manipulate the class (and query it for methods, etc) [and to make it even more confusing, RDT's internal RubyElement -> RubyModule -> RubyClass
hierarchy (used to get at the underlying source, analyze, modify, etc)]. I beleive you guys are working off the AST to do manipulations and analysis.Thomas E Enebo wrote:
> We do not directly link back to AST from an object (if this is what
> you are asking). That would not work well since multiple AST nodes could
> reference the same object.
>
Ok I think I expressed myself a bit bad. I'll make an example to to show
you what I'd like to have.
Here a simple Ruby file:
class X < Dir
end
What I need is the AST of the Class "Dir" (I want to get to its
constructor).
If I parse the example file I get a ClassNode. The method getSuperNode
gives me a node containing the
String "Dir". I would like to have way to get to the AST of the class
"Dir" over the String "Dir".
Of course "Dir" is only an example. It stands for any Built-in Class of
ruby.
One "solution" that I can see - write stubs for the core ruby classes in ruby and parse those stubs when we need to get AST for a core class for analysis. That's pretty ugly, but possible. As for the standard library, JRuby just got permission to include the real ruby libs, so hopefully you'll be able to parse those to AST as well.
Thanks,
Chris
--
http://cwilliams.textdriven.com
_______________________________________________ Jruby-devel mailing list Jruby-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jruby-devel