Download presentation
Presentation is loading. Please wait.
1
Tag at C++ Compiler Kei Hasegawa
2
scope : Symbol Table struct scope { }; scope* m_parent;
vector<scope*> m_children; map<string, vector<usr*> > m_usrs; // Variable etc map<string, tag*> m_tags; // Structure etc ... virtual ~scope(); };
3
tag : expressing structure etc
// C Compiler struct tag { // Scope where the structure is declared scope* m_scope; ... }; // C++ Compiler struct tag : scope { // scope::m_parent is correspond to m_scope of C Compiler ... };
4
Destroy symbol tables when finishing to compile a function definition
// C Compiler void destroy_temporary() { ... // Simple! vector<scope*>& children = scope::root.m_children; for (auto p : children) delete p; children.clear(); }
5
Destroy symbol tables when finishing to compile a function definition(2)
// C++ Compiler void destroy_temporary() { ... vector<scope*>& children = scope::root.m_children; for (IT p = begin(children) ; p != end(children) ; ) { switch ( (*p)->m_id) { case PARAM: case BLOCK: delete *p; p = children.erase(p); break; default: ++p; // Not delete structure or namespace }
6
scope::~scope() // C Compiler scope::~scope() { }
for (auto p : m_children) delete p; ... for (auto& p : m_tags) p.second->m_scope = 0; // Not understandable. See C Compiler Temporary Type Document. }
7
scope::~scope() (2) // C++ Compiler scope::~scope() {
for (auto p : m_children) { switch (p->m_id) { case PARAM: case BLOCK: delete p; break; default: p->m_parent = 0; // Break parent-child relation } // Nothing to be done for `m_tags’
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.