internal override bool TryEvaluate(Stack<Context> contextStack, CompilationState state, out Context context)
{
//Add the Identifier to the current context
var memberSymbol = contextStack.Any() ? contextStack.Peek().Symbol.FindMember(_value) :
state.Introspector.GetTypeSymbol(_value);
if (memberSymbol != null)
{
var identifierContext = new Context(string.Join(".", contextStack.Peek().FullPath, _value), memberSymbol);
if (_next == null)
{
//Last element => return IdentifierContext
context = identifierContext;
return true;
}
else
{
//Push the identifier on the contextStack and keep going
contextStack.Push(identifierContext);
return _next.TryEvaluate(contextStack, state, out context);
}
}
else
{
state.AddTypeError($"Could not find Member '{_value}' in Type '{contextStack.Peek().Symbol.ToDisplayString()}'!", HandlebarsTypeErrorKind.UnknownMember);
context = null;
return false;
}
}