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