ASTRefCount.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
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
This file is part of the documentation for KDevelop Version 3.1.2.