Example #1
0
    def _get_external_funcs(self):
        """
        Get a list of external functions called in the macros.
        """

        # Get the names of all called functions, local functions, and defined variables.
        call_visitor = function_call_visitor()
        defn_visitor = function_defn_visitor()
        var_visitor = var_defn_visitor()
        import_visitor = function_import_visitor()
        for module in self.modules:
            module.accept(call_visitor)
            module.accept(defn_visitor)
            module.accept(var_visitor)
            module.accept(import_visitor)

        # Eliminate variables and local functions from the list of called functions.
        r = []
        for f in call_visitor.called_funcs:
            if ((f in defn_visitor.funcs) or (f in var_visitor.variables)
                    or (len(f) == 0) or (("." in f) and (not "Shell" in f))):
                continue

            # Resolve aliases of imported functions to the actual function.
            if (f in import_visitor.aliases):
                if (len(import_visitor.funcs[f]) > 0):
                    r.append(import_visitor.funcs[f])
                continue

            # Regular local function call.
            r.append(f)

        # Sort and return the fingerprint function list.
        r.sort()
        return r
Example #2
0
    def _get_external_funcs(self):
        """
        Get a list of external functions called in the macros.
        """

        # Get the names of all called functions, local functions, and defined variables.
        call_visitor = function_call_visitor()
        defn_visitor = function_defn_visitor()
        var_visitor = var_defn_visitor()
        for module in self.modules:
            module.accept(call_visitor)
            module.accept(defn_visitor)
            module.accept(var_visitor)
        """
        print("************ CALLED FUNCS *************************")
        print(call_visitor.called_funcs)
        print("************ DEFINED FUNCS *************************")
        print(defn_visitor.funcs)
        print("************ DEFINED VARIABLES *************************")
        print(var_visitor.variables)
        """

        # Eliminate variables and local functions from the list of called functions.
        r = []
        for f in call_visitor.called_funcs:
            if ((f in defn_visitor.funcs) or (f in var_visitor.variables)
                    or (len(f) == 0) or (("." in f) and (not "Shell" in f))):
                continue
            r.append(f)
        r.sort()
        return r