ptree.cc
来自「这个程序是关于OpenC++的反射植入机制的编译器」· CC 代码 · 共 553 行 · 第 1/2 页
CC
553 行
//@beginlicenses@//@license{chiba_tokyo}{}@//@license{chiba_tsukuba}{}@//@license{chiba_tokyo}{}@//// Permission to use, copy, distribute and modify this software and its // documentation for any purpose is hereby granted without fee, provided that// the above copyright notice appears in all copies and that both that copyright// notice and this permission notice appear in supporting documentation.// // 1997-2001 Shigeru Chiba, Tokyo Institute of Technology. make(s) no representations about the suitability of this// software for any purpose. It is provided "as is" without express or implied// warranty.// // Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.//// -----------------------------------------------------------------//// Permission to use, copy, distribute and modify this software and its // documentation for any purpose is hereby granted without fee, provided that// the above copyright notice appears in all copies and that both that copyright// notice and this permission notice appear in supporting documentation.// // 1997-2001 Shigeru Chiba, University of Tsukuba. make(s) no representations about the suitability of this// software for any purpose. It is provided "as is" without express or implied// warranty.// // Copyright (C) 1997-2001 Shigeru Chiba, University of Tsukuba.//// -----------------------------------------------------------------//// Permission to use, copy, distribute and modify this software and its // documentation for any purpose is hereby granted without fee, provided that// the above copyright notice appears in all copies and that both that copyright// notice and this permission notice appear in supporting documentation.// // 1997-2001 Shigeru Chiba, Tokyo Institute of Technology. make(s) no representations about the suitability of this// software for any purpose. It is provided "as is" without express or implied// warranty.// // Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.////@endlicenses@#include <iostream>#include <cstdarg>#include <stdio.h>#include <string.h>#include <string>#include <strstream>#include <sys/time.h>#include <opencxx/parser/ErrorLog.h>#include <opencxx/parser/MopMsg.h>#include <opencxx/parser/TheErrorLog.h>#include <opencxx/parser/AbstractTranslatingWalker.h>#include <opencxx/parser/AbstractTypingWalker.h>#include <opencxx/parser/NonLeaf.h> // :TODO: cyclic dependency!!! get rid of it!#include <opencxx/parser/Ptree.h>#include <opencxx/parser/token-names.h>#include <opencxx/parser/ErrorLog.h>#include <opencxx/parser/Lex.h>#include <opencxx/parser/MopMsg.h>#include <opencxx/parser/TheErrorLog.h>#include <opencxx/parser/GC.h>#include <opencxx/parser/ptreeAll.h>#include <opencxx/parser/auxil.h>namespace Opencxx{using std::ostream;void Ptree::Display2(std::ostream& s){ Deprecated("Ptree::Display2(ostream& os)", "p->Display(os)"); Display(s);}void Ptree::Display(std::ostream& s){ if(this == 0) s << "0\n"; else{ Print(s, 0, 0); s << '\n'; }}void Ptree::Display(){ Display(std::cerr);}int Ptree::Write(ostream& s){ if(this == 0) return 0; else return Write(s, 0);}void Ptree::PrintIndent(std::ostream& out, int indent){ out << '\n'; for(int i = 0; i < indent; ++i) out << " ";}char* Ptree::ToString(){ if(this == 0) { return 0; // :TODO: why? shouldn't we assert(this) ??? } else{ std::strstream buf; PrintOn(buf); buf << std::ends; const std::string& s = buf.str(); char* result = new (GC) char[s.length() + 1]; std::strcpy(result, s.c_str()); buf.freeze(false); return result; }}bool Ptree::Eq(char c){ Deprecated("Ptree:Eq(char c)", "PtreeUtil::Eq(ptree,c)"); return PtreeUtil::Eq(this, c);}bool Ptree::Eq(const char* str){ Deprecated("Ptree::Eq(const char*)", "PtreeUtil:..."); return PtreeUtil::Eq(this, str);}bool Ptree::Eq(const char* str, int len){ Deprecated("Ptree::Eq(const char* str, int len)", "PtreeUtil::..."); return PtreeUtil::Eq(this, str, len);}Ptree* Ptree::Ca_ar(){ Deprecated("Ptree::Ca_ar()", "PtreeUtil::..."); return PtreeUtil::Ca_ar(this);}char* Ptree::LeftMost(){ Deprecated("Ptree::LeftMost()", "PtreeUtil::LeftMost(ptree)"); return PtreeUtil::LeftMost(this);}char* Ptree::RightMost(){ Deprecated("Ptree::RightMost()", "PtreeUtil::RightMost(ptree)"); return PtreeUtil::RightMost(this);}int Ptree::What(){ return BadToken;}bool Ptree::IsA(int kind){ if(this == 0) return false; else return bool(What() == kind);}bool Ptree::IsA(int kind1, int kind2){ Deprecated("Ptree::IsA(int k1, int k2)", "p->IsA(k1) || p->IsA(k2)"); if(this == 0) return false; else{ int k = What(); return bool(k == kind1 || k == kind2); }}bool Ptree::IsA(int kind1, int kind2, int kind3){ Deprecated("Ptree::IsA(int k1, int k2)", "p->IsA(k1) || p->IsA(k2) || p->IsA(k2)"); if(this == 0) return false; else{ int k = What(); return bool(k == kind1 || k == kind2 || k == kind3); }}Ptree* Ptree::Translate(AbstractTranslatingWalker* w){ return w->TranslatePtree(this);}void Ptree::Typeof(AbstractTypingWalker* w, TypeInfo& t){ w->TypeofPtree(this, t);}char* Ptree::GetEncodedType(){ return 0;}char* Ptree::GetEncodedName(){ return 0;}// static membersbool Ptree::Eq(Ptree* p, char c){ Deprecated("Ptree::Eq(Ptree* p, char c)", "PtreeUtil::Eq(Ptree* p, char c)"); return PtreeUtil::Eq(p, c);}bool Ptree::Eq(Ptree* p, const char* str){ Deprecated("Ptree::Eq(Ptree* p, const char* str)", "PtreeUtil::Eq(Ptree* p, char* str)"); return PtreeUtil::Eq(p, str);}bool Ptree::Eq(Ptree* p, const char* str, int len){ Deprecated("Ptree::Eq(Ptree* p, const char* str, int len)", "PtreeUtil::Eq(Ptree* p, char* str, int len)"); return PtreeUtil::Eq(p, str, len);}bool Ptree::Eq(Ptree* p, Ptree* q){ Deprecated("Ptree::Eq(Ptree* p, Ptree* q)", "PtreeUtil::Eq(Ptree* p, Ptree* q)"); return PtreeUtil::Eq(p, q);}bool Ptree::Equiv(Ptree* p, Ptree* q){ Deprecated("Ptree::Equiv(Ptree* p, Ptree* q)", "PtreeUtil::Equiv(Ptree* p, Ptree* q)"); return PtreeUtil::Equiv(p, q);}bool Ptree::Equal(Ptree* p, Ptree* q){ Deprecated("Ptree::Equal(Ptree* p, Ptree* q)", "PtreeUtil::Equal(Ptree* p, Ptree* q)"); return PtreeUtil::Equal(p, q);}Ptree* Ptree::Last(Ptree* p){ Deprecated("Ptree::Last(Ptree* p)", "PtreeUtil::Last(Ptree* p)"); return PtreeUtil::Last(p);}Ptree* Ptree::First(Ptree* p){ Deprecated("Ptree::First(Ptree* p)", "PtreeUtil::First(Ptree* p)"); return PtreeUtil::First(p);}Ptree* Ptree::Rest(Ptree* p){ Deprecated("Ptree::Rest(Ptree* p)", "PtreeUtil::Rest(Ptree* p)"); return PtreeUtil::Rest(p);}Ptree* Ptree::Second(Ptree* p)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?