prism-code-workspace 1.0.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.
@@ -0,0 +1,50 @@
1
+ """Function call graph data derived from static analysis results."""
2
+
3
+ from dataclasses import asdict, dataclass
4
+ from typing import Dict, Tuple
5
+
6
+ from .models import AnalysisResult
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class GraphNode:
11
+ id: str
12
+ label: str
13
+ module: str
14
+ file: str
15
+ line: int
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class GraphEdge:
20
+ source: str
21
+ target: str
22
+ line: int
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class FunctionGraph:
27
+ nodes: Tuple[GraphNode, ...]
28
+ edges: Tuple[GraphEdge, ...]
29
+
30
+ def to_dict(self) -> Dict[str, object]:
31
+ return asdict(self)
32
+
33
+
34
+ def build_function_graph(analysis: AnalysisResult) -> FunctionGraph:
35
+ """Build serializable graph nodes and edges from an analysis result."""
36
+ nodes = tuple(
37
+ GraphNode(
38
+ id=function.id,
39
+ label=function.name,
40
+ module=function.module,
41
+ file=function.file,
42
+ line=function.line,
43
+ )
44
+ for function in analysis.functions
45
+ )
46
+ edges = tuple(
47
+ GraphEdge(source=call.caller, target=call.callee, line=call.line)
48
+ for call in analysis.calls
49
+ )
50
+ return FunctionGraph(nodes=nodes, edges=edges)
@@ -0,0 +1,53 @@
1
+ """Data models shared by the analyzer, graph builder, and CLI."""
2
+
3
+ from dataclasses import asdict, dataclass
4
+ from typing import Dict, Optional, Tuple
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class ParameterInfo:
9
+ name: str
10
+ kind: str
11
+ default: Optional[str] = None
12
+ annotation: Optional[str] = None
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class FunctionInfo:
17
+ id: str
18
+ name: str
19
+ module: str
20
+ file: str
21
+ line: int
22
+ end_line: int
23
+ source: str
24
+ docstring: Optional[str]
25
+ parameters: Tuple[ParameterInfo, ...]
26
+ return_expressions: Tuple[str, ...]
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class CallEdge:
31
+ caller: str
32
+ callee: str
33
+ line: int
34
+ expression: str
35
+
36
+
37
+ @dataclass(frozen=True)
38
+ class Diagnostic:
39
+ file: str
40
+ message: str
41
+ severity: str
42
+ line: Optional[int] = None
43
+
44
+
45
+ @dataclass(frozen=True)
46
+ class AnalysisResult:
47
+ root: str
48
+ functions: Tuple[FunctionInfo, ...]
49
+ calls: Tuple[CallEdge, ...]
50
+ diagnostics: Tuple[Diagnostic, ...]
51
+
52
+ def to_dict(self) -> Dict[str, object]:
53
+ return asdict(self)
@@ -0,0 +1,17 @@
1
+ """Restricted, non-executing POV simulations."""
2
+
3
+ from .engine import (
4
+ PovSimulation,
5
+ SimulationError,
6
+ build_program_simulation_from_source,
7
+ build_simulation,
8
+ build_simulation_from_source,
9
+ )
10
+
11
+ __all__ = [
12
+ "PovSimulation",
13
+ "SimulationError",
14
+ "build_program_simulation_from_source",
15
+ "build_simulation",
16
+ "build_simulation_from_source",
17
+ ]