]> git.proxmox.com Git - mirror_edk2.git/blobdiff - 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
diff --git a/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp b/EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/h/ATokPtr.cpp
new file mode 100644 (file)
index 0000000..88df14b
--- /dev/null
@@ -0,0 +1,82 @@
+/* ATokPtr.C\r
+ *\r
+ * ANTLRToken MUST be defined before entry to this file.\r
+ *\r
+ * SOFTWARE RIGHTS\r
+ *\r
+ * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
+ * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
+ * company may do whatever they wish with source code distributed with\r
+ * PCCTS or the code generated by PCCTS, including the incorporation of\r
+ * PCCTS, or its output, into commerical software.\r
+ *\r
+ * We encourage users to develop software with PCCTS.  However, we do ask\r
+ * that credit is given to us for developing PCCTS.  By "credit",\r
+ * we mean that if you incorporate our source code into one of your\r
+ * programs (commercial product, research project, or otherwise) that you\r
+ * acknowledge this fact somewhere in the documentation, research report,\r
+ * etc...  If you like PCCTS and have developed a nice tool with the\r
+ * output, please mention that you developed it using PCCTS.  In\r
+ * addition, we ask that this header remain intact in our source code.\r
+ * As long as these guidelines are kept, we expect to continue enhancing\r
+ * this system and expect to make other tools available as they are\r
+ * completed.\r
+ *\r
+ * ANTLR 1.33\r
+ * Written by Russell Quong June 30, 1995\r
+ * Adapted by Terence Parr to ANTLR stuff\r
+ * Parr Research Corporation\r
+ * with Purdue University and AHPCRC, University of Minnesota\r
+ * 1989-1998\r
+ */\r
+\r
+#include "pcctscfg.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include "ATokPtr.h"\r
+\r
+void ANTLRTokenPtr::ref() const\r
+{\r
+    if (ptr_ != NULL) {\r
+               ptr_->ref();\r
+       }\r
+}\r
+\r
+void ANTLRTokenPtr::deref()\r
+{\r
+    if (ptr_ != NULL)\r
+    {\r
+               ptr_->deref();\r
+               if ( ptr_->nref()==0 )\r
+               {\r
+                   delete ptr_;\r
+                       ptr_ = NULL;\r
+               }\r
+    }\r
+}\r
+\r
+ANTLRTokenPtr::~ANTLRTokenPtr()\r
+{\r
+    deref();\r
+}\r
+\r
+//\r
+//  8-Apr-97   MR1     Make operator -> a const member function\r
+//                       as weall as some other member functions\r
+//\r
+void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs)     // MR1\r
+{\r
+    lhs.ref(); // protect against "xp = xp"; ie same underlying object\r
+    deref();\r
+    ptr_ = lhs.ptr_;\r
+}\r
+\r
+void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)\r
+{\r
+    if (addr != NULL) {\r
+       addr->ref();\r
+    }\r
+    deref();\r
+    ptr_ = addr;\r
+}\r