T PopBlock <T>() where T : BlockContainerNode { if (stack.IsEmpty()) { AddError(true, "No {0} has been opened".FormatWith(BlockContainerNode.UserString(typeof(T)))); return(null); } BlockContainerNode n = stack.Pop(); if (n == null || !(n is T)) { AddError(true, "Unexpected '{0}'".FormatWith(BlockContainerNode.UserString(n?.GetType()))); return(null); } variables = variables.Previous; return((T)n); }
T PeekBlock <T>() where T : BlockContainerNode { if (stack.IsEmpty()) { AddError(true, "No {0} has been opened".FormatWith(BlockContainerNode.UserString(typeof(T)))); return(null); } BlockContainerNode n = stack.Peek(); if (n == null || !(n is T)) { AddError(true, "Unexpected '{0}'".FormatWith(BlockContainerNode.UserString(n?.GetType()))); return(null); } variables = variables.Previous; variables = new ScopedDictionary <string, ValueProviderBase>(variables); return((T)n); }