Exemple #1
0
//-----------------------------------------------------------------------------        
// Main checking routine
// Return true if successful, else false
//-----------------------------------------------------------------------------
    public bool DoCheck(
        AST.ProgramDecl p,
        ICLRtypeProvider provider,
        Assembly [] refs
    )
    {   
        Debug.Assert(provider != null);
        Debug.Assert(p != null);
    
        m_provider = provider;
        
        string stSubPhase = "";
        try
        {   
            m_scopeGlobal = new Scope("Global", null, null);
            
                
                            
            // Import symbols            
            stSubPhase = "importing assemblies";            
            ImportAssembly(GetMscorlib());
            AddDefaultTypes(m_scopeGlobal);
            foreach(Assembly a in refs)
            {
                ImportAssembly(a);
            }
            
            // Pass 1 - Resolve the namespaces and stub the types.
            // This will stub all scopes and create a lexical-scope tree.            
            stSubPhase = "resolving namespaces";            
            p.ResolveNamespace(this, m_scopeGlobal);
            
            
            // Pass 2 - Resolve Types (to both CLR & Blue)             
            stSubPhase = "resolving to clr types";            
            p.ResolveTypes(this, provider);
                		    		    		
            // Pass 3 - resolve class member declarations (Methods & fields)
            stSubPhase = "resolving member declarations";            
            p.ResolveMemberDecls(this, provider);
                		    		
            // Pass 4 - resolve method bodies
            stSubPhase = "resolving member bodies";            
            p.ResolveBodies(this);
                        
            // Final Debug verify before codegen
            stSubPhase = "final debug check";
            p.DebugCheck(this);
            m_scopeGlobal.DebugCheck(this);
            
            p.NotifyResolutionDone();
            
            return true;
        }
        
        // Strip away SymbolErrors; we've already reported them when we first threw them.
        catch (SymbolError.SymbolErrorException)
        {            
            return false;
        }
        catch(System.Exception e)
        {
            Blue.Driver.PrintError_InternalError(e, "Symbol Resolution(" + stSubPhase + ")");
            return false;
        }
    }