• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ISemantic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISemantic的典型用法代码示例。如果您正苦于以下问题:C# ISemantic类的具体用法?C# ISemantic怎么用?C# ISemantic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISemantic类属于命名空间,在下文中一共展示了ISemantic类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UFCSResolver

 UFCSResolver(ResolutionContext ctxt, ISemantic firstArg, int nameHash = 0, ISyntaxRegion sr = null)
     : base(ctxt)
 {
     this.firstArgument = firstArg;
     this.nameFilterHash = nameHash;
     this.sr = sr;
 }
开发者ID:rainers,项目名称:D_Parser,代码行数:7,代码来源:UFCSResolver.cs


示例2: HandleDecl

		bool HandleDecl(TemplateTypeParameter p, IdentifierDeclaration id, ISemantic r)
		{
			// Bottom-level reached
			if (id.InnerDeclaration == null && Contains(id.IdHash) && !id.ModuleScoped)
			{
				// Associate template param with r
				return Set((p != null && id.IdHash == p.NameHash) ? p : null, r, id.IdHash);
			}

			var deducee = DResolver.StripMemberSymbols(AbstractType.Get(r)) as DSymbol;
			if (id.InnerDeclaration != null && deducee != null && deducee.Definition.NameHash == id.IdHash)
			{
				var physicalParentType = TypeDeclarationResolver.HandleNodeMatch(deducee.Definition.Parent, ctxt, null, id.InnerDeclaration);
				if (HandleDecl(p, id.InnerDeclaration, physicalParentType))
				{
					if (Contains(id.IdHash))
						Set((p != null && id.IdHash == p.NameHash) ? p : null, deducee, id.IdHash);
					return true;
				}
			}

			/*
			 * If not stand-alone identifier or is not required as template param, resolve the id and compare it against r
			 */
			var _r = TypeDeclarationResolver.ResolveSingle(id, ctxt);

			return _r != null && (EnforceTypeEqualityWhenDeducing ?
				ResultComparer.IsEqual(r,_r) :
				ResultComparer.IsImplicitlyConvertible(r,_r));
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:30,代码来源:TemplateTypeParameterDeduction.cs


示例3: FindFitting

        public IEnumerable<DMethod> FindFitting(ResolverContextStack ctxt, CodeLocation currentLocation, ISemantic firstArgument, string nameFilter = null)
        {
            if (IsProcessing)
                return null;

            var preMatchList = new List<DMethod>();

            bool dontUseNameFilter = nameFilter == null;

            lock(CachedMethods)
                foreach (var kv in CachedMethods)
                {
                    // First test if arg is matching the parameter
                    if ((dontUseNameFilter || kv.Key.Name == nameFilter) &&
                        ResultComparer.IsImplicitlyConvertible(firstArgument, kv.Value, ctxt))
                        preMatchList.Add(kv.Key);
                }

            // Then filter out methods which cannot be accessed in the current context
            // (like when the method is defined in a module that has not been imported)
            var mv = new MatchFilterVisitor<DMethod>(ctxt, preMatchList);

            mv.IterateThroughScopeLayers(currentLocation);

            return mv.filteredList;
        }
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:26,代码来源:UFCSCache.cs


示例4: IsEqual

        /// <summary>
        /// Checks given results for type equality
        /// </summary>
        public static bool IsEqual(ISemantic r1, ISemantic r2)
        {
            if (r1 is ISymbolValue && r2 is ISymbolValue)
                return SymbolValueComparer.IsEqual((ISymbolValue)r1, (ISymbolValue)r2);

            else if (r1 is TemplateIntermediateType && r2 is TemplateIntermediateType)
            {
                var tr1 = (TemplateIntermediateType)r1;
                var tr2 = (TemplateIntermediateType)r2;

                if (tr1.Definition != tr2.Definition)
                    return false;

                //TODO: Compare deduced types
                return true;
            }
            else if (r1 is PrimitiveType && r2 is PrimitiveType)
                return ((PrimitiveType)r1).TypeToken == ((PrimitiveType)r2).TypeToken;
            else if (r1 is ArrayType && r2 is ArrayType)
            {
                var ar1 = (ArrayType)r1;
                var ar2 = (ArrayType)r2;

                if (!IsEqual(ar1.KeyType, ar2.KeyType))
                    return false;

                return IsEqual(ar1.Base, ar2.Base);
            }

            //TODO: Handle other types

            return false;
        }
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:36,代码来源:ResultComparer.cs


示例5: HandleDecl

        public bool HandleDecl(TemplateTypeParameter p ,ITypeDeclaration td, ISemantic rr)
        {
            if (td is IdentifierDeclaration)
                return HandleDecl(p,(IdentifierDeclaration)td, rr);

            //HACK Ensure that no information gets lost by using this function
            // -- getting a value but requiring an abstract type and just extract it from the value - is this correct behaviour?
            var at = AbstractType.Get(rr);

            if (td is ArrayDecl)
                return HandleDecl(p,(ArrayDecl)td, DResolver.StripMemberSymbols(at) as AssocArrayType);
            else if (td is DTokenDeclaration)
                return HandleDecl((DTokenDeclaration)td, at);
            else if (td is DelegateDeclaration)
                return HandleDecl(p, (DelegateDeclaration)td, DResolver.StripMemberSymbols(at) as DelegateType);
            else if (td is PointerDecl)
                return HandleDecl(p, (PointerDecl)td, DResolver.StripMemberSymbols(at) as PointerType);
            else if (td is MemberFunctionAttributeDecl)
                return HandleDecl(p,(MemberFunctionAttributeDecl)td, at);
            else if (td is TypeOfDeclaration)
                return HandleDecl((TypeOfDeclaration)td, at);
            else if (td is VectorDeclaration)
                return HandleDecl((VectorDeclaration)td, at);
            else if (td is TemplateInstanceExpression)
                return HandleDecl(p,(TemplateInstanceExpression)td, at);

            return false;
        }
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:28,代码来源:TemplateTypeParameterDeduction.cs


示例6: E

        ISemantic E(OperatorBasedExpression x, ISemantic lValue=null)
        {
            if (x is AssignExpression)
                return E((AssignExpression)x,lValue);

            // TODO: Implement operator precedence (see http://forum.dlang.org/thread/[email protected] )

            if (x is XorExpression || // a ^ b
                x is OrExpression || // a | b
                x is AndExpression || // a & b
                x is ShiftExpression || // a << 8
                x is AddExpression || // a += b; a -= b;
                x is MulExpression || // a *= b; a /= b; a %= b;
                x is CatExpression || // a ~= b;
                x is PowExpression) // a ^^ b;
                return E_MathOp(x, lValue);

            else if (x is EqualExpression) // a==b
                return E((EqualExpression)x, lValue);

            else if (x is OrOrExpression || // a || b
                x is AndAndExpression || // a && b
                x is IdendityExpression || // a is T
                x is RelExpression) // a <= b
                return E_BoolOp(x, lValue as ISymbolValue);

            else if (x is InExpression) // a in b
                return E((InExpression)x, lValue);

            throw new WrongEvaluationArgException();
        }
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:31,代码来源:Evaluation.OperandExpressions.cs


示例7: IsEqual

        /// <summary>
        /// Checks given results for type equality
        /// </summary>
        public static bool IsEqual(ISemantic r1, ISemantic r2)
        {
            if(r1 is TemplateParameterSymbol)
                r1 = ((TemplateParameterSymbol)r1).Base;
            if(r2 is TemplateParameterSymbol)
                r2 = ((TemplateParameterSymbol)r2).Base;

            if (r1 is ISymbolValue && r2 is ISymbolValue)
                return SymbolValueComparer.IsEqual((ISymbolValue)r1, (ISymbolValue)r2);

            else if (r1 is TemplateIntermediateType && r2 is TemplateIntermediateType)
            {
                var tr1 = (TemplateIntermediateType)r1;
                var tr2 = (TemplateIntermediateType)r2;

                if (tr1.Definition != tr2.Definition)
                    return false;

                //TODO: Compare deduced types
                return true;
            }
            else if (r1 is PrimitiveType && r2 is PrimitiveType)
                return ((PrimitiveType)r1).TypeToken == ((PrimitiveType)r2).TypeToken;
            else if (r1 is ArrayType && r2 is ArrayType)
            {
                var ar1 = (ArrayType)r1;
                var ar2 = (ArrayType)r2;

                if (!IsEqual(ar1.KeyType, ar2.KeyType))
                    return false;

                return IsEqual(ar1.Base, ar2.Base);
            }
            else if(r1 is DelegateType && r2 is DelegateType)
            {
                var dg1 = r1 as DelegateType;
                var dg2 = r2 as DelegateType;

                if(dg1.IsFunctionLiteral != dg2.IsFunctionLiteral ||
                   !IsEqual(dg1.ReturnType, dg2.ReturnType))
                    return false;

                if(dg1.Parameters == null || dg1.Parameters.Length == 0)
                    return dg2.Parameters == null || dg2.Parameters.Length==0;
                else if(dg2.Parameters == null)
                    return dg1.Parameters == null || dg1.Parameters.Length==0;
                else if(dg1.Parameters.Length == dg2.Parameters.Length)
                {
                    for(int i = dg1.Parameters.Length-1; i != 0; i--)
                        if(!IsEqual(dg1.Parameters[i], dg2.Parameters[i]))
                            return false;
                    return true;
                }
            }

            //TODO: Handle other types

            return false;
        }
开发者ID:rainers,项目名称:D_Parser,代码行数:62,代码来源:ResultComparer.cs


示例8: Convert

 public static AbstractType Convert(ISemantic s)
 {
     if (s is AbstractType)
         return (AbstractType)s;
     else if(s is ISymbolValue)
         return ((ISymbolValue)s).RepresentedType;
     return null;
 }
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:8,代码来源:TypeDeclarationResolver.cs


示例9: Handle

		bool Handle(TemplateAliasParameter p, ISemantic arg)
		{
			#region Handle parameter defaults
			if (arg == null)
			{
				if (p.DefaultExpression != null)
				{
					var eval = Evaluation.EvaluateValue(p.DefaultExpression, ctxt);

					if (eval == null)
						return false;

					return Set(p, eval, 0);
				}
				else if (p.DefaultType != null)
				{
					var res = TypeDeclarationResolver.ResolveSingle(p.DefaultType, ctxt);

					return res != null && Set(p, res, 0);
				}
				return false;
			}
			#endregion

			#region Given argument must be a symbol - so no built-in type but a reference to a node or an expression
			var t=AbstractType.Get(arg);
			
			if (t == null)
				return false;
			
			if(!(t is DSymbol))
				while (t != null)
				{
					if (t is PrimitiveType) // arg must not base on a primitive type.
						return false;
	
					if (t is DerivedDataType)
						t = ((DerivedDataType)t).Base;
					else
						break;
				}
			#endregion

			#region Specialization check
			if (p.SpecializationExpression != null)
			{
				// LANGUAGE ISSUE: Can't do anything here - dmd won't let you use MyClass!(2) though you have class MyClass(alias X:2)
				return false;
			}
			else if (p.SpecializationType != null)
			{
				// ditto
				return false;
			}
			#endregion

			return Set(p,arg,0);
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:58,代码来源:TemplateAliasParameterDeduction.cs


示例10: TryResolveUFCS

		public static MemberSymbol[] TryResolveUFCS(
			ISemantic firstArgument, 
			PostfixExpression_Access acc, 
			ResolutionContext ctxt)
		{
			if (ctxt == null)
				return null;
			
			int name=0;

			if (acc.AccessExpression is IdentifierExpression)
				name = ((IdentifierExpression)acc.AccessExpression).ValueStringHash;
			else if (acc.AccessExpression is TemplateInstanceExpression)
				name = ((TemplateInstanceExpression)acc.AccessExpression).TemplateIdHash;
			else
				return null;

			var methodMatches = new List<MemberSymbol>();
			if(ctxt.ParseCache!=null)
				foreach (var pc in ctxt.ParseCache)
				{
					var tempResults=pc.UfcsCache.FindFitting(ctxt, acc.Location, firstArgument, name);

					if (tempResults != null)
						foreach (var m in tempResults)
						{
							ctxt.PushNewScope(m);

							if (m.TemplateParameters != null && m.TemplateParameters.Length != 0)
							{
								var ov = TemplateInstanceHandler.DeduceParamsAndFilterOverloads(
									new[] { new MemberSymbol(m, null, acc) }, 
									new[] { firstArgument }, true, ctxt);

								if (ov == null || ov.Length == 0)
									continue;

								var ms = (DSymbol)ov[0];
								ctxt.CurrentContext.IntroduceTemplateParameterTypes(ms);
							}
							
							var mr = TypeDeclarationResolver.HandleNodeMatch(m, ctxt, null, acc) as MemberSymbol;
							if (mr!=null)
							{
								mr.FirstArgument = firstArgument;
								mr.DeducedTypes = ctxt.CurrentContext.DeducedTemplateParameters.ToReadonly();
								mr.IsUFCSResult = true;
								methodMatches.Add(mr);
							}
							ctxt.Pop();
						}
				}

			return methodMatches.Count == 0 ? null : methodMatches.ToArray();
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:55,代码来源:UFCSResolver.cs


示例11: TryResolveUFCS

        public static List<AbstractType> TryResolveUFCS(
			ISemantic firstArgument,int nameHash,CodeLocation nameLoc,
			ResolutionContext ctxt, ISyntaxRegion nameSr = null)
        {
            if (firstArgument == null || ctxt == null)
                return new List<AbstractType>();

            var us = new UFCSResolver (ctxt, firstArgument, nameHash, nameSr);
            us.IterateThroughScopeLayers (nameLoc, MemberFilter.Methods | MemberFilter.Templates);
            return us.matches;
        }
开发者ID:rainers,项目名称:D_Parser,代码行数:11,代码来源:UFCSResolver.cs


示例12: AddArrayProperties

        public static void AddArrayProperties(ISemantic rr, ICompletionDataGenerator cdg, ArrayDecl ArrayDecl = null)
        {
            CreateArtificialProperties(ArrayProps, cdg, ArrayDecl);

            cdg.Add(new DVariable
            {
                Name = "ptr",
                Description = "Returns pointer to the array",
                Type = new PointerDecl(ArrayDecl == null ? new DTokenDeclaration(DTokens.Void) : ArrayDecl.ValueType)
            });
        }
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:11,代码来源:StaticTypePropertyProvider.cs


示例13: E

		ISemantic E(AssignExpression x, ISemantic lValue=null)
		{
			if (!eval)
				return E(x.LeftOperand);

			var l = TryGetValue(lValue ?? E(x.LeftOperand));

			//TODO

			return null;
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:11,代码来源:Evaluation.OperandExpressions.cs


示例14: Generate

 public static void Generate(ISemantic rr, ResolutionContext ctxt, IEditorData ed, ICompletionDataGenerator gen)
 {
     if(ed.ParseCache!=null)
         foreach (var pc in ed.ParseCache)
             if (pc != null && pc.UfcsCache != null && pc.UfcsCache.CachedMethods != null)
             {
                 var r=pc.UfcsCache.FindFitting(ctxt, ed.CaretLocation, rr);
                 if(r!=null)
                     foreach (var m in r)
                         gen.Add(m);
             }
 }
开发者ID:DinrusGroup,项目名称:DRC,代码行数:12,代码来源:UFCSCompletionProvider.cs


示例15: BuildTooltipContent

        static AbstractTooltipContent BuildTooltipContent(ISemantic res)
        {
            // Only show one description for items sharing descriptions
            string description = res is DSymbol ? ((DSymbol)res).Definition.Description : "";

            return new AbstractTooltipContent
            {
                ResolveResult = res,
                Title = (res is ModuleSymbol ? ((ModuleSymbol)res).Definition.FileName : res.ToString()),
                Description = description
            };
        }
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:12,代码来源:AbstractTooltipProvider.cs


示例16: Get

        public static AbstractType Get(ISemantic s)
        {
            //FIXME: What to do with the other overloads?
            if (s is InternalOverloadValue)
                return (s as InternalOverloadValue).Overloads[0];
            if (s is VariableValue)
                return (s as VariableValue).Member;
            if (s is ISymbolValue)
                return (s as ISymbolValue).RepresentedType;

            return s as AbstractType;
        }
开发者ID:DinrusGroup,项目名称:DRC,代码行数:12,代码来源:DType.cs


示例17: IsUfcsResult

        public static bool IsUfcsResult(AbstractType t, out ISemantic firstArgument)
        {
            var o = t.Tag as UfcsTag;

            if (o == null) {
                firstArgument = null;
                return false;
            }

            firstArgument = o.firstArgument;
            return true;
        }
开发者ID:rainers,项目名称:D_Parser,代码行数:12,代码来源:UFCSResolver.cs


示例18: BuildTooltipContent

        static AbstractTooltipContent BuildTooltipContent(ISemantic res)
        {
            // Only show one description for items sharing descriptions
            var ds = res as DSymbol;
            var description = ds != null ? ds.Definition.Description : "";

            return new AbstractTooltipContent
            {
                ResolveResult = res,
                Title = BuildTooltipTitle(res),
                Description = description
            };
        }
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:13,代码来源:AbstractTooltipProvider.cs


示例19: Handle

        public bool Handle(TemplateParameter parameter, ISemantic argumentToAnalyze)
        {
            // Packages aren't allowed at all
            if (argumentToAnalyze is PackageSymbol)
                return false;

            // Module symbols can be used as alias only
            if (argumentToAnalyze is ModuleSymbol &&
                !(parameter is TemplateAliasParameter))
                return false;

            //TODO: Handle __FILE__ and __LINE__ correctly - so don't evaluate them at the template declaration but at the point of instantiation

            /*
             * Introduce previously deduced parameters into current resolution context
             * to allow value parameter to be of e.g. type T whereas T is already set somewhere before
             */
            DeducedTypeDictionary _prefLocalsBackup = null;
            if (ctxt != null && ctxt.CurrentContext != null)
            {
                _prefLocalsBackup = ctxt.CurrentContext.DeducedTemplateParameters;

                var d = new DeducedTypeDictionary();
                foreach (var kv in TargetDictionary)
                    if (kv.Value != null)
                        d[kv.Key] = kv.Value;
                ctxt.CurrentContext.DeducedTemplateParameters = d;
            }

            bool res = false;

            if (parameter is TemplateAliasParameter)
                res = Handle((TemplateAliasParameter)parameter, argumentToAnalyze);
            else if (parameter is TemplateThisParameter)
                res = Handle((TemplateThisParameter)parameter, argumentToAnalyze);
            else if (parameter is TemplateTypeParameter)
                res = Handle((TemplateTypeParameter)parameter, argumentToAnalyze);
            else if (parameter is TemplateValueParameter)
                res = Handle((TemplateValueParameter)parameter, argumentToAnalyze);
            else if (parameter is TemplateTupleParameter)
                res = Handle((TemplateTupleParameter)parameter, new[] { argumentToAnalyze });

            if (ctxt != null && ctxt.CurrentContext != null)
                ctxt.CurrentContext.DeducedTemplateParameters = _prefLocalsBackup;

            return res;
        }
开发者ID:EnergonV,项目名称:D_Parser,代码行数:47,代码来源:TemplateParameterDeduction.cs


示例20: Handle

		bool Handle(TemplateValueParameter p, ISemantic arg)
		{
			// Handle default arg case
			if (arg == null)
			{
				if (p.DefaultExpression != null)
				{
					var eval = Evaluation.EvaluateValue(p.DefaultExpression, ctxt);

					if (eval == null)
						return false;

					return Set(p, eval, 0);
				}
				else
					return false;
			}

			var valueArgument = arg as ISymbolValue;

			// There must be a constant expression given!
			if (valueArgument == null)
				return false;

			// Check for param type <-> arg expression type match
			var paramType = TypeDeclarationResolver.Resolve(p.Type, ctxt);

			if (paramType == null || paramType.Length == 0)
				return false;

			if (valueArgument.RepresentedType == null ||
				!ResultComparer.IsImplicitlyConvertible(paramType[0], valueArgument.RepresentedType))
				return false;

			// If spec given, test for equality (only ?)
			if (p.SpecializationExpression != null) 
			{
				var specVal = Evaluation.EvaluateValue(p.SpecializationExpression, ctxt);

				if (specVal == null || !SymbolValueComparer.IsEqual(specVal, valueArgument))
					return false;
			}

			return Set(p, arg, 0);
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:45,代码来源:TemplateValueParameterDeduction.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISemanticResolver类代码示例发布时间:2022-05-24
下一篇:
C# ISelenium类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap