-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtypes.ts
More file actions
56 lines (48 loc) · 1.46 KB
/
types.ts
File metadata and controls
56 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* For better readable code
*/
type Try = Success | Failure;
type Success = { result: any };
type Failure = { errorMessage: string };
// State Types for the Frontend
type FrontendTrace = Array<FrontendTraceElem>;
type FrontendTraceElem = [number, string, string, string, string];
// ############################################################################################
// State Types for the Backend
type PartialBackendTrace = {
trace: BackendTrace;
complete: boolean;
};
type BackendTrace = Array<BackendTraceElem>;
type BackendTraceElem = {
line: number;
filePath: string,
stack: Array<StackElem>;
heap: Map<Address, HeapValue>;
stdout: string;
traceback: string | undefined;
};
type Address = number;
type Value =
| { type: 'int'; value: number }
| { type: 'float'; value: number }
| { type: 'str'; value: string }
| { type: 'none'; value: string }
| { type: 'bool'; value: string }
| { type: 'type'; value: string }
| { type: 'function'; value: string }
| { type: 'ref'; value: Address };
type NamedValue = Value & {
name: string;
};
type StackElem = {
frameName: string;
locals: Array<NamedValue>;
};
type HeapValue =
| { type: 'list'; value: Array<Value> }
| { type: 'tuple'; value: Array<Value> }
| { type: 'set'; value: Array<Value> }
| { type: 'dict'; keys: Map<any, Value>, value: Map<any, Value> }
| { type: 'instance'; name: string, value: Map<string, Value> };
// wrapper type -> frontend list elements dodge