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


C# FixedStatement.AddChild方法代码示例

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


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

示例1: Visit

			public override object Visit(Fixed fixedStatement)
			{
				var result = new FixedStatement();
				var location = LocationsBag.GetLocations(fixedStatement);
				
				result.AddChild(new CSharpTokenNode(Convert(fixedStatement.loc), FixedStatement.FixedKeywordRole), FixedStatement.FixedKeywordRole);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
				
				if (fixedStatement.Variables != null) {
					var blockVariableDeclaration = fixedStatement.Variables;
					result.AddChild(ConvertToType(blockVariableDeclaration.TypeExpression), Roles.Type);
					var varInit = new VariableInitializer();
					var initLocation = LocationsBag.GetLocations(blockVariableDeclaration);
					varInit.AddChild(Identifier.Create(blockVariableDeclaration.Variable.Name, Convert(blockVariableDeclaration.Variable.Location)), Roles.Identifier);
					if (blockVariableDeclaration.Initializer != null) {
						if (initLocation != null)
							varInit.AddChild(new CSharpTokenNode(Convert(initLocation [0]), Roles.Assign), Roles.Assign);
						varInit.AddChild((Expression)blockVariableDeclaration.Initializer.Accept(this), Roles.Expression);
					}
					
					result.AddChild(varInit, Roles.Variable);
					
					if (blockVariableDeclaration.Declarators != null) {
						foreach (var decl in blockVariableDeclaration.Declarators) {
							var loc = LocationsBag.GetLocations(decl);
							var init = new VariableInitializer();
							if (loc != null && loc.Count > 0)
								result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Comma), Roles.Comma);
							init.AddChild(Identifier.Create(decl.Variable.Name, Convert(decl.Variable.Location)), Roles.Identifier);
							if (decl.Initializer != null) {
								if (loc != null && loc.Count > 1)
									init.AddChild(new CSharpTokenNode(Convert(loc [1]), Roles.Assign), Roles.Assign);
								init.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
							}
							result.AddChild(init, Roles.Variable);
						}
					}
				}
				
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				if (fixedStatement.Statement != null)
					result.AddChild((Statement)fixedStatement.Statement.Accept(this), Roles.EmbeddedStatement);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:46,代码来源:CSharpParser.cs

示例2: Visit

			public override object Visit (Fixed fixedStatement)
			{
				var result = new FixedStatement ();
				var location = LocationsBag.GetLocations (fixedStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), "fixed".Length), FixedStatement.FixedKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar);
				
				result.AddChild ((INode)fixedStatement.Type.Accept (this), FixedStatement.PointerDeclarationRole);
				
				foreach (KeyValuePair<LocalInfo, Expression> declarator in fixedStatement.Declarators) {
					result.AddChild ((INode)declarator.Value.Accept (this), FixedStatement.DeclaratorRole);
				}
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar);
				result.AddChild ((INode)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement);
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:19,代码来源:CSharpParser.cs

示例3: Visit

			public override object Visit (Fixed fixedStatement)
			{
				var result = new FixedStatement ();
				var location = LocationsBag.GetLocations (fixedStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), "fixed".Length), FixedStatement.FixedKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar);
				
				if (fixedStatement.Variables != null) {
					result.AddChild ((INode)fixedStatement.Variables.TypeExpression.Accept (this), UsingStatement.Roles.ReturnType);
					result.AddChild (new Identifier (fixedStatement.Variables.Variable.Name, Convert (fixedStatement.Variables.Variable.Location)), UsingStatement.Roles.Identifier);
					var loc = LocationsBag.GetLocations (fixedStatement.Variables);
					if (loc != null)
						result.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), ContinueStatement.Roles.Assign);
					if (fixedStatement.Variables.Initializer != null)
						result.AddChild ((INode)fixedStatement.Variables.Initializer.Accept (this), UsingStatement.Roles.Initializer);
				}
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar);
				result.AddChild ((INode)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement);
				return result;
			}
开发者ID:silk,项目名称:monodevelop,代码行数:24,代码来源:CSharpParser.cs


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