Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopodl committed May 19, 2024
1 parent c208cb8 commit 832cb4f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions argon/vm/datatype/arobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ ArObject *argon::vm::datatype::Repr(ArObject *object) {
}

ArObject *ReprWrapper(ArObject *func, ArObject *self, ArObject **args, ArObject *kwargs, ArSize argc) {
return Repr(self);
auto repr = AR_GET_TYPE(self)->repr;
if (repr != nullptr)
return repr(self);

return (ArObject *) StringFormat("<object %s @%p>", AR_TYPE_NAME(self), self);
}

ArObject *argon::vm::datatype::Str(ArObject *object) {
Expand Down Expand Up @@ -577,7 +581,11 @@ ArObject *argon::vm::datatype::Str(ArObject *object) {
}

ArObject *StrWrapper(ArObject *func, ArObject *self, ArObject **args, ArObject *kwargs, ArSize argc) {
return Str(self);
auto str = AR_GET_TYPE(self)->str;
if (str != nullptr)
return str(self);

return Repr(self);
}

ArObject *argon::vm::datatype::TraitNew(const char *name, const char *qname, const char *doc, ArObject *ns,
Expand Down

0 comments on commit 832cb4f

Please sign in to comment.