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

Provide a way to specify existing bindings when analyzing an interactive document #54

Closed
alexrp opened this issue Mar 19, 2023 · 0 comments
Labels
area: analysis Issues related to language analyses. area: tests Issues related to the test suite. type: feature Issues that are classified as feature requests.
Milestone

Comments

@alexrp
Copy link
Sponsor Member

alexrp commented Mar 19, 2023

Also, we need to process let statements in a similar fashion to what we do in block expressions:

public override InteractiveDocumentSemantics VisitInteractiveDocument(InteractiveDocumentSyntax node)
{
var subs = ConvertList(node.Submissions, static (@this, sub) => @this.VisitSubmission(sub));
return new(node, subs);
}

public override BlockExpressionSemantics VisitBlockExpression(BlockExpressionSyntax node)
{
using var ctx = PushScope<BlockScope>();
var stmts = Builder<StatementSemantics>(node.Statements.Count);
// Let statements are somewhat special in that they introduce a 'horizontal' scope in the tree; that is,
// bindings in a let statement become available to siblings to the right of the let statement.
var lets = new List<ScopeContext<Scope>>();
var defers = ctx.Scope.DeferStatements;
foreach (var stmt in node.Statements)
{
if (stmt is LetStatementSyntax)
lets.Add(PushScope<Scope>());
var sema = VisitStatement(stmt);
if (sema is DeferStatementSemantics defer)
defers.Add(defer);
stmts.Add(sema);
}
for (var i = lets.Count - 1; i >= 0; i--)
lets[i].Dispose();
defers.Reverse();
return new(node, List(node.Statements, stmts), defers.DrainToImmutable());
}

@alexrp alexrp added state: approved Feature requests and housekeeping tasks that have been approved. type: feature Issues that are classified as feature requests. area: analysis Issues related to language analyses. labels Mar 19, 2023
@alexrp alexrp added this to the v1.0 milestone Mar 19, 2023
@alexrp alexrp self-assigned this Mar 19, 2023
@alexrp alexrp added the area: tests Issues related to the test suite. label Mar 25, 2023
@alexrp alexrp closed this as completed in 78248c6 Mar 25, 2023
@alexrp alexrp removed the state: approved Feature requests and housekeeping tasks that have been approved. label Mar 25, 2023
@alexrp alexrp removed their assignment Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: analysis Issues related to language analyses. area: tests Issues related to the test suite. type: feature Issues that are classified as feature requests.
Development

No branches or pull requests

1 participant