Author: Anton Gulenko <anton.gule...@googlemail.com> Branch: storage Changeset: r736:5713bb4e171f Date: 2014-04-01 11:53 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/5713bb4e171f/
Log: Fixed compilation. diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py --- a/spyvm/interpreter.py +++ b/spyvm/interpreter.py @@ -18,7 +18,7 @@ def get_printable_location(pc, self, method): bc = ord(method.bytes[pc]) - name = method.get_identifier_string() + name = method.safe_identifier_string() return '%d: [%s]%s (%s)' % (pc, hex(bc), BYTECODE_NAMES[bc], name) @@ -356,7 +356,7 @@ receiver, receiverclassshadow): if interp.should_trace(): print "%sSending selector #%s to %r with: %r" % ( - interp._last_indent, w_selector.as_string(), receiver, + interp._last_indent, w_selector.str_content(), receiver, [self.peek(argcount-1-i) for i in range(argcount)]) assert argcount >= 0 @@ -402,7 +402,7 @@ # ###################################################################### if interp.trace: - print '%s%s missing: #%s' % (interp.padding('#'), s_frame.short_str(), w_selector.as_string()) + print '%s%s missing: #%s' % (interp.padding('#'), s_frame.short_str(), w_selector.str_content()) if not objectmodel.we_are_translated(): import pdb; pdb.set_trace() @@ -417,7 +417,7 @@ if interp.trace: print "%s-> primitive %d \t(in %s, named #%s)" % ( ' ' * (interp.max_stack_depth - interp.remaining_stack_depth), - code, self.w_method().get_identifier_string(), w_selector.as_string()) + code, self.w_method().get_identifier_string(), w_selector.str_content()) try: # note: argcount does not include rcvr return func(interp, self, argcount, w_method) @@ -427,7 +427,7 @@ ' ' * (interp.max_stack_depth - interp.remaining_stack_depth),) if interp.should_trace(True): - print "PRIMITIVE FAILED: %d #%s" % (w_method.primitive, w_selector.as_string()) + print "PRIMITIVE FAILED: %d #%s" % (w_method.primitive, w_selector.str_content()) raise e @@ -895,19 +895,19 @@ receiver, receiverclassshadow): options = [False] def next(): interp.message_stepping = True; print 'Now continue (c).' - def over(): options[0] = True; print 'Skipping #%s. You still need to continue(c).' % w_selector.as_string() + def over(): options[0] = True; print 'Skipping #%s. You still need to continue(c).' % w_selector.str_content() def pstack(): print s_context.print_stack() if interp.message_stepping: if argcount == 0: print "-> %s #%s" % (receiver.as_repr_string(), - w_selector.as_string()) + w_selector.str_content()) elif argcount == 1: print "-> %s #%s %s" % (receiver.as_repr_string(), - w_selector.as_string(), + w_selector.str_content(), s_context.peek(0).as_repr_string()) else: print "-> %s #%s %r" % (receiver.as_repr_string(), - w_selector.as_string(), + w_selector.str_content(), [s_context.peek(argcount-1-i) for i in range(argcount)]) import pdb; pdb.set_trace() if options[0]: diff --git a/spyvm/model.py b/spyvm/model.py --- a/spyvm/model.py +++ b/spyvm/model.py @@ -817,7 +817,7 @@ return self._size def str_content(self): - return "'%s'" % self.as_string() + return self.as_string() def as_string(self): if self.bytes is not None: @@ -1301,6 +1301,7 @@ if w_candidate.is_class(space): w_compiledin = w_candidate self.w_compiledin = w_compiledin + assert isinstance(w_compiledin, W_PointersObject) return w_compiledin # === Object Access === @@ -1419,6 +1420,19 @@ def get_identifier_string(self): return "%s >> #%s" % (self.guess_containing_classname(), self._likely_methodname) + def safe_identifier_string(self): + if not we_are_translated(): + return self.get_identifier_string() + # This has the same functionality as get_identifier_string, but without calling any + # methods in order to avoid side effects that prevent translation. + w_class = self.w_compiledin + if isinstance(w_class, W_PointersObject): + from spyvm.shadow import ClassShadow + s_class = w_class.shadow + if isinstance(s_class, ClassShadow): + return "%s >> #%s" % (s_class.getname(), self._likely_methodname) + return "#%s" % self._likely_methodname + class DetachingShadowError(Exception): def __init__(self, old_shadow, new_shadow_class): self.old_shadow = old_shadow diff --git a/spyvm/storage_statistics.py b/spyvm/storage_statistics.py --- a/spyvm/storage_statistics.py +++ b/spyvm/storage_statistics.py @@ -73,7 +73,7 @@ sizes = self.stats[key] sum = 0 for s in sizes: sum += s - print "%s: %d times, avg size: %f" % (self.key_string(key), len(sizes), sum/len(sizes)) + print "%s: %d times, avg size: %f" % (self.key_string(key), len(sizes), float(sum)/len(sizes)) if self.do_stats_sizes: print " All sizes: %s" % sizes _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit