MCPcopy Index your code
hub / github.com/python/cpython / emit_default

Function emit_default

Tools/cases_generator/optimizer_generator.py:114–139  ·  view source on GitHub ↗
(out: CWriter, uop: Uop, stack: Stack)

Source from the content-addressed store, hash-verified

112
113
114def emit_default(out: CWriter, uop: Uop, stack: Stack) -> None:
115 null = CWriter.null()
116 for var in reversed(uop.stack.inputs):
117 stack.pop(var, null)
118 offset = stack.base_offset - stack.physical_sp
119 for var in uop.stack.outputs:
120 if var.is_array() and not var.peek and not var.name == "unused":
121 c_offset = offset.to_c()
122 out.emit(f"{var.name} = &stack_pointer[{c_offset}];\n")
123 offset = offset.push(var)
124 for var in uop.stack.outputs:
125 local = Local.undefined(var)
126 stack.push(local)
127 if var.name != "unused" and not var.peek:
128 local.in_local = True
129 if var.is_array():
130 if var.size == "1":
131 out.emit(f"{var.name}[0] = sym_new_not_null(ctx);\n")
132 else:
133 out.emit(f"for (int _i = {var.size}; --_i >= 0;) {{\n")
134 out.emit(f"{var.name}[_i] = sym_new_not_null(ctx);\n")
135 out.emit("}\n")
136 elif var.name == "null":
137 out.emit(f"{var.name} = sym_new_null(ctx);\n")
138 else:
139 out.emit(f"{var.name} = sym_new_not_null(ctx);\n")
140
141
142class OptimizerEmitter(Emitter):

Callers 1

write_uopFunction · 0.85

Calls 7

to_cMethod · 0.80
undefinedMethod · 0.80
nullMethod · 0.45
popMethod · 0.45
is_arrayMethod · 0.45
emitMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…