Skip to content

Commit

Permalink
added code for enumerate typ recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
nucccc committed Mar 26, 2024
1 parent d3a1408 commit e4c64c9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions markarth/convert/collect/ast_to_typ/ast_to_typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ def typ_from_iter(iter_stat : ast.AST) -> typs.Typ:
type_from_iter shall get the type of a variable "extracted"
out of an iterable statement
'''
# TODO: test this against a for loop taking stuff froma method
if type(iter_stat) == ast.Call:
if iter_stat.func.id == 'range':
return typs.TypPrimitive(typs.PrimitiveCod.INT)
elif iter_stat.func.id == 'enumerate':
# TODO: evaluate what's inside the enumerate
return typs.TypTuple(inner_typs=[
typs.TypPrimitive(typs.PrimitiveCod.INT),
typs.TypAny()
])
return typs.TypAny()

0 comments on commit e4c64c9

Please sign in to comment.