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

C# CSharp.ArrayCreation类代码示例

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

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



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

示例1: case_498

void case_498()
#line 3642 "cs-parser.jay"
{
	  	if (yyVals[0+yyTop] == null)
	  		report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer");

		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs


示例2: CreateCallSiteBinder

		public Expression CreateCallSiteBinder (ResolveContext ec, Arguments args)
		{
			Arguments binder_args = new Arguments (member != null ? 5 : 3);
			MemberAccess binder = GetBinderNamespace (loc);
			bool is_member_access = member is MemberAccess;

			string call_flags;
			if (!is_member_access && member is SimpleName) {
				call_flags = "SimpleNameCall";
				is_member_access = true;
			} else {
				call_flags = "None";
			}

			binder_args.Add (new Argument (new MemberAccess (new MemberAccess (binder, "CSharpCallFlags", loc), call_flags, loc)));

			if (is_member_access)
				binder_args.Add (new Argument (new StringLiteral (member.Name, member.Location)));

			binder_args.Add (new Argument (new TypeOf (new TypeExpression (ec.CurrentType, loc), loc)));

			if (member != null && member.HasTypeArguments) {
				TypeArguments ta = member.TypeArguments;
				if (ta.Resolve (ec)) {
					ArrayList targs = new ArrayList (ta.Count);
					foreach (Type t in ta.Arguments)
						targs.Add (new TypeOf (new TypeExpression (t, loc), loc));

					binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation ("[]", targs, loc)));
				}
			} else if (is_member_access) {
				binder_args.Add (new Argument (new NullLiteral (loc)));
			}

			Expression real_args;
			if (args == null) {
				// Cannot be null because .NET trips over
				real_args = new ArrayCreation (new MemberAccess (binder, "CSharpArgumentInfo", loc), "[]", new ArrayList (0), loc);
			} else {
				real_args = new ImplicitlyTypedArrayCreation ("[]", args.CreateDynamicBinderArguments (), loc);
			}

			binder_args.Add (new Argument (real_args));

			return new New (new MemberAccess (binder,
				is_member_access ? "CSharpInvokeMemberBinder" : "CSharpInvokeBinder", loc), binder_args, loc);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:47,代码来源:dynamic.cs


示例3: case_497

void case_497()
#line 3634 "cs-parser.jay"
{
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List<Expression>) yyVals[-3+yyTop],
				new ComposedTypeSpecifier (((List<Expression>) yyVals[-3+yyTop]).Count, GetLocation (yyVals[-4+yyTop])) {
	  				Next = (ComposedTypeSpecifier) yyVals[-1+yyTop]
			  	}, (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs


示例4: case_501

void case_501()
#line 3463 "cs-parser.jay"
{
		Error_SyntaxError (1526, yyToken, "Unexpected symbol");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:Ein,项目名称:monodevelop,代码行数:6,代码来源:cs-parser.cs


示例5: Visit

		public virtual object Visit (ArrayCreation arrayCreationExpression)
		{
			return null;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs


示例6: CreateCallSiteBinder

        public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args)
        {
            Arguments binder_args = new Arguments (member != null ? 5 : 3);
            bool is_member_access = member is MemberAccess;

            CSharpBinderFlags call_flags;
            if (!is_member_access && member is SimpleName) {
                call_flags = CSharpBinderFlags.InvokeSimpleName;
                is_member_access = true;
            } else {
                call_flags = 0;
            }

            binder_args.Add (new Argument (new BinderFlags (call_flags, this)));

            if (is_member_access)
                binder_args.Add (new Argument (new StringLiteral (member.Name, member.Location)));

            if (member != null && member.HasTypeArguments) {
                TypeArguments ta = member.TypeArguments;
                if (ta.Resolve (ec)) {
                    var targs = new ArrayInitializer (ta.Count, loc);
                    foreach (TypeSpec t in ta.Arguments)
                        targs.Add (new TypeOf (new TypeExpression (t, loc), loc));

                    binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation ("[]", targs, loc)));
                }
            } else if (is_member_access) {
                binder_args.Add (new Argument (new NullLiteral (loc)));
            }

            binder_args.Add (new Argument (new TypeOf (new TypeExpression (ec.CurrentType, loc), loc)));

            Expression real_args;
            if (args == null) {
                // Cannot be null because .NET trips over
                real_args = new ArrayCreation (
                    new MemberAccess (GetBinderNamespace (loc), "CSharpArgumentInfo", loc), "[]",
                    new ArrayInitializer (0, loc), loc);
            } else {
                real_args = new ImplicitlyTypedArrayCreation ("[]", args.CreateDynamicBinderArguments (ec), loc);
            }

            binder_args.Add (new Argument (real_args));

            return new Invocation (GetBinder (is_member_access ? "InvokeMember" : "Invoke", loc), binder_args);
        }
