Skip to content

Commit bbfc04b

Browse files
ahangsujasonpaulos
authored andcommitted
provide a method to know the type name (#176)
1 parent 382877b commit bbfc04b

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

pyteal/ast/abi/array.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ def map(self, mapFn: Callable[[T, Expr, T], Expr]) -> Expr:
214214
mappedArray.load(),
215215
)
216216

217+
def __str__(self) -> str:
218+
return self._valueType.__str__() + (
219+
"[]"
220+
if self._props.static_length is None
221+
else "[{}]".format(self._props.static_length)
222+
)
223+
217224

218225
Array.__module__ = "pyteal"
219226

pyteal/ast/abi/tuple.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def length(self) -> Expr:
146146
def __getitem__(self, index: int) -> "TupleElement":
147147
return TupleElement(self, index)
148148

149+
def __str__(self) -> str:
150+
return "({})".format(",".join(map(lambda x: x.__str__(), self.valueTypes)))
151+
149152

150153
Tuple.__module__ = "pyteal"
151154

pyteal/ast/abi/type.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ def encode(self) -> Expr:
3737
def decode(self, encoded: Expr, offset: Expr, length: Expr) -> Expr:
3838
pass
3939

40+
@abstractmethod
41+
def __str__(self) -> str:
42+
pass
43+
4044

4145
Type.__module__ = "pyteal"

pyteal/ast/abi/uint.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def get(self) -> Expr:
3939
def set(self, value: Union[int, Expr]) -> Expr:
4040
pass
4141

42+
def __str__(self) -> str:
43+
return "uint{}".format(self.bit_size)
44+
4245

4346
class Uint16(Uint):
4447
def __init__(

0 commit comments

Comments
 (0)