MCPcopy
hub / github.com/Nuitka/Nuitka / computeExpression

Method computeExpression

nuitka/nodes/ContainerMakingNodes.py:281–312  ·  view source on GitHub ↗
(self, trace_collection)

Source from the content-addressed store, hash-verified

279 return 1
280
281 def computeExpression(self, trace_collection):
282 # For sets, we need to consider hashing
283 are_constants = True
284 are_hashable = True
285
286 for element in self.subnode_elements:
287 if are_constants and not element.isCompileTimeConstant():
288 are_constants = False
289
290 if are_hashable and not element.isKnownToBeHashable():
291 are_hashable = False
292
293 if not are_hashable and not are_constants:
294 break
295
296 if not are_constants:
297 if not are_hashable:
298 trace_collection.onExceptionRaiseExit(BaseException)
299
300 return self, None, None
301
302 simulator = self.getSimulator()
303 assert simulator is not None
304
305 return trace_collection.getCompileTimeComputationResult(
306 node=self,
307 computation=lambda: simulator(
308 element.getCompileTimeConstant() for element in self.subnode_elements
309 ),
310 description="%s with constant arguments." % simulator.__name__.capitalize(),
311 user_provided=True,
312 )
313
314 def mayRaiseException(self, exception_type):
315 for element in self.subnode_elements:

Callers

nothing calls this directly

Calls 6

getSimulatorMethod · 0.95
isCompileTimeConstantMethod · 0.45
isKnownToBeHashableMethod · 0.45
onExceptionRaiseExitMethod · 0.45

Tested by

no test coverage detected