Thanks to everyone who responded - I've finally had a chance to spend a
couple of hours on this tonight.

On Fri, Feb 20, 2009 at 3:27 PM, Thomas E Enebo <[email protected]> wrote:

> On Fri, Feb 20, 2009 at 5:22 AM, Ben Evans
> <[email protected]> wrote:
> > Hi,
> >
> > I'm doing some work with JRuby's ast, and I've run into a few questions
> > about how the various classes are wired together.
> >
> > Scoping
> > What's the difference between a LocalStaticScope and a BlockStaticScope ?
>
> Scoping
>
> StaticScope represents lexical scoping rules.  A BlockStaticScope is a
> scope for local variables in a block.  A LocalStaticScope is a scope
> for local variables not in a block (method body/class body).


Thanks, that's great.

> Arguments and Method calls
> > How do ArgsNodes work?
> >
> > What do the special values for restArguments mean (-1 and -2 seem to be
> > special somehow) -1 crops up explicitly in a few places and there's a
> > boundary test for -2.
>
> -2 was an empty '*' argument.  That should be replaced with StarNode now.
> -1 represent no rest args.
>
> > What do static and instance methods ArgsNodes look like? Ie, if I was
> > calling the ArgsNodes constructor corresponding to a static or an
> instance
> > method, how would this look?
>
> They should look exactly the same.  The arguments for the methods are
> exactly the same.  The only real difference between these two is the
> receiver.


OK.

> Current State
> > My current status is that I have a very simple ast (programatically built
> > from scratch) which I can feed into the jruby compiler and have it
> compile
> > but the resulting JVM bytecode fails verification - I suspect because I
> > don't fully understand ArgsNodes yet, which is causing the verifier's
> stack
> > underflow check to fail.
> >
> > Btw, is there a way to ask JRuby to just produce an ast from a .rb,
> output
> > it and stop? Or is it just a case of using jdb and a breakpoint?
>
> We have an 'ast' program that will or is shipping with JRuby now:
> jruby -S ast source.rb.
> This will give you some output.


Thanks. Is this in 1.2.0RC1? Or is it only in svn? I seem to be having
problems with it:

CatBasket:~ boxcat$ jruby --version
jruby 1.2.0RC1 (ruby 1.8.6 patchlevel 287) (2009-02-24 rev 9315) [i386-java]
CatBasket:ruby_scratch boxcat$ jruby -S ast hw.rb
ast:1: undefined method `ast' for JRuby::Commands:Class (NoMethodError)
CatBasket:ruby_scratch boxcat$

I've got a very basic ast compiling now - but being able to see the ast
corresponding to an .rb will be a great help.

Thanks,

Ben

Reply via email to