开发者ID:speier,项目名称:shake,代码行数:47,代码来源:dynamic.cs


示例7: case_496

void case_496()
#line 3416 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
	  	if (yyVals[0+yyTop] == null)
	  		Report.Error (1586, GetLocation (yyVals[-3+yyTop]), "Array creation must have array size or array initializer");

		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (ComposedTypeSpecifier) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:8,代码来源:cs-parser.cs


示例8: GetInitializerExpression

		//
		// Resolves and returns the field initializer.
		//
		public Expression GetInitializerExpression (EmitContext ec)
		{
			if (init_expr_initialized)
				return init_expr;

			Expression e;
			if (init is Expression)
				e = (Expression) init;
			else
				e = new ArrayCreation (Type, "", (ArrayList)init, Location);

			ec.IsFieldInitializer = true;
			e = e.DoResolve (ec);
			ec.IsFieldInitializer = false;

			init_expr = e;
			init_expr_initialized = true;

			return init_expr;
		}
开发者ID:emtees,项目名称:old-code,代码行数:23,代码来源:class.cs


示例9: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			if (ec.Target == Target.JavaScript) {
				type = ec.BuiltinTypes.Dynamic;
				eclass = ExprClass.Value;
				return this;
			}

			if (Expr is AsArrayInitializer)
				return Expr.Resolve (ec);

			New newExpr = null;

			if (Expr is Invocation) {
				var inv = Expr as Invocation;
				newExpr = new New(inv.Exp, inv.Arguments, loc);
			} else if (Expr is ElementAccess) {
				if (loc.SourceFile != null && !loc.SourceFile.PsExtended) {
					ec.Report.Error (7103, loc, "Native arrays are only suppored in ASX.'");
					return null;
				}
				var elemAcc = Expr as ElementAccess;
				var exprList = new List<Expression>();
				foreach (var arg in elemAcc.Arguments) {
					exprList.Add (arg.Expr);
				}
				// TODO: Handle jagged arrays
				var arrayCreate = new ArrayCreation ((FullNamedExpression) elemAcc.Expr, exprList, 
				                new ComposedTypeSpecifier (exprList.Count, loc), null, loc);
				return arrayCreate.Resolve (ec);
			} else {
				var resolveExpr = Expr.Resolve (ec);
				if (resolveExpr == null)
					return null;
				if (resolveExpr is TypeOf) {
					newExpr = new New (((TypeOf)resolveExpr).TypeExpression, new Arguments (0), loc);
				} else {
					newExpr = new New (resolveExpr, new Arguments (0), loc);
				}
			}

			return newExpr.Resolve (ec);
		}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:43,代码来源:ps-lang.cs


示例10: case_492

void case_492()
{
		report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop]));
	  }
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs


示例11: Visit

			public override object Visit (ArrayCreation arrayCreationExpression)
			{
				var result = new ArrayCreateExpression ();
				
				var location = LocationsBag.GetLocations (arrayCreationExpression);
				result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Location), "new".Length), ArrayCreateExpression.Roles.Keyword);
				
				if (arrayCreationExpression.NewType != null)
					result.AddChild (ConvertToType (arrayCreationExpression.NewType), ArrayCreateExpression.Roles.Type);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayCreateExpression.Roles.LBracket);
				if (arrayCreationExpression.Arguments != null) {
					var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments);
					for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) {
						result.AddChild ((MonoDevelop.CSharp.Ast.Expression)arrayCreationExpression.Arguments[i].Accept (this), ArrayCreateExpression.Roles.Argument);
						if (commaLocations != null && i > 0)
							result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), ArrayCreateExpression.Roles.Comma);
					}
				}
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayCreateExpression.Roles.RBracket);
				
				if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) {
					//throw new NotImplementedException();
					/* TODO: use ArrayInitializerExpression
					var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers);
					result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayCreateExpression.Roles.LBrace);
					var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements);
					for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) {
						result.AddChild ((AstNode)arrayCreationExpression.Initializers[i].Accept (this), ObjectCreateExpression.Roles.Variable);
						if (commaLocations != null && i > 0) {
							result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma);
						}
					}
					
					if (initLocation != null)
						result.AddChild (new CSharpTokenNode (Convert (initLocation[initLocation.Count - 1]), 1), ArrayCreateExpression.Roles.RBrace); */
				}
				
				return result;
			}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:41,代码来源:CSharpParser.cs


