Skip to content

Commit

Permalink
Add 3 source files containing syntax nodes
Browse files Browse the repository at this point in the history
FinallyBlockSyntax.cs - for the IL finally block; TryBlockSyntax.cs - for the IL .try block, and TryFinallyBlockSyntax.cs - for IL .try { ... } finally { ... } block
  • Loading branch information
winscripter authored Jul 24, 2024
1 parent c6596e7 commit 80a1a61
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ILSourceParser/Syntax/FinallyBlockSyntax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using ILSourceParser.Trivia;
using System.Collections.Immutable;

namespace ILSourceParser.Syntax;

/// <summary>
/// Represents an IL <c>finally</c> block.
/// </summary>
public sealed class FinallyBlockSyntax : SyntaxNode
{
public override ImmutableArray<SyntaxTrivia> LeadingTrivia { get; init; }
public override ImmutableArray<SyntaxTrivia> TrailingTrivia { get; init; }

/// <summary>
/// Descendant nodes of the block.
/// </summary>
public IEnumerable<SyntaxNode> DescendantNodes { get; init; }

internal FinallyBlockSyntax(
ImmutableArray<SyntaxTrivia> leadingTrivia,
ImmutableArray<SyntaxTrivia> trailingTrivia,
IEnumerable<SyntaxNode> descendantNodes)
{
LeadingTrivia = leadingTrivia;
TrailingTrivia = trailingTrivia;
DescendantNodes = descendantNodes;
}
}
28 changes: 28 additions & 0 deletions ILSourceParser/Syntax/TryBlockSyntax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using ILSourceParser.Trivia;
using System.Collections.Immutable;

namespace ILSourceParser.Syntax;

/// <summary>
/// Represents an IL <c>.try</c> block.
/// </summary>
public sealed class TryBlockSyntax : SyntaxNode
{
public override ImmutableArray<SyntaxTrivia> LeadingTrivia { get; init; }
public override ImmutableArray<SyntaxTrivia> TrailingTrivia { get; init; }

/// <summary>
/// Descendant nodes of the block.
/// </summary>
public IEnumerable<SyntaxNode> DescendantNodes { get; init; }

internal TryBlockSyntax(
ImmutableArray<SyntaxTrivia> leadingTrivia,
ImmutableArray<SyntaxTrivia> trailingTrivia,
IEnumerable<SyntaxNode> descendantNodes)
{
LeadingTrivia = leadingTrivia;
TrailingTrivia = trailingTrivia;
DescendantNodes = descendantNodes;
}
}
24 changes: 24 additions & 0 deletions ILSourceParser/Syntax/TryFinallyBlockSyntax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using ILSourceParser.Trivia;
using System.Collections.Immutable;

namespace ILSourceParser.Syntax;

public sealed class TryFinallyBlockSyntax : SyntaxNode
{
public override ImmutableArray<SyntaxTrivia> LeadingTrivia { get; init; }
public override ImmutableArray<SyntaxTrivia> TrailingTrivia { get; init; }
public TryBlockSyntax TryBlock { get; init; }
public FinallyBlockSyntax FinallyBlock { get; init; }

internal TryFinallyBlockSyntax(
ImmutableArray<SyntaxTrivia> leadingTrivia,
ImmutableArray<SyntaxTrivia> trailingTrivia,
TryBlockSyntax tryBlock,
FinallyBlockSyntax finallyBlock)
{
LeadingTrivia = leadingTrivia;
TrailingTrivia = trailingTrivia;
TryBlock = tryBlock;
FinallyBlock = finallyBlock;
}
}

0 comments on commit 80a1a61

Please sign in to comment.