Add class name to method __repr__
This commit is contained in:
parent
ab158260f7
commit
181e378628
@ -29,7 +29,7 @@ Let's do some classes.
|
||||
<type 'Test'>
|
||||
yay: bax
|
||||
bar
|
||||
<method doAThing>
|
||||
<method Test.doAThing>
|
||||
yay: bar
|
||||
This is a great teapot!
|
||||
Subclass says: (I am a teapot)
|
||||
|
6
vm.c
6
vm.c
@ -1857,9 +1857,11 @@ static KrkValue _bound_str(int argc, KrkValue argv[]) {
|
||||
KrkValue s = _bound_get_name(argc, argv);
|
||||
krk_push(s);
|
||||
|
||||
size_t len = AS_STRING(s)->length + sizeof("<method >");
|
||||
const char * typeName = krk_typeName(AS_BOUND_METHOD(argv[0])->receiver);
|
||||
|
||||
size_t len = AS_STRING(s)->length + sizeof("<method >") + strlen(typeName) + 1;
|
||||
char * tmp = malloc(len);
|
||||
sprintf(tmp, "<method %s>", AS_CSTRING(s));
|
||||
sprintf(tmp, "<method %s.%s>", typeName, AS_CSTRING(s));
|
||||
s = OBJECT_VAL(krk_copyString(tmp,len-1));
|
||||
free(tmp);
|
||||
krk_pop();
|
||||
|
Loading…
Reference in New Issue
Block a user