def _toString(self): # only for testing purposes, and only if the Record represents a tuple from rpython.translator.cli.test.runtest import format_object for f_name in self.record._fields: if not f_name.startswith('item'): return # it's not a tuple self.ilasm.begin_function('ToString', [], 'string', False, 'virtual', 'instance', 'default') self.ilasm.opcode('ldstr', '"("') for i in xrange(len(self.record._fields)): f_name = 'item%d' % i FIELD_TYPE, f_default = self.record._fields[f_name] if FIELD_TYPE is ootype.Void: continue self.ilasm.opcode('ldarg.0') f_type = self.cts.lltype_to_cts(FIELD_TYPE) self.ilasm.get_field((f_type, self.name, f_name)) format_object(FIELD_TYPE, self.cts, self.ilasm) self.ilasm.call('string string::Concat(string, string)') self.ilasm.opcode('ldstr ", "') self.ilasm.call('string string::Concat(string, string)') self.ilasm.opcode('ldstr ")"') self.ilasm.call('string string::Concat(string, string)') self.ilasm.opcode('ret') self.ilasm.end_function()
def _trace_value(self, prompt, v): self.ilasm.stderr(' ' + prompt + ': ', writeline=False) self.ilasm.load_stderr() self.load(v) if v.concretetype is not ootype.String: from rpython.translator.cli.test.runtest import format_object format_object(v.concretetype, self.cts, self.ilasm) self.ilasm.write_stderr()