Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 07ce0ac

Browse files
author
Ehsan Totoni
committed
dict int32 int32 type
1 parent 0b3da02 commit 07ce0ac

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

hpat/dict_ext.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,39 @@ class DictType(types.Opaque):
1414
def __init__(self, key_typ, val_typ):
1515
self.key_typ = key_typ
1616
self.val_typ = val_typ
17-
super(DictType, self).__init__(name='DictType')
17+
super(DictType, self).__init__(name='DictType{}{}'.format(key_typ, val_typ))
1818

1919
dict_int_int_type = DictType(types.intp, types.intp)
20+
dict_int32_int32_type = DictType(types.int32, types.int32)
2021

2122
class DictIntInt(object):
2223
def __new__(cls, *args):
2324
return {}
2425

26+
class DictInt32Int32(object):
27+
def __new__(cls, *args):
28+
return {}
29+
2530
@typeof_impl.register(DictIntInt)
2631
def typeof_index(val, c):
2732
return dict_int_int_type
2833

34+
@typeof_impl.register(DictInt32Int32)
35+
def typeof_index(val, c):
36+
return dict_int32_int32_type
37+
2938
@type_callable(DictIntInt)
3039
def type_dict(context):
3140
def typer():
3241
return dict_int_int_type
3342
return typer
3443

44+
@type_callable(DictInt32Int32)
45+
def type_dict(context):
46+
def typer():
47+
return dict_int32_int32_type
48+
return typer
49+
3550
@infer
3651
class SetItemDict(AbstractTemplate):
3752
key = "setitem"
@@ -55,11 +70,12 @@ def generic(self, args, kws):
5570
@infer
5671
class PrintDictIntInt(ConcreteTemplate):
5772
key = "print_item"
58-
cases = [signature(types.none, dict_int_int_type)]
73+
cases = [signature(types.none, dict_int_int_type),
74+
signature(types.none, dict_int32_int32_type)]
5975

6076
@infer_getattr
6177
class DictAttribute(AttributeTemplate):
62-
key = dict_int_int_type
78+
key = DictType
6379

6480
@bound_function("dict.get")
6581
def resolve_get(self, dict, args, kws):
@@ -70,12 +86,12 @@ def resolve_get(self, dict, args, kws):
7086
@bound_function("dict.pop")
7187
def resolve_pop(self, dict, args, kws):
7288
assert not kws
73-
return signature(types.intp, *args)
89+
return signature(dict.val_typ, *args)
7490

7591
@bound_function("dict.keys")
7692
def resolve_keys(self, dict, args, kws):
7793
assert not kws
78-
return signature(dict_key_iterator_int_int_type)
94+
return signature(DictKeyIteratorType(dict.key_typ, dict.val_typ))
7995

8096
register_model(DictType)(models.OpaqueModel)
8197

@@ -97,7 +113,8 @@ class DictKeyIteratorType(types.SimpleIterableType):
97113
def __init__(self, key_typ, val_typ):
98114
self.key_typ = key_typ
99115
self.val_typ = val_typ
100-
super(types.SimpleIterableType, self).__init__('DictKeyIteratorType')
116+
super(types.SimpleIterableType, self).__init__(
117+
'DictKeyIteratorType{}{}'.format(key_typ, val_typ))
101118

102119
dict_key_iterator_int_int_type = DictKeyIteratorType(types.intp, types.intp)
103120

0 commit comments

Comments
 (0)