Inheritance: ICSharpCode.NRefactory.Ast.AbstractNode, INullable
Ejemplo n.º 1
0
	void ConstructorInitializer(
#line  1348 "cs.ATG" 
out ConstructorInitializer ci) {

#line  1349 "cs.ATG" 
		Expression expr; ci = new ConstructorInitializer(); 
		Expect(9);
		if (la.kind == 51) {
			lexer.NextToken();

#line  1353 "cs.ATG" 
			ci.ConstructorInitializerType = ConstructorInitializerType.Base; 
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  1354 "cs.ATG" 
			ci.ConstructorInitializerType = ConstructorInitializerType.This; 
		} else SynErr(184);
		Expect(20);
		if (StartOf(25)) {
			Argument(
#line  1357 "cs.ATG" 
out expr);

#line  1357 "cs.ATG" 
			SafeAdd(ci, ci.Arguments, expr); 
			while (la.kind == 14) {
				lexer.NextToken();
				Argument(
#line  1358 "cs.ATG" 
out expr);

#line  1358 "cs.ATG" 
				SafeAdd(ci, ci.Arguments, expr); 
			}
		}
		Expect(21);
	}
Ejemplo n.º 2
0
		public override object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
		{
			return null;
		}
        public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
        {
            // make constructor public if visiblity is not set (unless constructor is static)
            if ((constructorDeclaration.Modifier & (Modifiers.Visibility | Modifiers.Static)) == 0)
                constructorDeclaration.Modifier |= Modifiers.Public;

            // MyBase.New() and MyClass.New() calls inside the constructor are converted to :base() and :this()
            BlockStatement body = constructorDeclaration.Body;
            if (body != null && body.Children.Count > 0) {
                ExpressionStatement se = body.Children[0] as ExpressionStatement;
                if (se != null) {
                    InvocationExpression ie = se.Expression as InvocationExpression;
                    if (ie != null) {
                        MemberReferenceExpression fre = ie.TargetObject as MemberReferenceExpression;
                        if (fre != null && "New".Equals(fre.MemberName, StringComparison.InvariantCultureIgnoreCase)) {
                            if (fre.TargetObject is BaseReferenceExpression || fre.TargetObject is ClassReferenceExpression || fre.TargetObject is ThisReferenceExpression) {
                                body.Children.RemoveAt(0);
                                ConstructorInitializer ci = new ConstructorInitializer();
                                ci.Arguments = ie.Arguments;
                                if (fre.TargetObject is BaseReferenceExpression)
                                    ci.ConstructorInitializerType = ConstructorInitializerType.Base;
                                else
                                    ci.ConstructorInitializerType = ConstructorInitializerType.This;
                                constructorDeclaration.ConstructorInitializer = ci;
                            }
                        }
                    }
                }
            }
            return base.VisitConstructorDeclaration(constructorDeclaration, data);
        }
		public virtual object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) {
			Debug.Assert((constructorInitializer != null));
			Debug.Assert((constructorInitializer.Arguments != null));
			for (int i = 0; i < constructorInitializer.Arguments.Count; i++) {
				Expression o = constructorInitializer.Arguments[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (Expression)nodeStack.Pop();
				if (o == null)
					constructorInitializer.Arguments.RemoveAt(i--);
				else
					constructorInitializer.Arguments[i] = o;
			}
			return null;
		}
Ejemplo n.º 5
0
 public virtual object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) {
     throw CreateException(constructorInitializer);
 }
		public virtual object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) {
			return base.VisitConstructorInitializer(constructorInitializer, data);
		}
 public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 {
     if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This)
     {
         TypeDeclaration typeDeclaration = (TypeDeclaration) AstUtil.GetParentOfType(constructorInitializer, typeof(TypeDeclaration));
         List<Expression> args = ReplaceNullArguments(typeDeclaration, constructorInitializer.Arguments, constructorInitializer);
         constructorInitializer.Arguments = args;
     }
     return base.TrackedVisitConstructorInitializer(constructorInitializer, data);
 }
		public object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
		{
			throw new ApplicationException("ConstructorInitializer visited.");
		}
 public object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 {
     throw new NotImplementedException ();
 }
 public virtual bool VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object d)
 {
     if ((constructorInitializer == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((constructorInitializer.Arguments == null)) {
         return SetFailure();
     }
     if(constructorInitializer.GetType() != d.GetType()) {return SetFailure();}
     var data = (ConstructorInitializer)d;
     if (!IsMatch(constructorInitializer, data)) {
         return SetFailure();
     }
     if (constructorInitializer.Arguments.Count == data.Arguments.Count) {
     for (int i=0; i<constructorInitializer.Arguments.Count;i++) {
         Expression o = constructorInitializer.Arguments[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.Arguments[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     return true;
 }
Ejemplo n.º 11
0
		public ConstructorDeclaration(string name, Modifiers modifier, List<ParameterDeclarationExpression> parameters, ConstructorInitializer constructorInitializer, List<AttributeSection> attributes) : 
				base(modifier, attributes, name, parameters) {
			ConstructorInitializer = constructorInitializer;
			body = BlockStatement.Null;
		}
Ejemplo n.º 12
0
		public override object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
		{
			WriteLine("VisitConstructorInitializer");
			return base.VisitConstructorInitializer(constructorInitializer, data);
		}
 private bool IsMatch(ConstructorInitializer left, ConstructorInitializer right)
 {
     return true;
 }
Ejemplo n.º 14
0
 public override object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 {
     foreach (Expression argumet in constructorInitializer.Arguments)
         argumet.Parent = constructorInitializer;
     return base.VisitConstructorInitializer(constructorInitializer, data);
 }
Ejemplo n.º 15
0
		public virtual object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) {
			throw new global::System.NotImplementedException("ConstructorInitializer");
		}
Ejemplo n.º 16
0
 public virtual object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 {
     Debug.Assert((constructorInitializer != null));
     Debug.Assert((constructorInitializer.Arguments != null));
     foreach (Expression o in constructorInitializer.Arguments) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     return null;
 }
		public sealed override object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) {
			this.BeginVisit(constructorInitializer);
			object result = this.TrackedVisitConstructorInitializer(constructorInitializer, data);
			this.EndVisit(constructorInitializer);
			return result;
		}
Ejemplo n.º 18
0
		public ConstructorDeclaration(string name, Modifiers modifier, List<ParameterDeclarationExpression> parameters, ConstructorInitializer constructorInitializer, List<AttributeSection> attributes) {
			Name = name;
			Modifier = modifier;
			Parameters = parameters;
			ConstructorInitializer = constructorInitializer;
			Attributes = attributes;
			body = BlockStatement.Null;
		}
 public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 {
     Console.WriteLine("VisitConstructorInitializer");
     return null;
 }
Ejemplo n.º 20
0
	void ConstructorInitializer(
#line  1280 "cs.ATG" 
out ConstructorInitializer ci) {

#line  1281 "cs.ATG" 
		Expression expr; ci = new ConstructorInitializer(); 
		Expect(9);
		if (la.kind == 51) {
			lexer.NextToken();

#line  1285 "cs.ATG" 
			ci.ConstructorInitializerType = ConstructorInitializerType.Base; 
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  1286 "cs.ATG" 
			ci.ConstructorInitializerType = ConstructorInitializerType.This; 
		} else SynErr(183);
		Expect(20);
		if (StartOf(26)) {
			Argument(
#line  1289 "cs.ATG" 
out expr);

#line  1289 "cs.ATG" 
			if (expr != null) { ci.Arguments.Add(expr); } 
			while (la.kind == 14) {
				lexer.NextToken();
				Argument(
#line  1289 "cs.ATG" 
out expr);

#line  1289 "cs.ATG" 
				if (expr != null) { ci.Arguments.Add(expr); } 
			}
		}
		Expect(21);
	}