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

Method visitSum

Parser/asdl_c.py:2067–2083  ·  view source on GitHub ↗
(self, sum, name)

Source from the content-addressed store, hash-verified

2065 self.emit("", 0)
2066
2067 def visitSum(self, sum, name):
2068 if is_simple(sum):
2069 self.simpleSum(sum, name)
2070 return
2071 self.func_begin(name)
2072 self.emit("switch (o->kind) {", 1)
2073 for i in range(len(sum.types)):
2074 t = sum.types[i]
2075 self.visitConstructor(t, i + 1, name)
2076 self.emit("}", 1)
2077 for a in sum.attributes:
2078 self.emit("value = ast2obj_%s(state, o->%s);" % (a.type, a.name), 1)
2079 self.emit("if (!value) goto failed;", 1)
2080 self.emit('if (PyObject_SetAttr(result, state->%s, value) < 0)' % a.name, 1)
2081 self.emit('goto failed;', 2)
2082 self.emit('Py_DECREF(value);', 1)
2083 self.func_end()
2084
2085 def simpleSum(self, sum, name):
2086 self.emit("PyObject* ast2obj_%s(struct ast_state *state, %s_ty o)" % (name, name), 0)

Callers

nothing calls this directly

Calls 6

simpleSumMethod · 0.95
func_beginMethod · 0.95
emitMethod · 0.95
visitConstructorMethod · 0.95
func_endMethod · 0.95
is_simpleFunction · 0.85

Tested by

no test coverage detected