示例12: yyparse


//.........这里部分代码省略.........
		if(current_container.Kind == MemberKind.Interface && current_extensionContainer != null){
		    var parameters = new List<Parameter>();
            var typeExpression = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[-9+yyTop]));
            var parameter = new Parameter(typeExpression, "self", Parameter.Modifier.This, null, GetLocation(yyVals[-9+yyTop]));
            parameters.Add(parameter);
            parameters.Add(new Parameter(typeExpression, "ctx", Parameter.Modifier.NONE, null, GetLocation(yyVals[-9+yyTop])));
		    var clone = current_local_parameters.Clone();
		    for(var i = 0; i < clone.Count; i++){
		       parameters.Add(clone[i]);
		    }
		    
			var parameterTypeExpressions = parameters.Select(p=>p.TypeExpression).ToList();
			var key = current_namespace.NS.Name + "," + name.Name + "," + string.Join(",",parameterTypeExpressions.Select(p => p.ToString()));
			if(roleExtensionMethodDummies.Add(key)){
               var returnType = (FullNamedExpression) yyVals[-7+yyTop];
			   var parametersCompiled = new ParametersCompiled(parameters.ToArray(),false);
		       var dummy = Method.Create (current_extensionContainer, generic, (FullNamedExpression) yyVals[-7+yyTop], Modifiers.PUBLIC | Modifiers.STATIC,
				       name, parametersCompiled, (Attributes) yyVals[-9+yyTop], yyVals[0+yyTop] != null);
                var location = GetLocation(yyVals[-9+yyTop]);
				var parameterName = new SimpleName("self", null, location);
				var getTypeAccess = new MemberAccess(parameterName, "GetType", null, location);
                var getTypeExpression =  new Invocation(getTypeAccess, new Arguments(0));
                var argCount = parameterTypeExpressions.Count-1;
                var argumentsForGetMethod = new Arguments(2);
				var stringLiteral =  new StringLiteral(compiler.BuiltinTypes,name.Name,location);
                argumentsForGetMethod.Add(new Argument(stringLiteral));
				var typeName = new SimpleName("Type", null, location);
				var types = parameterTypeExpressions.Skip(2)
				                          .Select(t =>(Expression)(t.Type != null 
										                             ? new TypeOf(t.Type,location) 
																	 : new TypeOf(t,location))
									  ).ToList();
				var initializer = new ArrayInitializer(types,location);
                var parameterTypes = new ImplicitlyTypedArrayCreation (
				                           new ComposedTypeSpecifier (1, location), 
										   initializer, 
										   location);
		        lbag.AddLocation (parameterTypes, location, location);
				
                argumentsForGetMethod.Add(new Argument(parameterTypes));
                var getMethodExpression = new Invocation(new MemberAccess(getTypeExpression,"GetMethod"),argumentsForGetMethod);
                var argumentsForMethod = new Arguments(2);

                var delegatedArguments = parameters.Skip(2).Select(p =>
                         (Expression)new Cast(
                                  new TypeExpression(compiler.BuiltinTypes.Object,location),
                                  new SimpleName(p.Name,location),
                                  location)).ToList();
		        argumentsForMethod.Add(new Argument(new SimpleName("self", null, location)));
                if(delegatedArguments.Any()){
				      initializer = new ArrayInitializer(delegatedArguments,location);
				
				      argumentsForMethod.Add(new Argument(new ImplicitlyTypedArrayCreation(
				                           new ComposedTypeSpecifier (1, location), 
										   initializer, 
										   location)));
                } else {
				   argumentsForMethod.Add(new Argument(new ArrayCreation(new TypeExpression(compiler.BuiltinTypes.Object,location),new ArrayInitializer(0,location)))); 
				}    

                var invocation = new Invocation(new MemberAccess(getMethodExpression,"Invoke"),argumentsForMethod);
				Statement statement = new StatementExpression(invocation);
				var retType = (returnType as TypeExpression);
                if(retType != null && retType.Type.Name != "Void"){
				    var cast = new Cast(returnType,invocation,location);
                    statement = new Return(cast,location);
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs


示例13: case_499

void case_499()
#line 3435 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		Error_SyntaxError (1526, yyToken, "Unexpected symbol");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:6,代码来源:cs-parser.cs


示例14: case_498

void case_498()
#line 3430 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		Report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:6,代码来源:cs-parser.cs


示例15: case_500

void case_500()
#line 3656 "cs-parser.jay"
{
		report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs


示例16: yyparse


//.........这里部分代码省略.........
	  }
  break;
case 487:
#line 3402 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 488:
#line 3409 "cs-parser.jay"
  {
		if (yyVals[0+yyTop] != null) {
			if (RootContext.Version <= LanguageVersion.ISO_2)
				Report.FeatureIsNotAvailable (GetLocation (yyVals[-4+yyTop]), "object initializers");
				
			yyVal = new NewInitialize ((Expression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
		}
		else
			yyVal = new New ((Expression) yyVals[-4+yyTop], (Arguments) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 489:
#line 3420 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-1+yyTop]), "collection initializers");
	  
		yyVal = new NewInitialize ((Expression) yyVals[-1+yyTop], null, (CollectionOrObjectInitializers) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 490:
#line 3432 "cs-parser.jay"
  {
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List<Expression>) yyVals[-3+yyTop], (string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop]));
	  }
  break;
case 491:
#line 3436 "cs-parser.jay"
  {
	  	if (yyVals[0+yyTop] == null)
	  		Report.Error (1586, GetLocation (yyVals[-2+yyTop]), "Array creation must have array size or array initializer");

		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-2+yyTop], (string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 492:
#line 3443 "cs-parser.jay"
  {
		if (RootContext.Version <= LanguageVersion.ISO_2)
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays");
	  
		yyVal = new ImplicitlyTypedArrayCreation ((string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 493:
#line 3450 "cs-parser.jay"
  {
		Report.Error (1526, GetLocation (yyVals[-1+yyTop]), "A new expression requires () or [] after type");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], "[]", null, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 494:
#line 3458 "cs-parser.jay"
  {
		++lexer.parsing_type;
	  }
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs


示例17: Visit

			public override object Visit(ArrayCreation arrayCreationExpression)
			{
				var result = new ArrayCreateExpression();
				
				var location = LocationsBag.GetLocations(arrayCreationExpression);
				result.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Location), ArrayCreateExpression.NewKeywordRole), ArrayCreateExpression.NewKeywordRole);
				if (arrayCreationExpression.TypeExpression != null)
					result.AddChild(ConvertToType(arrayCreationExpression.TypeExpression), Roles.Type);
				
				var next = arrayCreationExpression.Rank;
				if (arrayCreationExpression.Arguments != null) {
					// skip first array rank.
					next = next.Next;
					
					if (location != null)
						result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LBracket), Roles.LBracket);
					
					var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Arguments);
					for (int i = 0; i < arrayCreationExpression.Arguments.Count; i++) {
						var arg = arrayCreationExpression.Arguments [i];
						if (arg != null)
							result.AddChild((Expression)arg.Accept(this), Roles.Argument);
						if (commaLocations != null && i < commaLocations.Count)
							result.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma);
					}
					if (location != null && location.Count > 1)
						result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RBracket), Roles.RBracket);
					
				}
				
				while (next != null) {
					var spec = new ArraySpecifier(next.Dimension);
					var loc = LocationsBag.GetLocations(next);
					spec.AddChild(new CSharpTokenNode(Convert(next.Location), Roles.LBracket), Roles.LBracket);
					result.AddChild(spec, ArrayCreateExpression.AdditionalArraySpecifierRole);
					if (loc != null)
						result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.RBracket), Roles.RBracket);
					next = next.Next;
				}
				
				if (arrayCreationExpression.Initializers != null) {
					var initLocation = LocationsBag.GetLocations(arrayCreationExpression.Initializers);
					var initializer = new ArrayInitializerExpression();
					
					initializer.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Initializers.Location), Roles.LBrace), Roles.LBrace);
					var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Initializers.Elements);
					for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) {
						var init = arrayCreationExpression.Initializers [i];
						if (init == null)
							continue;
						initializer.AddChild((Expression)init.Accept(this), Roles.Expression);
						if (commaLocations != null && i < commaLocations.Count) {
							initializer.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma);
						}
					}
					if (initLocation != null) {
						if (initLocation.Count == 2) // optional comma
							initializer.AddChild(new CSharpTokenNode(Convert(initLocation [0]), Roles.Comma), Roles.Comma);
						initializer.AddChild(new CSharpTokenNode(Convert(initLocation [initLocation.Count - 1]), Roles.RBrace), Roles.RBrace);
					}
					result.AddChild(initializer, ArrayCreateExpression.InitializerRole);
				}
				
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:65,代码来源:CSharpParser.cs


