Skip to content
Permalink
Browse files

Merge pull request #682 from krekoten/module_name

Module#name
  • Loading branch information
alex committed May 6, 2013
2 parents dcb6282 + 84300c1 commit f02639c81577d72bb932c470d1108592e4ac79fb
Showing with 10 additions and 6 deletions.
  1. +0 −3 spec/tags/core/module/name_tags.txt
  2. +3 −2 topaz/interpreter.py
  3. +6 −0 topaz/objects/moduleobject.py
  4. +1 −1 topaz/objspace.py
@@ -1,6 +1,3 @@
fails:Module#name is nil for a nested module created with the module keyword
fails:Module#name is set with a conditional assignment to a nested constant
fails:Module#name is set with a conditional assignment to a constant
fails:Module#name preserves the encoding in which the class was defined
fails:Module#name is set when the anonymous outer module name is set
fails:Module#name is nil when assigned to a constant in an anonymous module
@@ -202,8 +202,9 @@ def STORE_CONSTANT(self, space, bytecode, frame, pc, idx):
w_value = frame.pop()
w_scope = frame.pop()
space.set_const(w_scope, name, w_value)
if isinstance(w_value, W_ModuleObject) and w_value.name is None:
w_value.name = space.buildname(name, w_scope)
if (isinstance(w_value, W_ModuleObject) and w_value.name is None
and isinstance(w_scope, W_ModuleObject) and w_scope.name is not None):
w_value.set_name_in_scope(space, name, w_scope)
frame.push(w_value)

def DEFINED_CONSTANT(self, space, bytecode, frame, pc, idx):
@@ -315,6 +315,12 @@ def method_undefined(self, space, w_name):
def method_removed(self, space, w_name):
space.send(self, space.newsymbol("method_removed"), [w_name])

def set_name_in_scope(self, space, name, w_scope):
self.name = space.buildname(name, w_scope)
for name, w_const in self.constants_w.iteritems():
if isinstance(w_const, W_ModuleObject):
w_const.set_name_in_scope(space, name, self)

@classdef.singleton_method("nesting")
def singleton_method_nesting(self, space):
frame = space.getexecutioncontext().gettoprubyframe()
@@ -441,7 +441,7 @@ def buildname(self, name, w_scope):
if w_scope is not None:
assert isinstance(w_scope, W_ModuleObject)
if w_scope is not self.w_object:
complete_name = "%s::%s" % (w_scope.name, name)
complete_name = "%s::%s" % (self.obj_to_s(w_scope), name)
return complete_name

def int_w(self, w_obj):

0 comments on commit f02639c

Please sign in to comment.
You can’t perform that action at this time.