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

Method visitConstructor

Parser/asdl_c.py:1936–1950  ·  view source on GitHub ↗
(self, cons, name, simple)

Source from the content-addressed store, hash-verified

1934 self.visitConstructor(t, name, simple)
1935
1936 def visitConstructor(self, cons, name, simple):
1937 if cons.fields:
1938 fields = cons.name+"_fields"
1939 else:
1940 fields = "NULL"
1941 self.emit('state->%s_type = make_type(state, "%s", state->%s_type, %s, %d,' %
1942 (cons.name, cons.name, name, fields, len(cons.fields)), 1)
1943 self.emit('%s);' % reflow_c_string(asdl_of(cons.name, cons), 2), 2, reflow=False)
1944 self.emit("if (!state->%s_type) return -1;" % cons.name, 1)
1945 self.emit_defaults(cons.name, cons.fields, 1)
1946 if simple:
1947 self.emit("state->%s_singleton = PyType_GenericNew((PyTypeObject *)"
1948 "state->%s_type, NULL, NULL);" %
1949 (cons.name, cons.name), 1)
1950 self.emit("if (!state->%s_singleton) return -1;" % cons.name, 1)
1951
1952 def emit_defaults(self, name, fields, depth):
1953 for field in fields:

Callers 1

visitSumMethod · 0.95

Calls 4

emit_defaultsMethod · 0.95
reflow_c_stringFunction · 0.85
asdl_ofFunction · 0.85
emitMethod · 0.45

Tested by

no test coverage detected