Exemple #1
0
        protected void PushScope(Scope scope)
        {
            scopeStack.AddFirst(currentScope);
            currentScope = scope;

            // Differentiate between pseudo-scopes.
            if(!currentScope.IsPseudoScope())
                currentContainer = currentScope;

            // Push the unsafe context.
            if(scope.IsUnsafe())
                PushUnsafe();
        }
Exemple #2
0
        protected void PopScope()
        {
            // Restore the unsafe context.
            if(currentScope != null && currentScope.IsUnsafe())
                PopUnsafe();

            currentScope = scopeStack.First.Value;
            scopeStack.RemoveFirst();

            if(currentScope == null || !currentScope.IsPseudoScope())
            {
                currentContainer = currentScope;
            }
            else
            {
                // Find the closest container.
                currentContainer = null;
                foreach(Scope scope in scopeStack)
                {
                    if(!scope.IsPseudoScope())
                    {
                        currentContainer = scope;
                        break;
                    }
                }

                // Couldn't find a container.
                if(currentContainer == null)
                    throw new System.ApplicationException("couldn't find a container scope.");
            }
        }