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

C# AstType类代码示例

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

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



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

示例1: AddLocal

        public string AddLocal(string name, AstType type)
        {
            this.Emitter.Locals.Add(name, type);

            name = name.StartsWith(Bridge.Translator.Emitter.FIX_ARGUMENT_NAME) ? name.Substring(Bridge.Translator.Emitter.FIX_ARGUMENT_NAME.Length) : name;
            string vName = name;

            if (Helpers.IsReservedWord(name))
            {
                vName = this.GetUniqueName(name);
            }

            if (!this.Emitter.LocalsNamesMap.ContainsKey(name))
            {
                this.Emitter.LocalsNamesMap.Add(name, vName);
            }
            else
            {
                this.Emitter.LocalsNamesMap[name] = this.GetUniqueName(vName);
            }

            var result = this.Emitter.LocalsNamesMap[name];

            if (this.Emitter.IsAsync && !this.Emitter.AsyncVariables.Contains(result))
            {
                this.Emitter.AsyncVariables.Add(result);
            }

            return result;
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:30,代码来源:AbstractEmitterBlock.Locals.cs


示例2: AddTypeArguments

			void AddTypeArguments (ATypeNameExpression texpr, AstType result)
			{
				if (!texpr.HasTypeArguments)
					return;
				foreach (var arg in texpr.TypeArguments.Args) {
					result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
				}
			}
开发者ID:madkat,项目名称:NRefactory,代码行数:8,代码来源:CSharpParser.cs


示例3: GetDefaultFieldValue

        public static object GetDefaultFieldValue(AstType type, IMemberResolver resolver)
        {
            if (type is PrimitiveType)
            {
                var primitiveType = (PrimitiveType)type;

                switch (primitiveType.KnownTypeCode)
                {
                    case KnownTypeCode.Decimal:
                        return 0m;

                    case KnownTypeCode.Int16:
                    case KnownTypeCode.Int32:
                    case KnownTypeCode.Int64:
                    case KnownTypeCode.UInt16:
                    case KnownTypeCode.UInt32:
                    case KnownTypeCode.UInt64:
                    case KnownTypeCode.Byte:
                    case KnownTypeCode.Double:
                    case KnownTypeCode.SByte:
                    case KnownTypeCode.Single:
                        return 0;

                    case KnownTypeCode.Boolean:
                        return false;
                }
            }

            var resolveResult = resolver.ResolveNode(type, null);

            var o = GetDefaultFieldValue(resolveResult.Type, false);

            if (o != null)
            {
                return o;
            }

            if (!resolveResult.IsError && NullableType.IsNullable(resolveResult.Type))
            {
                return null;
            }

            if (!resolveResult.IsError && resolveResult.Type.IsKnownType(KnownTypeCode.Enum))
            {
                return 0;
            }

            if (!resolveResult.IsError && resolveResult.Type.Kind == TypeKind.Struct)
            {
                return type;
            }

            return null;
        }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:54,代码来源:Inspector.cs


示例4: GetFieldDeclaration

        protected FieldDeclaration GetFieldDeclaration(String name, AstType propertyType)
        {
            var declaration = new FieldDeclaration();
            declaration.Name = name;
            declaration.Modifiers = Modifiers.Public;
            declaration.ReturnType = propertyType;

            IDELogger.Log("BaseRefactoringDialog::GetFieldDeclaration -- {0}", declaration.Name);

            return declaration;
        }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:11,代码来源:BaseRefactoringDialog.cs


示例5: GetVariableDeclarationStatement

		static VariableDeclarationStatement GetVariableDeclarationStatement (RefactoringContext context, out AstType resolvedType)
		{
			var result = context.GetNode<VariableDeclarationStatement> ();
			if (result != null && result.Variables.Count == 1 && !result.Variables.First ().Initializer.IsNull && result.Variables.First ().NameToken.Contains (context.Location.Line, context.Location.Column)) {
				resolvedType = context.ResolveType (result.Variables.First ().Initializer);
				if (resolvedType == null)
					return null;
				return result;
			}
			resolvedType = null;
			return null;
		}
开发者ID:hduregger,项目名称:monodevelop,代码行数:12,代码来源:SplitDeclarationAndAssignment.cs


示例6: GetVariableDeclarationStatement

		static VariableDeclarationStatement GetVariableDeclarationStatement (RefactoringContext context, out AstType resolvedType, CancellationToken cancellationToken = default(CancellationToken))
		{
			var result = context.GetNode<VariableDeclarationStatement> ();
			if (result != null && result.Variables.Count == 1 && !result.Variables.First ().Initializer.IsNull && result.Variables.First ().NameToken.Contains (context.Location.Line, context.Location.Column)) {
				resolvedType = result.Type.Clone ();
				// resolvedType = context.Resolve (result.Variables.First ().Initializer).Type.ConvertToAstType ();
				// if (resolvedType == null)
				// 	return null;
				return result;
			}
			resolvedType = null;
			return null;
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:13,代码来源:SplitDeclarationAndAssignmentAction.cs


示例7: GetVariableDeclarationStatement

		static VariableInitializer GetVariableDeclarationStatement (RefactoringContext context, out AstType resolvedType, CancellationToken cancellationToken = default(CancellationToken))
		{
			var result = context.GetNode<VariableInitializer> ();
			if (result != null && !result.Initializer.IsNull && context.Location <= result.Initializer.StartLocation) {
				var type = context.Resolve(result).Type;
				if (type.Equals(SpecialType.NullType) || type.Equals(SpecialType.UnknownType)) {
					resolvedType = new PrimitiveType ("object");
				} else {
					resolvedType = context.CreateShortType (type);
				}
				return result;
			}
			resolvedType = null;
			return null;
		}
开发者ID:sphynx79,项目名称:dotfiles,代码行数:15,代码来源:SplitDeclarationAndAssignmentAction.cs


示例8: GetVariableDeclarationStatement

 static VariableDeclarationStatement GetVariableDeclarationStatement(RefactoringContext context, out AstType resolvedType, CancellationToken cancellationToken = default(CancellationToken))
 {
     var result = context.GetNode<VariableDeclarationStatement> ();
     if (result != null && result.Variables.Count == 1 && !result.Variables.First ().Initializer.IsNull && result.Variables.First ().NameToken.Contains (context.Location.Line, context.Location.Column)) {
         var type = context.Resolve(result.Variables.First ().Initializer).Type;
         if (type.Equals(SpecialType.NullType) || type.Equals(SpecialType.UnknownType)) {
             resolvedType = new PrimitiveType ("object");
         } else {
             resolvedType = context.CreateShortType (type);
         }
         return result;
     }
     resolvedType = null;
     return null;
 }
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:15,代码来源:SplitDeclarationAndAssignmentAction.cs


示例9: GetDefaultValueExpression

			Expression GetDefaultValueExpression (AstType astType)
			{
				var type = ctx.ResolveType (astType);

				if ((type.IsReferenceType ?? false) || type.Kind == TypeKind.Dynamic)
					return new NullReferenceExpression ();

				var typeDefinition = type.GetDefinition ();
				if (typeDefinition != null) {
					switch (typeDefinition.KnownTypeCode) {
						case KnownTypeCode.Boolean:
							return new PrimitiveExpression (false);

						case KnownTypeCode.Char:
							return new PrimitiveExpression ('\0');

						case KnownTypeCode.SByte:
						case KnownTypeCode.Byte:
						case KnownTypeCode.Int16:
						case KnownTypeCode.UInt16:
						case KnownTypeCode.Int32:
							return new PrimitiveExpression (0);

						case KnownTypeCode.Int64:
							return new Choice { new PrimitiveExpression (0), new PrimitiveExpression (0L) };
						case KnownTypeCode.UInt32:
							return new Choice { new PrimitiveExpression (0), new PrimitiveExpression (0U) };
						case KnownTypeCode.UInt64:
							return new Choice {
								new PrimitiveExpression (0), new PrimitiveExpression (0U), new PrimitiveExpression (0UL)
							};
						case KnownTypeCode.Single:
							return new Choice { new PrimitiveExpression (0), new PrimitiveExpression (0F) };
						case KnownTypeCode.Double:
							return new Choice {
								new PrimitiveExpression (0), new PrimitiveExpression (0F), new PrimitiveExpression (0D)
							};
						case KnownTypeCode.Decimal:
							return new Choice { new PrimitiveExpression (0), new PrimitiveExpression (0M) };

						case KnownTypeCode.NullableOfT:
							return new NullReferenceExpression ();
					}
					if (type.Kind == TypeKind.Struct)
						return new ObjectCreateExpression (astType.Clone ());
				}
				return new DefaultValueExpression (astType.Clone ());
			} 
开发者ID:Gobiner,项目名称:ILSpy,代码行数:48,代码来源:RedundantFieldInitializerIssue.cs


示例10: AddTypeArguments

			void AddTypeArguments (ATypeNameExpression texpr, AstType result)
			{
				if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null)
					return;
				var loc = LocationsBag.GetLocations (texpr.TypeArguments);
				if (loc != null && loc.Count >= 2)
					result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 2]), 1), AstType.Roles.LChevron);
				int i = 0;
				foreach (var arg in texpr.TypeArguments.Args) {
					result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
					if (loc != null && i < loc.Count - 2)
						result.AddChild (new CSharpTokenNode (Convert (loc [i++]), 1), AstType.Roles.Comma);
				}
				if (loc != null && loc.Count >= 2)
					result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1]), 1), AstType.Roles.RChevron);
			}
