pyflow-analysis 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyflow/__init__.py +22 -0
- pyflow/_pyflow.py +50 -0
- pyflow/analysis/__init__.py +14 -0
- pyflow/analysis/alias/__init__.py +3 -0
- pyflow/analysis/alias/flow_sensitive/__init__.py +148 -0
- pyflow/analysis/alias/flow_sensitive/_transfer_calls.py +3493 -0
- pyflow/analysis/alias/flow_sensitive/_transfer_ops.py +1969 -0
- pyflow/analysis/alias/flow_sensitive/abstraction.py +1632 -0
- pyflow/analysis/alias/flow_sensitive/heap_analysis.py +280 -0
- pyflow/analysis/alias/flow_sensitive/heap_effects.py +1209 -0
- pyflow/analysis/alias/flow_sensitive/heap_state.py +381 -0
- pyflow/analysis/alias/flow_sensitive/heap_summary.py +299 -0
- pyflow/analysis/alias/flow_sensitive/intrinsics.py +948 -0
- pyflow/analysis/alias/flow_sensitive/model.py +449 -0
- pyflow/analysis/alias/flow_sensitive/points_to_graph.py +722 -0
- pyflow/analysis/alias/flow_sensitive/transfer.py +1483 -0
- pyflow/analysis/alias/kcfa/__init__.py +33 -0
- pyflow/analysis/alias/kcfa/_pythonstan/__init__.py +2 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/__init__.py +1 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/__init__.py +53 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/logging.py +490 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/operation.py +1601 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/pointer_adapter.py +353 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/solver.py +559 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/state.py +701 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/ai/value.py +804 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/analysis.py +86 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/class_hierarchy.py +83 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/closure.py +69 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/dataflow/__init__.py +4 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/dataflow/analysis.py +58 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/dataflow/driver.py +38 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/dataflow/liveness.py +33 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/dataflow/reaching_definition.py +52 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/dataflow/solver.py +178 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/defuse.py +46 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/__init__.py +18 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/__init__.py +110 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/analysis.py +382 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/builtin_api_handler.py +1872 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/call_graph_analyzer.py +289 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/class_hierarchy.py +304 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/config.py +139 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/constraints.py +576 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/context.py +496 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/context_selector.py +297 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/debug_monitor.py +34 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/heap_model.py +221 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/ir_translator.py +1181 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/libs/__init__.py +2 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/libs/math.py +244 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/module_analysis.py +269 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/module_summary.py +191 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/object.py +685 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/pointer_flow_graph.py +282 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/points_to_set.py +301 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/__init__.py +21 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/attribute_semantics.py +512 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/compose_processor.py +46 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/container.py +128 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/generator.py +353 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/normal_call.py +664 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/processor.py +36 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/processor/super_resolve.py +131 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/pta_query_adapter.py +329 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/solver.py +917 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/solver_interface.py +76 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/state.py +735 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/unknown_tracker.py +126 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/pointer/kcfa/variable.py +144 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/scope/__init__.py +2 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/scope/analysis.py +37 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/scope/closure.py +81 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/__init__.py +8 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/block_cfg.py +133 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/cfg.py +95 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/driver.py +26 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/__init__.py +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/base.py +112 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/baseprocess.py +524 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/icfg.py +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/icfg_pre_transform.py +69 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/icfg_transform.py +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/postprocessor.py +308 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/icfg/preprocessor.py +375 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/ir.py +361 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/three_address.py +1161 -0
- pyflow/analysis/alias/kcfa/_pythonstan/analysis/transform/transform.py +27 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/__init__.py +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/call_graph/__init__.py +2 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/call_graph/call_edge.py +45 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/call_graph/call_graph.py +77 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/cfg/__init__.py +3 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/cfg/base_block.py +83 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/cfg/cfg.py +200 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/cfg/dump.py +20 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/cfg/edges.py +162 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/cfg/visualize.py +112 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/dominator_tree.py +126 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/graph.py +81 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/icfg/__init__.py +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/graph/icfg/icfg.py +98 -0
- pyflow/analysis/alias/kcfa/_pythonstan/ir/__init__.py +2 -0
- pyflow/analysis/alias/kcfa/_pythonstan/ir/ir_statements.py +1579 -0
- pyflow/analysis/alias/kcfa/_pythonstan/ir/ir_visitor.py +21 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/LICENSE.pythonstan +28 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/README.md +99 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/abc.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/base64.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/bisect.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/collections.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/contextlib.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/copy.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/csv.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/dataclasses.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/datetime.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/email.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/enum.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/fnmatch.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/functools.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/glob.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/hashlib.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/heapq.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/hmac.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/http.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/importlib.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/inspect.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/io.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/itertools.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/json.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/logging.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/math.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/mimetypes.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/operator.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/os.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/pathlib.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/pickle.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/random.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/re.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/secrets.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/shutil.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/somelib.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/tempfile.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/time.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/traceback.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/types.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/uuid.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/warnings.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/__pycache__/weakref.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/abc.py +80 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/base64.py +62 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/bisect.py +52 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/collections.py +187 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/contextlib.py +113 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/copy.py +15 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/csv.py +163 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/dataclasses.py +150 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/datetime.py +171 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/email.py +270 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/enum.py +144 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/fnmatch.py +14 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/functools.py +84 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/glob.py +10 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/hashlib.py +74 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/heapq.py +91 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/hmac.py +31 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/http.py +317 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/importlib.py +126 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/inspect.py +246 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/io.py +471 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/itertools.py +164 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/json.py +80 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/logging.py +193 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/math.py +244 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/mimetypes.py +119 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/operator.py +310 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/os.py +286 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/pathlib.py +196 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/pickle.py +153 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/random.py +125 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/re.py +125 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/secrets.py +29 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/shutil.py +99 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/somelib.py +2 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/tempfile.py +76 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/time.py +65 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/traceback.py +151 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/types.py +247 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/urllib/__init__.py +1 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/urllib/__pycache__/__init__.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/urllib/__pycache__/parse.cpython-313.pyc +0 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/urllib/parse.py +221 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/uuid.py +34 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/warnings.py +82 -0
- pyflow/analysis/alias/kcfa/_pythonstan/stubs/stdlib/weakref.py +272 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/__init__.py +1 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/ast_rename.py +35 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/common.py +70 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/persistent_rb_tree.py +364 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/temp_var_generator.py +68 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/toposort.py +63 -0
- pyflow/analysis/alias/kcfa/_pythonstan/utils/var_collector.py +72 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/__init__.py +1 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/analysis_manager.py +141 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/class_hierarchy.py +56 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/config.py +93 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/import_manager.py +16 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/namespace.py +327 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/pipeline.py +153 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/scope_manager.py +133 -0
- pyflow/analysis/alias/kcfa/_pythonstan/world/world.py +49 -0
- pyflow/analysis/alias/kcfa/bridge.py +136 -0
- pyflow/analysis/astcollector.py +171 -0
- pyflow/analysis/cache/incremental.py +226 -0
- pyflow/analysis/callgraph/__init__.py +58 -0
- pyflow/analysis/callgraph/ast_based.py +184 -0
- pyflow/analysis/callgraph/callgraph.py +86 -0
- pyflow/analysis/callgraph/constraint_based/__init__.py +26 -0
- pyflow/analysis/callgraph/constraint_based/_analyzer.py +1976 -0
- pyflow/analysis/callgraph/constraint_based/_collector.py +704 -0
- pyflow/analysis/callgraph/constraint_based/_evaluator.py +984 -0
- pyflow/analysis/callgraph/constraint_based/_loader.py +115 -0
- pyflow/analysis/callgraph/constraint_based/_resolver.py +2852 -0
- pyflow/analysis/callgraph/constraint_based/api.py +233 -0
- pyflow/analysis/callgraph/constraint_based/engine.py +717 -0
- pyflow/analysis/callgraph/constraint_based/model.py +303 -0
- pyflow/analysis/callgraph/formats.py +99 -0
- pyflow/analysis/callgraph/pycg_based.py +273 -0
- pyflow/analysis/cdg/__init__.py +52 -0
- pyflow/analysis/cdg/construction.py +256 -0
- pyflow/analysis/cdg/dump.py +415 -0
- pyflow/analysis/cdg/graph.py +456 -0
- pyflow/analysis/cfg/__init__.py +38 -0
- pyflow/analysis/cfg/dfs.py +55 -0
- pyflow/analysis/cfg/dom.py +243 -0
- pyflow/analysis/cfg/dump.py +322 -0
- pyflow/analysis/cfg/expandphi.py +113 -0
- pyflow/analysis/cfg/gc.py +93 -0
- pyflow/analysis/cfg/graph.py +878 -0
- pyflow/analysis/cfg/inline.py +337 -0
- pyflow/analysis/cfg/killflow.py +360 -0
- pyflow/analysis/cfg/optimize.py +164 -0
- pyflow/analysis/cfg/simplify.py +19 -0
- pyflow/analysis/cfg/ssa.py +693 -0
- pyflow/analysis/cfg/ssatransform.py +13 -0
- pyflow/analysis/cfg/structuralanalysis.py +422 -0
- pyflow/analysis/cfg/transform.py +527 -0
- pyflow/analysis/cpa/__init__.py +657 -0
- pyflow/analysis/cpa/base.py +430 -0
- pyflow/analysis/cpa/codecloner.py +262 -0
- pyflow/analysis/cpa/constraintextractor.py +797 -0
- pyflow/analysis/cpa/constraints.py +1071 -0
- pyflow/analysis/cpa/simpleimagebuilder.py +299 -0
- pyflow/analysis/cpasignature.py +132 -0
- pyflow/analysis/cpg/__init__.py +93 -0
- pyflow/analysis/cpg/build.py +221 -0
- pyflow/analysis/cpg/dump.py +102 -0
- pyflow/analysis/cpg/graph.py +1877 -0
- pyflow/analysis/cpg/persist.py +346 -0
- pyflow/analysis/cpg/profiles.py +286 -0
- pyflow/analysis/cpg/rules.py +365 -0
- pyflow/analysis/cpg/taint.py +1934 -0
- pyflow/analysis/dataflowIR/__init__.py +6 -0
- pyflow/analysis/dataflowIR/annotations.py +174 -0
- pyflow/analysis/dataflowIR/convert.py +795 -0
- pyflow/analysis/dataflowIR/dump.py +443 -0
- pyflow/analysis/dataflowIR/graph.py +1648 -0
- pyflow/analysis/dataflowIR/ordering.py +134 -0
- pyflow/analysis/dataflowIR/predicate.py +233 -0
- pyflow/analysis/dataflowIR/transform/__init__.py +15 -0
- pyflow/analysis/dataflowIR/transform/dce.py +215 -0
- pyflow/analysis/dataflowIR/transform/loadelimination.py +185 -0
- pyflow/analysis/dataflowIR/traverse.py +91 -0
- pyflow/analysis/ddg/__init__.py +53 -0
- pyflow/analysis/ddg/construction.py +310 -0
- pyflow/analysis/ddg/dump.py +218 -0
- pyflow/analysis/ddg/graph.py +295 -0
- pyflow/analysis/dump/__init__.py +15 -0
- pyflow/analysis/dump/dumpgraphs.py +93 -0
- pyflow/analysis/dump/dumpreport.py +841 -0
- pyflow/analysis/dump/dumputil.py +98 -0
- pyflow/analysis/fsdf/__init__.py +1107 -0
- pyflow/analysis/fsdf/canonicalset.py +176 -0
- pyflow/analysis/fsdf/canonicaltree.py +1071 -0
- pyflow/analysis/ifds/__init__.py +284 -0
- pyflow/analysis/ifds/annotation_fallback.py +21 -0
- pyflow/analysis/ifds/annotation_synthesis.py +803 -0
- pyflow/analysis/ifds/api.py +567 -0
- pyflow/analysis/ifds/backward_solver.py +328 -0
- pyflow/analysis/ifds/cfg_adapter.py +1575 -0
- pyflow/analysis/ifds/clients/_call_model.py +166 -0
- pyflow/analysis/ifds/clients/_client_common.py +1617 -0
- pyflow/analysis/ifds/clients/flow_path_collector.py +159 -0
- pyflow/analysis/ifds/clients/library_presets.py +1134 -0
- pyflow/analysis/ifds/clients/nullness.py +754 -0
- pyflow/analysis/ifds/clients/registry/__init__.py +26 -0
- pyflow/analysis/ifds/clients/registry/loader.py +688 -0
- pyflow/analysis/ifds/clients/registry/validate.py +37 -0
- pyflow/analysis/ifds/clients/taint.py +782 -0
- pyflow/analysis/ifds/clients/typestate.py +1550 -0
- pyflow/analysis/ifds/clients/typestate_engine.py +534 -0
- pyflow/analysis/ifds/diagnostics.py +29 -0
- pyflow/analysis/ifds/preparation.py +97 -0
- pyflow/analysis/ifds/problem.py +363 -0
- pyflow/analysis/ifds/queries.py +142 -0
- pyflow/analysis/ifds/reporting.py +289 -0
- pyflow/analysis/ifds/shadow_scan.py +349 -0
- pyflow/analysis/ifds/solver.py +1495 -0
- pyflow/analysis/ifds/supergraph.py +186 -0
- pyflow/analysis/ifds/transfers.py +187 -0
- pyflow/analysis/ipa/__init__.py +77 -0
- pyflow/analysis/ipa/calling/__init__.py +17 -0
- pyflow/analysis/ipa/calling/callbinder.py +93 -0
- pyflow/analysis/ipa/calling/cpa.py +197 -0
- pyflow/analysis/ipa/calling/transfer.py +208 -0
- pyflow/analysis/ipa/constraintextractor.py +804 -0
- pyflow/analysis/ipa/constraints/__init__.py +18 -0
- pyflow/analysis/ipa/constraints/base.py +66 -0
- pyflow/analysis/ipa/constraints/calls.py +424 -0
- pyflow/analysis/ipa/constraints/flow.py +445 -0
- pyflow/analysis/ipa/constraints/node.py +299 -0
- pyflow/analysis/ipa/constraints/qualifiers.py +17 -0
- pyflow/analysis/ipa/constraints/split.py +178 -0
- pyflow/analysis/ipa/dump.py +246 -0
- pyflow/analysis/ipa/entrypointbuilder.py +52 -0
- pyflow/analysis/ipa/escape/__init__.py +19 -0
- pyflow/analysis/ipa/escape/objectescape.py +77 -0
- pyflow/analysis/ipa/ipanalysis.py +319 -0
- pyflow/analysis/ipa/memory/__init__.py +16 -0
- pyflow/analysis/ipa/memory/extractorpolicy.py +38 -0
- pyflow/analysis/ipa/memory/storegraphpolicy.py +17 -0
- pyflow/analysis/ipa/model/__init__.py +18 -0
- pyflow/analysis/ipa/model/context.py +277 -0
- pyflow/analysis/ipa/model/invocation.py +159 -0
- pyflow/analysis/ipa/model/object.py +102 -0
- pyflow/analysis/ipa/model/objectname.py +77 -0
- pyflow/analysis/ipa/model/region.py +51 -0
- pyflow/analysis/ipa/summary/__init__.py +120 -0
- pyflow/analysis/ir_utils.py +215 -0
- pyflow/analysis/lifetimeanalysis/__init__.py +935 -0
- pyflow/analysis/lifetimeanalysis/database/__init__.py +17 -0
- pyflow/analysis/lifetimeanalysis/database/base.py +72 -0
- pyflow/analysis/lifetimeanalysis/database/lattice.py +189 -0
- pyflow/analysis/lifetimeanalysis/database/mapping.py +174 -0
- pyflow/analysis/lifetimeanalysis/database/structure.py +224 -0
- pyflow/analysis/lifetimeanalysis/database/tupleset.py +141 -0
- pyflow/analysis/numbering/__init__.py +17 -0
- pyflow/analysis/numbering/dataflow.py +214 -0
- pyflow/analysis/numbering/dominance.py +120 -0
- pyflow/analysis/numbering/readmodify.py +251 -0
- pyflow/analysis/numbering/ssa.py +604 -0
- pyflow/analysis/pdg/__init__.py +55 -0
- pyflow/analysis/pdg/construction.py +447 -0
- pyflow/analysis/pdg/cypher.py +1150 -0
- pyflow/analysis/pdg/dump.py +129 -0
- pyflow/analysis/pdg/graph.py +308 -0
- pyflow/analysis/programculler.py +224 -0
- pyflow/analysis/shape/__init__.py +466 -0
- pyflow/analysis/shape/constraintbuilder.py +933 -0
- pyflow/analysis/shape/constraints.py +510 -0
- pyflow/analysis/shape/dataflow.py +202 -0
- pyflow/analysis/shape/model/__init__.py +27 -0
- pyflow/analysis/shape/model/canonical.py +137 -0
- pyflow/analysis/shape/model/configuration.py +78 -0
- pyflow/analysis/shape/model/expressions.py +268 -0
- pyflow/analysis/shape/model/pathinformation.py +645 -0
- pyflow/analysis/shape/model/referencecount.py +212 -0
- pyflow/analysis/shape/model/secondary.py +31 -0
- pyflow/analysis/shape/model/slots.py +69 -0
- pyflow/analysis/shape/regionanalysis.py +152 -0
- pyflow/analysis/shape/transferfunctions.py +353 -0
- pyflow/analysis/storegraph/__init__.py +19 -0
- pyflow/analysis/storegraph/annotations.py +70 -0
- pyflow/analysis/storegraph/canonicalobjects.py +329 -0
- pyflow/analysis/storegraph/extendedtypes.py +311 -0
- pyflow/analysis/storegraph/setmanager.py +123 -0
- pyflow/analysis/storegraph/storegraph.py +577 -0
- pyflow/analysis/tools.py +112 -0
- pyflow/analysis/typeinfo/__init__.py +93 -0
- pyflow/analysis/typeinfo/_config.py +84 -0
- pyflow/analysis/typeinfo/annotation_resolver.py +483 -0
- pyflow/analysis/typeinfo/collector.py +361 -0
- pyflow/analysis/typeinfo/constants.py +378 -0
- pyflow/analysis/typeinfo/docstring_parser.py +289 -0
- pyflow/analysis/typeinfo/generic_binder.py +145 -0
- pyflow/analysis/typeinfo/gradual_typing.py +255 -0
- pyflow/analysis/typeinfo/models.py +43 -0
- pyflow/analysis/typeinfo/service.py +774 -0
- pyflow/analysis/typeinfo/string_subtype_inference.py +113 -0
- pyflow/analysis/typeinfo/string_subtypes.py +150 -0
- pyflow/analysis/typeinfo/stub_loader.py +667 -0
- pyflow/analysis/typeinfo/type_inference.py +747 -0
- pyflow/analysis/typeinfo/type_utils.py +361 -0
- pyflow/analysis/typeinfo/typesystem.py +2346 -0
- pyflow/analysis/typeinfo/typetracing.py +672 -0
- pyflow/api/__init__.py +94 -0
- pyflow/api/entrypoints/__init__.py +36 -0
- pyflow/api/entrypoints/declaration.py +345 -0
- pyflow/api/entrypoints/entry_point.py +59 -0
- pyflow/api/entrypoints/wrappers.py +83 -0
- pyflow/api/queries/__init__.py +65 -0
- pyflow/api/queries/_cfg_utils.py +53 -0
- pyflow/api/queries/_dataflow_ipa.py +29 -0
- pyflow/api/queries/_dataflow_reaching_defs.py +105 -0
- pyflow/api/queries/_dataflow_store_graph.py +152 -0
- pyflow/api/queries/_dataflow_taint.py +76 -0
- pyflow/api/queries/_models.py +177 -0
- pyflow/api/queries/call_graph.py +168 -0
- pyflow/api/queries/capabilities.py +106 -0
- pyflow/api/queries/context.py +152 -0
- pyflow/api/queries/control_flow.py +35 -0
- pyflow/api/queries/data_flow.py +157 -0
- pyflow/api/queries/engine.py +201 -0
- pyflow/api/queries/localization.py +8 -0
- pyflow/api/queries/service.py +339 -0
- pyflow/api/queries/tasks/__init__.py +8 -0
- pyflow/api/queries/tasks/code_localization.py +425 -0
- pyflow/api/queries/tasks/test_generation.py +338 -0
- pyflow/api/queries/test_generation.py +8 -0
- pyflow/application/__init__.py +109 -0
- pyflow/application/context.py +116 -0
- pyflow/application/errors.py +55 -0
- pyflow/application/makefile.py +213 -0
- pyflow/application/passes.py +515 -0
- pyflow/application/passmanager.py +755 -0
- pyflow/application/pipeline.py +459 -0
- pyflow/application/program.py +147 -0
- pyflow/checker/__init__.py +51 -0
- pyflow/checker/formatters/__init__.py +14 -0
- pyflow/checker/formatters/json.py +153 -0
- pyflow/checker/formatters/sarif.py +263 -0
- pyflow/checker/formatters/text.py +168 -0
- pyflow/checker/formatters/utils.py +17 -0
- pyflow/checker/llm/__init__.py +19 -0
- pyflow/checker/llm/exploit.py +129 -0
- pyflow/checker/llm/judge.py +105 -0
- pyflow/checker/llm/llm_utils.py +131 -0
- pyflow/checker/microbench.py +338 -0
- pyflow/checker/pattern/__init__.py +14 -0
- pyflow/checker/pattern/checkers/__init__.py +34 -0
- pyflow/checker/pattern/checkers/aws_security.py +234 -0
- pyflow/checker/pattern/checkers/blacklist_calls.py +54 -0
- pyflow/checker/pattern/checkers/blacklist_imports.py +73 -0
- pyflow/checker/pattern/checkers/class_pollution.py +459 -0
- pyflow/checker/pattern/checkers/command_injection.py +340 -0
- pyflow/checker/pattern/checkers/deserialization.py +373 -0
- pyflow/checker/pattern/checkers/django_security.py +285 -0
- pyflow/checker/pattern/checkers/exception_handling.py +317 -0
- pyflow/checker/pattern/checkers/exec_use.py +16 -0
- pyflow/checker/pattern/checkers/fastapi_security.py +291 -0
- pyflow/checker/pattern/checkers/flask_security.py +264 -0
- pyflow/checker/pattern/checkers/hardcoded_password.py +239 -0
- pyflow/checker/pattern/checkers/hardcoded_secrets.py +279 -0
- pyflow/checker/pattern/checkers/ldap_injection.py +281 -0
- pyflow/checker/pattern/checkers/path_traversal.py +124 -0
- pyflow/checker/pattern/checkers/shell_injection.py +46 -0
- pyflow/checker/pattern/checkers/sql_injection.py +170 -0
- pyflow/checker/pattern/checkers/sql_injection_enhanced.py +574 -0
- pyflow/checker/pattern/checkers/ssrf.py +419 -0
- pyflow/checker/pattern/checkers/template_security.py +310 -0
- pyflow/checker/pattern/checkers/weak_crypto.py +89 -0
- pyflow/checker/pattern/checkers/xxe_vulnerabilities.py +155 -0
- pyflow/checker/pattern/core/__init__.py +17 -0
- pyflow/checker/pattern/core/blacklist.py +569 -0
- pyflow/checker/pattern/core/config.py +15 -0
- pyflow/checker/pattern/core/constants.py +52 -0
- pyflow/checker/pattern/core/context.py +276 -0
- pyflow/checker/pattern/core/issue.py +325 -0
- pyflow/checker/pattern/core/manager.py +253 -0
- pyflow/checker/pattern/core/metrics.py +78 -0
- pyflow/checker/pattern/core/node_visitor.py +430 -0
- pyflow/checker/pattern/core/test_loader.py +41 -0
- pyflow/checker/pattern/core/test_properties.py +54 -0
- pyflow/checker/pattern/core/test_set.py +33 -0
- pyflow/checker/pattern/core/tester.py +244 -0
- pyflow/checker/pattern/core/utils.py +167 -0
- pyflow/checker/quality.py +374 -0
- pyflow/checker/semantic/__init__.py +16 -0
- pyflow/checker/semantic/core/__init__.py +23 -0
- pyflow/checker/semantic/core/base.py +26 -0
- pyflow/checker/semantic/core/context.py +270 -0
- pyflow/checker/semantic/core/issue.py +9 -0
- pyflow/checker/semantic/core/manager.py +150 -0
- pyflow/checker/semantic/core/runner.py +58 -0
- pyflow/checker/semantic/detectors/__init__.py +17 -0
- pyflow/checker/semantic/detectors/ast_helpers.py +114 -0
- pyflow/checker/semantic/detectors/leak.py +500 -0
- pyflow/checker/semantic/detectors/null_dereference.py +132 -0
- pyflow/checker/semantic/detectors/semantic_taint.py +2258 -0
- pyflow/checker/supply_chain.py +568 -0
- pyflow/cli/__init__.py +12 -0
- pyflow/cli/alias.py +397 -0
- pyflow/cli/callgraph.py +185 -0
- pyflow/cli/ir.py +461 -0
- pyflow/cli/main.py +125 -0
- pyflow/cli/optimize.py +603 -0
- pyflow/cli/security.py +1262 -0
- pyflow/cli/supply_chain.py +114 -0
- pyflow/config/nullness/django.json +21 -0
- pyflow/config/nullness/fastapi.json +17 -0
- pyflow/config/nullness/flask.json +37 -0
- pyflow/config/nullness/sql.json +21 -0
- pyflow/config/nullness/sqlalchemy.json +33 -0
- pyflow/config/nullness/stdlib.json +161 -0
- pyflow/config/rule-pack.schema.json +54 -0
- pyflow/config/taint/aiohttp.json +640 -0
- pyflow/config/taint/cloud.json +485 -0
- pyflow/config/taint/concurrency.json +25 -0
- pyflow/config/taint/django.json +710 -0
- pyflow/config/taint/falcon.json +375 -0
- pyflow/config/taint/fastapi.json +192 -0
- pyflow/config/taint/flask.json +504 -0
- pyflow/config/taint/injection.json +2294 -0
- pyflow/config/taint/network.json +367 -0
- pyflow/config/taint/nosql.json +166 -0
- pyflow/config/taint/pandas.json +463 -0
- pyflow/config/taint/requests.json +952 -0
- pyflow/config/taint/serialization.json +109 -0
- pyflow/config/taint/sql.json +730 -0
- pyflow/config/taint/sqlalchemy.json +235 -0
- pyflow/config/taint/stdlib.json +4388 -0
- pyflow/config/taint/tornado.json +151 -0
- pyflow/config/taint/xml.json +89 -0
- pyflow/config/typestate/concurrency.json +145 -0
- pyflow/config/typestate/network.json +130 -0
- pyflow/config/typestate/requests.json +88 -0
- pyflow/config/typestate/sql.json +107 -0
- pyflow/config/typestate/sqlalchemy.json +45 -0
- pyflow/config/typestate/stdlib.json +91 -0
- pyflow/config.py +30 -0
- pyflow/frontend/__init__.py +28 -0
- pyflow/frontend/ast_converter.py +2593 -0
- pyflow/frontend/class_hierarchy.py +665 -0
- pyflow/frontend/dependency_resolver.py +1836 -0
- pyflow/frontend/function_extractor.py +602 -0
- pyflow/frontend/object_manager.py +224 -0
- pyflow/frontend/programextractor.py +1033 -0
- pyflow/frontend/project_resolution.py +511 -0
- pyflow/frontend/source_locator.py +163 -0
- pyflow/frontend/stub_manager.py +425 -0
- pyflow/language/__init__.py +5 -0
- pyflow/language/asttools/__init__.py +34 -0
- pyflow/language/asttools/annotation.py +242 -0
- pyflow/language/asttools/antlrtranslator.py +344 -0
- pyflow/language/asttools/astpprint.py +132 -0
- pyflow/language/asttools/complexity.py +224 -0
- pyflow/language/asttools/decorators.py +71 -0
- pyflow/language/asttools/metaast/__init__.py +370 -0
- pyflow/language/asttools/metaast/codegeneration.py +622 -0
- pyflow/language/asttools/origin.py +83 -0
- pyflow/language/asttools/symbols.py +204 -0
- pyflow/language/asttools/visitors.py +179 -0
- pyflow/language/modules/__init__.py +18 -0
- pyflow/language/modules/_scope_graph.py +484 -0
- pyflow/language/modules/ast_helper.py +211 -0
- pyflow/language/modules/module_definitions.py +240 -0
- pyflow/language/modules/project_handler.py +110 -0
- pyflow/language/modules/transform.py +290 -0
- pyflow/language/modules/util.py +413 -0
- pyflow/language/python/__init__.py +21 -0
- pyflow/language/python/annotations.py +378 -0
- pyflow/language/python/ast.py +749 -0
- pyflow/language/python/collapser.py +604 -0
- pyflow/language/python/default_markers.py +8 -0
- pyflow/language/python/defuse.py +469 -0
- pyflow/language/python/fold.py +220 -0
- pyflow/language/python/program.py +371 -0
- pyflow/language/python/pythonbase.py +353 -0
- pyflow/language/python/pythonoutput.py +82 -0
- pyflow/language/python/simplecodegen.py +975 -0
- pyflow/optimization/__init__.py +29 -0
- pyflow/optimization/argumentnormalization.py +429 -0
- pyflow/optimization/callconverter.py +295 -0
- pyflow/optimization/clone.py +743 -0
- pyflow/optimization/codeinlining.py +587 -0
- pyflow/optimization/convertboolelimination.py +111 -0
- pyflow/optimization/cullprogram.py +155 -0
- pyflow/optimization/dataflow/__init__.py +17 -0
- pyflow/optimization/dataflow/base.py +780 -0
- pyflow/optimization/dataflow/forward.py +681 -0
- pyflow/optimization/dataflow/reverse.py +454 -0
- pyflow/optimization/dce.py +354 -0
- pyflow/optimization/fold.py +780 -0
- pyflow/optimization/loadelimination.py +342 -0
- pyflow/optimization/methodcall.py +554 -0
- pyflow/optimization/rewrite.py +129 -0
- pyflow/optimization/simplify.py +143 -0
- pyflow/optimization/storeelimination.py +129 -0
- pyflow/optimization/termrewrite.py +287 -0
- pyflow/stats/__init__.py +436 -0
- pyflow/stubs/__init__.py +34 -0
- pyflow/stubs/__pycache__/__init__.cpython-313.pyc +0 -0
- pyflow/stubs/__pycache__/lltranslator.cpython-313.pyc +0 -0
- pyflow/stubs/__pycache__/stubcollector.cpython-313.pyc +0 -0
- pyflow/stubs/lltranslator.py +493 -0
- pyflow/stubs/std/__init__.py +83 -0
- pyflow/stubs/std/__pycache__/__init__.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/argparse_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/collections_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/container.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/copy_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/csv_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/datetime_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/functools_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/hashlib_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/interpreter.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/io_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/itertools_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/json_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/llfunc.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/logging_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/mathstubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/operator_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/os_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/pathlib_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/pickle_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/random.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/re_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/sampler.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/shutil_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/subprocess_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/sys_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/tempfile_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/threading_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/__pycache__/time_stubs.cpython-313.pyc +0 -0
- pyflow/stubs/std/argparse_stubs.py +200 -0
- pyflow/stubs/std/collections_stubs.py +77 -0
- pyflow/stubs/std/container.py +374 -0
- pyflow/stubs/std/copy_stubs.py +54 -0
- pyflow/stubs/std/csv_stubs.py +187 -0
- pyflow/stubs/std/datetime_stubs.py +70 -0
- pyflow/stubs/std/functools_stubs.py +61 -0
- pyflow/stubs/std/hashlib_stubs.py +198 -0
- pyflow/stubs/std/interpreter.py +360 -0
- pyflow/stubs/std/io_stubs.py +339 -0
- pyflow/stubs/std/itertools_stubs.py +89 -0
- pyflow/stubs/std/json_stubs.py +40 -0
- pyflow/stubs/std/llfunc.py +240 -0
- pyflow/stubs/std/logging_stubs.py +295 -0
- pyflow/stubs/std/mathstubs.py +393 -0
- pyflow/stubs/std/objects/__init__.py +9 -0
- pyflow/stubs/std/objects/__pycache__/__init__.cpython-313.pyc +0 -0
- pyflow/stubs/std/objects/__pycache__/float.cpython-313.pyc +0 -0
- pyflow/stubs/std/objects/__pycache__/int.cpython-313.pyc +0 -0
- pyflow/stubs/std/objects/__pycache__/str.cpython-313.pyc +0 -0
- pyflow/stubs/std/objects/float.py +248 -0
- pyflow/stubs/std/objects/int.py +221 -0
- pyflow/stubs/std/objects/str.py +175 -0
- pyflow/stubs/std/operator_stubs.py +148 -0
- pyflow/stubs/std/os_stubs.py +727 -0
- pyflow/stubs/std/pathlib_stubs.py +364 -0
- pyflow/stubs/std/pickle_stubs.py +97 -0
- pyflow/stubs/std/random.py +29 -0
- pyflow/stubs/std/re_stubs.py +178 -0
- pyflow/stubs/std/sampler.py +17 -0
- pyflow/stubs/std/shutil_stubs.py +212 -0
- pyflow/stubs/std/subprocess_stubs.py +149 -0
- pyflow/stubs/std/sys_stubs.py +226 -0
- pyflow/stubs/std/tempfile_stubs.py +129 -0
- pyflow/stubs/std/threading_stubs.py +328 -0
- pyflow/stubs/std/time_stubs.py +283 -0
- pyflow/stubs/stubcollector.py +463 -0
- pyflow/util/PADS/Automata.py +640 -0
- pyflow/util/PADS/BFS.py +28 -0
- pyflow/util/PADS/Biconnectivity.py +270 -0
- pyflow/util/PADS/Bipartite.py +89 -0
- pyflow/util/PADS/BipartiteMatching.py +129 -0
- pyflow/util/PADS/CardinalityMatching.py +316 -0
- pyflow/util/PADS/Chordal.py +33 -0
- pyflow/util/PADS/CubicHam.py +351 -0
- pyflow/util/PADS/DFS.py +100 -0
- pyflow/util/PADS/Eratosthenes.py +138 -0
- pyflow/util/PADS/GraphExamples.py +36 -0
- pyflow/util/PADS/Graphs.py +82 -0
- pyflow/util/PADS/GrayGraph.py +36 -0
- pyflow/util/PADS/IntegerPartitions.py +317 -0
- pyflow/util/PADS/LCA.py +349 -0
- pyflow/util/PADS/LCS.py +38 -0
- pyflow/util/PADS/LexBFS.py +32 -0
- pyflow/util/PADS/LongestIncreasingSubsequence.py +65 -0
- pyflow/util/PADS/Medium.py +414 -0
- pyflow/util/PADS/MinimumSpanningTree.py +26 -0
- pyflow/util/PADS/OrderedSequence.py +133 -0
- pyflow/util/PADS/PartialCube.py +227 -0
- pyflow/util/PADS/PartialOrder.py +129 -0
- pyflow/util/PADS/PartitionRefinement.py +85 -0
- pyflow/util/PADS/ReadUndirectedGraph.py +431 -0
- pyflow/util/PADS/Repetitivity.py +160 -0
- pyflow/util/PADS/SMAWK.py +190 -0
- pyflow/util/PADS/Sequence.py +118 -0
- pyflow/util/PADS/StrongConnectivity.py +106 -0
- pyflow/util/PADS/Sudoku.py +2028 -0
- pyflow/util/PADS/UnionFind.py +63 -0
- pyflow/util/PADS/Util.py +28 -0
- pyflow/util/PADS/Wrap.py +79 -0
- pyflow/util/PADS/__init__.py +13 -0
- pyflow/util/PADS/xyzGraph.py +127 -0
- pyflow/util/__init__.py +19 -0
- pyflow/util/antlr3/__init__.py +134 -0
- pyflow/util/antlr3/compat.py +12 -0
- pyflow/util/antlr3/constants.py +24 -0
- pyflow/util/antlr3/dfa.py +179 -0
- pyflow/util/antlr3/dottreegen.py +170 -0
- pyflow/util/antlr3/exceptions.py +346 -0
- pyflow/util/antlr3/extras.py +11 -0
- pyflow/util/antlr3/main.py +198 -0
- pyflow/util/antlr3/recognizers.py +1341 -0
- pyflow/util/antlr3/streams.py +1250 -0
- pyflow/util/antlr3/tokens.py +370 -0
- pyflow/util/antlr3/tree.py +2190 -0
- pyflow/util/antlr3/treewizard.py +566 -0
- pyflow/util/application/__init__.py +13 -0
- pyflow/util/application/async_utils.py +101 -0
- pyflow/util/application/compilerexceptions.py +21 -0
- pyflow/util/application/console.py +235 -0
- pyflow/util/application/errorhandler.py +241 -0
- pyflow/util/canonical.py +204 -0
- pyflow/util/debug/__init__.py +11 -0
- pyflow/util/debug/blame.py +94 -0
- pyflow/util/debug/debugger.py +105 -0
- pyflow/util/debug/trace.py +56 -0
- pyflow/util/graphalgorithim/__init__.py +17 -0
- pyflow/util/graphalgorithim/basic.py +77 -0
- pyflow/util/graphalgorithim/color.py +104 -0
- pyflow/util/graphalgorithim/djtree.py +299 -0
- pyflow/util/graphalgorithim/dominator.py +531 -0
- pyflow/util/graphalgorithim/exclusiongraph.py +624 -0
- pyflow/util/graphalgorithim/merge.py +221 -0
- pyflow/util/io/__init__.py +6 -0
- pyflow/util/io/dot.py +540 -0
- pyflow/util/io/filesystem.py +210 -0
- pyflow/util/io/formatting.py +71 -0
- pyflow/util/io/report.py +224 -0
- pyflow/util/io/xmloutput.py +270 -0
- pyflow/util/json_dict.py +92 -0
- pyflow/util/monkeypatch/__init__.py +21 -0
- pyflow/util/monkeypatch/xcollections.py +206 -0
- pyflow/util/monkeypatch/xmath.py +108 -0
- pyflow/util/monkeypatch/xnamedtuple.py +180 -0
- pyflow/util/monkeypatch/xtypes.py +56 -0
- pyflow/util/orderedset.py +420 -0
- pyflow/util/pydot.py +1998 -0
- pyflow/util/python/__init__.py +136 -0
- pyflow/util/python/apply.py +180 -0
- pyflow/util/python/calling.py +558 -0
- pyflow/util/python/opnames.py +153 -0
- pyflow/util/randomness.py +230 -0
- pyflow/util/singleton.py +112 -0
- pyflow/util/tvl.py +321 -0
- pyflow/util/typedispatch.py +342 -0
- pyflow/util/unionfind.py +169 -0
- pyflow_analysis-0.1.0.dist-info/METADATA +184 -0
- pyflow_analysis-0.1.0.dist-info/RECORD +757 -0
- pyflow_analysis-0.1.0.dist-info/WHEEL +5 -0
- pyflow_analysis-0.1.0.dist-info/entry_points.txt +2 -0
- pyflow_analysis-0.1.0.dist-info/licenses/LICENSE.txt +202 -0
- pyflow_analysis-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from typing import Dict, List
|
|
2
|
+
from queue import Queue
|
|
3
|
+
|
|
4
|
+
from .base import ICFGTransformBase, IR
|
|
5
|
+
from pyflow.analysis.alias.kcfa._pythonstan.ir import *
|
|
6
|
+
from pyflow.analysis.alias.kcfa._pythonstan.graph.cfg import ControlFlowGraph, BaseBlock, IfEdge
|
|
7
|
+
from pyflow.analysis.alias.kcfa._pythonstan.world import World
|
|
8
|
+
from pyflow.analysis.alias.kcfa._pythonstan.utils.persistent_rb_tree import PersistentMap
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ICFGPreTransform(ICFGTransformBase):
|
|
12
|
+
def analysis_module(self, module: IRModule, env: PersistentMap):
|
|
13
|
+
visited = {*()}
|
|
14
|
+
cfg: ControlFlowGraph = World().scope_manager.get_ir(module, IR)
|
|
15
|
+
q: Queue[BaseBlock] = Queue()
|
|
16
|
+
q.put(cfg.get_entry())
|
|
17
|
+
while not q.empty():
|
|
18
|
+
cur_blk = q.get()
|
|
19
|
+
visited.add(cur_blk)
|
|
20
|
+
cond_assigns = {}
|
|
21
|
+
for stmt in cur_blk.get_stmts():
|
|
22
|
+
if isinstance(stmt, IRAstStmt):
|
|
23
|
+
self.analysis_stmt(stmt.get_ast(), env)
|
|
24
|
+
elif isinstance(stmt, IRClass):
|
|
25
|
+
...
|
|
26
|
+
elif isinstance(stmt, IRFunc):
|
|
27
|
+
...
|
|
28
|
+
elif isinstance(stmt, IRImport):
|
|
29
|
+
...
|
|
30
|
+
elif isinstance(stmt, IRCall):
|
|
31
|
+
...
|
|
32
|
+
elif isinstance(stmt, IRReturn):
|
|
33
|
+
...
|
|
34
|
+
elif isinstance(stmt, IRYield):
|
|
35
|
+
...
|
|
36
|
+
elif isinstance(stmt, Phi):
|
|
37
|
+
...
|
|
38
|
+
elif isinstance(stmt, JumpIfTrue):
|
|
39
|
+
if stmt.label in cfg.label2blk:
|
|
40
|
+
tgt_blk = cfg.label2blk[stmt.label]
|
|
41
|
+
cond_assigns[tgt_blk] = [(t, [self._const(True)])
|
|
42
|
+
for t in self.resolve_node(env, stmt.test)]
|
|
43
|
+
elif isinstance(stmt, JumpIfFalse):
|
|
44
|
+
if stmt.label in cfg.label2blk:
|
|
45
|
+
tgt_blk = cfg.label2blk[stmt.label]
|
|
46
|
+
cond_assigns[tgt_blk] = [(t, [self._const(False)])
|
|
47
|
+
for t in self.resolve_node(env, stmt.test)]
|
|
48
|
+
for succ in cfg.succs_of(cur_blk):
|
|
49
|
+
new_env = PersistentMap(env.backup())
|
|
50
|
+
if succ in cond_assigns:
|
|
51
|
+
for k, v in cond_assigns[succ]:
|
|
52
|
+
new_env[k] = v
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def analysis_cls(self, cls: IRClass, env: PersistentMap):
|
|
57
|
+
if cls.keywords is not None:
|
|
58
|
+
for kw in cls.keywords:
|
|
59
|
+
if kw.arg == "metaclass":
|
|
60
|
+
for v in self.resolve_node(env, kw.value):
|
|
61
|
+
if self.resolve_attribute():
|
|
62
|
+
...
|
|
63
|
+
...
|
|
64
|
+
|
|
65
|
+
def analysis_func(self, func: IRFunc, env: PersistentMap):
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
#self.analysis_stmt(env, stmt.get_ast())
|
|
File without changes
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2020 Vitalis Salis.
|
|
3
|
+
#
|
|
4
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
5
|
+
# or more contributor license agreements. See the NOTICE file
|
|
6
|
+
# distributed with this work for additional information
|
|
7
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
8
|
+
# to you under the Apache License, Version 2.0 (the
|
|
9
|
+
# "License"); you may not use this file except in compliance
|
|
10
|
+
# with the License. You may obtain a copy of the License at
|
|
11
|
+
#
|
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
#
|
|
14
|
+
# Unless required by applicable law or agreed to in writing,
|
|
15
|
+
# software distributed under the License is distributed on an
|
|
16
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
17
|
+
# KIND, either express or implied. See the License for the
|
|
18
|
+
# specific language governing permissions and limitations
|
|
19
|
+
# under the License.
|
|
20
|
+
#
|
|
21
|
+
import ast
|
|
22
|
+
|
|
23
|
+
from pycg.processing.base import ProcessingBase
|
|
24
|
+
from pycg.machinery.definitions import Definition
|
|
25
|
+
from pycg import utils
|
|
26
|
+
|
|
27
|
+
class PostProcessor(ProcessingBase):
|
|
28
|
+
def __init__(self, input_file, modname, import_manager,
|
|
29
|
+
scope_manager, def_manager, class_manager, module_manager, modules_analyzed=None):
|
|
30
|
+
super().__init__(input_file, modname, modules_analyzed)
|
|
31
|
+
self.import_manager = import_manager
|
|
32
|
+
self.scope_manager = scope_manager
|
|
33
|
+
self.def_manager = def_manager
|
|
34
|
+
self.class_manager = class_manager
|
|
35
|
+
self.module_manager = module_manager
|
|
36
|
+
self.closured = self.def_manager.transitive_closure()
|
|
37
|
+
|
|
38
|
+
def visit_Lambda(self, node):
|
|
39
|
+
counter = self.scope_manager.get_scope(self.current_ns).inc_lambda_counter()
|
|
40
|
+
lambda_name = utils.get_lambda_name(counter)
|
|
41
|
+
super().visit_Lambda(node, lambda_name)
|
|
42
|
+
|
|
43
|
+
def visit_Call(self, node):
|
|
44
|
+
self.visit(node.func)
|
|
45
|
+
|
|
46
|
+
names = self.retrieve_call_names(node)
|
|
47
|
+
if not names:
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
self.last_called_names = names
|
|
51
|
+
|
|
52
|
+
for name in names:
|
|
53
|
+
defi = self.def_manager.get(name)
|
|
54
|
+
if not defi:
|
|
55
|
+
continue
|
|
56
|
+
if defi.get_type() == utils.constants.CLS_DEF:
|
|
57
|
+
self.update_parent_classes(defi)
|
|
58
|
+
defi = self.def_manager.get(utils.join_ns(defi.get_ns(), utils.constants.CLS_INIT))
|
|
59
|
+
if not defi:
|
|
60
|
+
continue
|
|
61
|
+
self.iterate_call_args(defi, node)
|
|
62
|
+
|
|
63
|
+
def visit_Assign(self, node):
|
|
64
|
+
self._visit_assign(node.value, node.targets)
|
|
65
|
+
|
|
66
|
+
def visit_Return(self, node):
|
|
67
|
+
self._visit_return(node)
|
|
68
|
+
|
|
69
|
+
def visit_Yield(self, node):
|
|
70
|
+
self._visit_return(node)
|
|
71
|
+
|
|
72
|
+
def visit_For(self, node):
|
|
73
|
+
# only handle name targets
|
|
74
|
+
if isinstance(node.target, ast.Name):
|
|
75
|
+
target_def = self.def_manager.get(utils.join_ns(self.current_ns, node.target.id))
|
|
76
|
+
# if the target definition exists
|
|
77
|
+
if target_def:
|
|
78
|
+
iter_decoded = self.decode_node(node.iter)
|
|
79
|
+
# assign the target to the return value
|
|
80
|
+
# of the next function
|
|
81
|
+
for item in iter_decoded:
|
|
82
|
+
if not isinstance(item, Definition):
|
|
83
|
+
continue
|
|
84
|
+
# return value for generators
|
|
85
|
+
for name in self.closured.get(item.get_ns(), []):
|
|
86
|
+
# If there exists a next method on the iterable
|
|
87
|
+
# and if yes, add a pointer to it
|
|
88
|
+
next_defi = self.def_manager.get(utils.join_ns(name,
|
|
89
|
+
utils.constants.NEXT_METHOD, utils.constants.RETURN_NAME))
|
|
90
|
+
if next_defi:
|
|
91
|
+
for name in self.closured.get(next_defi.get_ns(), []):
|
|
92
|
+
target_def.get_name_pointer().add(name)
|
|
93
|
+
else: # otherwise, add a pointer to the name (e.g. a yield)
|
|
94
|
+
target_def.get_name_pointer().add(name)
|
|
95
|
+
|
|
96
|
+
super().visit_For(node)
|
|
97
|
+
|
|
98
|
+
def visit_Return(self, node):
|
|
99
|
+
self._visit_return(node)
|
|
100
|
+
|
|
101
|
+
def visit_Yield(self, node):
|
|
102
|
+
self._visit_return(node)
|
|
103
|
+
|
|
104
|
+
def visit_AsyncFunctionDef(self, node):
|
|
105
|
+
self.visit_FunctionDef(node)
|
|
106
|
+
|
|
107
|
+
def visit_FunctionDef(self, node):
|
|
108
|
+
# here we iterate decorators
|
|
109
|
+
if node.decorator_list:
|
|
110
|
+
fn_def = self.def_manager.get(utils.join_ns(self.current_ns, node.name))
|
|
111
|
+
reversed_decorators = list(reversed(node.decorator_list))
|
|
112
|
+
|
|
113
|
+
# add to the name pointer of the function definition
|
|
114
|
+
# the return value of the first decorator
|
|
115
|
+
# since, now the function is a namespace to that point
|
|
116
|
+
if hasattr(fn_def, "decorator_names") and reversed_decorators:
|
|
117
|
+
last_decoded = self.decode_node(reversed_decorators[-1])
|
|
118
|
+
for d in last_decoded:
|
|
119
|
+
if not isinstance(d, Definition):
|
|
120
|
+
continue
|
|
121
|
+
fn_def.decorator_names.add(utils.join_ns(d.get_ns(), utils.constants.RETURN_NAME))
|
|
122
|
+
|
|
123
|
+
previous_names = self.closured.get(fn_def.get_ns(), set())
|
|
124
|
+
for decorator in reversed_decorators:
|
|
125
|
+
# assign the previous_def as the first parameter of the decorator
|
|
126
|
+
decoded = self.decode_node(decorator)
|
|
127
|
+
new_previous_names = set()
|
|
128
|
+
for d in decoded:
|
|
129
|
+
if not isinstance(d, Definition):
|
|
130
|
+
continue
|
|
131
|
+
for name in self.closured.get(d.get_ns(), []):
|
|
132
|
+
return_ns = utils.join_ns(name, utils.constants.RETURN_NAME)
|
|
133
|
+
|
|
134
|
+
if self.closured.get(return_ns, None) == None:
|
|
135
|
+
continue
|
|
136
|
+
|
|
137
|
+
new_previous_names = new_previous_names.union(self.closured.get(return_ns))
|
|
138
|
+
|
|
139
|
+
for prev_name in previous_names:
|
|
140
|
+
pos_arg_names = d.get_name_pointer().get_pos_arg(0)
|
|
141
|
+
if not pos_arg_names:
|
|
142
|
+
continue
|
|
143
|
+
for name in pos_arg_names:
|
|
144
|
+
arg_def = self.def_manager.get(name)
|
|
145
|
+
arg_def.get_name_pointer().add(prev_name)
|
|
146
|
+
previous_names = new_previous_names
|
|
147
|
+
|
|
148
|
+
super().visit_FunctionDef(node)
|
|
149
|
+
|
|
150
|
+
def visit_ClassDef(self, node):
|
|
151
|
+
# create a definition for the class (node.name)
|
|
152
|
+
cls_def = self.def_manager.handle_class_def(self.current_ns, node.name)
|
|
153
|
+
|
|
154
|
+
# iterate bases to compute MRO for the class
|
|
155
|
+
cls = self.class_manager.get(cls_def.get_ns())
|
|
156
|
+
if not cls:
|
|
157
|
+
cls = self.class_manager.create(cls_def.get_ns(), self.modname)
|
|
158
|
+
|
|
159
|
+
cls.clear_mro()
|
|
160
|
+
for base in node.bases:
|
|
161
|
+
# all bases are of the type ast.Name
|
|
162
|
+
self.visit(base)
|
|
163
|
+
|
|
164
|
+
bases = self.decode_node(base)
|
|
165
|
+
for base_def in bases:
|
|
166
|
+
if not isinstance(base_def, Definition):
|
|
167
|
+
continue
|
|
168
|
+
names = set()
|
|
169
|
+
if base_def.get_name_pointer().get():
|
|
170
|
+
names = base_def.get_name_pointer().get()
|
|
171
|
+
else:
|
|
172
|
+
names.add(base_def.get_ns())
|
|
173
|
+
for name in names:
|
|
174
|
+
# add the base as a parent
|
|
175
|
+
cls.add_parent(name)
|
|
176
|
+
|
|
177
|
+
# add the base's parents
|
|
178
|
+
parent_cls = self.class_manager.get(name)
|
|
179
|
+
if parent_cls:
|
|
180
|
+
cls.add_parent(parent_cls.get_mro())
|
|
181
|
+
|
|
182
|
+
cls.compute_mro()
|
|
183
|
+
|
|
184
|
+
super().visit_ClassDef(node)
|
|
185
|
+
|
|
186
|
+
def visit_List(self, node):
|
|
187
|
+
# Works similarly with dicts
|
|
188
|
+
current_scope = self.scope_manager.get_scope(self.current_ns)
|
|
189
|
+
list_counter = current_scope.inc_list_counter()
|
|
190
|
+
list_name = utils.get_list_name(list_counter)
|
|
191
|
+
list_full_ns = utils.join_ns(self.current_ns, list_name)
|
|
192
|
+
|
|
193
|
+
# create a scope for the list
|
|
194
|
+
list_scope = self.scope_manager.create_scope(list_full_ns, current_scope)
|
|
195
|
+
|
|
196
|
+
# create a list definition
|
|
197
|
+
list_def = self.def_manager.get(list_full_ns)
|
|
198
|
+
if not list_def:
|
|
199
|
+
list_def = self.def_manager.create(list_full_ns, utils.constants.NAME_DEF)
|
|
200
|
+
current_scope.add_def(list_name, list_def)
|
|
201
|
+
|
|
202
|
+
self.name_stack.append(list_name)
|
|
203
|
+
for idx, elt in enumerate(node.elts):
|
|
204
|
+
self.visit(elt)
|
|
205
|
+
key_full_ns = utils.join_ns(list_def.get_ns(), utils.get_int_name(idx))
|
|
206
|
+
key_def = self.def_manager.get(key_full_ns)
|
|
207
|
+
if not key_def:
|
|
208
|
+
key_def = self.def_manager.create(key_full_ns, utils.constants.NAME_DEF)
|
|
209
|
+
|
|
210
|
+
decoded_elt = self.decode_node(elt)
|
|
211
|
+
for v in decoded_elt:
|
|
212
|
+
if isinstance(v, Definition):
|
|
213
|
+
key_def.get_name_pointer().add(v.get_ns())
|
|
214
|
+
else:
|
|
215
|
+
key_def.get_lit_pointer().add(v)
|
|
216
|
+
|
|
217
|
+
self.name_stack.pop()
|
|
218
|
+
|
|
219
|
+
def visit_Dict(self, node):
|
|
220
|
+
# 1. create a scope using a counter
|
|
221
|
+
# 2. Iterate keys and add them as children of the scope
|
|
222
|
+
# 3. Iterate values and makes a points to connection with the keys
|
|
223
|
+
current_scope = self.scope_manager.get_scope(self.current_ns)
|
|
224
|
+
dict_counter = current_scope.inc_dict_counter()
|
|
225
|
+
dict_name = utils.get_dict_name(dict_counter)
|
|
226
|
+
dict_full_ns = utils.join_ns(self.current_ns, dict_name)
|
|
227
|
+
|
|
228
|
+
# create a scope for the dict
|
|
229
|
+
dict_scope = self.scope_manager.create_scope(dict_full_ns, current_scope)
|
|
230
|
+
|
|
231
|
+
# Create a dict definition
|
|
232
|
+
dict_def = self.def_manager.get(dict_full_ns)
|
|
233
|
+
if not dict_def:
|
|
234
|
+
dict_def = self.def_manager.create(dict_full_ns, utils.constants.NAME_DEF)
|
|
235
|
+
# add it to the current scope
|
|
236
|
+
current_scope.add_def(dict_name, dict_def)
|
|
237
|
+
|
|
238
|
+
self.name_stack.append(dict_name)
|
|
239
|
+
for key, value in zip(node.keys, node.values):
|
|
240
|
+
if key:
|
|
241
|
+
self.visit(key)
|
|
242
|
+
if value:
|
|
243
|
+
self.visit(value)
|
|
244
|
+
decoded_key = self.decode_node(key)
|
|
245
|
+
decoded_value = self.decode_node(value)
|
|
246
|
+
|
|
247
|
+
# iterate decoded keys and values
|
|
248
|
+
# to do the assignment operation
|
|
249
|
+
for k in decoded_key:
|
|
250
|
+
if isinstance(k, Definition):
|
|
251
|
+
# get literal pointer
|
|
252
|
+
names = k.get_lit_pointer().get()
|
|
253
|
+
else:
|
|
254
|
+
names = set()
|
|
255
|
+
if isinstance(k, list):
|
|
256
|
+
continue
|
|
257
|
+
names.add(k)
|
|
258
|
+
for name in names:
|
|
259
|
+
# create a definition for the key
|
|
260
|
+
if isinstance(name, int):
|
|
261
|
+
name = utils.get_int_name(name)
|
|
262
|
+
key_full_ns = utils.join_ns(dict_def.get_ns(), str(name))
|
|
263
|
+
key_def = self.def_manager.get(key_full_ns)
|
|
264
|
+
if not key_def:
|
|
265
|
+
key_def = self.def_manager.create(key_full_ns, utils.constants.NAME_DEF)
|
|
266
|
+
dict_scope.add_def(str(name), key_def)
|
|
267
|
+
for v in decoded_value:
|
|
268
|
+
if isinstance(v, Definition):
|
|
269
|
+
key_def.get_name_pointer().add(v.get_ns())
|
|
270
|
+
else:
|
|
271
|
+
key_def.get_lit_pointer().add(v)
|
|
272
|
+
self.name_stack.pop()
|
|
273
|
+
|
|
274
|
+
def update_parent_classes(self, defi):
|
|
275
|
+
cls = self.class_manager.get(defi.get_ns())
|
|
276
|
+
if not cls:
|
|
277
|
+
return
|
|
278
|
+
current_scope = self.scope_manager.get_scope(defi.get_ns())
|
|
279
|
+
for parent in cls.get_mro():
|
|
280
|
+
parent_def = self.def_manager.get(parent)
|
|
281
|
+
if not parent_def:
|
|
282
|
+
continue
|
|
283
|
+
parent_scope = self.scope_manager.get_scope(parent)
|
|
284
|
+
if not parent_scope:
|
|
285
|
+
continue
|
|
286
|
+
parent_items = list(parent_scope.get_defs().keys())
|
|
287
|
+
for key, child_def in current_scope.get_defs().items():
|
|
288
|
+
if key == "__init__":
|
|
289
|
+
continue
|
|
290
|
+
# resolve name from the parent_def
|
|
291
|
+
names = self.find_cls_fun_ns(parent_def.get_ns(), key)
|
|
292
|
+
|
|
293
|
+
new_ns = utils.join_ns(parent_def.get_ns(), key)
|
|
294
|
+
new_def = self.def_manager.get(new_ns)
|
|
295
|
+
if not new_def:
|
|
296
|
+
new_def = self.def_manager.create(new_ns, utils.constants.NAME_DEF)
|
|
297
|
+
|
|
298
|
+
new_def.get_name_pointer().add_set(names)
|
|
299
|
+
new_def.get_name_pointer().add(child_def.get_ns())
|
|
300
|
+
|
|
301
|
+
def analyze_submodules(self):
|
|
302
|
+
super().analyze_submodules(PostProcessor, self.import_manager,
|
|
303
|
+
self.scope_manager, self.def_manager, self.class_manager,
|
|
304
|
+
self.module_manager, modules_analyzed=self.get_modules_analyzed())
|
|
305
|
+
|
|
306
|
+
def analyze(self):
|
|
307
|
+
self.visit(ast.parse(self.contents, self.filename))
|
|
308
|
+
self.analyze_submodules()
|