Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #529 from modcloth/mbh/main-to_s-with-toplevel-bin…
…ding
Kernel#eval, TOPLEVEL_BINDING, and top #to_s returns "main"
- Loading branch information
|
|
@@ -1,3 +1,5 @@ |
|
|
TOPLEVEL_BINDING = binding |
|
|
|
|
|
class << self |
|
|
def include(*mods) |
|
|
Object.include(*mods) |
|
|
|
@@ -3,11 +3,8 @@ fails:Kernel#eval evaluates within the scope of the eval |
|
|
fails:Kernel#eval evaluates such that consts are scoped to the class of the eval |
|
|
fails:Kernel#eval updates a local in a scope above when modified in a nested block scope |
|
|
fails:Kernel#eval does not share locals across eval scopes |
|
|
fails:Kernel#eval doesn't accept a Proc object as a binding |
|
|
fails:Kernel#eval does not make Proc locals visible to evaluated code |
|
|
fails:Kernel#eval allows a binding to be captured inside an eval |
|
|
fails:Kernel#eval allows creating a new class in a binding |
|
|
fails:Kernel#eval allows creating a new class in a binding created by #eval |
|
|
fails:Kernel#eval includes file and line information in syntax error |
|
|
fails:Kernel#eval sets constants at the toplevel from inside a block |
|
|
fails:Kernel#eval uses the filename of the binding if none is provided |
|
|
Oops, something went wrong.
|
@@ -10,6 +10,7 @@ |
|
|
from topaz.error import RubyError, error_for_oserror |
|
|
from topaz.module import Module, ModuleDef |
|
|
from topaz.modules.process import Process |
|
|
from topaz.objects.bindingobject import W_BindingObject |
|
|
from topaz.objects.exceptionobject import W_ExceptionObject |
|
|
from topaz.objects.procobject import W_ProcObject |
|
|
from topaz.objects.stringobject import W_StringObject |
|
@@ -305,9 +306,15 @@ def method_instance_of(self, space, w_mod): |
|
|
return space.newbool(space.getnonsingletonclass(self) is w_mod) |
|
|
|
|
|
@moduledef.method("eval") |
|
|
def method_eval(self, space, w_source): |
|
|
frame = space.getexecutioncontext().gettoprubyframe() |
|
|
w_binding = space.newbinding_fromframe(frame) |
|
|
def method_eval(self, space, w_source, w_binding=None): |
|
|
if w_binding is None: |
|
|
frame = space.getexecutioncontext().gettoprubyframe() |
|
|
w_binding = space.newbinding_fromframe(frame) |
|
|
elif not isinstance(w_binding, W_BindingObject): |
|
|
raise space.error(space.w_TypeError, |
|
|
"wrong argument type %s (expected Binding)" % |
|
|
space.getclass(w_binding).name |
|
|
) |
|
|
return space.send(w_binding, space.newsymbol("eval"), [w_source]) |
|
|
|
|
|
@moduledef.method("set_trace_func") |
|
|