-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmemo.ts
More file actions
146 lines (131 loc) · 3.39 KB
/
memo.ts
File metadata and controls
146 lines (131 loc) · 3.39 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import type { Pointer } from "@ethdebug/format";
import type { Cursor } from "#cursor";
import type { Data } from "#data";
/**
* A single state transition for processing on a stack
*/
export type Memo =
| Memo.DereferencePointer
| Memo.SaveRegions
| Memo.SaveVariables
| Memo.PushRegionRenames
| Memo.PopRegionRenames
| Memo.PushTemplates
| Memo.PopTemplates;
export namespace Memo {
/**
* A request to dereference a pointer
*/
export interface DereferencePointer {
kind: "dereference-pointer";
pointer: Pointer;
}
/**
* Initialize a DereferencePointer memo
*/
export const dereferencePointer = (pointer: Pointer): DereferencePointer => ({
kind: "dereference-pointer",
pointer,
});
/**
* A request to modify the stateful map of regions by name with a
* particular set of new entries.
*
* This does not indicate that any change should be made to region names not
* included in this memo.
*/
export interface SaveRegions {
kind: "save-regions";
regions: Record<string, Cursor.Region>;
}
/**
* Initialize a SaveRegions memo
*/
export const saveRegions = (
regions: Record<string, Cursor.Region>,
): SaveRegions => ({
kind: "save-regions",
regions,
});
/**
* A request to modify the stateful map of variable values with a
* particular set of new entries.
*
* This does not indicate that any change should be made to variables not
* included in this memo.
*/
export interface SaveVariables {
kind: "save-variables";
variables: Record<string, Data>;
}
/**
* Initialize a SaveVariables memo
*/
export const saveVariables = (
variables: Record<string, Data>,
): SaveVariables => ({
kind: "save-variables",
variables,
});
/**
* A request to push a region rename mapping onto the context stack.
* While active, regions with names in the mapping will be saved under
* both their original name (for internal references) and their new name
* (for external references after the template).
*/
export interface PushRegionRenames {
kind: "push-region-renames";
mapping: Record<string, string>;
}
/**
* Initialize a PushRegionRenames memo
*/
export const pushRegionRenames = (
mapping: Record<string, string>,
): PushRegionRenames => ({
kind: "push-region-renames",
mapping,
});
/**
* A request to pop the current region rename mapping from the context stack.
*/
export interface PopRegionRenames {
kind: "pop-region-renames";
}
/**
* Initialize a PopRegionRenames memo
*/
export const popRegionRenames = (): PopRegionRenames => ({
kind: "pop-region-renames",
});
/**
* A request to push template definitions onto the context stack.
* While active, these templates are available for use by reference
* collections.
*/
export interface PushTemplates {
kind: "push-templates";
templates: Pointer.Templates;
}
/**
* Initialize a PushTemplates memo
*/
export const pushTemplates = (
templates: Pointer.Templates,
): PushTemplates => ({
kind: "push-templates",
templates,
});
/**
* A request to pop the current template definitions from the context stack.
*/
export interface PopTemplates {
kind: "pop-templates";
}
/**
* Initialize a PopTemplates memo
*/
export const popTemplates = (): PopTemplates => ({
kind: "pop-templates",
});
}