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

Class Integer

mypyc/ir/ops.py:194–221  ·  view source on GitHub ↗

Short integer literal. Integer literals are treated as constant values and are generally not included in data flow analyses and such, unlike Register and Op subclasses. Integer can represent multiple types: * Short tagged integers (short_int_primitive type; the tag bit is cle

Source from the content-addressed store, hash-verified

192
193@final
194class Integer(Value):
195 """Short integer literal.
196
197 Integer literals are treated as constant values and are generally
198 not included in data flow analyses and such, unlike Register and
199 Op subclasses.
200
201 Integer can represent multiple types:
202
203 * Short tagged integers (short_int_primitive type; the tag bit is clear)
204 * Ordinary fixed-width integers (e.g., int32_rprimitive)
205 * Values of other unboxed primitive types that are represented as integers
206 (none_rprimitive, bool_rprimitive)
207 * Null pointers (value 0) of various types, including object_rprimitive
208 """
209
210 def __init__(self, value: int, rtype: RType = short_int_rprimitive, line: int = -1) -> None:
211 if is_short_int_rprimitive(rtype) or is_int_rprimitive(rtype):
212 self.value = value * 2
213 else:
214 self.value = value
215 self.type = rtype
216 self.line = line
217
218 def numeric_value(self) -> int:
219 if is_short_int_rprimitive(self.type) or is_int_rprimitive(self.type):
220 return self.value // 2
221 return self.value
222
223
224@final

Callers 15

join_formatted_stringsFunction · 0.90
join_formatted_bytesFunction · 0.90
make_for_loop_generatorFunction · 0.90
initMethod · 0.90
gen_conditionMethod · 0.90
initMethod · 0.90
gen_stepMethod · 0.90
initMethod · 0.90
gen_stepMethod · 0.90
get_expr_length_valueFunction · 0.90
as_platform_intFunction · 0.90
vec_createFunction · 0.90

Calls

no outgoing calls

Tested by 9

test_invalid_assignMethod · 0.72
test_duplicate_opMethod · 0.72
test_int_opMethod · 0.72
test_assignMethod · 0.72
test_integerMethod · 0.72
test_long_unsignedMethod · 0.72
test_long_signedMethod · 0.72
test_registerMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…