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

Method visitProduct

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

Source from the content-addressed store, hash-verified

591 self.complexSum(sum, name)
592
593 def visitProduct(self, prod, name):
594 ctype = get_c_type(name)
595 self.emit("int", 0)
596 self.emit("obj2ast_%s(struct ast_state *state, PyObject* obj, %s* out, PyArena* arena)" % (name, ctype), 0)
597 self.emit("{", 0)
598 self.emit("PyObject* tmp = NULL;", 1)
599 for f in prod.fields:
600 self.visitFieldDeclaration(f, name, prod=prod, depth=1)
601 for a in prod.attributes:
602 self.visitFieldDeclaration(a, name, prod=prod, depth=1)
603 self.emit("", 0)
604 for f in prod.fields:
605 self.visitField(f, name, prod=prod, depth=1)
606 for a in prod.attributes:
607 self.visitField(a, name, prod=prod, depth=1)
608 args = [f.name for f in prod.fields]
609 args.extend([a.name for a in prod.attributes])
610 self.emit("*out = %s(%s);" % (ast_func_name(name), self.buildArgs(args)), 1)
611 self.emit("if (*out == NULL) goto failed;", 1)
612 self.emit("return 0;", 1)
613 self.emit("failed:", 0)
614 self.emit("Py_XDECREF(tmp);", 1)
615 self.emit("return -1;", 1)
616 self.emit("}", 0)
617 self.emit("", 0)
618
619 def visitFieldDeclaration(self, field, name, sum=None, prod=None, depth=0):
620 ctype = get_c_type(field.type)

Callers

nothing calls this directly

Calls 7

visitFieldDeclarationMethod · 0.95
visitFieldMethod · 0.95
buildArgsMethod · 0.95
get_c_typeFunction · 0.85
ast_func_nameFunction · 0.85
emitMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected