CLanguage by praeclarum

<PackageReference Include="CLanguage" Version="0.16.36" />

 BlockContext

public class BlockContext : EmitContext
using CLanguage.Interpreter; using CLanguage.Syntax; using CLanguage.Types; using System.Runtime.CompilerServices; namespace CLanguage.Compiler { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public class BlockContext : EmitContext { public Block Block { get; } public BlockContext(Block block, EmitContext parentContext) : base(parentContext) { Block = block; } public BlockContext(Block block, MachineInfo machineInfo, Report report, CompiledFunction fdecl, EmitContext parentContext) : base(machineInfo, report, fdecl, parentContext) { Block = block; } [return: System.Runtime.CompilerServices.Nullable(2)] public override ResolvedVariable TryResolveVariable(string name, [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] CType[] argTypes) { foreach (Statement statement in Block.Statements) { MultiDeclaratorStatement multiDeclaratorStatement = statement as MultiDeclaratorStatement; if (multiDeclaratorStatement != null && multiDeclaratorStatement.InitDeclarators != null) { foreach (InitDeclarator initDeclarator in multiDeclaratorStatement.InitDeclarators) { if (initDeclarator.Declarator.DeclaredIdentifier == name) { CType variableType = MakeCType(multiDeclaratorStatement.Specifiers, initDeclarator.Declarator, initDeclarator.Initializer, Block); return new ResolvedVariable(Block.VariableScope, 0, variableType); } } } } return base.TryResolveVariable(name, argTypes); } } }