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


C# TemplateParameter类代码示例

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


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

示例1: ContainsTemplateParameter

		public bool ContainsTemplateParameter(TemplateParameter p)
		{
			if(TemplateParameters != null)
				for(int i = 0; i < TemplateParameters.Length; i++)
					if(TemplateParameters[i] == p)
						return true;
			return false;
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:8,代码来源:DNode.cs

示例2: TerminatingStringTemplate

 public TerminatingStringTemplate(string name, IEnumerable<TemplateParameter> parameters,
     int endingValue, int offsetMod, StringComparer stringComparer)
 {
     this.offsetMod = offsetMod;;
     this.parameter = parameters.First();
     this.endingValue = BitConverter.GetBytes(endingValue).Take(parameter.LenghtInBytes).ToArray();
     this.name = name;
     this.comparer = stringComparer;
 }
开发者ID:Diegoisawesome,项目名称:AwesomeMapEditor-old,代码行数:9,代码来源:TerminatingStringTemplate.cs

示例3: TryGetTemplateParameter

		public bool TryGetTemplateParameter(int nameHash, out TemplateParameter p)
		{
			if (TemplateParameters != null)
				for (int i = 0; i < TemplateParameters.Length; i++)
					if (TemplateParameters[i].NameHash == nameHash)
					{
						p = TemplateParameters[i];
						return true;
					}

			p = null;
			return false;
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:13,代码来源:DNode.cs

示例4: evalIsExpression_WithAliases

		private bool evalIsExpression_WithAliases(IsExpression isExpression, AbstractType typeToCheck)
		{
			/*
			 * Note: It's needed to let the abstract ast scanner also scan through IsExpressions etc.
			 * in order to find aliases and/or specified template parameters!
			 */

			var expectedTemplateParams = new TemplateParameter[isExpression.TemplateParameterList == null  ? 1 : (isExpression.TemplateParameterList.Length + 1)];
			expectedTemplateParams [0] = isExpression.ArtificialFirstSpecParam;
			if(expectedTemplateParams.Length > 1)
				isExpression.TemplateParameterList.CopyTo (expectedTemplateParams, 1);

			var tpl_params = new DeducedTypeDictionary(expectedTemplateParams);


			var tpd = new TemplateParameterDeduction(tpl_params, ctxt);
			bool retTrue = false;

			if (isExpression.EqualityTest) // 6.
			{
				// a)
				if (isExpression.TypeSpecialization != null)
				{
					tpd.EnforceTypeEqualityWhenDeducing = true;
					retTrue = tpd.Handle(isExpression.ArtificialFirstSpecParam, typeToCheck);
					tpd.EnforceTypeEqualityWhenDeducing = false;
				}
				else // b)
				{
					var r = evalIsExpression_EvalSpecToken(isExpression, typeToCheck, true);
					retTrue = r.Item1;
					tpl_params[isExpression.ArtificialFirstSpecParam] = new TemplateParameterSymbol(isExpression.ArtificialFirstSpecParam, r.Item2);
				}
			}
			else // 5.
				retTrue = tpd.Handle(isExpression.ArtificialFirstSpecParam, typeToCheck);

			if (retTrue && isExpression.TemplateParameterList != null)
				foreach (var p in isExpression.TemplateParameterList)
					if (!tpd.Handle(p, tpl_params[p] != null ? tpl_params[p].Base : null))
						return false;

			if (retTrue)
			{
				foreach (var kv in tpl_params)
					ctxt.CurrentContext.DeducedTemplateParameters[kv.Key] = kv.Value;
			}

			return retTrue;
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:50,代码来源:Evaluation.IsExpression.cs

示例5: 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

示例6: evalIsExpression_WithAliases

		private bool evalIsExpression_WithAliases(IsExpression isExpression, AbstractType typeToCheck)
		{
			/*
			 * Note: It's needed to let the abstract ast scanner also scan through IsExpressions etc.
			 * in order to find aliases and/or specified template parameters!
			 */

			var expectedTemplateParams = new TemplateParameter[isExpression.TemplateParameterList.Length + 1];
			expectedTemplateParams [0] = isExpression.ArtificialFirstSpecParam;
			if(expectedTemplateParams.Length > 1)
				isExpression.TemplateParameterList.CopyTo (expectedTemplateParams, 1);

			var tpl_params = new DeducedTypeDictionary(expectedTemplateParams);


			var tpd = new TemplateParameterDeduction(tpl_params, ctxt);
			bool retTrue = false;

			if (isExpression.EqualityTest) // 6.
			{
				// a)
				if (isExpression.TypeSpecialization != null)
				{
					tpd.EnforceTypeEqualityWhenDeducing = true;
					retTrue = tpd.Handle(isExpression.ArtificialFirstSpecParam, typeToCheck);
					tpd.EnforceTypeEqualityWhenDeducing = false;
				}
				else // b)
				{
					var r = evalIsExpression_EvalSpecToken(isExpression, typeToCheck, true);
					retTrue = r.Item1;
					tpl_params[isExpression.TypeAliasIdentifierHash] = new TemplateParameterSymbol(null, r.Item2);
				}
			}
			else // 5.
				retTrue = tpd.Handle(isExpression.ArtificialFirstSpecParam, typeToCheck);

			if (retTrue && isExpression.TemplateParameterList != null)
				foreach (var p in isExpression.TemplateParameterList)
					if (!tpd.Handle(p, tpl_params[p.NameHash] != null ? tpl_params[p.NameHash].Base : null))
						return false;

			//TODO: Put all tpl_params results into the resolver context or make a new scope or something! 

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

示例7: TemplateParameter

 protected TemplateParameter(TemplateParameter.Internal* native, bool skipVTables = false)
 {
     if (native == null)
         return;
     __Instance = new global::System.IntPtr(native);
 }
开发者ID:CSRedRat,项目名称:CppSharp,代码行数:6,代码来源:AST.cs

示例8: __CreateInstance

 public static TemplateParameter __CreateInstance(TemplateParameter.Internal native, bool skipVTables = false)
 {
     return new TemplateParameter(native, skipVTables);
 }
开发者ID:CSRedRat,项目名称:CppSharp,代码行数:4,代码来源:AST.cs

示例9: TemplateParameterSymbol

 public TemplateParameterSymbol(TemplateParameter tpn, ISemantic typeOrValue, ISyntaxRegion paramIdentifier = null)
     : base(tpn != null ? tpn.Representation : null, AbstractType.Get(typeOrValue), paramIdentifier)
 {
     this.Parameter = tpn;
     this.ParameterValue = typeOrValue as ISymbolValue;
 }
开发者ID:DinrusGroup,项目名称:DRC,代码行数:6,代码来源:DType.cs

示例10: __CopyValue

 private static void* __CopyValue(TemplateParameter.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(140);
     global::CppSharp.Parser.AST.TemplateParameter.__Internal.cctor_1(ret, new global::System.IntPtr(&native));
     return ret.ToPointer();
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:6,代码来源:CppSharp.CppParser.cs

示例11: Set

        /// <summary>
        /// Returns false if the item has already been set before and if the already set item is not equal to 'r'.
        /// Inserts 'r' into the target dictionary and returns true otherwise.
        /// </summary>
        bool Set(TemplateParameter p, ISemantic r, int nameHash)
        {
            if (p == null) {
                if (nameHash != 0 && TargetDictionary.ExpectedParameters != null) {
                    foreach (var tpar in TargetDictionary.ExpectedParameters)
                        if (tpar.NameHash == nameHash) {
                            p = tpar;
                            break;
                        }
                }
            }

            if (p == null) {
                ctxt.LogError (null, "no fitting template parameter found!");
                return false;
            }

            // void call(T)(T t) {}
            // call(myA) -- T is *not* myA but A, so only assign myA's type to T.
            if (p is TemplateTypeParameter)
            {
                var newR = Resolver.TypeResolution.DResolver.StripMemberSymbols(AbstractType.Get(r));
                if (newR != null)
                    r = newR;
            }

            TemplateParameterSymbol rl;
            if (!TargetDictionary.TryGetValue(p, out rl) || rl == null)
            {
                TargetDictionary[p] = new TemplateParameterSymbol(p, r);
                return true;
            }
            else
            {
                if (ResultComparer.IsEqual(rl.Base, r))
                {
                    return true;
                }
                else
                {
                    // Error: Ambiguous assignment
                }

                TargetDictionary[p] = new TemplateParameterSymbol(p, r);

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

示例12: HasDefaultType

 public static bool HasDefaultType(TemplateParameter p)
 {
     if (p is TemplateTypeParameter)
         return ((TemplateTypeParameter)p).Default != null;
     else if (p is TemplateAliasParameter)
     {
         var ap = (TemplateAliasParameter)p;
         return ap.DefaultExpression != null || ap.DefaultType != null;
     }
     else if (p is TemplateThisParameter)
         return HasDefaultType(((TemplateThisParameter)p).FollowParameter);
     else if (p is TemplateValueParameter)
         return ((TemplateValueParameter)p).DefaultExpression != null;
     return false;
 }
开发者ID:EnergonV,项目名称:D_Parser,代码行数:15,代码来源:TemplateInstanceHandler.cs

示例13: __CreateInstance

 public static TemplateParameter __CreateInstance(TemplateParameter.Internal native)
 {
     return new TemplateParameter(native);
 }
开发者ID:RainsSoft,项目名称:CppSharp,代码行数:4,代码来源:AST.cs

示例14: TemplateParameter

 private TemplateParameter(TemplateParameter.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
开发者ID:RainsSoft,项目名称:CppSharp,代码行数:6,代码来源:AST.cs

示例15: IsMoreSpecialized

		bool IsMoreSpecialized(ITypeDeclaration Spec, TemplateParameter t2, Dictionary<TemplateParameter, ISemantic> t1_DummyParamList)
		{
			AbstractType t1_TypeResults;
			// Make a type out of t1's specialization
			using (ctxt.Push(ctxt.ScopedBlock != null ? ctxt.ScopedBlock.Parent : null))
			{
				var dict = ctxt.CurrentContext.DeducedTemplateParameters;
				// Make the T in e.g. T[] a virtual type so T will be replaced by it
				// T** will be X** then - so a theoretically valid type instead of a template param
				var dummyType = new ClassType(new DClassLike { Name = "X" }, null, null);
				foreach (var kv in t1_DummyParamList)
					dict[kv.Key] = new TemplateParameterSymbol(t2, dummyType);

				t1_TypeResults = Resolver.TypeResolution.TypeDeclarationResolver.ResolveSingle(Spec, ctxt);
			}
			
			if (t1_TypeResults == null)
				return true;

			// Now try to fit the virtual Type t2 into t1 - and return true if it's possible
			return new TemplateParameterDeduction(new DeducedTypeDictionary(), ctxt).Handle(t2, t1_TypeResults);
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:22,代码来源:SpecializationOrdering.cs


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