public override Expression VisitCall(EqlGrammerParser.CallContext context) { var method = context.method.GetText(); if (!_methodProvider.EntityTypeHasMethod(_currentContext.Type, method)) { throw new EqlCompilerException($"Method '{method}' not found on current context '{_currentContext.Type.Name}'"); } // Keep the current context var outerContext = _currentContext; // some methods might have a different inner context (IEnumerable etc) var methodArgContext = _methodProvider.GetMethodContext(_currentContext, method); _currentContext = methodArgContext; // Compile the arguments with the new context var args = context.arguments?.children.Select(c => Visit(c)).ToList(); // build our method call var call = _methodProvider.MakeCall(outerContext, methodArgContext, method, args); _currentContext = call; return(call); }
/// <summary> /// Visit a parse tree produced by <see cref="EqlGrammerParser.call"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitCall([NotNull] EqlGrammerParser.CallContext context) { return(VisitChildren(context)); }