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


C# Ast.ArrayCreateExpression类代码示例

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


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

示例1: VisitArrayCreateExpression

 public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
 {
     for (int i = 0; i < arrayCreateExpression.Arguments.Count; i++) {
         arrayCreateExpression.Arguments[i] = Expression.AddInteger(arrayCreateExpression.Arguments[i], -1);
     }
     return base.VisitArrayCreateExpression(arrayCreateExpression, data);
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:7,代码来源:ToVBNetConvertVisitor.cs

示例2: VisitArrayCreateExpression

 public override object VisitArrayCreateExpression(ArrayCreateExpression array, object data)
 {
     for(int i = 0; i < array.Arguments.Count; i++) {
         array.Arguments[i] = Deparenthesize(array.Arguments[i]);
     }
     return base.VisitArrayCreateExpression(array, data);
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:7,代码来源:RemoveParenthesis.cs

示例3: VisitArrayCreateExpression

 public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
 {
     if (arrayCreateExpression.IsImplicitlyTyped) {
         return CreateResolveResult(arrayCreateExpression.ArrayInitializer);
     } else {
         return CreateTypeResolveResult(TypeVisitor.CreateReturnType(arrayCreateExpression.CreateType, resolver));
     }
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:8,代码来源:ResolveVisitor.cs

示例4: VisitArrayCreateExpression

        public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
        {
            arrayCreateExpression.CreateType.Parent = arrayCreateExpression;
            arrayCreateExpression.ArrayInitializer.Parent = arrayCreateExpression;
            foreach (INode argument in arrayCreateExpression.Arguments)
                argument.Parent = arrayCreateExpression;

            return base.VisitArrayCreateExpression(arrayCreateExpression, data);
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:9,代码来源:ParentVisitor.cs

示例5: VisitArrayCreateExpression

 public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
 {
     if (arrayCreateExpression.ArrayInitializer == null) {
         return new CodeArrayCreateExpression(ConvType(arrayCreateExpression.CreateType),
                                              arrayCreateExpression.Arguments[0].AcceptVisitor(this, data) as CodeExpression);
     }
     return new CodeArrayCreateExpression(ConvType(arrayCreateExpression.CreateType),
                                          GetExpressionList(arrayCreateExpression.ArrayInitializer.CreateExpressions));
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:9,代码来源:CodeDOMOutputVisitor.cs

示例6: VisitArrayCreateExpression

 public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
 {
     for (int i = 0; i < arrayCreateExpression.Arguments.Count; i++) {
         arrayCreateExpression.Arguments[i] = Expression.AddInteger(arrayCreateExpression.Arguments[i], 1);
     }
     if (arrayCreateExpression.ArrayInitializer.CreateExpressions.Count == 0) {
         arrayCreateExpression.ArrayInitializer = null;
     }
     return base.VisitArrayCreateExpression(arrayCreateExpression, data);
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:10,代码来源:VBNetConstructsConvertVisitor.cs

示例7: GetArrayInitStatements

 private List<Statement> GetArrayInitStatements(ArrayCreateExpression arrayCreateExpression, string variableName, List<Expression> initializerList)
 {
     List<Statement> list = new List<Statement>();
     for (int idx = 0; idx < initializerList.Count; idx++)
     {
         AssignmentExpression assignment = InitArrayStatement(arrayCreateExpression, variableName, ((CollectionInitializerExpression) initializerList[idx]).CreateExpressions, idx);
         ExpressionStatement expressionStatement = new ExpressionStatement(assignment);
         list.Add(expressionStatement);
     }
     return list;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:11,代码来源:ArrayInitializerTransformer.cs

示例8: VisitArrayCreateExpression

		public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			Debug.Assert((arrayCreateExpression != null));
			Debug.Assert((arrayCreateExpression.CreateType != null));
			Debug.Assert((arrayCreateExpression.Arguments != null));
			Debug.Assert((arrayCreateExpression.ArrayInitializer != null));
			arrayCreateExpression.CreateType.AcceptVisitor(this, data);
			foreach (Expression o in arrayCreateExpression.Arguments) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			return arrayCreateExpression.ArrayInitializer.AcceptVisitor(this, data);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:12,代码来源:AbstractASTVisitor.cs

示例9: TrackedVisitArrayCreateExpression

        public override object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
        {
            string variableName = GetVariableName(arrayCreateExpression);
            List<Expression> initializerList = arrayCreateExpression.ArrayInitializer.CreateExpressions;
            Expression replacedExpression = arrayCreateExpression;
            if (initializerList.Count > 0 && initializerList[0] is CollectionInitializerExpression && data is InsertionBlockData)
            {
                ArrayCreateExpression replacedArrayCreateExpression = arrayCreateExpression;
                replacedArrayCreateExpression.ArrayInitializer = null;
                replacedArrayCreateExpression.Arguments.Add(new PrimitiveExpression(initializerList.Count, initializerList.Count.ToString()));

                string arrayTypeName = arrayCreateExpression.CreateType.Type + "s";
                Position position = Position.After;
                if (variableName == null)
                {
                    variableName = arrayTypeName;
                    position = Position.Before;
                }

                List<Statement> initStatements = GetArrayInitStatements(replacedArrayCreateExpression, variableName, initializerList);
                InsertionBlockData insertionBlockData = (InsertionBlockData) data;
                insertionBlockData.Block = (BlockStatement) AstUtil.GetParentOfType(replacedArrayCreateExpression, typeof(BlockStatement));
                insertionBlockData.BlockChildIndex = GetBlockChildIndex(replacedArrayCreateExpression, position);
                insertionBlockData.Statements = initStatements;

                if (variableName == arrayTypeName)
                {
                    IdentifierExpression identifierExpression = new IdentifierExpression(variableName);
                    replacedExpression = identifierExpression;

                    VariableDeclaration variableDeclaration = new VariableDeclaration(variableName, arrayCreateExpression);
                    LocalVariableDeclaration localVariable = new LocalVariableDeclaration(variableDeclaration);
                    localVariable.TypeReference = arrayCreateExpression.CreateType;

                    initStatements.Insert(0, localVariable);
                }

                ReplaceCurrentNode(replacedExpression);
            }

            return base.TrackedVisitArrayCreateExpression(arrayCreateExpression, data);
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:42,代码来源:ArrayInitializerTransformer.cs

示例10: VisitArrayCreateExpression

		public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			Debug.Assert((arrayCreateExpression != null));
			Debug.Assert((arrayCreateExpression.CreateType != null));
			Debug.Assert((arrayCreateExpression.Arguments != null));
			Debug.Assert((arrayCreateExpression.ArrayInitializer != null));
			nodeStack.Push(arrayCreateExpression.CreateType);
			arrayCreateExpression.CreateType.AcceptVisitor(this, data);
			arrayCreateExpression.CreateType = ((TypeReference)(nodeStack.Pop()));
			for (int i = 0; i < arrayCreateExpression.Arguments.Count; i++) {
				Expression o = arrayCreateExpression.Arguments[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (Expression)nodeStack.Pop();
				if (o == null)
					arrayCreateExpression.Arguments.RemoveAt(i--);
				else
					arrayCreateExpression.Arguments[i] = o;
			}
			nodeStack.Push(arrayCreateExpression.ArrayInitializer);
			arrayCreateExpression.ArrayInitializer.AcceptVisitor(this, data);
			arrayCreateExpression.ArrayInitializer = ((CollectionInitializerExpression)(nodeStack.Pop()));
			return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:24,代码来源:AbstractAstTransformer.cs

示例11: ObjectCreateExpression

	void ObjectCreateExpression(
#line  1935 "VBNET.ATG" 
out Expression oce) {

#line  1937 "VBNET.ATG" 
		TypeReference type = null;
		Expression initializer = null;
		List<Expression> arguments = null;
		ArrayList dimensions = null;
		oce = null;
		bool canBeNormal; bool canBeReDim;
		
		Expect(148);
		if (StartOf(7)) {
			NonArrayTypeName(
#line  1945 "VBNET.ATG" 
out type, false);
			if (la.kind == 25) {
				lexer.NextToken();
				NormalOrReDimArgumentList(
#line  1946 "VBNET.ATG" 
out arguments, out canBeNormal, out canBeReDim);
				Expect(26);
				if (la.kind == 23 || 
#line  1947 "VBNET.ATG" 
la.kind == Tokens.OpenParenthesis) {
					if (
#line  1947 "VBNET.ATG" 
la.kind == Tokens.OpenParenthesis) {
						ArrayTypeModifiers(
#line  1948 "VBNET.ATG" 
out dimensions);
						CollectionInitializer(
#line  1949 "VBNET.ATG" 
out initializer);
					} else {
						CollectionInitializer(
#line  1950 "VBNET.ATG" 
out initializer);
					}
				}

#line  1952 "VBNET.ATG" 
				if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression(); 
			}
		}

#line  1956 "VBNET.ATG" 
		if (initializer == null) {
		oce = new ObjectCreateExpression(type, arguments);
		} else {
			if (dimensions == null) dimensions = new ArrayList();
			dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0));
			type.RankSpecifier = (int[])dimensions.ToArray(typeof(int));
			ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer as CollectionInitializerExpression);
			ace.Arguments = arguments;
			oce = ace;
		}
		
		if (la.kind == 218) {

#line  1970 "VBNET.ATG" 
			NamedArgumentExpression memberInitializer = null;
			
			lexer.NextToken();

#line  1974 "VBNET.ATG" 
			CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression();
			memberInitializers.StartLocation = la.Location;
			
			Expect(23);
			MemberInitializer(
#line  1978 "VBNET.ATG" 
out memberInitializer);

#line  1979 "VBNET.ATG" 
			memberInitializers.CreateExpressions.Add(memberInitializer); 
			while (la.kind == 12) {
				lexer.NextToken();
				MemberInitializer(
#line  1981 "VBNET.ATG" 
out memberInitializer);

#line  1982 "VBNET.ATG" 
				memberInitializers.CreateExpressions.Add(memberInitializer); 
			}
			Expect(24);

#line  1986 "VBNET.ATG" 
			memberInitializers.EndLocation = t.Location;
			if(oce is ObjectCreateExpression)
			{
				((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers;
			}
			
		}
	}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:97,代码来源:Parser.cs

示例12: VisitReDimStatement

		public override object VisitReDimStatement(ReDimStatement reDimStatement, object data)
		{
			base.VisitReDimStatement(reDimStatement, data);
			
			if (resolver.CompilationUnit == null)
				return null;
			
			if (reDimStatement.ReDimClauses.Count != 1)
				return null;
			
			if (reDimStatement.IsPreserve) {
				if (reDimStatement.ReDimClauses[0].Arguments.Count > 1) {
					// multidimensional Redim Preserve
					// replace with:
					// MyArray = (int[,])Microsoft.VisualBasic.CompilerServices.Utils.CopyArray(MyArray, new int[dim1+1, dim2+1]);
					
					ResolveResult rr = Resolve(reDimStatement.ReDimClauses[0].TargetObject);
					if (rr != null && rr.ResolvedType != null && rr.ResolvedType.IsArrayReturnType) {
						ArrayCreateExpression ace = new ArrayCreateExpression(ConvertType(rr.ResolvedType));
						foreach (Expression arg in reDimStatement.ReDimClauses[0].Arguments) {
							ace.Arguments.Add(Expression.AddInteger(arg, 1));
						}
						
						ReplaceCurrentNode(new ExpressionStatement(
							new AssignmentExpression(
								reDimStatement.ReDimClauses[0].TargetObject,
								AssignmentOperatorType.Assign,
								new CastExpression(
									ace.CreateType,
									new InvocationExpression(
										MakeFieldReferenceExpression("Microsoft.VisualBasic.CompilerServices.Utils.CopyArray"),
										new List<Expression> {
											reDimStatement.ReDimClauses[0].TargetObject,
											ace
										}
									),
									CastType.Cast
								)
							)));
					}
				}
			} else {
				// replace with array create expression
				
				ResolveResult rr = Resolve(reDimStatement.ReDimClauses[0].TargetObject);
				if (rr != null && rr.ResolvedType != null && rr.ResolvedType.IsArrayReturnType) {
					ArrayCreateExpression ace = new ArrayCreateExpression(ConvertType(rr.ResolvedType));
					foreach (Expression arg in reDimStatement.ReDimClauses[0].Arguments) {
						ace.Arguments.Add(Expression.AddInteger(arg, 1));
					}
					
					ReplaceCurrentNode(new ExpressionStatement(
						new AssignmentExpression(reDimStatement.ReDimClauses[0].TargetObject, AssignmentOperatorType.Assign, ace)));
				}
			}
			return null;
		}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:57,代码来源:VBNetToCSharpConvertVisitor.cs

示例13: NewExpression

	void NewExpression(
#line  2065 "cs.ATG" 
out Expression pexpr) {

#line  2066 "cs.ATG" 
		pexpr = null;
		List<Expression> parameters = new List<Expression>();
		TypeReference type = null;
		Expression expr;
		
		Expect(89);
		if (StartOf(10)) {
			NonArrayType(
#line  2073 "cs.ATG" 
out type);
		}
		if (la.kind == 16 || la.kind == 20) {
			if (la.kind == 20) {

#line  2079 "cs.ATG" 
				ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); 
				lexer.NextToken();

#line  2080 "cs.ATG" 
				if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); 
				if (StartOf(25)) {
					Argument(
#line  2081 "cs.ATG" 
out expr);

#line  2081 "cs.ATG" 
					SafeAdd(oce, parameters, expr); 
					while (la.kind == 14) {
						lexer.NextToken();
						Argument(
#line  2082 "cs.ATG" 
out expr);

#line  2082 "cs.ATG" 
						SafeAdd(oce, parameters, expr); 
					}
				}
				Expect(21);

#line  2084 "cs.ATG" 
				pexpr = oce; 
				if (la.kind == 16) {
					CollectionOrObjectInitializer(
#line  2085 "cs.ATG" 
out expr);

#line  2085 "cs.ATG" 
					oce.ObjectInitializer = (CollectionInitializerExpression)expr; 
				}
			} else {

#line  2086 "cs.ATG" 
				ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); 
				CollectionOrObjectInitializer(
#line  2087 "cs.ATG" 
out expr);

#line  2087 "cs.ATG" 
				oce.ObjectInitializer = (CollectionInitializerExpression)expr; 

#line  2088 "cs.ATG" 
				pexpr = oce; 
			}
		} else if (la.kind == 18) {
			lexer.NextToken();

#line  2093 "cs.ATG" 
			ArrayCreateExpression ace = new ArrayCreateExpression(type);
			/* we must not change RankSpecifier on the null type reference*/
			if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); }
			pexpr = ace;
			int dims = 0; List<int> ranks = new List<int>();
			
			if (la.kind == 14 || la.kind == 19) {
				while (la.kind == 14) {
					lexer.NextToken();

#line  2100 "cs.ATG" 
					dims += 1; 
				}
				Expect(19);

#line  2101 "cs.ATG" 
				ranks.Add(dims); dims = 0; 
				while (la.kind == 18) {
					lexer.NextToken();
					while (la.kind == 14) {
						lexer.NextToken();

#line  2102 "cs.ATG" 
						++dims; 
					}
					Expect(19);

#line  2102 "cs.ATG" 
//.........这里部分代码省略.........
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:101,代码来源:Parser.cs

示例14: VisitArrayCreateExpression

		public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
		{
			if (arrayCreateExpression.IsImplicitlyTyped) {
//				Console.WriteLine (arrayCreateExpression.ArrayInitializer);
				return Resolve (arrayCreateExpression.ArrayInitializer);
			}
			return CreateResult (arrayCreateExpression.CreateType);
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:8,代码来源:ResolveVisitor.cs

示例15: ObjectCreateExpression

	void ObjectCreateExpression(
#line  1860 "VBNET.ATG" 
out Expression oce) {

#line  1862 "VBNET.ATG" 
		TypeReference type = null;
		Expression initializer = null;
		List<Expression> arguments = null;
		ArrayList dimensions = null;
		oce = null;
		bool canBeNormal; bool canBeReDim;
		
		Expect(127);
		NonArrayTypeName(
#line  1869 "VBNET.ATG" 
out type, false);
		if (la.kind == 24) {
			lexer.NextToken();
			NormalOrReDimArgumentList(
#line  1870 "VBNET.ATG" 
out arguments, out canBeNormal, out canBeReDim);
			Expect(25);
			if (la.kind == 22 || 
#line  1871 "VBNET.ATG" 
la.kind == Tokens.OpenParenthesis) {
				if (
#line  1871 "VBNET.ATG" 
la.kind == Tokens.OpenParenthesis) {
					ArrayTypeModifiers(
#line  1872 "VBNET.ATG" 
out dimensions);
					CollectionInitializer(
#line  1873 "VBNET.ATG" 
out initializer);
				} else {
					CollectionInitializer(
#line  1874 "VBNET.ATG" 
out initializer);
				}
			}

#line  1876 "VBNET.ATG" 
			if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression(); 
		}

#line  1879 "VBNET.ATG" 
		if (type == null) type = new TypeReference("Object"); // fallback type on parser errors
		if (initializer == null) {
			oce = new ObjectCreateExpression(type, arguments);
		} else {
			if (dimensions == null) dimensions = new ArrayList();
			dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0));
			type.RankSpecifier = (int[])dimensions.ToArray(typeof(int));
			ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer as CollectionInitializerExpression);
			ace.Arguments = arguments;
			oce = ace;
		}
		
	}
开发者ID:almazik,项目名称:ILSpy,代码行数:59,代码来源:Parser.cs


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