The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Marshalling Ruby 2.0 Codes

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Marshalling Ruby 2.0 Codes Posted: Aug 21, 2006 2:23 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Marshalling Ruby 2.0 Codes
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

We’re all eager to see YARV spout real live bytecode, but ko1 has a fun sort of inbetween option: marshalling arrays containing Ruby 2.0 instructions to an .rbc file. All it is: 4 bytes reading RBCM and then the marshal.

Assuming you have YARV installed with the -yarv suffix, go to the root directory of your checked out source code. We’re interested in rb/compile.rb.

 ruby-yarv rb/compile.rb ~/svn/camping/lib/camping.rb -o camping.rbc

This isn’t anything that exciting. The .rbc file will likely be four times the size of your original source. And, in my tests, it’s no quicker to parse. But it is an interesting way to store source code, for sure.

Load it like so:

 open("camping.rbc") do |f|
 exit "Not really an RBCM!" unless f.read(4) == "RBCM" 
 iseq = YARVCore::InstructionSequence.load(Marshal.load(f))
 iseq.eval
 end

This was all covered in issue no. 15 of the Rubyist Magazine, which has a bunch of quick dissections of the instruction set and YARV assembly.

Read: Marshalling Ruby 2.0 Codes

Topic: Functions accepting blocks in Ruby's C API make for tricky bugs Previous Topic   Next Topic Topic: Camping Gets J'd, Placing It at the Very Epicenter of Hate!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use