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


C# ISemanticResolver.GetCurrentClass方法代码示例

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


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

示例1: GetResolvedNode

 // An ObjExp is just a temporary node. But that's the best a Context-Free parse can
 // do. So now that we're building a symbol table, we can do a Context-Sensitive resolution
 // and figure out what type of node this really is.
 public Exp GetResolvedNode(ISemanticResolver s, bool fRight)
 {   
     Exp eResolved = null;
     
     // Lookup the symbol and determine what we are
     //SymEntry sym = s.LookupSymbol(this.m_strId, true);
     string stName = this.m_strId.Text;
     SymEntry sym = s.LookupSymbolWithContext(this.m_strId, false); // allow methods
     
     // Namespace
     if (sym is NamespaceEntry)
     {
         eResolved = new NamespaceExp(sym as NamespaceEntry);
     }
     
     // Local Variable
     else if (sym is LocalVarExpEntry)
     {
         eResolved = new LocalExp(sym as LocalVarExpEntry);
     }
     
     // Parameter
     else if (sym is ParamVarExpEntry)
     {
         eResolved = new ParamExp(sym as ParamVarExpEntry);   
     }
     
     // A type name
     else if (sym is TypeEntry)
     {
         eResolved = new TypeExp(sym as TypeEntry);
     }
     
     // A field (w/ an implied 'this' pointer)
     else if (sym is FieldExpEntry)
     {
         // When a single identifier resolves to a field, it can be either
         // an instance field with an implied 'this' ref, or a static field of this class.
         FieldExpEntry f = sym as FieldExpEntry;
         Exp expInstance = null;
         if (!f.IsStatic)
         {
             expInstance = new SimpleObjExp("this");
             Exp.ResolveExpAsRight(ref expInstance, s);
         }
         eResolved = new FieldExp(f, expInstance);
     }
     
     // An event (w/ an implied 'this' ptr)
     else if (sym is EventExpEntry)
     {
         EventExpEntry e = (EventExpEntry) sym;
         Exp expInstance = null;
         if (!e.Mods.IsStatic)
         {
             expInstance = new SimpleObjExp("this");
             Exp.ResolveExpAsRight(ref expInstance, s);
         }
         eResolved = new EventExp(e, expInstance);            
     }
     
     // A property (w/ an implied 'this' ptr).
     // Properties will eventually be converted into method calls.
     else if (sym is PropertyExpEntry)
     {
         PropertyExpEntry p = (PropertyExpEntry) sym;
         
         Exp expInstance = null;
         if (!p.IsStatic)            
         {
             expInstance = new SimpleObjExp("this");
             Exp.ResolveExpAsRight(ref expInstance, s);
         }
         
         eResolved = new PropertyExp(p, expInstance);
     }
     
     // Not recognized.
     else {
         if (stName == "this") // check a common error case...            
             Debug.Assert(false, "Can't access 'this'. Are we in a static?");
         
         if (sym == null)
         {
             MethodHeaderEntry h = s.GetCurrentClass().LookupMethodHeader(this.m_strId.Text);
             if (h != null)
             {                    
                 return this;
             }
             
             ThrowError(SymbolError.UndefinedSymbol(m_strId));
             //Debug.Assert(false, "Unknown name in SimpleObjExp:" + stName);
         }
         Debug.Assert(false, "Unknown symbol type:" + ((sym == null) ? "null" : sym.ToString()));
     }
     
     
//.........这里部分代码省略.........
开发者ID:chenzuo,项目名称:blue,代码行数:101,代码来源:ObjExpAST.cs

示例2: ResolveExpAsRight

    // Semantic resolution
    protected override Exp ResolveExpAsRight(ISemanticResolver s)
    {   
        // Only resolve once.     
        if (m_symbol != null)
            return this;
            
        // First, resolve our parameters (because of overloading)
        // We need to know the URT types for our parameters
        // in order to resolve between overloaded operators
        
        Type [] alParamTypes = new Type[m_arParams.Length];
        
        
        for(int i = 0; i < m_arParams.Length; i++)        
        {
            Exp e = m_arParams[i];
            ResolveExpAsRight(ref e, s);
            Debug.Assert(e == m_arParams[i]);
            
            Type tParam = e.CLRType;
            
            //if ((tParam !=null) && tParam.IsByRef)
            //    tParam = tParam.GetElementType();
            
            alParamTypes[i] = tParam;
            //Debug.Assert(alParamTypes[i] != null);
            
        }   
        
        TypeEntry tCur = s.GetCurrentClass();    
        TypeEntry tLeft = null; // Type to lookup in   
        
        // Is this a 'base' access?
        // Convert to the real type and set a non-virtual flag
        if (m_objExp is SimpleObjExp)
        {
            SimpleObjExp e = m_objExp as SimpleObjExp;
            if (e.Name.Text == "base")
            {
                // Set the scope that we lookup in.
                tLeft = tCur.Super;
                
                // Still need to resolve the expression.
                m_objExp = new SimpleObjExp("this");               
                                               
                m_fIsNotPolymorphic = true;
            }
        }
        
#if true
        // See if we have a delegate here
        Exp eDelegate = null;
        if (m_objExp == null)
        {
            Exp e = new SimpleObjExp(m_idName);
            Exp.ResolveExpAsRight(ref e, s);
            if (!(e is SimpleObjExp))                
                eDelegate = e;
        } else {
            // If it's an interface, then we know we can't have a delegate field on it, 
            // so short-circuit now. 
            Exp.ResolveExpAsRight(ref m_objExp, s);
            if (!m_objExp.CLRType.IsInterface)
            {                
                Exp e = new DotObjExp(m_objExp, m_idName);
                Exp.ResolveExpAsRight(ref e, s);
                if (!(e is DotObjExp))                
                    eDelegate = e;        
            }
        }

        if (eDelegate != null)
        {
            if (!DelegateDecl.IsDelegate(eDelegate.CLRType))
            {
                //Debug.Assert(false, "@todo - " + m_strName + " is not a delegate or function"); // @todo - legit
                // Just fall through for now, method resolution will decide if this is a valid function
            } else 
            {            
                Exp e = new MethodCallExp(
                    eDelegate, 
                    new Identifier("Invoke"), 
                    this.m_arParams
                );
                
                Exp.ResolveExpAsRight(ref e, s);
                return e;        
            }
        }        
#endif    
        // No delegate, carry on with a normal function call
                        
        // If there's no objexp, then the function is a method
        // of the current class. 
        // make it either a 'this' or a static call
        if (m_objExp == null)
        {   
            // Lookup
            bool fIsVarArgDummy;
//.........这里部分代码省略.........
开发者ID:chenzuo,项目名称:blue,代码行数:101,代码来源:ObjExpAST.cs


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