MCPcopy Index your code
hub / github.com/rocky/python-uncompyle6 / n_call

Function n_call

uncompyle6/semantics/customize35.py:144–210  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

142 self.n_build_list_unpack = n_build_list_unpack
143
144 def n_call(node):
145 p = self.prec
146 self.prec = 100
147 mapping = self._get_mapping(node)
148 table = mapping[0]
149 key = node
150 for i in mapping[1:]:
151 key = key[i]
152 pass
153 if key.kind.startswith("CALL_FUNCTION_VAR_KW"):
154 # Python 3.5 changes the stack position of
155 # *args: kwargs come after *args whereas
156 # in earlier Pythons, *args is at the end
157 # which simplifies things from our
158 # perspective. Python 3.6+ replaces
159 # CALL_FUNCTION_VAR_KW with
160 # CALL_FUNCTION_EX We will just swap the
161 # order to make it look like earlier
162 # Python 3.
163 entry = table[key.kind]
164 kwarg_pos = entry[2][1]
165 args_pos = kwarg_pos - 1
166 # Put last node[args_pos] after subsequent kwargs
167 while node[kwarg_pos] == "kwarg" and kwarg_pos < len(node):
168 # swap node[args_pos] with node[kwargs_pos]
169 node[kwarg_pos], node[args_pos] = node[args_pos], node[kwarg_pos]
170 args_pos = kwarg_pos
171 kwarg_pos += 1
172 elif key.kind.startswith("CALL_FUNCTION_VAR"):
173 # CALL_FUNCTION_VAR's top element of the stack contains
174 # the variable argument list, then comes
175 # annotation args, then keyword args.
176 # In the most least-top-most stack entry, but position 1
177 # in node order, the positional args.
178 argc = node[-1].attr
179 nargs = argc & 0xFF
180 kwargs = (argc >> 8) & 0xFF
181 # FIXME: handle annotation args
182 if nargs > 0:
183 template = ("%c(%P, ", 0, (1, nargs + 1, ", ", 100))
184 else:
185 template = ("%c(", 0)
186 self.template_engine(template, node)
187
188 args_node = node[-2]
189 if args_node in ("pos_arg", "expr"):
190 args_node = args_node[0]
191 if args_node == "build_list_unpack":
192 template = ("*%P)", (0, len(args_node) - 1, ", *", 100))
193 self.template_engine(template, args_node)
194 else:
195 if len(node) - nargs > 3:
196 template = (
197 "*%c, %P)",
198 nargs + 1,
199 (nargs + kwargs + 1, -1, ", ", 100),
200 )
201 else:

Callers

nothing calls this directly

Calls 4

_get_mappingMethod · 0.45
template_engineMethod · 0.45
defaultMethod · 0.45

Tested by

no test coverage detected