Exemplo n.º 1
0
        public override void OnDestructor(Boo.Lang.Compiler.Ast.Destructor node)
        {
            CodeMemberMethod cmm = new CodeMemberMethod();

            cmm.Name = "Finalize";
            ConvertMethod(node, cmm);
        }
Exemplo n.º 2
0
        override public object Clone()
        {
            Destructor clone = (Destructor)FormatterServices.GetUninitializedObject(typeof(Destructor));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            clone._modifiers = _modifiers;
            clone._name      = _name;
            if (null != _attributes)
            {
                clone._attributes = _attributes.Clone() as AttributeCollection;
                clone._attributes.InitializeParent(clone);
            }
            if (null != _parameters)
            {
                clone._parameters = _parameters.Clone() as ParameterDeclarationCollection;
                clone._parameters.InitializeParent(clone);
            }
            if (null != _genericParameters)
            {
                clone._genericParameters = _genericParameters.Clone() as GenericParameterDeclarationCollection;
                clone._genericParameters.InitializeParent(clone);
            }
            if (null != _returnType)
            {
                clone._returnType = _returnType.Clone() as TypeReference;
                clone._returnType.InitializeParent(clone);
            }
            if (null != _returnTypeAttributes)
            {
                clone._returnTypeAttributes = _returnTypeAttributes.Clone() as AttributeCollection;
                clone._returnTypeAttributes.InitializeParent(clone);
            }
            if (null != _body)
            {
                clone._body = _body.Clone() as Block;
                clone._body.InitializeParent(clone);
            }
            if (null != _locals)
            {
                clone._locals = _locals.Clone() as LocalCollection;
                clone._locals.InitializeParent(clone);
            }
            clone._implementationFlags = _implementationFlags;
            if (null != _explicitInfo)
            {
                clone._explicitInfo = _explicitInfo.Clone() as ExplicitMemberInfo;
                clone._explicitInfo.InitializeParent(clone);
            }
            return(clone);
        }
 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);
 }
Exemplo n.º 4
0
        public override void LeaveDestructor(Destructor node)
        {
            if (node.Modifiers != TypeMemberModifiers.None)
            {
                Error(CompilerErrorFactory.InvalidDestructorModifier(node));
            }

            if (node.Parameters.Count != 0)
            {
                Error(CompilerErrorFactory.CantHaveDestructorParameters(node));
            }

            CannotReturnValue(node);
        }
