Skip to content

Commit 4eb8cc8

Browse files
authored
Update ppa type definitions (#11067)
* Update ppa type definitions
1 parent d96be50 commit 4eb8cc8

39 files changed

+97
-19183
lines changed
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
import { Cell } from './cell';
22
import { LocationSet } from './slice';
33
export declare class CellSlice {
4+
readonly cell: Cell;
5+
slice: LocationSet;
6+
readonly executionTime?: Date;
47
/**
58
* Construct an instance of a cell slice.
69
*/
710
constructor(cell: Cell, slice: LocationSet, executionTime?: Date);
811
/**
912
* Get the text in the slice of a cell.
1013
*/
11-
readonly textSlice: string;
14+
get textSlice(): string;
1215
/**
1316
* Get the text of all lines in a slice (no deletions from lines).
1417
*/
15-
readonly textSliceLines: string;
18+
get textSliceLines(): string;
1619
private getTextSlice;
17-
/**
18-
* Get the slice.
19-
*/
20-
/**
21-
* Set the slice.
22-
*/
23-
slice: LocationSet;
24-
readonly cell: Cell;
25-
readonly executionTime: Date;
26-
private _slice;
2720
}

types/@msrvida-python-program-analysis/control-flow.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ export declare class Block {
33
id: number;
44
readonly hint: string;
55
statements: ast.SyntaxNode[];
6+
private imports;
67
loopVariables: ast.SyntaxNode[];
7-
constructor(id: number, hint: string, statements: ast.SyntaxNode[], loopVariables?: ast.SyntaxNode[]);
8+
private ssa;
9+
constructor(id: number, hint: string, statements: ast.SyntaxNode[], imports: string[], loopVariables?: ast.SyntaxNode[]);
810
toString(): string;
11+
get flattenedStatements(): ast.SyntaxNode[];
912
}
1013
export declare class ControlFlowGraph {
1114
private _blocks;
@@ -14,9 +17,10 @@ export declare class ControlFlowGraph {
1417
private exit;
1518
private successors;
1619
private loopVariables;
20+
private imports;
1721
constructor(node: ast.SyntaxNode);
1822
private makeBlock;
19-
readonly blocks: Block[];
23+
get blocks(): Block[];
2024
getSuccessors(block: Block): Block[];
2125
getPredecessors(block: Block): Block[];
2226
print(): void;

types/@msrvida-python-program-analysis/data-flow.d.ts

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
11
import * as ast from './python-parser';
22
import { ControlFlowGraph } from './control-flow';
33
import { Set } from './set';
4-
import { JsonSpecs, PythonType } from './specs';
5-
declare class DefUse {
4+
import { Spec } from './specs';
5+
import { SymbolTable } from './symbol-table';
6+
export interface Dataflow {
7+
fromNode: ast.SyntaxNode;
8+
toNode: ast.SyntaxNode;
9+
fromRef?: Ref;
10+
toRef?: Ref;
11+
}
12+
export declare enum ReferenceType {
13+
DEFINITION = "DEFINITION",
14+
UPDATE = "UPDATE",
15+
USE = "USE"
16+
}
17+
export interface Ref {
18+
level: ReferenceType;
19+
name: string;
20+
location: ast.Location;
21+
node: ast.SyntaxNode;
22+
}
23+
export declare class RefSet extends Set<Ref> {
24+
constructor(...items: Ref[]);
25+
}
26+
declare class DefUseDelta {
627
DEFINITION: RefSet;
728
UPDATE: RefSet;
829
USE: RefSet;
9-
constructor(DEFINITION?: RefSet, UPDATE?: RefSet, USE?: RefSet);
10-
readonly defs: Set<Ref>;
11-
readonly uses: Set<Ref>;
30+
leaks: LeakInfo[];
31+
constructor(DEFINITION?: RefSet, UPDATE?: RefSet, USE?: RefSet, leaks?: LeakInfo[]);
32+
get uses(): Set<Ref>;
33+
createFlowsFrom(fromSet: DefUse): [Set<Dataflow>, Set<Ref>];
34+
}
35+
declare class DefUse {
36+
private DEFINITION;
37+
private UPDATE;
38+
private USE;
39+
leaks: LeakInfo[];
40+
constructor(DEFINITION?: RefSet, UPDATE?: RefSet, USE?: RefSet, leaks?: LeakInfo[]);
41+
get defs(): Set<Ref>;
1242
union(that: DefUse): DefUse;
13-
update(newRefs: DefUse): void;
43+
update(newRefs: DefUseDelta): void;
1444
equals(that: DefUse): boolean;
15-
createFlowsFrom(fromSet: DefUse): [Set<Dataflow>, Set<Ref>];
1645
}
1746
/**
1847
* Use a shared dataflow analyzer object for all dataflow analysis / querying for defs and uses.
1948
* It caches defs and uses for each statement, which can save time.
2049
* For caching to work, statements must be annotated with a cell's ID and execution count.
2150
*/
2251
export declare class DataflowAnalyzer {
23-
constructor(moduleMap?: JsonSpecs);
24-
getDefUseForStatement(statement: ast.SyntaxNode, defsForMethodResolution: RefSet): DefUse;
52+
constructor(moduleMap?: Spec, symbolTable?: SymbolTable);
53+
getDefUseForStatement(statement: ast.SyntaxNode, incomingDefs: RefSet, incomingLeaks: LeakInfo[]): DefUseDelta;
2554
analyze(cfg: ControlFlowGraph, refSet?: RefSet): DataflowAnalysisResult;
26-
getDefs(statement: ast.SyntaxNode, defsForMethodResolution: RefSet): RefSet;
55+
getDefs(statement: ast.SyntaxNode, stateLeaks: LeakInfo[]): {
56+
defs: RefSet;
57+
leaks: LeakInfo[];
58+
};
2759
private getClassDefs;
2860
private getFuncDefs;
2961
private getAssignDefs;
@@ -35,41 +67,15 @@ export declare class DataflowAnalyzer {
3567
private getClassDeclUses;
3668
private getFuncDeclUses;
3769
private getAssignUses;
38-
private _symbolTable;
70+
private symbolTable;
3971
private _defUsesCache;
4072
}
41-
export interface Dataflow {
42-
fromNode: ast.SyntaxNode;
43-
toNode: ast.SyntaxNode;
44-
fromRef?: Ref;
45-
toRef?: Ref;
46-
}
47-
export declare enum ReferenceType {
48-
DEFINITION = "DEFINITION",
49-
UPDATE = "UPDATE",
50-
USE = "USE"
51-
}
52-
export declare enum SymbolType {
53-
VARIABLE = 0,
54-
CLASS = 1,
55-
FUNCTION = 2,
56-
IMPORT = 3,
57-
MUTATION = 4,
58-
MAGIC = 5
59-
}
60-
export interface Ref {
61-
type: SymbolType;
62-
level: ReferenceType;
63-
name: string;
64-
inferredType?: PythonType;
65-
location: ast.Location;
66-
node: ast.SyntaxNode;
67-
}
68-
export declare class RefSet extends Set<Ref> {
69-
constructor(...items: Ref[]);
70-
}
7173
export declare function sameLocation(loc1: ast.Location, loc2: ast.Location): boolean;
7274
export declare const GlobalSyntheticVariable = "$global";
75+
interface LeakInfo {
76+
innerName: string;
77+
outerName: string;
78+
}
7379
export declare type DataflowAnalysisResult = {
7480
dataflows: Set<Dataflow>;
7581
undefinedRefs: RefSet;

types/@msrvida-python-program-analysis/genspec/main.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

types/@msrvida-python-program-analysis/genspec/moduleSpecWalker.d.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

types/@msrvida-python-program-analysis/graph.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export declare class Graph<T> {
55
private _nodes;
66
constructor(getIdentifier: (item: T) => string);
77
addEdge(fromNode: T, toNode: T): void;
8-
readonly nodes: T[];
8+
get nodes(): T[];
99
topoSort(): T[];
1010
}

types/@msrvida-python-program-analysis/log-slicer.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export declare class ExecutionLogSlicer<TCell extends Cell> {
6666
* Relevant line numbers are relative to the cell's start line (starting at first line = 0).
6767
*/
6868
sliceAllExecutions(cellId: string, seedLocations?: LocationSet): SlicedExecution[];
69-
readonly cellExecutions: ReadonlyArray<CellExecution<TCell>>;
69+
get cellExecutions(): ReadonlyArray<CellExecution<TCell>>;
7070
/**
7171
* Get the cell program (tree, defs, uses) for a cell.
7272
*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export declare function startLogging(): void;
2+
export declare function stopLogging(): void;
23
export declare function log(message: string, ...args: any[]): void;

types/@msrvida-python-program-analysis/python-parser.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface From extends Locatable {
4141
type: typeof FROM;
4242
base: string;
4343
imports: {
44-
path: string;
44+
name: string;
4545
alias: string;
4646
location: Location;
4747
}[];

types/@msrvida-python-program-analysis/rewrite-magics.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export declare class MagicsRewriter {
5555
* Rewrite code so that it doesn't contain magics.
5656
*/
5757
rewrite(text: string, lineMagicRewriters?: LineMagicRewriter[]): string;
58+
rewriteShellCommand(text: string): string;
5859
/**
5960
* Default rewrite rule for cell magics.
6061
*/

types/@msrvida-python-program-analysis/set.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ export declare class Set<T> {
22
private getIdentifier;
33
private _items;
44
constructor(getIdentifier: (item: T) => string, ...items: T[]);
5-
readonly size: number;
5+
get size(): number;
66
add(...items: T[]): void;
77
remove(item: T): void;
88
pop(): T;
99
has(item: T): boolean;
10-
readonly items: T[];
10+
get items(): T[];
1111
equals(that: Set<T>): boolean;
12-
readonly empty: boolean;
12+
get empty(): boolean;
1313
union(...those: Set<T>[]): Set<T>;
1414
intersect(that: Set<T>): Set<T>;
1515
filter(predicate: (item: T) => boolean): Set<T>;

types/@msrvida-python-program-analysis/specs/__builtins__.json

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,14 @@
1-
export interface FunctionSpec {
2-
name: string;
3-
updates?: (string | number)[];
4-
reads?: string[];
5-
returns?: string;
6-
returnsType?: PythonType;
7-
higherorder?: number;
1+
export interface Spec {
2+
[name: string]: any;
83
}
9-
export declare type FunctionDescription = string | FunctionSpec;
10-
export declare function getFunctionName(fd: FunctionDescription): string;
11-
export declare function isFunctionSpec(fd: FunctionDescription): fd is FunctionSpec;
124
export declare type PythonType = ListType | ClassType;
135
export declare class ListType {
146
elementType: PythonType;
157
constructor(elementType: PythonType);
168
}
179
export declare class ClassType {
18-
spec: TypeSpec<FunctionSpec>;
19-
constructor(spec: TypeSpec<FunctionSpec>);
10+
private spec;
11+
constructor(spec: Spec);
12+
lookupMethod(name: string): any;
2013
}
21-
export interface TypeSpec<FD> {
22-
methods?: FD[];
23-
}
24-
export interface ModuleSpec<FD> extends TypeSpec<FD> {
25-
functions?: FD[];
26-
modules?: ModuleMap<FD>;
27-
types?: {
28-
[typeName: string]: TypeSpec<FD>;
29-
};
30-
}
31-
export interface ModuleMap<FD> {
32-
[moduleName: string]: ModuleSpec<FD>;
33-
}
34-
export declare type JsonSpecs = ModuleMap<FunctionDescription>;
35-
export declare const DefaultSpecs: JsonSpecs;
14+
export declare const DefaultSpecs: Spec;

0 commit comments

Comments
 (0)