Ejemplo n.º 1
0
		public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
		{
			if ((destructorDeclaration.Body.StartLocation < start) &&
			    (destructorDeclaration.Body.EndLocation > end)) {
				this.member = destructorDeclaration;
			}
			
			return base.VisitDestructorDeclaration(destructorDeclaration, data);
		}
Ejemplo n.º 2
0
        public override object VisitDestructorDeclaration(AST.DestructorDeclaration destructorDeclaration, object data)
        {
            DomRegion region     = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation);
            DomRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : RefParser.Location.Empty);

            DefaultClass c = GetCurrentClass();

            Destructor destructor = new Destructor(region, bodyRegion, c);

            ConvertAttributes(destructorDeclaration, destructor);
            c.Methods.Add(destructor);
            return(null);
        }
Ejemplo n.º 3
0
 public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
 {
     UnlockWith(destructorDeclaration);
     return base.VisitDestructorDeclaration(destructorDeclaration, data);
 }
 public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
 {
     if (this.CheckNode(destructorDeclaration)) {
         return null;
     }
     return base.VisitDestructorDeclaration(destructorDeclaration, data);
 }
Ejemplo n.º 5
0
	void ClassMemberDecl(
#line  1084 "cs.ATG" 
ModifierList m, List<AttributeSection> attributes) {

#line  1085 "cs.ATG" 
		BlockStatement stmt = null; 
		if (StartOf(20)) {
			StructMemberDecl(
#line  1087 "cs.ATG" 
m, attributes);
		} else if (la.kind == 27) {

#line  1088 "cs.ATG" 
			m.Check(Modifiers.Destructors); Location startPos = la.Location; 
			lexer.NextToken();
			Identifier();

#line  1089 "cs.ATG" 
			DestructorDeclaration d = new DestructorDeclaration(t.val, m.Modifier, attributes); 
			d.Modifier = m.Modifier;
			d.StartLocation = m.GetDeclarationLocation(startPos);
			
			Expect(20);
			Expect(21);

#line  1093 "cs.ATG" 
			d.EndLocation = t.EndLocation; 
			if (la.kind == 16) {
				Block(
#line  1093 "cs.ATG" 
out stmt);
			} else if (la.kind == 11) {
				lexer.NextToken();
			} else SynErr(160);

#line  1094 "cs.ATG" 
			d.Body = stmt;
			AddChild(d);
			
		} else SynErr(161);
	}
        public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
        {
            if (!IsClassType(ClassType.Interface) && (methodDeclaration.Modifier & Modifiers.Visibility) == 0)
                methodDeclaration.Modifier |= Modifiers.Public;

            if ("Finalize".Equals(methodDeclaration.Name, StringComparison.InvariantCultureIgnoreCase)
                && methodDeclaration.Parameters.Count == 0
                && methodDeclaration.Modifier == (Modifiers.Protected | Modifiers.Override)
                && methodDeclaration.Body.Children.Count == 1)
            {
                TryCatchStatement tcs = methodDeclaration.Body.Children[0] as TryCatchStatement;
                if (tcs != null
                    && tcs.StatementBlock is BlockStatement
                    && tcs.CatchClauses.Count == 0
                    && tcs.FinallyBlock is BlockStatement
                    && tcs.FinallyBlock.Children.Count == 1)
                {
                    ExpressionStatement se = tcs.FinallyBlock.Children[0] as ExpressionStatement;
                    if (se != null) {
                        InvocationExpression ie = se.Expression as InvocationExpression;
                        if (ie != null
                            && ie.Arguments.Count == 0
                            && ie.TargetObject is MemberReferenceExpression
                            && (ie.TargetObject as MemberReferenceExpression).TargetObject is BaseReferenceExpression
                            && "Finalize".Equals((ie.TargetObject as MemberReferenceExpression).MemberName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            DestructorDeclaration des = new DestructorDeclaration("Destructor", Modifiers.None, methodDeclaration.Attributes);
                            ReplaceCurrentNode(des);
                            des.Body = (BlockStatement)tcs.StatementBlock;
                            return base.VisitDestructorDeclaration(des, data);
                        }
                    }
                }
            }

            if ((methodDeclaration.Modifier & (Modifiers.Static | Modifiers.Extern)) == Modifiers.Static
                && methodDeclaration.Body.Children.Count == 0)
            {
                foreach (AttributeSection sec in methodDeclaration.Attributes) {
                    foreach (Attribute att in sec.Attributes) {
                        if ("DllImport".Equals(att.Name, StringComparison.InvariantCultureIgnoreCase)) {
                            methodDeclaration.Modifier |= Modifiers.Extern;
                            methodDeclaration.Body = null;
                        }
                    }
                }
            }

            if (methodDeclaration.TypeReference.Type != "System.Void" && methodDeclaration.Body.Children.Count > 0) {
                if (IsAssignmentTo(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1], methodDeclaration.Name))
                {
                    Expression returnValue = GetAssignmentFromStatement(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1]).Right;
                    methodDeclaration.Body.Children.RemoveAt(methodDeclaration.Body.Children.Count - 1);
                    methodDeclaration.Body.Return(returnValue);
                } else {
                    ReturnStatementForFunctionAssignment visitor = new ReturnStatementForFunctionAssignment(methodDeclaration.Name);
                    methodDeclaration.Body.AcceptVisitor(visitor, null);
                    if (visitor.replacementCount > 0) {
                        Expression init;
                        init = ExpressionBuilder.CreateDefaultValueForType(methodDeclaration.TypeReference);
                        methodDeclaration.Body.Children.Insert(0, new LocalVariableDeclaration(new VariableDeclaration(FunctionReturnValueName, init, methodDeclaration.TypeReference)));
                        methodDeclaration.Body.Children[0].Parent = methodDeclaration.Body;
                        methodDeclaration.Body.Return(new IdentifierExpression(FunctionReturnValueName));
                    }
                }
            }

            return base.VisitMethodDeclaration(methodDeclaration, data);
        }
 private bool IsMatch(DestructorDeclaration left, DestructorDeclaration right)
 {
     return left.Name == right.Name;
 }
		public virtual object TrackedVisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) {
			return base.VisitDestructorDeclaration(destructorDeclaration, data);
		}
