Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the scopes proposal example for recent changes #118

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 45 additions & 18 deletions proposals/scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,37 @@ function _z(_m) {
console.log("Hello World2"); // <- Inlined
```

Scopes:
Original Scopes:

```
A| var x = 1;
|B| function z(message) {
| | let y = 2;
| | console.log(message + y);
| | }
| z("Hello World");
```

`LX CY`: Line X Column Y

```
Start Original Scope L0 C0 { // A
kind: global
field flags: none
name: none
variables: x, z
}
Start Original Scope L1 C10 { // B
kind: function
field flags: has name
name: z
variables: message, y
}
End Original Scope L4 C1 // B
End Original Scope L5 C17 // A
```

Generated Ranges:

```
A| var _x = 1;
Expand All @@ -307,38 +337,35 @@ A| var _x = 1;
`LX CY`: Line X Column Y

```
Start Scope C0 { // A
field flags: has definition
info flags:
definition: file.js L1 C0 - L6 C17
Start Generated Range C0 { // A
field flags: has definition, is scope
definition: file.js, scope offset 0
callsite: none
bindings: x -> _x, z -> _z
}
;
Start Scope C16 { // B
field flags: has name, has definition
info flags: function, inherit parent bindings
name: z
definition: file.js L2 C20 - L5 C1
Start Generated Range C16 { // B
field flags: has definition, is scope
definition: file.js, scope offset 1
callsite: none
bindings: message -> _m, y -> _y
}
;
;
;
End Scope C1 // B
End Generated Range C1 // B
;
Start Scope C0 { // C
field flags: has name, has definition, has callsite
info flags: function, inherit parent bindings
name: z
definition: file.js L2 C0 - L5 C1
callsite: file.js L6 C0
Start Generated Range C0 { // C
field flags: has definition, has callsite
definition: file.js, scope offset 1
callsite: file.js L5 C0
bindings: message -> "Hello World", y -> 2
}
End Scope C28 // C
End Scope C28 // A
```

`XXXX` stands for a "Start Scope" item, `X` for an "End Scope" item
`XXXX` stands for a "Start Generated Range" item, `X` for an "End Generated Range" item
```
XXXX;XXXX;;;X;XXXX,X,X
```
Expand Down
Loading