コード例 #1
0
ファイル: SemanticChecker.cs プロジェクト: richardy2012/blue
 // We only need Lookup() during the resolve phase (because that's the only time
 // we need to convert text into symbols)
 // After that, we can just use the symbols directly    
 
 // Lookup an entry in a specific scope
 // If it doesn't exist, then return null if !fMustExist and throw if fMustExist
 public SymEntry LookupSymbol(Scope scope, Identifier id, bool fMustExist)
 {
     SymEntry  s = scope.LookupSymbol(id.Text);
     if (fMustExist && s == null)
     {
         ThrowError(SymbolError.UndefinedSymbol(id));
     }
     return s;
 }
コード例 #2
0
ファイル: SemanticChecker.cs プロジェクト: richardy2012/blue
    // Lookup a symbol in the current context.
    // The context includes the lexical scope stack, super scopes, 
    // and using directives        
    // If it doesn't exist, then return null if !fMustExist and throw exception if fMustExist
    public virtual SymEntry LookupSymbolWithContext(Identifier id, bool fMustExist)
    {   
        string strName = id.Text;
    
        // Search through stack of lexical scopes
        SymEntry sym = null;
        Scope t = m_CurrentContext;
        while(t != null)
        {
            sym = LookupSymbol(t, id, false); // <-- smart lookup, go through ILookupController
            if (sym != null) 
                return sym;
            t = t.m_LexicalParent;            
        }

        // Don't need this any more with ILookupControllers
        #if false
        // Check using directives if not found in the current scope stack
        // Do this by traversing the scope stack and looking for UserNamespaceEntry
        // (we can never be in an imported namespace, so that's ok)
        t = m_CurrentContext;
        while (t != null)
        {            
            AST.NamespaceDecl node = t.Node as AST.NamespaceDecl;            
            if (node != null)
            {
                sym = node.LookupSymbolInUsingDirectives(this, id);
                if (sym != null)
                    return sym;
            }

            t = t.m_LexicalParent;
        }
        #endif

            
        // Symbol  not found
        if (fMustExist) 
        {            
            //ThrowError_UndefinedSymbol(id);
            ThrowError(SymbolError.UndefinedSymbol(id));
        }
        return null;
    }
コード例 #3
0
ファイル: SemanticChecker.cs プロジェクト: richardy2012/blue
 // Get rid of this function
 public SymEntry LookupSymbol(Scope scope, string st, bool fMustExist)
 {
     SymEntry s = scope.LookupSymbol(st);        
     bool f= false;
     if (f) {
         System.Xml.XmlWriter o = new System.Xml.XmlTextWriter(new System.IO.StreamWriter("dump.xml"));
         scope.Dump(o, true);
         o.Close();
     }
     
     if (fMustExist && s == null)
     {
         FileRange range = new FileRange();
         range.Filename = "<not specified>";
         
         Identifier id = new Identifier(st, range);
         //ThrowError_UndefinedSymbol(id);
         ThrowError(SymbolError.UndefinedSymbol(id));
     }
     return s;
 }