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); } }
protected bool InsideEachLoopCheck(CompilationState state) { if (state.LoopLevel > 0) { return(true); } state.AddTypeError("SpecialExpressions can only exist inside EachBlocks", HandlebarsTypeErrorKind.SpecialExpressionOutsideEachLoop); return(false); }
internal override bool TryEvaluate(Stack <Context> contextStack, CompilationState state, out Context context) { if (!contextStack.Any() || contextStack.Count == 1) { state.AddTypeError("Error in MemberExpression: Empty ContextStack but PathUp Element ('../')!", HandlebarsTypeErrorKind.EmptyContextStack); context = null; return(false); } contextStack.Pop(); return(_next.TryEvaluate(contextStack, state, out context)); }
internal override bool TryEvaluate(CompilationState state, out Context context) { var ctLoopContext = IsCompileTimeLoop(state); if (ctLoopContext != null) { context = new Context($"\"{ctLoopContext.Key}\"", state.Introspector.GetStringTypeSymbol()); return(true); } else { state.AddTypeError("KeyExpression outside a compiletime loop over an Object", HandlebarsTypeErrorKind.IllegalKeyExpression); context = null; return(false); } }