Ejemplo n.º 9
0
 public virtual object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
 {
     Debug.Assert((destructorDeclaration != null));
     Debug.Assert((destructorDeclaration.Attributes != null));
     Debug.Assert((destructorDeclaration.Body != null));
     foreach (AttributeSection o in destructorDeclaration.Attributes) {
         Debug.Assert(o != null);
         o.AcceptVisitor(this, data);
     }
     return destructorDeclaration.Body.AcceptVisitor(this, data);
 }
 public object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
 {
     throw new NotImplementedException ();
 }
Ejemplo n.º 11
0
		public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
		{
			if (!IsClassType(ClassType.Interface) && (methodDeclaration.Modifier & Modifiers.Visibility) == 0)
				methodDeclaration.Modifier |= Modifiers.Public;
			
			if ("Finalize".Equals(methodDeclaration.Name, StringComparison.InvariantCultureIgnoreCase)
			    && methodDeclaration.Parameters.Count == 0
			    && methodDeclaration.Modifier == (Modifiers.Protected | Modifiers.Override)
			    && methodDeclaration.Body.Children.Count == 1)
			{
				TryCatchStatement tcs = methodDeclaration.Body.Children[0] as TryCatchStatement;
				if (tcs != null
				    && tcs.StatementBlock is BlockStatement
				    && tcs.CatchClauses.Count == 0
				    && tcs.FinallyBlock is BlockStatement
				    && tcs.FinallyBlock.Children.Count == 1)
				{
					ExpressionStatement se = tcs.FinallyBlock.Children[0] as ExpressionStatement;
					if (se != null) {
						InvocationExpression ie = se.Expression as InvocationExpression;
						if (ie != null
						    && ie.Arguments.Count == 0
						    && ie.TargetObject is MemberReferenceExpression
						    && (ie.TargetObject as MemberReferenceExpression).TargetObject is BaseReferenceExpression
						    && "Finalize".Equals((ie.TargetObject as MemberReferenceExpression).MemberName, StringComparison.InvariantCultureIgnoreCase))
						{
							DestructorDeclaration des = new DestructorDeclaration("Destructor", Modifiers.None, methodDeclaration.Attributes);
							ReplaceCurrentNode(des);
							des.Body = (BlockStatement)tcs.StatementBlock;
							return base.VisitDestructorDeclaration(des, data);
						}
					}
				}
			}
			
			if ((methodDeclaration.Modifier & (Modifiers.Static | Modifiers.Extern)) == Modifiers.Static
			    && methodDeclaration.Body.Children.Count == 0)
			{
				foreach (AttributeSection sec in methodDeclaration.Attributes) {
					foreach (Attribute att in sec.Attributes) {
						if ("DllImport".Equals(att.Name, StringComparison.InvariantCultureIgnoreCase)) {
							methodDeclaration.Modifier |= Modifiers.Extern;
							methodDeclaration.Body = null;
						}
					}
				}
			}
			
			if (methodDeclaration.TypeReference.Type != "System.Void" && methodDeclaration.Body.Children.Count > 0) {
				ReplaceAllFunctionAssignments(methodDeclaration.Body, methodDeclaration.Name, methodDeclaration.TypeReference);
			}
			
			return base.VisitMethodDeclaration(methodDeclaration, data);
		}
		public object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
		{
			B.Destructor m = new B.Destructor(GetLexicalInfo(destructorDeclaration));
			ConvertAttributes(destructorDeclaration.Attributes, m.Attributes);
			if (currentType != null) currentType.Members.Add(m);
			m.EndSourceLocation = GetLocation(destructorDeclaration.EndLocation);
			m.Body = ConvertMethodBlock(destructorDeclaration.Body);
			return m;
		}
 public virtual bool VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object d)
 {
     if ((destructorDeclaration == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((destructorDeclaration.Attributes == null)) {
         return SetFailure();
     }
     if ((destructorDeclaration.Body == null)) {
         return SetFailure();
     }
     if(destructorDeclaration.GetType() != d.GetType()) {return SetFailure();}
     var data = (DestructorDeclaration)d;
     if (!IsMatch(destructorDeclaration, data)) {
         return SetFailure();
     }
     if (destructorDeclaration.Attributes.Count == data.Attributes.Count) {
     for (int i=0; i<destructorDeclaration.Attributes.Count;i++) {
         AttributeSection o = destructorDeclaration.Attributes[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.Attributes[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     return destructorDeclaration.Body.AcceptVisitor(this, data.Body);
 }
		public override object TrackedVisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
		{
			AppendIndentedLine("def finalize()");
			IncreaseIndent();
			destructorDeclaration.Body.AcceptVisitor(this, data);
			DecreaseIndent();
			AppendIndentedLine("end");
			return null;
		}
Ejemplo n.º 15
0
		public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
		{
			if (!this.copyAllMembers)
				this.RemoveCurrentNode();
			return base.VisitDestructorDeclaration(destructorDeclaration, data);
		}
Ejemplo n.º 16
0
		public virtual object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) {
			throw new global::System.NotImplementedException("DestructorDeclaration");
		}
		public sealed override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) {
			this.BeginVisit(destructorDeclaration);
			object result = this.TrackedVisitDestructorDeclaration(destructorDeclaration, data);
			this.EndVisit(destructorDeclaration);
			return result;
		}
		public virtual object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) {
			Debug.Assert((destructorDeclaration != null));
			Debug.Assert((destructorDeclaration.Attributes != null));
			Debug.Assert((destructorDeclaration.Body != null));
			for (int i = 0; i < destructorDeclaration.Attributes.Count; i++) {
				AttributeSection o = destructorDeclaration.Attributes[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (AttributeSection)nodeStack.Pop();
				if (o == null)
					destructorDeclaration.Attributes.RemoveAt(i--);
				else
					destructorDeclaration.Attributes[i] = o;
			}
			nodeStack.Push(destructorDeclaration.Body);
			destructorDeclaration.Body.AcceptVisitor(this, data);
			destructorDeclaration.Body = ((BlockStatement)(nodeStack.Pop()));
			return null;
		}
 public override object TrackedVisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
 {
     this.AppendIndentedLine("def __del__(self):");
     this.IncreaseIndent();
     destructorDeclaration.Body.AcceptVisitor(this, data);
     this.DecreaseIndent();
     return null;
 }
Ejemplo n.º 20
0
 public virtual object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) {
     throw CreateException(destructorDeclaration);
 }