berkesokhan / rubydotnetcompiler

Automatically exported from code.google.com/p/rubydotnetcompiler
1 stars 0 forks source link

TOPLEVEL_BINDING #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
(1)
  str = "a=2"
  eval(str,TOPLEVEL_BINDING)

What is the expected output? What do you see instead?
Expect a to become 2.
Get: Unhandled Exception: Ruby.Runtime.RubyException: uninitialized 
constant TOPLEVEL_BINDING

What version of the product are you using? On what operating system?
Rev 86. Windows XP

Please provide any additional information below.
TOPLEVEL_BINDING is a binding object representing the Ruby top level and 
is needed for ERB in particular. Maybe a post-1.8.2 value?

Original issue reported on code.google.com by djl_davi...@rifraf.net on 11 Sep 2007 at 1:20

GoogleCodeExporter commented 9 years ago
TOPLEVEL_BINDING exists in 1.8.2, but Ruby.NET doesn't have it yet.

The following patch is wrong but it's probably a start.  It's wrong because, if 
I 
understand correctly, at that point in the code the toplevel frame is not known.

Index: src/RubyRuntime/Runtime/Inits.cs
===================================================================
--- src/RubyRuntime/Runtime/Inits.cs    (revision 87)
+++ src/RubyRuntime/Runtime/Inits.cs    (working copy)
@@ -151,6 +151,9 @@
             Init_marshal();
             Init_version();

+            // DOES NOT WORK, the null is wrong
+            Variables.rb_define_global_const("TOPLEVEL_BINDING", new 
Binding(null, 
Object.ruby_top_self));
+
             Init_Prog();

             // BBTAG: need to set default visibility to private

Original comment by sason...@gmail.com on 13 Sep 2007 at 4:51