mark <msparshatt / yahoo.co.uk> skrev den Sat, 23 Aug 2003 02:52:55 +0900:

> However if you try something like
>
> [mark@laptop ruth-0.10]$ ruby tests/parse_ruby_file.rb 'def m(a); x=1; 
> end'
> Def
> :m
> [:a, :x]
> LocalAssign
> :x
> IntegerLiteral
> 1
>
> So it seems that the array [:a, :x] is a list of all local variables used 
> in the function.
>
> Is there any way to find out what parameters the function takes?
>
There transformation from internal to AST is very sketchy/incomplete
as of now but if you check the internal tree:

$ ruby tests/parse_ruby_file.rb 'def m(a); x = 1; end' internal
Internal tree:
Newline(Defn(:m
             Scope([:a, :x]
                   Block(Args(1
                              -1
                              nil)
                         Block(Newline(Lasgn(3
                                             :x
                                             Lit(1)))
                               nil)))))

You can see the info is there (1 arg to the block that is
the body => first in the scope => a) so its a bug
in the transformation.

anyway, I'm offline for some time now so will be back
with fixes at a later time.

Regards,

Robert