add __repr__ for all dotnet.types classes
This commit is contained in:
parent
88f252ec35
commit
20ece93b96
|
@ -17,6 +17,9 @@ class CLIPrimitiveType(CLIType):
|
|||
def __str__(self):
|
||||
return self.type.name.lower()
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {}>'.format(self.__class__.__name__, self.type.value)
|
||||
|
||||
class CLIPointerType(CLIType):
|
||||
def __init__(self, child: CLIType):
|
||||
self.child = child
|
||||
|
@ -24,6 +27,9 @@ class CLIPointerType(CLIType):
|
|||
def __str__(self):
|
||||
return str(self.child) + '*'
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}>'.format(self.__class__.__name__, self.child)
|
||||
|
||||
class CLIRefType(CLIType):
|
||||
def __init__(self, child: CLIType):
|
||||
self.child = child
|
||||
|
@ -31,6 +37,9 @@ class CLIRefType(CLIType):
|
|||
def __str__(self):
|
||||
return str(self.child) + '&'
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}>'.format(self.__class__.__name__, self.child)
|
||||
|
||||
class CLIPinnedType(CLIType):
|
||||
def __init__(self, child: CLIType):
|
||||
self.child = child
|
||||
|
@ -38,6 +47,9 @@ class CLIPinnedType(CLIType):
|
|||
def __str__(self):
|
||||
return str(self.child) + ' fixed&'
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}>'.format(self.__class__.__name__, self.child)
|
||||
|
||||
class CLIUserTypeKind(enum.Enum):
|
||||
Class = 'class'
|
||||
ValueType = 'enum'
|
||||
|
@ -54,6 +66,9 @@ class CLIUserType(CLIType):
|
|||
prefix = ''
|
||||
return '{}{}#{}'.format(prefix, self.kind.value, self.token.row)
|
||||
|
||||
def __repr__(self):
|
||||
return '<{} ({}): {!r}>'.format(self.__class__.__name__, self.kind.value, self.token)
|
||||
|
||||
class CLIOptionalType(CLIType):
|
||||
def __init__(self, child):
|
||||
self.child = child
|
||||
|
@ -61,6 +76,9 @@ class CLIOptionalType(CLIType):
|
|||
def __str__(self):
|
||||
return str(self.child) + '?'
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}>'.format(self.__class__.__name__, self.child)
|
||||
|
||||
class CLIRequiredType(CLIType):
|
||||
def __init__(self, child):
|
||||
self.child = child
|
||||
|
@ -68,6 +86,9 @@ class CLIRequiredType(CLIType):
|
|||
def __str__(self):
|
||||
return str(self.child) + '!'
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}>'.format(self.__class__.__name__, self.child)
|
||||
|
||||
class CLIGenericParamScope(enum.Enum):
|
||||
Type = 'type'
|
||||
Method = 'method'
|
||||
|
@ -80,6 +101,9 @@ class CLIGenericParamType(CLIType):
|
|||
def __str__(self):
|
||||
return '#' + str(self.index)
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {} @ {}>'.format(self.__class__.__name__, self.index, self.scope.value)
|
||||
|
||||
class CLIGenericInstantiationType(CLIType):
|
||||
def __init__(self, child, args):
|
||||
self.child = child
|
||||
|
@ -88,6 +112,9 @@ class CLIGenericInstantiationType(CLIType):
|
|||
def __str__(self):
|
||||
return str(self.child) + '[' + ', '.join(str(a) for a in self.args) + ']'
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}[{}]>'.format(self.__class__.__name__, self.child, ', '.join(repr(a) for a in self.args))
|
||||
|
||||
class CLIArrayType(CLIType):
|
||||
def __init__(self, child, rank, sizes=None, lowers=None):
|
||||
self.child = child
|
||||
|
@ -101,6 +128,12 @@ class CLIArrayType(CLIType):
|
|||
for _, lower, upper in zip_longest(range(self.rank), self.lowers, self.sizes)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return '<{}: {!r}{}>'.format(self.__class__.__name__, self.child, ''.join(
|
||||
'[{}{}]'.format(str(lower) + '...' if lower else '', upper + (lower or 0) if upper else '')
|
||||
for _, lower, upper in zip_longest(range(self.rank), self.lowers, self.sizes)
|
||||
))
|
||||
|
||||
class CLIElement(Type):
|
||||
def __init__(self, child):
|
||||
self.child = child
|
||||
|
|
Loading…
Reference in New Issue