예제 #1
0
    def computeFunctionRaw(self, trace_collection):
        from nuitka.optimizations.TraceCollections import TraceCollectionFunction

        trace_collection = TraceCollectionFunction(parent=trace_collection,
                                                   function_body=self)
        old_collection = self.setTraceCollection(trace_collection)

        self.computeFunction(trace_collection)

        trace_collection.updateVariablesFromCollection(old_collection)
예제 #2
0
    def computeFunctionRaw(self, trace_collection):
        from nuitka.optimizations.TraceCollections import TraceCollectionFunction

        trace_collection = TraceCollectionFunction(
            parent=trace_collection, function_body=self
        )
        old_collection = self.setTraceCollection(trace_collection)

        self.computeFunction(trace_collection)

        trace_collection.updateVariablesFromCollection(old_collection)
예제 #3
0
    def computeExpressionRaw(self, trace_collection):
        function_body = self.getFunctionBody()

        owning_module = function_body.getParentModule()

        # Make sure the owning module is added to the used set. This is most
        # important for helper functions, or modules, which otherwise have
        # become unused.
        from nuitka.ModuleRegistry import addUsedModule
        addUsedModule(owning_module)

        owning_module.addUsedFunction(function_body)

        from nuitka.optimizations.TraceCollections import \
            TraceCollectionFunction

        # TODO: Doesn't this mean, we can do this multiple times by doing it
        # in the reference. We should do it in the body, and there we should
        # limit us to only doing it once per module run, e.g. being based on
        # presence in used functions of the module already.
        trace_collection = TraceCollectionFunction(parent=trace_collection,
                                                   function_body=function_body)
        old_collection = function_body.setTraceCollection(trace_collection)

        statements_sequence = function_body.getBody()

        if statements_sequence is not None and \
           not statements_sequence.getStatements():
            function_body.setStatements(None)
            statements_sequence = None

        if statements_sequence is not None:
            result = statements_sequence.computeStatementsSequence(
                trace_collection=trace_collection)

            if result is not statements_sequence:
                function_body.setBody(result)

        trace_collection.updateVariablesFromCollection(old_collection)

        # TODO: Function collection may now know something.
        return self, None, None