当前位置: 首页>>代码示例>>C#>>正文


C# ISemanticResolver.RestoreContext方法代码示例

本文整理汇总了C#中ISemanticResolver.RestoreContext方法的典型用法代码示例。如果您正苦于以下问题:C# ISemanticResolver.RestoreContext方法的具体用法?C# ISemanticResolver.RestoreContext怎么用?C# ISemanticResolver.RestoreContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISemanticResolver的用法示例。


在下文中一共展示了ISemanticResolver.RestoreContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveTypesAsCLR

    public void ResolveTypesAsCLR(
        ISemanticResolver s,
        ICLRtypeProvider provider
    )
    {
        // We shouldn't have to update the scope stack since
        // we should only be looking at resolved symbols

        Scope prev = s.SetCurrentContext(m_context);
        
        // add all classes in this namespace
        {   
            foreach(TypeDeclBase e in m_arTypes)
                e.ResolveTypesAsCLR(s, provider);
        }
        
        s.RestoreContext(prev);
            
        // Recursively add all classes from nested namespaces
        foreach(NamespaceDecl n in NestedNamespaces)
            n.ResolveTypesAsCLR(s, provider);
    }
开发者ID:chenzuo,项目名称:blue,代码行数:22,代码来源:AST.cs

示例2: ResolveBodies

    // Resolve the bodies of methods
    public void ResolveBodies(ISemanticResolver s)
    {
        if (Mods.IsAbstract)
            return;

        Scope scope = m_symbol.m_scope;
        
        //s.PushScope(scope);
        Scope prev = s.SetCurrentContext(scope);
        s.SetCurrentMethod(m_symbol);        
        
        m_stmtBody.ResolveStatement(s);

        // Do a second pass, for goto statements to resolve against labels.        
        m_stmtBody.ResolveStatement2(s);
   
        s.SetCurrentMethod(null);
        //s.PopScope(scope);
        s.RestoreContext(prev);
    
    }
开发者ID:chenzuo,项目名称:blue,代码行数:22,代码来源:AST.cs

示例3: EnterNamespace

/*    
    void EnterNamespace(ISemanticResolver s)
    {
        m_symbol.SetCurrentNode(this);
        s.PushScope(m_symbol.ChildScope);
    }
    
    void ExitNamespace(ISemanticResolver s)
    {
        m_symbol.SetCurrentNode(null);
        s.PopScope(m_symbol.ChildScope);
    }
*/    

    // Resolve the using declarations
    public void ResolveUsingDecls(ISemanticResolver s)
    {
        // All using declarations are resolved at global scope,
        // so don't enter / exit namespaces here
        //EnterNamespace(s);

        
        // Resolve all the using clauses in this namespace block
        Scope prev = s.SetCurrentContext(this.m_context);
        
        foreach(UsingDirective u in this.m_arUsingDirectives)
            u.Resolve(s, m_context);
            
        s.RestoreContext(prev);            
            
        // Recursively add all classes from nested namespaces
        foreach(NamespaceDecl n in NestedNamespaces)
            n.ResolveUsingDecls(s);

        //ExitNamespace(s);

        m_fResolvedUsing = true;
    }
开发者ID:chenzuo,项目名称:blue,代码行数:38,代码来源:AST.cs

示例4: ResolveMember


//.........这里部分代码省略.........
                // Rename to avoid a naming collision w/ a default ctor.
                // Since no one will call a static ctor (and codegen ignores ctor names),
                // we can pick anything here.
                //this.m_strName = "$static_ctor";
                this.m_idName = new Identifier("$static_ctor", m_idName.Location);

                // Is there a static field initializer to chain to?
                if (nodeClass.StaticInitMethod != null)
                {
                    /*                           
                    Statement stmt = new ExpStatement(
                        new MethodCallExp(
                        null,
                        new Identifier(nodeClass.StaticInitMethod.Name, nodeClass.StaticInitMethod.Location),
                        new ArgExp[0]
                        ));
                    */
                    // If there are Static, ReadOnly fields, then they must be assigned directly
                    // in a constructor, not in a function called by the constructor.
                    Statement stmt = nodeClass.StaticInitMethod.Body;
                    Body.InjectStatementAtHead(stmt);                    
                }
            } // static ctor
            else 
            {
                if (nodeClass.InstanceInitMethod != null)
                {
                    // Chain to an instance-field initializer if we don't chain to
                    // a this() ctor.
                    CtorChainStatement chain = (this.Body.Statements[0]) as CtorChainStatement;
                    Debug.Assert(chain != null);
                    
                    if (chain.TargetType == CtorChainStatement.ETarget.cBase)
                    {       
                        /*                 
                        Statement stmt = new MethodCallStatement(
                            new MethodCallExp(
                                null,
                                new Identifier(nodeClass.InstanceInitMethod.Name, nodeClass.InstanceInitMethod.Location),
                                new ArgExp[0]
                            ));
                        */
                        // PEVerify barfs if we try to do an instance method call in the ctor,
                        // so just inject the raw method body. It's just a bunch of assigns anyway,
                        // so we're ok.
                        Statement stmt = nodeClass.InstanceInitMethod.Body;
                            
                        Body.InjectStatementAtHead(stmt);
                    }
                }
            } // instance ctor
        }
                       
        // Add new sym entry to our parent class's scope
        MethodExpEntry m = new MethodExpEntry(
            Name, 
            this, 
            symDefiningClass, 
            IsCtor ? null : m_tRetType.BlueType
        );
        
        m.m_scope = new Scope(
            "method: " + symDefiningClass.m_strName + "." + Name, 
            this,
            symDefiningClass.MemberScope);
        
        m_symbol = m;
        
        //s.PushScope(m.m_scope);
        Scope prev = s.SetCurrentContext(m.m_scope);
        
        // resolve params (because we'll need them for overloading)
        // Add param 0 for 'this' (if not static)
        // For structs, "this" is a reference, for classes, it's a value.
        if (!Mods.IsStatic)
        {
            ParamVarExpEntry e = new ParamVarExpEntry();
            e.m_strName = "this";
            
            TypeEntry t = m_symbol.SymbolClass;
            if (t.IsStruct)
            {
                t = new RefTypeEntry(t, s);
            }
            e.m_type = t; // 'this' is the type of the containg class   
            e.CodeGenSlot = 0;
            s.GetCurrentContext().AddSymbol(e);
        }
        
        // do rest of the params
        foreach(ParamVarDecl param in m_arParams)
        {
            param.ResolveVarDecl(s);
        }

        //s.PopScope(m.m_scope);
        s.RestoreContext(prev);
                
        symDefiningClass.AddMethodToScope(m);
    }
