Skip to content

Instantly share code, notes, and snippets.

View jgabriellima's full-sized avatar

João Gabriel Lima jgabriellima

View GitHub Profile
@jgabriellima
jgabriellima / interprocedural control flow graph (ICFG)
Created April 3, 2024 21:25
Call graphs (CG) and control flow graphs (CFG) consist of nodes and edges. CG is interprocedural, nodes represent subroutines (methods, functions, ...), while edges represent the relationship caller-called between two subroutines (e.g., A->B, "A" is the caller subroutine, while "B" is the called subroutine). CFG is intraprocedural, nodes represe…
import ast
import jedi
import os
class CodeAnalyzer(ast.NodeVisitor):
def __init__(self, source_code, project_root, file_path, target_function):
self.source_code = source_code
self.file_path = file_path
self.project_root = project_root