示例18: Visit

			public override object Visit (ArrayCreation arrayCreationExpression)
			{
				var result = new ArrayCreateExpression ();
				
				var location = LocationsBag.GetLocations (arrayCreationExpression);
				if (arrayCreationExpression.NewType != null)
					result.AddChild (ConvertToType (arrayCreationExpression.NewType), ArrayCreateExpression.Roles.Type);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayCreateExpression.Roles.LBracket);
				if (arrayCreationExpression.Arguments != null) {
					var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments);
					for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) {
						result.AddChild ((Expression)arrayCreationExpression.Arguments[i].Accept (this), ArrayCreateExpression.Roles.Argument);
						if (commaLocations != null && i > 0)
							result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), ArrayCreateExpression.Roles.Comma);
					}
				}
				var next = arrayCreationExpression.Rank.Next;
				while (next != null) {
					ArraySpecifier spec = new ArraySpecifier (next.Dimension);
					var loc = LocationsBag.GetLocations (next);
					spec.AddChild (new CSharpTokenNode (Convert (next.Location), 1), ArraySpecifier.Roles.LBracket);
					if (loc != null)
						result.AddChild (new CSharpTokenNode (Convert (loc[0]), 1), ArraySpecifier.Roles.RBracket);
					result.AddChild (spec, ArrayCreateExpression.AdditionalArraySpecifierRole);
					next = next.Next;
				}
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayCreateExpression.Roles.RBracket);
				
				if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) {
					var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers);
					ArrayInitializerExpression initializer = new ArrayInitializerExpression();
					
					initializer.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayCreateExpression.Roles.LBrace);
					var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements);
					for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) {
						initializer.AddChild ((Expression)arrayCreationExpression.Initializers[i].Accept (this), ArrayInitializerExpression.Roles.Expression);
						if (commaLocations != null && i > 0) {
							initializer.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma);
						}
					}
					
					if (initLocation != null)
						initializer.AddChild (new CSharpTokenNode (Convert (initLocation[initLocation.Count - 1]), 1), ArrayCreateExpression.Roles.RBrace);
					result.AddChild (initializer, ArrayCreateExpression.InitializerRole);
				}
				
				return result;
			}