开发者ID:chenzuo,项目名称:blue,代码行数:101,代码来源:AST.cs

示例5: ResolveMemberDecls

 // Resolve the members (fields & methods)
 public override void ResolveMemberDecls(
     ISemanticResolver s,
     ICLRtypeProvider provider
 )
 {   
     // If we've already been resolved, then skip
     if (this.Symbol.MemberScope.IsLocked)
         return;
         
     // We need our base types to have resolved members so that we can 
     // do inheritence checks.            
     FixBaseMemberDecls(s, provider);    
     
     // Setup our context to do evaluation
     Scope prev = s.SetCurrentContext(m_symbol.MemberScope);
     s.SetCurrentClass(m_symbol);            
             
     // Add our members to our scope
     {
         // Do events first because they generate methods & fields
         FixEvents(s, provider);
     
         if (!IsInterface)
             this.FixFields(s, provider);
         
         // Resolve properties before methods, since properties create methods
         foreach(PropertyDecl p in m_alProperties)
         {
             p.ResolveMember(m_symbol, s, provider);                            
         }
         
         // This can change both the normal methods as well as accessor methods on properties.
         FixMethods(s, provider);
         
         // Set property symbols after we've touched up the methods.
         foreach(PropertyDecl p in m_alProperties)
         {
             p.Symbol.SetInfo(provider);
         }
         
         PostFixEvents(s, provider);
               
         // Nested types
         foreach(TypeDeclBase t in this.m_alNestedTypes)
         {
             t.ResolveMemberDecls(s, provider);        
         }              
                
                 
         // If we have no ctor at all, then add a default one.
         // (default ctor - takes no parameters, chains to base's default ctor)
         if (!IsInterface)
             FixCtors(s, provider);
         
         // We're done adding to the scope, so lock it.
         m_symbol.MemberScope.LockScope();
     }
     
     s.SetCurrentClass(null);        
     s.RestoreContext(prev);
 }
开发者ID:chenzuo,项目名称:blue,代码行数:62,代码来源:AST.cs

示例6: ResolveStatement2

    public override void ResolveStatement2(ISemanticResolver s)
    {
        Scope prev = null;
        if (m_scopeLocals != null)
            //s.PushScope(m_scopeLocals);
            prev = s.SetCurrentContext(m_scopeLocals);

        foreach(Statement stmt in Statements)
        {
            stmt.ResolveStatement2(s);
        }

        if (m_scopeLocals != null)
            //s.PopScope(m_scopeLocals);
            s.RestoreContext(prev);
    }
开发者ID:chenzuo,项目名称:blue,代码行数:16,代码来源:StatementAST.cs

示例7: ResolveStatement

    // Semantic resolution
    public override void ResolveStatement(ISemanticResolver s)
    {        
        Scope prev = null;
        if (this.m_arLocals.Length != 0)
        {
            //s.PushScope(m_scopeLocals);
            m_scopeLocals = new Scope("block_scope", null, s.GetCurrentContext());
            prev = s.SetCurrentContext(m_scopeLocals);
        }
            
        foreach(LocalVarDecl v in Locals)
        {
            v.ResolveVarDecl(s);
        }
                
        foreach(Statement stmt in Statements)
        {
            stmt.ResolveStatement(s);
        }

        if (m_scopeLocals != null)
            //s.PopScope(m_scopeLocals);
            s.RestoreContext(prev);
            
    }
开发者ID:chenzuo,项目名称:blue,代码行数:26,代码来源:StatementAST.cs


注:本文中的ISemanticResolver.RestoreContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。