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


C# ArrayCreateExpression类代码示例

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


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

示例1: VisitArrayCreateExpression

 public virtual void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(arrayCreateExpression);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs

示例2: VisitArrayCreateExpression

 public override void VisitArrayCreateExpression(ArrayCreateExpression node)
 {
     node.Initializer.Elements.ToList().ForEach
     (
         item => item.AcceptVisitor(this)
     );
 }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:7,代码来源:ArrayInitializerVisitor.cs

示例3: VisitArrayCreateExpression

            public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
            {
                if (arrayCreateExpression.Arguments.Count >= 10)
                {
                    UnlockWith(arrayCreateExpression);
                }

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

示例4: 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:mgagne-atman,项目名称:Projects,代码行数:12,代码来源:AbstractASTVisitor.cs

示例5: VisitArrayCreateExpression

		public void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression)
		{
			StartNode(arrayCreateExpression);
//			WriteKeyword(ArrayCreateExpression.NewKeywordRole);
//			arrayCreateExpression.Type.AcceptVisitor(this);

			if (arrayCreateExpression.Arguments.Count > 0) {
				WriteKeyword ("new");
				WriteIdentifier ("Array");
				WriteToken (Roles.LChevron);
				arrayCreateExpression.Type.AcceptVisitor(this);
				WriteToken (Roles.RChevron);
				LPar ();
				WriteCommaSeparatedList(arrayCreateExpression.Arguments);
				RPar ();
			}
//			foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) {
//				specifier.AcceptVisitor(this);
//			}
			arrayCreateExpression.Initializer.AcceptVisitor(this);

			EndNode(arrayCreateExpression);
		}
开发者ID:cbsistem,项目名称:Netjs,代码行数:23,代码来源:TsOutputVisitor.cs

示例6: VisitArrayCreateExpression

 public abstract StringBuilder VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, int data);
开发者ID:hach-que,项目名称:SLSharp,代码行数:1,代码来源:VisitorBase.Abstract.cs

