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

Method visitProduct

Parser/asdl_c.py:2096–2109  ·  view source on GitHub ↗
(self, prod, name)

Source from the content-addressed store, hash-verified

2094 self.emit("}", 0)
2095
2096 def visitProduct(self, prod, name):
2097 self.func_begin(name)
2098 self.emit("tp = (PyTypeObject *)state->%s_type;" % name, 1)
2099 self.emit("result = PyType_GenericNew(tp, NULL, NULL);", 1);
2100 self.emit("if (!result) return NULL;", 1)
2101 for field in prod.fields:
2102 self.visitField(field, name, 1, True)
2103 for a in prod.attributes:
2104 self.emit("value = ast2obj_%s(state, o->%s);" % (a.type, a.name), 1)
2105 self.emit("if (!value) goto failed;", 1)
2106 self.emit("if (PyObject_SetAttr(result, state->%s, value) < 0)" % a.name, 1)
2107 self.emit('goto failed;', 2)
2108 self.emit('Py_DECREF(value);', 1)
2109 self.func_end()
2110
2111 def visitConstructor(self, cons, enum, name):
2112 self.emit("case %s_kind:" % cons.name, 1)

Callers

nothing calls this directly

Calls 4

func_beginMethod · 0.95
emitMethod · 0.95
visitFieldMethod · 0.95
func_endMethod · 0.95

Tested by

no test coverage detected