开发者ID:N3X15,项目名称:ILSpy,代码行数:16,代码来源:CSharpParser.cs


示例11: DeclareVariable

 /// <summary>
 /// Declares a variable in the smallest required scope.
 /// </summary>
 /// <param name="node">The root of the subtree being searched for the best insertion position</param>
 /// <param name="type">The type of the new variable</param>
 /// <param name="name">The name of the new variable</param>
 /// <param name="allowPassIntoLoops">Whether the variable is allowed to be placed inside a loop</param>
 public static VariableDeclarationStatement DeclareVariable(AstNode node, AstType type, string name, bool allowPassIntoLoops = true)
 {
     VariableDeclarationStatement result = null;
     AstNode pos = FindInsertPos(node, name, allowPassIntoLoops);
     if (pos != null) {
         Match m = assignmentPattern.Match(pos);
         if (m != null && m.Get<IdentifierExpression>("ident").Single().Identifier == name) {
             result = new VariableDeclarationStatement(type, name, m.Get<Expression>("init").Single().Detach());
             pos.ReplaceWith(result);
         } else {
             result = new VariableDeclarationStatement(type, name);
             pos.Parent.InsertChildBefore(pos, result, BlockStatement.StatementRole);
         }
     }
     return result;
 }
开发者ID:petr-k,项目名称:ILSpy,代码行数:23,代码来源:DeclareVariableInSmallestScope.cs


