Skip to content

Instantly share code, notes, and snippets.

@jgouly
Created March 24, 2011 18:50
Show Gist options
  • Save jgouly/885612 to your computer and use it in GitHub Desktop.
Save jgouly/885612 to your computer and use it in GitHub Desktop.
#!/usr/bin/env rbx
g = Rubinius::Generator.new
g.name = :call
g.file = :"repl"
g.set_line 1
g.push_const :Kernel
g.push_int 1
g.allow_private
g.send_stack :p, 1
g.ret
g.close
g.encode
class Code; end
cm = g.package ::Rubinius::CompiledMethod
puts cm.decode
code = Code.new
ss = ::Rubinius::StaticScope.new Object
::Rubinius.attach_method g.name, cm, ss, code
p code.call
An exception occurred running ./compiler.rb
Only Fixnums valid for Tuple indices (TypeError)
Backtrace:
Rubinius::Tuple#[] at kernel/bootstrap/tuple.rb:22
{ } in Rubinius::CompiledMethod::Instruction#initialize at kernel/common/compiled_method.rb:523
Array#each_index at kernel/common/array.rb:704
Rubinius::CompiledMethod::Instruction#initialize at kernel/common
/compiled_method.rb:520
{ } in Rubinius::CompiledMethod#decode at kernel/common/compiled_method.rb:414
{ } in Array#map at kernel/bootstrap/array.rb:95
Array#each at kernel/bootstrap/array.rb:76
Array#map at kernel/bootstrap/array.rb:95
Rubinius::CompiledMethod#decode at kernel/common/compiled_method.rb:413
main.__script__ at compiler.rb:19
Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:67
Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:91
Rubinius::Loader#script at kernel/loader.rb:583
Rubinius::Loader#main at kernel/loader.rb:713
Rubinius::Loader.main at kernel/loader.rb:752
Object#__script__ at kernel/loader.rb:763
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment