Skip to content

Commit ade9bcb

Browse files
committed
[scopes] Add isStackFrame/isHidden bits and make 'OriginalScope.kind' optional
1 parent 8be0fe1 commit ade9bcb

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

proposals/scopes.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,15 @@ interface SourceMap {
132132
interface OriginalScope {
133133
start: OriginalPosition;
134134
end: OriginalPosition;
135-
kind: string;
135+
/** Serves as a label in source-map consumers */
136+
kind?: string;
136137
/** Class/module/function name. Can be used for stack traces or naming scopes in a debugger's scope view */
137138
name?: string;
139+
/**
140+
* Whether this scope corresponds to the semantic equivalent of a function call in
141+
* the authored language, and as such can show up in stack traces.
142+
*/
143+
isStackFrame: boolean;
138144
/** Symbols defined in this scope */
139145
variables?: string[];
140146
children?: OriginalScope[];
@@ -143,7 +149,18 @@ interface OriginalScope {
143149
interface GeneratedRange {
144150
start: GeneratedPosition;
145151
end: GeneratedPosition;
146-
isScope: boolean;
152+
/**
153+
* Whether this range is a JavaScript function/method/generator/constructor and can show
154+
* up in Error.stack as a stack frame.
155+
*/
156+
isStackFrame: boolean;
157+
/**
158+
* Whether calls to this range should be removed from stack traces.
159+
* Intended for outlined functions or transpiler inserted function that correspond
160+
* to an original scope, but should be hidden from stack traces (e.g. an original block
161+
* scope outlined into a function).
162+
*/
163+
isHidden: boolean;
147164
originalScope?: OriginalScope;
148165
/** If this scope corresponds to an inlined function body, record the callsite of the inlined function in the original code */
149166
callsite?: OriginalPosition;
@@ -199,17 +216,20 @@ Note: Each DATA represents one VLQ number.
199216
* Note: this is the point in the original code where the scope starts. `line` is relative to the `line` of the preceding "start/end original scope" item.
200217
* DATA column in the original code
201218
* Note: Column is always absolute.
202-
* DATA kind offset into `names` field
203-
* Note: This offset is relative to the offset of the last `kind` or absolute if this is the first `kind`.
204-
* Note: This is type of the scope.
205-
* Note: JavaScript implementations should use `'global'`, `'class'`, `'function'`, and `'block'`.
206-
* DATA field flags
219+
* DATA flags
207220
* Note: binary flags that specify if a field is used for this scope.
208221
* Note: Unknown flags would skip the whole scope.
209222
* 0x1 has name
223+
* 0x2 has kind
224+
* 0x4 is stack frame
210225
* name: (only exists if `has name` flag is set)
211226
* DATA offset into `names` field
212227
* Note: This name should be shown as function name in the stack trace for function scopes.
228+
* kind: (only exists if `has kind` flag is set)
229+
* DATA offset into `names` field
230+
* Note: This offset is relative to the offset of the last `kind` or absolute if this is the first `kind`.
231+
* Note: This is type of the scope.
232+
* Note: JavaScript implementations should use `'global'`, `'class'`, `'function'`, and `'block'`.
213233
* variables:
214234
* for each variable:
215235
* DATA offset into `names` field for the original symbol name defined in this scope
@@ -231,7 +251,8 @@ Note: Each DATA represents one VLQ number.
231251
* Note: Unknown flags would skip the whole scope.
232252
* 0x1 has definition
233253
* 0x2 has callsite
234-
* 0x4 is scope
254+
* 0x4 is stack frame
255+
* 0x8 is hidden
235256
* definition: (only existing if `has definition` flag is set)
236257
* DATA offset into `sources`
237258
* Note: This offset is relative to the offset of the last definition or absolute if this is the first definition

0 commit comments

Comments
 (0)