示例12: GenerateNameProposals

		public static IEnumerable<string> GenerateNameProposals(AstType type)
		{
			if (type is PrimitiveType) {
				var pt = (PrimitiveType)type;
				switch (pt.Keyword) {
					case "object":
						yield return "o";
						yield return "obj";
						break;
					case "bool":
						yield return "b";
						yield return "pred";
						break;
					case "double":
					case "float":
					case "decimal":
						yield return "d";
						yield return "f";
						yield return "m";
						break;
					case "char":
						yield return "c";
						break;
					default:
						yield return "i";
						yield return "j";
						yield return "k";
						break;
				}
				yield break;
			}
			string name;
			if (type is SimpleType) {
				name = ((SimpleType)type).Identifier;
			} else if (type is MemberType) {
				name = ((MemberType)type).MemberName;
			} else {
				yield break;
			}

			var names = WordParser.BreakWords(name);
			if (names.Count > 0) {
				names [0] = Char.ToLower(names [0] [0]) + names [0].Substring(1);
			}
			yield return string.Join("", names);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:46,代码来源:NamingHelper.cs


示例13: TypeMetadata

 public TypeMetadata(string typeName, string @namespace, string csharpName, string scriptName, IReadOnlyList<string> tagNames, bool generate, bool inherit, TypeKind typeKind, bool includeConstructors, IReadOnlyList<TypeOverride> typeOverrides, AstType aliasFor, IEnumerable<Tuple<string, string>> renames, IEnumerable<string> removes, IReadOnlyList<string> addInDerivedTypes, IReadOnlyList<GeneratedEnum> generatedEnums)
 {
     TypeName = typeName;
     Namespace = @namespace;
     CSharpName = csharpName;
     ScriptName = scriptName;
     TagNames = tagNames.AsReadOnlySafe();
     Generate = generate && typeKind != TypeKind.Mixin && typeKind != TypeKind.Skip;
     Inherit = inherit;
     TypeKind = typeKind;
     IncludeConstructors = includeConstructors;
     TypeOverrides = typeOverrides.AsReadOnlySafe();
     AliasFor = aliasFor;
     Renames = new ReadOnlyDictionary<string, string>((renames ?? new Tuple<string, string>[0]).ToDictionary(x => x.Item1, x => x.Item2));
     Removes = removes.AsReadOnlySafe();
     AddInDerivedTypes = addInDerivedTypes.AsReadOnlySafe();
     GeneratedEnums = generatedEnums.AsReadOnlySafe();
 }
开发者ID:Saltarelle,项目名称:SaltarelleWeb,代码行数:18,代码来源:TypeMetadata.cs


示例14: GetTypeDefinition

 public virtual TypeDefinition GetTypeDefinition(AstType reference, bool safe = false)
 {
     var resolveResult = this.Resolver.ResolveNode(reference, this) as TypeResolveResult;
     var type = this.BridgeTypes.Get(resolveResult.Type, safe);
     return type != null ? type.TypeDefinition :  null;
 }
开发者ID:RashmiPankaj,项目名称:Bridge,代码行数:6,代码来源:Emitter.TypeHelpers.cs


示例15: TypeParamExpression

 public TypeParamExpression(string name, AstType type, IType iType, bool inherited = false)
 {
     this.Name = name;
     this.AstType = type;
     this.IType = iType;
     this.Inherited = inherited;
 }
开发者ID:RashmiPankaj,项目名称:Bridge,代码行数:7,代码来源:ArgumentsInfo.cs


示例16: BuildTypedArguments

        private void BuildTypedArguments(AstType type)
        {
            var simpleType = type as SimpleType;

            if (simpleType != null)
            {
                AstNodeCollection<AstType> typedArguments = simpleType.TypeArguments;
                IList<ITypeParameter> typeParams = null;

                if (this.ResolveResult.Member.DeclaringTypeDefinition != null)
                {
                    typeParams = this.ResolveResult.Member.DeclaringTypeDefinition.TypeParameters;
                }
                else if (this.ResolveResult.Member is SpecializedMethod)
                {
                    typeParams = ((SpecializedMethod)this.ResolveResult.Member).TypeParameters;
                }

                this.TypeArguments = new TypeParamExpression[typedArguments.Count];
                var list = typedArguments.ToList();
                for (int i = 0; i < list.Count; i++)
                {
                    this.TypeArguments[i] = new TypeParamExpression(typeParams[i].Name, list[i], null);
                }
            }
        }
开发者ID:RashmiPankaj,项目名称:Bridge,代码行数:26,代码来源:ArgumentsInfo.cs


示例17: QualifiedTypeName

 void QualifiedTypeName(out AstType type)
 {
     if (la.kind == 130) {
     Get();
     } else if (StartOf(4)) {
     Identifier();
     } else SynErr(246);
     type = new SimpleType(TextTokenType.Text, t.val, t.Location);
     while (la.kind == 26) {
     Get();
     Identifier();
     type = new QualifiedType(type, new Identifier (TextTokenType.Text, t.val, t.Location));
     }
 }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:14,代码来源:Parser.cs


示例18: GenerateNameProposals

		IEnumerable<string> GenerateNameProposals(AstType type)
		{
			if (type is PrimitiveType) {
				var pt = (PrimitiveType)type;
				switch (pt.Keyword) {
					case "object":
						yield return "o";
						yield return "obj";
						break;
					case "bool":
						yield return "b";
						yield return "pred";
						break;
					case "double":
					case "float":
					case "decimal":
						yield return "d";
						yield return "f";
						yield return "m";
						break;
					default:
						yield return "i";
						yield return "j";
						yield return "k";
						break;
				}
				yield break;
			}
			string name;
			if (type is SimpleType) {
				name = ((SimpleType)type).Identifier;
			} else if (type is MemberType) {
				name = ((MemberType)type).MemberName;
			} else {
				yield break;
			}

			var names = WordParser.BreakWords(name);

			var possibleName = new StringBuilder();
			for (int i = 0; i < names.Count; i++) {
				possibleName.Length = 0;
				for (int j = i; j < names.Count; j++) {
					if (string.IsNullOrEmpty(names [j])) {
						continue;
					}
					if (j == i) { 
						names [j] = Char.ToLower(names [j] [0]) + names [j].Substring(1);
					}
					possibleName.Append(names [j]);
				}
				yield return possibleName.ToString();
			}
		}
开发者ID:pentp,项目名称:SharpDevelop,代码行数:54,代码来源:CSharpCompletionEngine.cs


示例19: ResolveType

		public IType ResolveType (AstType type)
		{
			return resolver.Resolve (type, cancellationToken).Type;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:4,代码来源:BaseRefactoringContext.cs


示例20: TypeBlock

 public TypeBlock(IEmitter emitter, AstType type)
     : base(emitter, type)
 {
     this.Emitter = emitter;
     this.Type = type;
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:6,代码来源:TypeBlock.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# AstarPath类代码示例发布时间:2022-05-24
下一篇:
C# AstParserRuleReturnScope类代码示例发布时间: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