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


C# ISemanticResolver.LookupSystemType方法代码示例

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


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

示例1: ResolveExpAsRight

 // Nothing to resolve for literal expressions
 protected override Exp ResolveExpAsRight(ISemanticResolver s)
 {   
     // Always resolve our children     
     ResolveExpAsRight(ref m_left, s);
     ResolveExpAsRight(ref m_right, s);
     
     // If we don't match a predefined operator, then check for overloads
     if (!MatchesPredefinedOp(Op, this.Left.CLRType, this.Right.CLRType))
     {
         // Packagage Left & Right into parameters for a method call
         ArgExp [] args = new ArgExp [2] {
             new ArgExp(EArgFlow.cIn, m_left),
             new ArgExp(EArgFlow.cIn, m_right)
         };
                                 
         // Check for delegate combination
         // D operator+(D, D)
         // D operator-(D, D)            
         if (AST.DelegateDecl.IsDelegate(m_left.CLRType))
         {
             if (m_left.CLRType == m_right.CLRType)
             {
                 if (Op == BinaryOp.cAdd || Op == BinaryOp.cSub)
                 {
                     System.Type d = m_left.CLRType;
                     
                     // Translates to:
                     // op+ --> (D) System.Delegate.Combine(left, right)
                     // op- --> (D) System.Delegate.Remove(left, right)
                     
                     TypeEntry tDelegate = s.LookupSystemType("MulticastDelegate");
                     string stName = (Op == BinaryOp.cAdd) ? "Combine" : "Remove";
                     
                     bool dummy;
                     MethodExpEntry sym = tDelegate.LookupMethod(s, new Identifier(stName), 
                         new Type[] { d, d}, out dummy);
                     
                     
                     Exp call2 = new CastObjExp(
                         new ResolvedTypeSig(d, s),
                         new MethodCallExp(
                             null,sym, args, s)
                     );
                     
                     Exp.ResolveExpAsRight(ref call2, s);
                     return call2;                                
                 
                 }
             }
         
         } // end delgate op+ check
                                         
         // Check for System.String.Concat().
         // @todo - this should be able to compress an entire subtree, not just 2 args.
         // (ie, a+b+c -> String.Concat(a,b,c);
         // So we can't merge this into the SearchForOverload.
         // But for now we'll be lazy...
         if ((Op == BinaryOp.cAdd) && (Left.CLRType == typeof(string) || Right.CLRType == typeof(string)))
         {                
             Exp call2 = new MethodCallExp(                    
                     new DotObjExp(
                         new SimpleObjExp(
                             new Identifier("System", this.m_filerange)
                         ),
                         new Identifier("String", this.m_filerange)),
                     new Identifier("Concat", m_filerange),
                     args);
             call2.SetLocation(this.Location);
             Exp.ResolveExpAsRight(ref call2, s);
                     
             return call2;
         }
     
         MethodExpEntry  m = SearchForOverloadedOp(s);
         if (m == null && (Op == BinaryOp.cEqu || Op == BinaryOp.cNeq))
         {
             // If it's '==' or '!=', then it's ok if we didn't find 
             // an overload.
         } else 
         {
             // Couldn't find an overload, throw error
             if (m == null)
             {
                 //ThrowError_NoAcceptableOperator(s, this.Location, m_left.CLRType, m_right.CLRType, Op);
                 ThrowError(SymbolError.NoAcceptableOperator(this.Location, m_left.CLRType, m_right.CLRType, Op));
             }
             
             // Replace this node w/ the method call            
             MethodCallExp call = new MethodCallExp(null, m, args, s);
             call.SetLocation(this.Location);
             
             return call;
         }
     }
     
     
     CalcCLRType(s);
     
     return this;
//.........这里部分代码省略.........
开发者ID:chenzuo,项目名称:blue,代码行数:101,代码来源:ExpAST.cs


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