示例7: VisitArrayCreateExpression

		public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) {
			throw new global::System.NotImplementedException("ArrayCreateExpression");
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NotImplementedAstVisitor.cs

示例8: VisitArrayCreateExpression

		public virtual void VisitArrayCreateExpression (ArrayCreateExpression arrayCreateExpression)
		{
			VisitChildren (arrayCreateExpression);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs

示例9: ConvertNewArrayBounds

        Expression ConvertNewArrayBounds(InvocationExpression invocation)
        {
            if (invocation.Arguments.Count != 2)
                return NotSupported(invocation);

            AstType elementType = ConvertTypeReference(invocation.Arguments.ElementAt(0));
            IList<Expression> arguments = ConvertExpressionsArray(invocation.Arguments.ElementAt(1));
            if (elementType != null && arguments != null) {
                if (ContainsAnonymousType(elementType)) {
                    elementType = null;
                }
                ArrayCreateExpression ace = new ArrayCreateExpression();
                ace.Type = elementType;
                ace.Arguments.AddRange(arguments);
                return ace;
            }
            return null;
        }
开发者ID:ropean,项目名称:Usable,代码行数:18,代码来源:ExpressionTreeConverter.cs

示例10: VisitArrayCreateExpression

			public override void VisitArrayCreateExpression (ArrayCreateExpression arrayCreateExpression)
			{
				base.VisitArrayCreateExpression (arrayCreateExpression);

				if (arrayCreateExpression.Arguments.Count != 1 || !arrayCreateExpression.Initializer.IsNull)
					return;

				var count = arrayCreateExpression.Arguments.First ();
				if (count is PrimitiveExpression && Convert.ToInt32 (((PrimitiveExpression)count).Value) == 0)
					return;

				var s = arrayCreateExpression.GetParent<Statement> ();
				if (s == null)
					return;

				var find = new FindFirstUseOfArray ();

				var variableDeclarationStatement = s as VariableDeclarationStatement;
				if (variableDeclarationStatement != null) {
					var v = arrayCreateExpression.GetParent <VariableInitializer> ();
					find.Variable = new IdentifierExpression (v.Name);

				} else {
					var es = s as ExpressionStatement;
					if (es != null && es.Expression is AssignmentExpression) {
						find.Variable = ((AssignmentExpression)es.Expression).Left;
					} else {
						return; // Don't know what's going on
					}
				}

				if (find.Variable == null)
					return;

				arrayCreateExpression.GetParent<EntityDeclaration> ().AcceptVisitor (find);
				if ((find.First is AssignmentExpression))
					return;

				var i = new IdentifierExpression ("_ai");
				var def = GetDefaultValue (arrayCreateExpression.Type);

				var init = new ForStatement {
					Condition = new BinaryOperatorExpression (
						i,
						BinaryOperatorType.LessThan,
						new MemberReferenceExpression ((Expression)find.Variable.Clone (), "length")),
					EmbeddedStatement = new ExpressionStatement (
						new AssignmentExpression (
							new IndexerExpression ((Expression)find.Variable.Clone (), i.Clone ()),
							def.Clone ())),
				};
				init.Initializers.Add (new VariableDeclarationStatement (new PrimitiveType ("number"), i.Identifier, new PrimitiveExpression (0)));
				init.Iterators.Add (new ExpressionStatement (new UnaryOperatorExpression (UnaryOperatorType.Increment, (Expression)i.Clone ())));

				s.Parent.InsertChildAfter (s, init, (Role<Statement>)s.Role);
			}
开发者ID:RReverser,项目名称:Netjs,代码行数:56,代码来源:CsToTs.cs

示例11: TransformByteCode

		AstNode TransformByteCode(ILExpression byteCode)
		{
			object operand = byteCode.Operand;
			AstType operandAsTypeRef = AstBuilder.ConvertType(operand as ITypeDefOrRef);

			List<Expression> args = new List<Expression>();
			foreach(ILExpression arg in byteCode.Arguments) {
				args.Add((Expression)TransformExpression(arg));
			}
			Expression arg1 = args.Count >= 1 ? args[0] : null;
			Expression arg2 = args.Count >= 2 ? args[1] : null;
			Expression arg3 = args.Count >= 3 ? args[2] : null;
			
			switch (byteCode.Code) {
					#region Arithmetic
				case ILCode.Add:
				case ILCode.Add_Ovf:
				case ILCode.Add_Ovf_Un:
					{
						BinaryOperatorExpression boe;
						if (byteCode.InferredType is PtrSig) {
							boe = new BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
							if (byteCode.Arguments[0].ExpectedType is PtrSig ||
								byteCode.Arguments[1].ExpectedType is PtrSig) {
								boe.AddAnnotation(IntroduceUnsafeModifier.PointerArithmeticAnnotation);
							}
						} else {
							boe = new BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
						}
						boe.AddAnnotation(byteCode.Code == ILCode.Add ? AddCheckedBlocks.UncheckedAnnotation : AddCheckedBlocks.CheckedAnnotation);
						return boe;
					}
				case ILCode.Sub:
				case ILCode.Sub_Ovf:
				case ILCode.Sub_Ovf_Un:
					{
						BinaryOperatorExpression boe;
						if (byteCode.InferredType is PtrSig) {
							boe = new BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
							if (byteCode.Arguments[0].ExpectedType is PtrSig) {
								boe.WithAnnotation(IntroduceUnsafeModifier.PointerArithmeticAnnotation);
							}
						} else {
							boe = new BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
						}
						boe.AddAnnotation(byteCode.Code == ILCode.Sub ? AddCheckedBlocks.UncheckedAnnotation : AddCheckedBlocks.CheckedAnnotation);
						return boe;
					}
					case ILCode.Div:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.Divide, arg2);
					case ILCode.Div_Un:     return new BinaryOperatorExpression(arg1, BinaryOperatorType.Divide, arg2);
					case ILCode.Mul:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2).WithAnnotation(AddCheckedBlocks.UncheckedAnnotation);
					case ILCode.Mul_Ovf:    return new BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2).WithAnnotation(AddCheckedBlocks.CheckedAnnotation);
					case ILCode.Mul_Ovf_Un: return new BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2).WithAnnotation(AddCheckedBlocks.CheckedAnnotation);
					case ILCode.Rem:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.Modulus, arg2);
					case ILCode.Rem_Un:     return new BinaryOperatorExpression(arg1, BinaryOperatorType.Modulus, arg2);
					case ILCode.And:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.BitwiseAnd, arg2);
					case ILCode.Or:         return new BinaryOperatorExpression(arg1, BinaryOperatorType.BitwiseOr, arg2);
					case ILCode.Xor:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.ExclusiveOr, arg2);
					case ILCode.Shl:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftLeft, arg2);
					case ILCode.Shr:        return new BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftRight, arg2);
					case ILCode.Shr_Un:     return new BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftRight, arg2);
					case ILCode.Neg:        return new UnaryOperatorExpression(UnaryOperatorType.Minus, arg1).WithAnnotation(AddCheckedBlocks.UncheckedAnnotation);
					case ILCode.Not:        return new UnaryOperatorExpression(UnaryOperatorType.BitNot, arg1);
				case ILCode.PostIncrement:
				case ILCode.PostIncrement_Ovf:
				case ILCode.PostIncrement_Ovf_Un:
					{
						if (arg1 is DirectionExpression)
							arg1 = ((DirectionExpression)arg1).Expression.Detach();
						var uoe = new UnaryOperatorExpression(
							(int)byteCode.Operand > 0 ? UnaryOperatorType.PostIncrement : UnaryOperatorType.PostDecrement, arg1);
						uoe.AddAnnotation((byteCode.Code == ILCode.PostIncrement) ? AddCheckedBlocks.UncheckedAnnotation : AddCheckedBlocks.CheckedAnnotation);
						return uoe;
					}
					#endregion
					#region Arrays
					case ILCode.Newarr: {
						var ace = new ArrayCreateExpression();
						ace.Type = operandAsTypeRef;
						ComposedType ct = operandAsTypeRef as ComposedType;
						if (ct != null) {
							// change "new (int[,])[10] to new int[10][,]"
							ct.ArraySpecifiers.MoveTo(ace.AdditionalArraySpecifiers);
						}
						if (byteCode.Code == ILCode.InitArray) {
							ace.Initializer = new ArrayInitializerExpression();
							ace.Initializer.Elements.AddRange(args);
						} else {
							ace.Arguments.Add(arg1);
						}
						return ace;
					}
					case ILCode.InitArray: {
						var ace = new ArrayCreateExpression();
						ace.Type = operandAsTypeRef;
						ComposedType ct = operandAsTypeRef as ComposedType;
						var arrayType = (ArraySigBase)((ITypeDefOrRef)operand).ToTypeSig(); ;
						if (ct != null)
						{
							// change "new (int[,])[10] to new int[10][,]"
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:101,代码来源:AstMethodBodyBuilder.cs

示例12: VisitArrayCreateExpression

		public virtual void VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression)
		{
			DebugExpression(arrayCreateExpression);
			StartNode(arrayCreateExpression);
			WriteKeyword(ArrayCreateExpression.NewKeywordRole);
			arrayCreateExpression.Type.AcceptVisitor(this);
			if (arrayCreateExpression.Arguments.Count > 0) {
				WriteCommaSeparatedListInBrackets(arrayCreateExpression.Arguments, CodeBracesRangeFlags.SquareBrackets);
			}
			int count = 0;
			foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) {
				if (count-- <= 0) {
					cancellationToken.ThrowIfCancellationRequested();
					count = CANCEL_CHECK_LOOP_COUNT;
				}
				specifier.AcceptVisitor(this);
			}
			arrayCreateExpression.Initializer.AcceptVisitor(this);
			EndNode(arrayCreateExpression);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:20,代码来源:CSharpOutputVisitor.cs

示例13: NewExpression

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

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

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

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

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

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

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

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

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

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

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

#line  2042 "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  2049 "cs.ATG" 
					dims += 1; 
				}
				Expect(19);

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

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

#line  2051 "cs.ATG" 
//.........这里部分代码省略.........
开发者ID:mgagne-atman,项目名称:Projects,代码行数:101,代码来源:Parser.cs

示例14: ArrayCreateBlock

 public ArrayCreateBlock(IEmitter emitter, ArrayCreateExpression arrayCreateExpression)
     : base(emitter, arrayCreateExpression)
 {
     this.Emitter = emitter;
     this.ArrayCreateExpression = arrayCreateExpression;
 }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:6,代码来源:ArrayCreateBlock.cs

示例15: 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:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:ToVBNetConvertVisitor.cs


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