KDevelop API Documentation

ASTRefCount.cpp

Go to the documentation of this file.
00001 /* ANTLR Translator Generator
00002  * Project led by Terence Parr at http://www.jGuru.com
00003  * Software rights: http://www.antlr.org/RIGHTS.html
00004  *
00005  * $Id: ASTRefCount.cpp,v 1.2 2003/05/02 00:36:20 okellogg Exp $
00006  */
00007 #include "antlr/ASTRefCount.hpp"
00008 #include "antlr/AST.hpp"
00009 
00010 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00011 namespace antlr {
00012 #endif
00013 
00014 ASTRef::ASTRef(AST* p)
00015 : ptr(p), count(1)
00016 {
00017     if (p && !p->ref)
00018         p->ref = this;
00019 }
00020 
00021 ASTRef::~ASTRef()
00022 {
00023     delete ptr;
00024 }
00025 
00026 ASTRef* ASTRef::getRef(const AST* p)
00027 {
00028     if (p) {
00029         AST* pp = const_cast<AST*>(p);
00030         if (pp->ref)
00031             return pp->ref->increment();
00032         else
00033             return new ASTRef(pp);
00034     } else
00035         return 0;
00036 }
00037 
00038 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00039 }
00040 #endif
00041 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:34 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003