Beispiel #1
0
 public Scope(String name, Scope parentScope, bool isTypeScope) {
     m_scopeName = name;
     m_parentScope = parentScope;
     if (m_parentScope != null) {
         m_parentScope.addChildScope(this);
     }
     m_isTypeScope = isTypeScope;
 }
 /** opens a scope in the current scope */
 public Scope openScope(String scopeName, bool isTypeScope) {
     if (m_currentScope.containsChildScope(scopeName)) {
         m_currentScope = m_currentScope.getChildScope(scopeName);
     } else {
         Scope newScope = new Scope(scopeName, m_currentScope, isTypeScope);
         m_currentScope = newScope;
     }
     return m_currentScope;
 }
 /** 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;
 }
 /// <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();
 }
 public SymbolTable() {
     m_currentScope = new Scope("", null, false);
     m_topScope = m_currentScope;
     AddPredefinedSymbols();
 }
 /** close the opened pragma scope */
 public void closePragmaScope() {
     PragmaScope scopeToClose = getOpenPragmaScope();
     if (scopeToClose != null) {
         m_currentScope = scopeToClose.getParentScope();
     }
 }
 public PragmaScope(String name, Scope parentScope) : base(name, parentScope, false) {
 }
 public SymbolValue(String symbolName, Scope declaredIn) : base(symbolName, declaredIn) {
 }
 /// <summary>search starting from serachScope for a scope with name scopeNameParts
 private Scope ResolveScopedNameToScopeFromScope(Scope searchScope, IList parts) {
     if ((parts == null) || (parts.Count == 0)) {
         return null;
     }
     Scope currentScope = searchScope;
     for (int i = 0; i < parts.Count; i++) {
         // resolve scopes
         currentScope = currentScope.getChildScope((String)parts[i]);
         if (currentScope == null) { 
             return null; // not found within this searchScope
         }
     }
     return currentScope;
 }
 /// <summary>
 /// resolve a scoped name to a symbol starting in searchScope 
 /// </summary>
 private Symbol ResolveScopedNameToSymbolFromScope(Scope searchScope, IList parts) {
     if ((parts == null) || (parts.Count == 0)) {
         return null;
     }
     Scope currentScope = searchScope;
     for (int i = 0; i < parts.Count - 1; i++) {
         // resolve scopes
         currentScope = currentScope.getChildScope((String)parts[i]);
         if (currentScope == null) { 
             return null; // not found within this searchScope
         }
     }
     // resolve symbol
     Symbol sym = currentScope.getSymbol((String)parts[parts.Count - 1]);
     return sym;
 }    
 public BuildInfo(Scope buildScope, TypeBuilder containerType, 
                  Symbol containerSymbol) {
     m_buildScope = buildScope;
     m_containerType = containerType;
     m_containerSymbol = containerSymbol;
 }
 public ConcreteValTypeBuildInfo(Scope buildScope,
                                 TypeBuilder containerType,
                                 Symbol containerSymbol,
                                 ConstructorBuilder defConstr) :
                                     base(buildScope, containerType,
                                          containerSymbol) {
     m_defaultConstr = defConstr;
 }
 public UnionBuildInfo(Scope buildScope, UnionGenerationHelper helper,
                       Symbol containerSymbol) : 
                       base(buildScope, helper.Builder, containerSymbol) {
     m_helper = helper;
 }
 /**
  * Constructor for SymbolDefinition.
  * @param symbolName
  */
 public SymbolDefinition(String symbolName, Scope declaredIn) : base(symbolName, declaredIn) {
 }
Beispiel #15
0
 public void addChildScope(Scope scope) {
     m_childScopes[scope.getScopeName()] = scope;
 }
Beispiel #16
0
 public Symbol(String symbolName, Scope declaredIn) {
     m_symbolName = symbolName;
     m_declaredIn = declaredIn;
 }
 public SymbolTypedef(String symbolName, Scope declaredIn) : base(symbolName, declaredIn) {
 }
 /// <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;
 }
 public SymbolFwdDecl(String symbolName, Scope declaredIn) : base(symbolName, declaredIn) {
 }
 /// <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;
 }
 /** open a pragma-scope */
 public Scope openPragmaScope(String scopeName) {
     if (!(scopeName.Equals(""))) {
         if (m_currentScope.containsChildScope(scopeName)) {
             m_currentScope = m_currentScope.getChildScope(scopeName);
         } else {
             Scope newScope = new PragmaScope(scopeName, m_currentScope);
             m_currentScope = newScope;
         }
     }
     return m_currentScope;
 }
Beispiel #22
0
 /// <summary>
 /// adds an inherited scope (e.g. interface A : B leads to A inheriting scope B)
 /// </summary>
 public void AddInheritedScope(Scope scope) {
     m_inheritedScopes.Add(scope);
 }