Forum: Ruby IL Generator syntax proposal

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2c8df79b2a68a7532af01d8851f7fa2d?d=identicon&s=25 drjflam (Guest)
on 2005-12-02 18:17
(Received via mailing list)
In my rewrite of my Ruby <=> CLR bridge, I've been thinking about
pushing
most of the logic into Ruby, and leaving as little as possible in
Managed
C++. I was just hacking around this morning in emacs thinking about what
the
syntax for an IL generator should look like, and this was what I came up
with:

d = DynamicMethod.new("Int32, UInt32*, UInt32")
g = d.get_generator

g.begin_exception_block do
  g.call "static Throws.ThrowException()"
  g.br_s "EndOfMethod"
  g.catch("Exception") do
    g.call "ToString()"
    g.call "static Console.WriteLine(String)"
  end
  g.label "EndOfMethod"
  g.ldc_i4 Qnil
  g.ret
end

I'd love it if folks could comment on how this syntax might be improved
in
Ruby before I crank out the underlying MC++ / Ruby code ...

Thanks!
-John
http://www.iunknown.com
Eb9493c94d8db9887e5f15284d2c767f?d=identicon&s=25 ptkwt (Guest)
on 2005-12-03 03:35
(Received via mailing list)
In article <d0b50b7f0512020916h6a4211fj437c5e0ca329c19@mail.gmail.com>,
John Lam  <drjflam@gmail.com> wrote:
>with:
>  end
>  g.label "EndOfMethod"
>  g.ldc_i4 Qnil
>  g.ret
>end
>
>I'd love it if folks could comment on how this syntax might be improved in
>Ruby before I crank out the underlying MC++ / Ruby code ...
>

Are you the person who got the Google summer of code grant to do a
Ruby/.NET
bridge?

Phil
E0ed615bd6632dd23165e045e3c1df09?d=identicon&s=25 florgro (Guest)
on 2005-12-03 05:25
(Received via mailing list)
Phil Tomson wrote:

> Are you the person who got the Google summer of code grant to do a Ruby/.NET
> bridge?

Wasn't that a Summer of Code grant to do a Ruby.NET compiler...? ;)
D83785463666ae9bb98a0753eebc8950?d=identicon&s=25 nightphotos (Guest)
on 2005-12-04 00:53
(Received via mailing list)
Hi John,

It was great meeting you at RubyConf!

We can avoid having to do all the "g." prefixes on the methods like
this:

module CLR_IL
  def use_generator(g)
    @il_generator = g
  end

  def begin_exception_block
    @il_generator.begin_exception_block
  end

  def call(s)
    @il_generator.call(s)
  end
end

then your example becomes

  d = DynamicMethod.new("Int32, UInt32*, UInt32")
  g = d.get_generator
  use_generator(g)

  begin_exception_block do
    call "static Throws.ThrowException()"
    br_s "EndOfMethod"
  ...etc...

Of course, we could use method_missing in module CLR_IL to avoid
having to write each of the individual wrappers that forward to
@il_generator.whatever.

Wayne Vucenic
No Bugs Software
"Ruby and C++ Agile Contract Programming in Silicon Valley"
2c8df79b2a68a7532af01d8851f7fa2d?d=identicon&s=25 drjflam (Guest)
on 2005-12-04 03:31
(Received via mailing list)
Hi Wayne,

It was great meeting you too! Thanks for the suggestion - I was already
thinking along the lines of moving everything to modules, and your
example
really drives home just how much better the syntax can be if I implement
method_missing on the module itself. Hopefully I'll have something
working
early next week so that I can post some code for folks to try out.

Thanks for the suggestion!
-John
http://www.iunknown.com
D83785463666ae9bb98a0753eebc8950?d=identicon&s=25 nightphotos (Guest)
on 2005-12-04 13:35
(Received via mailing list)
Hi John,

I just noticed that I left out the line

    include CLR_IL

before the line

    d = DynamicMethod.new("Int32, UInt32*, UInt32")

> Hopefully I'll have something working
> early next week so that I can post some code for folks to try out.

I'm looking forward to seeing this.

By the way, iunknown.com is such an outrageously good domain name for a
COM guy!

Wayne
This topic is locked and can not be replied to.