/// <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); }
/// <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); }
/// <summary> /// closes an open scope /// </summary> public void closeScope() { if (m_currentScope == m_topScope) { throw new ScopeException("top scope can't be closed"); } m_currentScope = m_currentScope.getParentScope(); }
/** get the opened pragma scope, if one is open */ public PragmaScope getOpenPragmaScope() { Scope current = getCurrentScope(); while ((current != null) && (!(current is PragmaScope))) { current = current.getParentScope(); } return((PragmaScope)current); }
/// <summary>returns the fully qualified CLS name of this scope (usable for type generation)</summary> /// <remarks>for type-scopes, returns the nested scope name, because this one is needed for type generation</remarks> private String GetFullyQualifiedScopeName() { string result = ""; for (Scope scope = this; scope.getParentScope() != null; scope = scope.getParentScope()) { string scopeName = IdlNaming.MapIdlNameToClsName(scope.getTypeScopeName()); if (result == "") { result = scopeName; } else { result = scopeName + '.' + result; } } return(result); }
/** returns a Stack of all scope names from a child scope of the pragma scope up to the pragmascope itself */ public static Stack getPathToPragmaScope(Scope fromScope) { Scope current = fromScope; Stack result = new Stack(); while ((current != null) && (!(current is PragmaScope))) { result.Push(current.getScopeName()); current = current.getParentScope(); } if (!(current is PragmaScope)) { result = new Stack(); } return(result); }