]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Other / Maintained / Tools / Pccts / h / ATokPtr.cpp
1 /* ATokPtr.C
2 *
3 * ANTLRToken MUST be defined before entry to this file.
4 *
5 * SOFTWARE RIGHTS
6 *
7 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
8 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
9 * company may do whatever they wish with source code distributed with
10 * PCCTS or the code generated by PCCTS, including the incorporation of
11 * PCCTS, or its output, into commerical software.
12 *
13 * We encourage users to develop software with PCCTS. However, we do ask
14 * that credit is given to us for developing PCCTS. By "credit",
15 * we mean that if you incorporate our source code into one of your
16 * programs (commercial product, research project, or otherwise) that you
17 * acknowledge this fact somewhere in the documentation, research report,
18 * etc... If you like PCCTS and have developed a nice tool with the
19 * output, please mention that you developed it using PCCTS. In
20 * addition, we ask that this header remain intact in our source code.
21 * As long as these guidelines are kept, we expect to continue enhancing
22 * this system and expect to make other tools available as they are
23 * completed.
24 *
25 * ANTLR 1.33
26 * Written by Russell Quong June 30, 1995
27 * Adapted by Terence Parr to ANTLR stuff
28 * Parr Research Corporation
29 * with Purdue University and AHPCRC, University of Minnesota
30 * 1989-1998
31 */
32
33 #include "pcctscfg.h"
34
35 PCCTS_NAMESPACE_STD
36
37 #include "ATokPtr.h"
38
39 void ANTLRTokenPtr::ref() const
40 {
41 if (ptr_ != NULL) {
42 ptr_->ref();
43 }
44 }
45
46 void ANTLRTokenPtr::deref()
47 {
48 if (ptr_ != NULL)
49 {
50 ptr_->deref();
51 if ( ptr_->nref()==0 )
52 {
53 delete ptr_;
54 ptr_ = NULL;
55 }
56 }
57 }
58
59 ANTLRTokenPtr::~ANTLRTokenPtr()
60 {
61 deref();
62 }
63
64 //
65 // 8-Apr-97 MR1 Make operator -> a const member function
66 // as weall as some other member functions
67 //
68 void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs) // MR1
69 {
70 lhs.ref(); // protect against "xp = xp"; ie same underlying object
71 deref();
72 ptr_ = lhs.ptr_;
73 }
74
75 void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)
76 {
77 if (addr != NULL) {
78 addr->ref();
79 }
80 deref();
81 ptr_ = addr;
82 }