Esempio n. 1
0
    def visit_Call(self, node):
        for i, arg in enumerate(node.args):
            n = self.argument_index(arg)
            if n >= 0:
                func_aliases = self.aliases[node].state[
                    Aliases.access_path(node.func)]

                # expand argument if any
                func_aliases = reduce(
                    lambda x, y: x + (
                        self.node_to_functioneffect.keys()  # all functions
                        if (isinstance(y, ast.Name) and
                            self.argument_index(y) >= 0)
                        else [y]),
                    func_aliases,
                    list())

                for func_alias in func_aliases:
                    # special hook for binded functions
                    if isinstance(func_alias, ast.Call):
                        bound_name = func_alias.args[0].id
                        func_alias = self.global_declarations[bound_name]
                    func_alias = self.node_to_functioneffect[func_alias]
                    predecessors = self.result.predecessors(func_alias)
                    if self.current_function not in predecessors:
                        self.result.add_edge(
                            self.current_function,
                            func_alias,
                            effective_parameters=[],
                            formal_parameters=[])
                    edge = self.result.edge[self.current_function][func_alias]
                    edge["effective_parameters"].append(n)
                    edge["formal_parameters"].append(i)
        self.generic_visit(node)
Esempio n. 2
0
    def visit_Call(self, node):
        l0 = self.generic_visit(node)
        index_corres = dict()
        func = None
        for i, arg in enumerate(node.args):
            n = self.argument_index(arg)
            if n >= 0:
                func_aliases = self.aliases[node].state.get(
                    Aliases.access_path(node.func), [])

                # expand argument if any
                func_aliases = reduce(
                    lambda x, y: x + (
                        self.node_to_functioneffect.keys()  # all functions
                        if (isinstance(y, ast.Name) and self.argument_index(y)
                            >= 0) else [y]),
                    func_aliases,
                    list())

                for func_alias in func_aliases:
                    # special hook for binded functions
                    if isinstance(func_alias, ast.Call):
                        bound_name = func_alias.args[0].id
                        func_alias = self.global_declarations[bound_name]
                    func_alias = self.node_to_functioneffect[func_alias]
                    index_corres[n] = i
                    func = func_alias

        return lambda ctx: l0(ctx) + self.recursive_weight(
            func, index_corres[ctx.index], ctx.path) if (
                (ctx.index in index_corres) and ctx.global_dependencies) else 0
    def visit_Call(self, node):
        l0 = self.generic_visit(node)
        index_corres = dict()
        func = None
        for i, arg in enumerate(node.args):
            n = self.argument_index(arg)
            if n >= 0:
                func_aliases = self.aliases[node].state[
                    Aliases.access_path(node.func)]

                # expand argument if any
                func_aliases = reduce(
                    lambda x, y: x + (
                        self.node_to_functioneffect.keys()  # all functions
                        if (isinstance(y, ast.Name)
                            and self.argument_index(y) >= 0)
                        else [y]),
                    func_aliases,
                    list())

                for func_alias in func_aliases:
                    # special hook for binded functions
                    if isinstance(func_alias, ast.Call):
                        bound_name = func_alias.args[0].id
                        func_alias = self.global_declarations[bound_name]
                    func_alias = self.node_to_functioneffect[func_alias]
                    index_corres[n] = i
                    func = func_alias

        return lambda ctx: l0(ctx) + self.recursive_weight(
            func, index_corres[ctx.index], ctx.path) if (
            (ctx.index in index_corres) and ctx.global_dependencies) else 0
Esempio n. 4
0
    def visit_Call(self, node):
        for i, arg in enumerate(node.args):
            n = self.argument_index(arg)
            if n >= 0:
                func_aliases = self.aliases[node].state[
                    Aliases.access_path(node.func)]

                # expand argument if any
                func_aliases = reduce(
                    lambda x, y: x + (
                        self.node_to_functioneffect.keys()  # all functions
                        if (isinstance(y, ast.Name) and
                            self.argument_index(y) >= 0)
                        else [y]),
                    func_aliases,
                    list())

                for func_alias in func_aliases:
                    # special hook for binded functions
                    if isinstance(func_alias, ast.Call):
                        bound_name = func_alias.args[0].id
                        func_alias = self.global_declarations[bound_name]
                    func_alias = self.node_to_functioneffect[func_alias]
                    predecessors = self.result.predecessors(func_alias)
                    if self.current_function not in predecessors:
                        self.result.add_edge(
                            self.current_function,
                            func_alias,
                            effective_parameters=[],
                            formal_parameters=[])
                    edge = self.result.edge[self.current_function][func_alias]
                    edge["effective_parameters"].append(n)
                    edge["formal_parameters"].append(i)
        self.generic_visit(node)
Esempio n. 5
0
 def visit_Call(self, node):
     # try to get all aliases of the function, if possible
     # else use [] as a fallback
     ap = Aliases.access_path(node.func)
     func_aliases = self.aliases[node].state.get(ap, [])
     # expand argument if any
     func_aliases = reduce(
         lambda x, y: x + (self.node_to_functioneffect.keys()  # all funcs
                           if isinstance(y, ast.Name) else [y]),
         func_aliases,
         list())
     for func_alias in func_aliases:
         # special hook for binded functions
         if isinstance(func_alias, ast.Call):
             bound_name = func_alias.args[0].id
             func_alias = self.global_declarations[bound_name]
         func_alias = self.node_to_functioneffect[func_alias]
         self.result.add_edge(self.current_function, func_alias)
     self.generic_visit(node)
Esempio n. 6
0
 def visit_Call(self, node):
     # try to get all aliases of the function, if possible
     # else use [] as a fallback
     ap = Aliases.access_path(node.func)
     func_aliases = self.aliases[node].state.get(ap, [])
     # expand argument if any
     func_aliases = reduce(
         lambda x, y: x + (
             self.node_to_functioneffect.keys()  # all funcs
             if isinstance(y, ast.Name) else [y]),
         func_aliases,
         list())
     for func_alias in func_aliases:
         # special hook for binded functions
         if isinstance(func_alias, ast.Call):
             bound_name = func_alias.args[0].id
             func_alias = self.global_declarations[bound_name]
         func_alias = self.node_to_functioneffect[func_alias]
         self.result.add_edge(self.current_function, func_alias)
     self.generic_visit(node)
Esempio n. 7
0
 def visit_Attribute(self, node):
     return Aliases.access_path(node).isconst() and self.add(node)
 def visit_Attribute(self, node):
     return Aliases.access_path(node).isconst() and self.add(node)