开发者ID:aleksandersumowski,项目名称:monodevelop,代码行数:51,代码来源:CSharpParser.cs


示例19: Visit

			public override object Visit (ArrayCreation arrayCreationExpression)
			{
				var result = new ArrayObjectCreateExpression ();
				
				var location = LocationsBag.GetLocations (arrayCreationExpression);
				result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Location), "new".Length), ArrayObjectCreateExpression.Roles.Keyword);
				
				if (arrayCreationExpression.NewType != null)
					result.AddChild ((INode)arrayCreationExpression.NewType.Accept (this), ArrayObjectCreateExpression.Roles.ReturnType);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ArrayObjectCreateExpression.Roles.LBracket);
				if (arrayCreationExpression.Arguments != null) {
					var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Arguments);
					for (int i = 0 ;i < arrayCreationExpression.Arguments.Count; i++) {
						result.AddChild ((INode)arrayCreationExpression.Arguments[i].Accept (this), ObjectCreateExpression.Roles.Initializer);
						if (commaLocations != null && i > 0)
							result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma);
					}
				}
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), ArrayObjectCreateExpression.Roles.RBracket);
				
				if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Elements != null) {
					var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers);
					result.AddChild (new CSharpTokenNode (Convert (arrayCreationExpression.Initializers.Location), 1), ArrayObjectCreateExpression.Roles.LBrace);
					if (arrayCreationExpression.Initializers.Elements != null) {
						var commaLocations = LocationsBag.GetLocations (arrayCreationExpression.Initializers.Elements);
						for (int i = 0; i < arrayCreationExpression.Initializers.Elements.Count; i++) {
							result.AddChild ((INode)arrayCreationExpression.Initializers.Elements[i].Accept (this), ObjectCreateExpression.Roles.Initializer);
							if (commaLocations != null && i > 0)
								result.AddChild (new CSharpTokenNode (Convert (commaLocations [commaLocations.Count - i]), 1), IndexerExpression.Roles.Comma);
						}
					}
					if (initLocation != null)
						result.AddChild (new CSharpTokenNode (Convert (initLocation[0]), 1), ArrayObjectCreateExpression.Roles.RBrace);
				}
				
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:39,代码来源:CSharpParser.cs


示例20: case_495

void case_495()
#line 3408 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], (List<Expression>) yyVals[-3+yyTop],
				new ComposedTypeSpecifier (((List<Expression>) yyVals[-3+yyTop]).Count, GetLocation (yyVals[-4+yyTop])) {
	  				Next = (ComposedTypeSpecifier) yyVals[-1+yyTop]
			  	}, (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-6+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:9,代码来源:cs-parser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.As类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.Arguments类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap