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