예제 #1
0
        /// <summary>serach for a scoped name with name parts in searchStartScope and all visible scopes</summary>
        public Scope ResolveScopedNameToScope(Scope searchStartScope, IList parts)
        {
            IList alreadySearchedScopes = new ArrayList(); // more efficient, don't search two times the same scope.
            Queue scopesToSearch        = new Queue();

            scopesToSearch.Enqueue(searchStartScope);
            Scope found = null;

            // search in this scope and all parent scopes
            while ((found == null) && (scopesToSearch.Count > 0))
            {
                Scope searchScope = (Scope)scopesToSearch.Dequeue();
                alreadySearchedScopes.Add(searchScope);
                found = ResolveScopedNameToScopeFromScope(searchScope, parts);
                // if not found: next scope to search in is parent scope
                if ((searchScope.getParentScope() != null) &&
                    (!alreadySearchedScopes.Contains(searchScope.getParentScope())))
                {
                    // if parent scope not null, search in parent
                    scopesToSearch.Enqueue(searchScope.getParentScope());
                }
                // search also in inherited Scopes
                foreach (Scope inheritedScope in searchScope.GetInheritedScopes())
                {
                    if (!alreadySearchedScopes.Contains(inheritedScope))
                    {
                        scopesToSearch.Enqueue(inheritedScope);
                    }
                }
            }

            return(found);
        }
예제 #2
0
        /// <summary>serach for a scoped name representing a symbol with name parts in searchStartScope and all visible scopes</summary>
        public Symbol ResolveScopedNameToSymbol(Scope searchStartScope, IList parts)
        {
            Queue scopesToSearch        = new Queue();
            IList alreadySearchedScopes = new ArrayList(); // more efficient, don't search two times the same scope.

            scopesToSearch.Enqueue(searchStartScope);
            Symbol found = null;

            // search in this scope and all parent scopes
            while ((found == null) && (scopesToSearch.Count > 0))
            {
                Scope searchScope = (Scope)scopesToSearch.Dequeue();
                alreadySearchedScopes.Add(searchScope);
                found = ResolveScopedNameToSymbolFromScope(searchScope, parts);
                // if not found: next scope to search in is parent scope
                if ((searchScope.getParentScope() != null) &&
                    (!alreadySearchedScopes.Contains(searchScope.getParentScope())))
                {
                    // if parent scope not null, search in parent
                    scopesToSearch.Enqueue(searchScope.getParentScope());
                }
                // for interfaces, search in inherited scopes as described in CORBA 2.3, section 3.15.2
                // "Inheritance causes all identifiers defined in base interfaces, both direct and indirect, to
                // be visible in derived interfaces"
                foreach (Scope inheritedScope in searchScope.GetInheritedScopes())
                {
                    if (!alreadySearchedScopes.Contains(inheritedScope))
                    {
                        scopesToSearch.Enqueue(inheritedScope);
                    }
                }
            }
            return(found);
        }