Add an inst.all_typevars() method.

Get all type variables controlling an instruction, whether it is
polymorphic or not.
This commit is contained in:
Jakob Stoklund Olesen
2017-07-28 14:45:56 -07:00
parent 1f02d1f880
commit 939f188e27
2 changed files with 11 additions and 5 deletions

View File

@@ -267,6 +267,16 @@ class Instruction(object):
return other_tvs
def all_typevars(self):
# type: () -> List[TypeVar]
"""
Get a list of all type variables in the instruction.
"""
if self.is_polymorphic:
return [self.ctrl_typevar] + self.other_typevars
else:
return []
@staticmethod
def _to_operand_tuple(x):
# type: (Union[Sequence[Operand], Operand]) -> Tuple[Operand, ...]

View File

@@ -796,11 +796,7 @@ def ti_def(definition, typ):
# Create a dict m mapping each free typevar in the signature of definition
# to a fresh copy of itself.
if inst.is_polymorphic:
free_formal_tvs = [inst.ctrl_typevar] + inst.other_typevars
else:
free_formal_tvs = []
free_formal_tvs = inst.all_typevars()
m = {tv: tv.get_fresh_copy(str(typ.get_uid())) for tv in free_formal_tvs}
# Update m with any explicitly bound type vars