From 0db0e695b4923d060d63721d008634880380e3c3 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 29 Jul 2024 16:53:47 -0700 Subject: [PATCH 1/2] Update the scopes proposal example for recent changes * Use "original scope" + "generated range" terminology * Update to use current flags & arguments --- proposals/scopes.md | 61 ++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/proposals/scopes.md b/proposals/scopes.md index 74c3574..979a480 100644 --- a/proposals/scopes.md +++ b/proposals/scopes.md @@ -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; @@ -307,30 +337,27 @@ 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 +Start Generated Range C0 { // C + field flags: has definition, has callsite + definition: file.js, scope offset 1 callsite: file.js L6 C0 bindings: message -> "Hello World", y -> 2 } @@ -338,7 +365,7 @@ 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 ``` From 9a7a84358cc62ef18bb891fd1f80c90e6818120e Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 30 Jul 2024 12:07:29 -0700 Subject: [PATCH 2/2] Adjust callsite line number --- proposals/scopes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/scopes.md b/proposals/scopes.md index 979a480..1359312 100644 --- a/proposals/scopes.md +++ b/proposals/scopes.md @@ -358,7 +358,7 @@ End Generated Range C1 // B Start Generated Range C0 { // C field flags: has definition, has callsite definition: file.js, scope offset 1 - callsite: file.js L6 C0 + callsite: file.js L5 C0 bindings: message -> "Hello World", y -> 2 } End Scope C28 // C