in src/Core/Compiling/Syntax/ExpressionStatementCompiler.cs [23:63]
public void Compile(ICompilationContext context, SyntaxNode node)
{
var statement = node as ExpressionStatementSyntax ?? throw new NullReferenceException(nameof(node));
var invocation = statement.Expression as InvocationExpressionSyntax;
if (invocation == null)
{
context.Report(Diagnostic.Create(
CompilationErrors.ExpressionNotSupported,
statement.Expression.GetLocation(),
statement.Expression.GetType().Name,
nameof(InvocationExpressionSyntax)
));
return;
}
var memberAccess = invocation.Expression as MemberAccessExpressionSyntax;
if (memberAccess == null)
{
context.Report(Diagnostic.Create(
CompilationErrors.ExpressionNotSupported,
invocation.Expression.GetLocation(),
invocation.Expression.GetType().Name,
nameof(MemberAccessExpressionSyntax)
));
return;
}
var name = memberAccess.Name.ToString();
if (_handlers.TryGetValue(name, out var handler))
{
handler.Handle(context, invocation);
}
else
{
context.Report(Diagnostic.Create(
CompilationErrors.MethodNotSupported,
memberAccess.GetLocation(),
name
));
}
}