def generate_slot_map_op(ops: List[str], op: str, base: TypeInfo, typ: TypeInfo) -> None: ops.append('def {}(t)'.format(op)) nslots = num_slots(typ) slots = compile_slot_mapping(base) a = [] # type: List[str] for t in slots: a.append(transform_type_to_runtime_repr(t)) for i in range(len(slots), nslots): a.append('__Dyn') ops.append(' return [' + ', '.join(a) + ']') ops.append('end')
void add_slot_map_support_for_type_pair(str[] map, str[] ops, TypeInfo base, TypeInfo typ): op = '__{}TypeTo{}Slots'.format(base.name(), typ.name()) map.append(' ({}, {}) : {},'.format(base.name(), typ.name(), op)) if typ.is_generic(): map.append(' ({}, {}) : {},'.format(base.name(), typ.name() + dynamic_suffix(False), op)) generate_slot_map_op(ops, op, base, typ) void generate_slot_map_op(str[] ops, str op, TypeInfo base, TypeInfo typ): ops.append('def {}(t)'.format(op)) nslots = num_slots(typ) slots = compile_slot_mapping(base) a = <str> [] for t in slots: a.append(transform_type_to_runtime_repr(t)) for i in range(len(slots), nslots): a.append('__Dyn') ops.append(' return [' + ', '.join(a) + ']') ops.append('end') str transform_type_to_runtime_repr(Type t): if isinstance(t, Instance): inst = (Instance)t if inst.args == []: return inst.type.name() else: