예제 #1
0
 public virtual object Visit(NewAnonymousType newAnonymousType)
 {
     return(null);
 }
예제 #2
0
void case_549()
#line 4040 "cs-parser.jay"
{
		if (lang_version <= LanguageVersion.ISO_2)
	  		FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types");

		yyVal = new NewAnonymousType ((List<AnonymousTypeParameter>) yyVals[-1+yyTop], current_container, GetLocation (yyVals[-3+yyTop]));
		
		/* TODO: lbag comma location*/
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
			public override object Visit (NewAnonymousType newAnonymousType)
			{
				var result = new AnonymousTypeCreateExpression ();
				var location = LocationsBag.GetLocations (newAnonymousType);
				result.AddChild (new CSharpTokenNode (Convert (newAnonymousType.Location), ObjectCreateExpression.NewKeywordRole), ObjectCreateExpression.NewKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LBrace), Roles.LBrace);
				if (newAnonymousType.Parameters != null) {
					foreach (var par in newAnonymousType.Parameters) {
						if (par == null)
							continue;
						var parLocation = LocationsBag.GetLocations (par);
						
						if (parLocation == null) {
							if (par.Expr != null)
								result.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression);
						} else {
							var namedExpression = new NamedExpression ();
							namedExpression.AddChild (Identifier.Create (par.Name, Convert (par.Location)), Roles.Identifier);
							namedExpression.AddChild (new CSharpTokenNode (Convert (parLocation [0]), Roles.Assign), Roles.Assign);
							if (par.Expr != null)
								namedExpression.AddChild ((Expression)par.Expr.Accept (this), Roles.Expression);
							result.AddChild (namedExpression, Roles.Expression);
						}
					}
				}
				if (location != null && location.Count > 1)
					result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RBrace), Roles.RBrace);
				return result;
			}
예제 #4
0
		public virtual object Visit (NewAnonymousType newAnonymousType)
		{
			return null;
		}