Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 9e9cbeb

Browse files
author
Hendrik van Antwerpen
authored
Merge pull request #59 from github/one-scope-doctrine
Unify internal and exported scopes
2 parents 48334af + 95e7c75 commit 9e9cbeb

10 files changed

Lines changed: 140 additions & 186 deletions

File tree

‎stack-graphs/include/stack-graphs.h‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ enum sg_deque_direction {
3131
enum sg_node_kind {
3232
// Removes everything from the current scope stack.
3333
SG_NODE_KIND_DROP_SCOPES,
34-
// A node that can be referred to on the scope stack, which allows "jump to" nodes in any
35-
// other part of the graph can jump back here.
36-
SG_NODE_KIND_EXPORTED_SCOPE,
37-
// A node internal to a single file. This node has no effect on the symbol or scope stacks;
38-
// it's just used to add structure to the graph.
39-
SG_NODE_KIND_INTERNAL_SCOPE,
4034
// The singleton "jump to" node, which allows a name binding path to jump back to another part
4135
// of the graph.
4236
SG_NODE_KIND_JUMP_TO,
@@ -53,6 +47,10 @@ enum sg_node_kind {
5347
SG_NODE_KIND_PUSH_SYMBOL,
5448
// The singleton root node, which allows a name binding path to cross between files.
5549
SG_NODE_KIND_ROOT,
50+
// A node that adds structure to the graph. If the node is exported, it can be
51+
// referred to on the scope stack, which allows "jump to" nodes in any other
52+
// part of the graph can jump back here.
53+
SG_NODE_KIND_SCOPE,
5654
};
5755

5856
// Manages the state of a collection of partial paths to be used in the path-stitching algorithm.
@@ -176,10 +174,11 @@ struct sg_node {
176174
// attached to the symbol before it's pushed onto the symbol stack. For all other node types,
177175
// this will be null.
178176
struct sg_node_id scope;
179-
// Whether this node is "clickable". For push nodes, this indicates that the node represents
177+
// Whether this node is an endpoint. For push nodes, this indicates that the node represents
180178
// a reference in the source. For pop nodes, this indicates that the node represents a
181-
// definition in the source. For all other node types, this field will be unused.
182-
bool is_clickable;
179+
// definition in the source. For scopes, this indicates that the scope is exported. For all
180+
// other node types, this field will be unused.
181+
bool is_endpoint;
183182
};
184183

185184
// An array of all of the nodes in a stack graph. Node handles are indices into this array.

‎stack-graphs/src/c.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ pub struct sg_node {
429429
/// attached to the symbol before it's pushed onto the symbol stack. For all other node types,
430430
/// this will be null.
431431
pub scope: sg_node_id,
432-
/// Whether this node is "clickable". For push nodes, this indicates that the node represents
432+
/// Whether this node is an endpoint. For push nodes, this indicates that the node represents
433433
/// a reference in the source. For pop nodes, this indicates that the node represents a
434-
/// definition in the source. For all other node types, this field will be unused.
435-
pub is_clickable: bool,
434+
/// definition in the source. For scopes, this indicates that the scope is exported. For all
435+
/// other node types, this field will be unused.
436+
pub is_endpoint: bool,
436437
}
437438

438439
impl Into<Node> for sg_node {
@@ -447,12 +448,6 @@ impl Into<Node> for sg_node {
447448
pub enum sg_node_kind {
448449
/// Removes everything from the current scope stack.
449450
SG_NODE_KIND_DROP_SCOPES,
450-
/// A node that can be referred to on the scope stack, which allows "jump to" nodes in any
451-
/// other part of the graph can jump back here.
452-
SG_NODE_KIND_EXPORTED_SCOPE,
453-
/// A node internal to a single file. This node has no effect on the symbol or scope stacks;
454-
/// it's just used to add structure to the graph.
455-
SG_NODE_KIND_INTERNAL_SCOPE,
456451
/// The singleton "jump to" node, which allows a name binding path to jump back to another part
457452
/// of the graph.
458453
SG_NODE_KIND_JUMP_TO,
@@ -469,6 +464,10 @@ pub enum sg_node_kind {
469464
SG_NODE_KIND_PUSH_SYMBOL,
470465
/// The singleton root node, which allows a name binding path to cross between files.
471466
SG_NODE_KIND_ROOT,
467+
/// A node that adds structure to the graph. If the node is exported, it can be
468+
/// referred to on the scope stack, which allows "jump to" nodes in any other
469+
/// part of the graph can jump back here.
470+
SG_NODE_KIND_SCOPE,
472471
}
473472

474473
/// A handle to a node in a stack graph. A zero handle represents a missing node.

0 commit comments

Comments
 (0)