MCPcopy
hub / github.com/python/mypy / reg

Method reg

mypyc/codegen/emitfunc.py:904–934  ·  view source on GitHub ↗
(self, reg: Value)

Source from the content-addressed store, hash-verified

902 return self.emitter.label(label)
903
904 def reg(self, reg: Value) -> str:
905 if isinstance(reg, Integer):
906 val = reg.value
907 if val == 0 and is_pointer_rprimitive(reg.type):
908 return "NULL"
909 s = str(val)
910 if val >= (1 << 31):
911 # Avoid overflowing signed 32-bit int
912 if val >= (1 << 63):
913 s += "ULL"
914 else:
915 s += "LL"
916 elif val == -(1 << 63):
917 # Avoid overflowing C integer literal
918 s = "(-9223372036854775807LL - 1)"
919 elif val <= -(1 << 31):
920 s += "LL"
921 return s
922 elif isinstance(reg, Float):
923 r = repr(reg.value)
924 if r == "inf":
925 return "INFINITY"
926 elif r == "-inf":
927 return "-INFINITY"
928 elif r == "nan":
929 return "NAN"
930 return r
931 elif isinstance(reg, CString):
932 return '"' + encode_c_string_literal(reg.value) + '"'
933 else:
934 return self.emitter.reg(reg)
935
936 def ctype(self, rtype: RType) -> str:
937 return self.emitter.ctype(rtype)

Callers 15

error_value_checkMethod · 0.95
visit_branchMethod · 0.95
visit_returnMethod · 0.95
visit_tuple_setMethod · 0.95
visit_assignMethod · 0.95
visit_assign_multiMethod · 0.95
visit_load_literalMethod · 0.95
visit_get_attrMethod · 0.95
visit_set_attrMethod · 0.95
visit_load_staticMethod · 0.95

Calls 5

is_pointer_rprimitiveFunction · 0.90
isinstanceFunction · 0.85
strClass · 0.85
reprFunction · 0.85
encode_c_string_literalFunction · 0.85

Tested by

no test coverage detected