Exemplo n.º 5
0
	protected void method(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  t = null;
		IToken  spliceBegin = null;
		IToken  c = null;
		IToken  d = null;
		IToken  cc = null;
		IToken  dd = null;
		
				Method m = null;
				TypeReference rt = null;
				TypeReference it = null;
				ExplicitMemberInfo emi = null;
				ParameterDeclarationCollection parameters = null;
				GenericParameterDeclarationCollection genericParameters = null;
				Block body = null;
				StatementCollection statements = null;
				Expression nameSplice = null;
				TypeMember typeMember = null;
				IToken id = null;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case DEF:
				{
					t = LT(1);
					match(DEF);
					{
						switch ( LA(1) )
						{
						case EVENT:
						case GET:
						case INTERNAL:
						case PUBLIC:
						case PROTECTED:
						case REF:
						case SET:
						case YIELD:
						case ID:
						case SPLICE_BEGIN:
						{
							{
								{
									{
										if ((LA(1)==ID) && (LA(2)==DOT))
										{
											emi=explicit_member_info();
										}
										else if ((tokenSet_33_.member(LA(1))) && (tokenSet_34_.member(LA(2)))) {
										}
										else
										{
											throw new NoViableAltException(LT(1), getFilename());
										}
										
									}
									{
										switch ( LA(1) )
										{
										case EVENT:
										case GET:
										case INTERNAL:
										case PUBLIC:
										case PROTECTED:
										case REF:
										case SET:
										case YIELD:
										case ID:
										{
											id=member();
											break;
										}
										case SPLICE_BEGIN:
										{
											spliceBegin = LT(1);
											match(SPLICE_BEGIN);
											nameSplice=atom();
											break;
										}
										default:
										{
											throw new NoViableAltException(LT(1), getFilename());
										}
										 }
									}
								}
								if (0==inputState.guessing)
								{
									
														IToken token = id ?? spliceBegin;
														if (emi != null) {
															m = new Method(emi.LexicalInfo);
														} else {
															m = new Method(ToLexicalInfo(token));
														}
														m.Name = token.getText();
														m.ExplicitInfo  = emi;
														
														if (nameSplice != null) {
															typeMember = new SpliceTypeMember(m, nameSplice);
														} else {
															typeMember = m;
														}
													
								}
							}
							break;
						}
						case CONSTRUCTOR:
						{
							c = LT(1);
							match(CONSTRUCTOR);
							if (0==inputState.guessing)
							{
								typeMember = m = new Constructor(ToLexicalInfo(c));
							}
							break;
						}
						case DESTRUCTOR:
						{
							d = LT(1);
							match(DESTRUCTOR);
							if (0==inputState.guessing)
							{
								typeMember = m = new Destructor(ToLexicalInfo(d));
							}
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					break;
				}
				case CONSTRUCTOR:
				{
					cc = LT(1);
					match(CONSTRUCTOR);
					if (0==inputState.guessing)
					{
						typeMember = m = new Constructor(ToLexicalInfo(cc));
					}
					break;
				}
				case DESTRUCTOR:
				{
					dd = LT(1);
					match(DESTRUCTOR);
					if (0==inputState.guessing)
					{
						typeMember = m = new Destructor(ToLexicalInfo(dd));
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						m.Modifiers = _modifiers;
						AddAttributes(m.Attributes);
						parameters = m.Parameters;
						genericParameters = m.GenericParameters;
						body = m.Body;
						statements = body.Statements;
					
			}
			{
				if ((LA(1)==LBRACK) && (LA(2)==OF||LA(2)==ID))
				{
					match(LBRACK);
					{
						switch ( LA(1) )
						{
						case OF:
						{
							match(OF);
							break;
						}
						case ID:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					generic_parameter_declaration_list(genericParameters);
					match(RBRACK);
				}
				else if ((tokenSet_35_.member(LA(1))) && (tokenSet_36_.member(LA(2)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				{
					match(LPAREN);
					parameter_declaration_list(parameters);
					match(RPAREN);
					break;
				}
				case AS:
				case LBRACK:
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			attributes();
			if (0==inputState.guessing)
			{
				AddAttributes(m.ReturnTypeAttributes);
			}
			{
				switch ( LA(1) )
				{
				case AS:
				{
					match(AS);
					rt=type_reference();
					if (0==inputState.guessing)
					{
						m.ReturnType = rt;
					}
					break;
				}
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			begin_block_with_doc(m, body);
			block(statements);
			end(body);
			if (0==inputState.guessing)
			{
				
						container.Add(typeMember);
						m.EndSourceLocation = body.EndSourceLocation;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "method");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemplo n.º 6
0
        //throws RecognitionException, TokenStreamException
        protected void method(
            TypeMemberCollection container
            )
        {
            IToken  t = null;
            IToken  c = null;
            IToken  d = null;

                Method m = null;
                TypeReference rt = null;
                TypeReference it = null;
                ExplicitMemberInfo emi = null;
                ParameterDeclarationCollection parameters = null;
                GenericParameterDeclarationCollection genericParameters = null;
                Block body = null;
                StatementCollection statements = null;
                IToken id = null;

            try {      // for error handling
            t = LT(1);
            match(DEF);
            {
                switch ( LA(1) )
                {
                case EVENT:
                case GET:
                case INTERNAL:
                case PUBLIC:
                case PROTECTED:
                case REF:
                case SET:
                case ID:
                {
                    {
                        if ((LA(1)==ID) && (LA(2)==DOT))
                        {
                            emi=explicit_member_info();
                        }
                        else if ((tokenSet_27_.member(LA(1))) && (LA(2)==LPAREN||LA(2)==LBRACK)) {
                        }
                        else
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }

                    }
                    id=member();
                    if (0==inputState.guessing)
                    {

                                    if (emi != null)
                                    {
                                        m = new Method(emi.LexicalInfo);
                                    }
                                    else
                                    {
                                        m = new Method(SourceLocationFactory.ToLexicalInfo(id));
                                    }
                                    m.Name = id.getText();
                                    m.ExplicitInfo  = emi;

                    }
                    break;
                }
                case CONSTRUCTOR:
                {
                    c = LT(1);
                    match(CONSTRUCTOR);
                    if (0==inputState.guessing)
                    {
                        m = new Constructor(SourceLocationFactory.ToLexicalInfo(c));
                    }
                    break;
                }
                case DESTRUCTOR:
                {
                    d = LT(1);
                    match(DESTRUCTOR);
                    if (0==inputState.guessing)
                    {
                        m = new Destructor(SourceLocationFactory.ToLexicalInfo(d));
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            if (0==inputState.guessing)
            {

                        m.Modifiers = _modifiers;
                        AddAttributes(m.Attributes);
                        parameters = m.Parameters;
                        genericParameters = m.GenericParameters;
                        body = m.Body;
                        statements = body.Statements;

            }
            {
                switch ( LA(1) )
                {
                case LBRACK:
                {
                    match(LBRACK);
                    {
                        switch ( LA(1) )
                        {
                        case OF:
                        {
                            match(OF);
                            break;
                        }
                        case ID:
                        {
                            break;
                        }
                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                         }
                    }
                    generic_parameter_declaration_list(genericParameters);
                    match(RBRACK);
                    break;
                }
                case LPAREN:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            match(LPAREN);
            parameter_declaration_list(parameters);
            match(RPAREN);
            attributes();
            if (0==inputState.guessing)
            {
                AddAttributes(m.ReturnTypeAttributes);
            }
            {
                switch ( LA(1) )
                {
                case AS:
                {
                    match(AS);
                    rt=type_reference();
                    if (0==inputState.guessing)
                    {
                        m.ReturnType = rt;
                    }
                    break;
                }
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            begin_block_with_doc(m, body);
            block(statements);
            end(body);
            if (0==inputState.guessing)
            {

                        container.Add(m);

            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_32_);
            }
            else
            {
                throw ex;
            }
            }
        }
        public override void OnDestructor(Destructor node)
        {
            Method finalizer = CodeBuilder.CreateMethod(
                "Finalize",
                TypeSystemServices.VoidType,
                TypeMemberModifiers.Protected | TypeMemberModifiers.Override);
            finalizer.LexicalInfo = node.LexicalInfo;

            MethodInvocationExpression mie = new MethodInvocationExpression(new SuperLiteralExpression());

            Block bodyNew = new Block();
            Block ensureBlock = new Block();
            ensureBlock.Add (mie);

            TryStatement tryStatement = new TryStatement();
            tryStatement.EnsureBlock = ensureBlock;
            tryStatement.ProtectedBlock = node.Body;

            bodyNew.Add(tryStatement);
            finalizer.Body = bodyNew;

            node.ParentNode.Replace(node, finalizer);
        }
Exemplo n.º 8
0
 public override void OnDestructor(Destructor node)
 {
     OnMethod(node);
 }
Exemplo n.º 9
0
 public override void OnDestructor(Destructor node)
 {
     CheckExtensionSemantics(node);
 }
		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;
		}
Exemplo n.º 11
0
		override public object Clone()
		{
		
			Destructor clone = new Destructor();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._modifiers = _modifiers;
			clone._name = _name;
			if (null != _attributes)
			{
				clone._attributes = _attributes.Clone() as AttributeCollection;
				clone._attributes.InitializeParent(clone);
			}
			if (null != _parameters)
			{
				clone._parameters = _parameters.Clone() as ParameterDeclarationCollection;
				clone._parameters.InitializeParent(clone);
			}
			if (null != _genericParameters)
			{
				clone._genericParameters = _genericParameters.Clone() as GenericParameterDeclarationCollection;
				clone._genericParameters.InitializeParent(clone);
			}
			if (null != _returnType)
			{
				clone._returnType = _returnType.Clone() as TypeReference;
				clone._returnType.InitializeParent(clone);
			}
			if (null != _returnTypeAttributes)
			{
				clone._returnTypeAttributes = _returnTypeAttributes.Clone() as AttributeCollection;
				clone._returnTypeAttributes.InitializeParent(clone);
			}
			if (null != _body)
			{
				clone._body = _body.Clone() as Block;
				clone._body.InitializeParent(clone);
			}
			if (null != _locals)
			{
				clone._locals = _locals.Clone() as LocalCollection;
				clone._locals.InitializeParent(clone);
			}
			clone._implementationFlags = _implementationFlags;
			if (null != _explicitInfo)
			{
				clone._explicitInfo = _explicitInfo.Clone() as ExplicitMemberInfo;
				clone._explicitInfo.InitializeParent(clone);
			}
			return clone;


		}
Exemplo n.º 12
0
 public override void OnDestructor(Destructor c)
 {
     OnMethod(c);
 }