From 7b0774752e8f163f4861bb338172fcdcd60cee36 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Thu, 29 Sep 2016 16:15:38 -0600 Subject: changes for recusing --- include/chillAST/chillAST_node.hh | 38 +++++++++++++++++++++++++++++++------- src/ast/node.cpp | 12 ------------ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/include/chillAST/chillAST_node.hh b/include/chillAST/chillAST_node.hh index b0e7622..a8fb50f 100644 --- a/include/chillAST/chillAST_node.hh +++ b/include/chillAST/chillAST_node.hh @@ -5,15 +5,41 @@ #include "chillAST_def.hh" #include +#include //! generic node of the actual chillAST, a multiway tree node. class chillAST_Node { protected: - void gatherTypedef(std::map> map, chillAST_TypedefTable* tdt); - void gatherSymbol(std::map> map, chillAST_SymbolTable* tdt); - void gatherRecord(std::map> map, chillAST_RecordTable *tdt); - void gatherOther(chillAST_SourceFile *s); - void fixReference(std::map> map); + /*! + * Add typedef to containing scope + * @param tdt the containing scope + */ + void gatherTypedef(chillAST_TypedefTable* tdt); + /*! + * Add symboldefinition to containing scope + * @param st the containing scope + */ + void gatherSymbol(chillAST_SymbolTable* st); + /*! + * Add struct definition to containing scope + * @param rt the containing scope + */ + void gatherRecord(chillAST_RecordTable *rt); + /*! + * Add function declaration & definition to the source file + * @param s + */ + void gatherFunctionDecl(std::vector *s); + /*! + * Add macro definition to the source file + * @param s + */ + void gatherMacroDecl(std::vector *s); + /*! + * Fix the pointer reference in a source file + * @param nameMap a mapping from string to the corresponding declarations, stack is used to mimic scoping + */ + void fixReference(std::map> nameMap); public: // TODO decide how to hide some data //! this Node's parent @@ -199,8 +225,6 @@ public: void setMetaComment(const char *c) { metacomment = strdup(c); }; - virtual void mergeChildInfo(chillAST_Node); - virtual void addChild(chillAST_Node *c); virtual void addChildren(const chillAST_NodeList &c); diff --git a/src/ast/node.cpp b/src/ast/node.cpp index 1b1995c..7af48f1 100644 --- a/src/ast/node.cpp +++ b/src/ast/node.cpp @@ -7,20 +7,8 @@ #include "printer/cfamily.h" #include -void chillAST_Node::fixChildInfo(std::stack &tdt, std::stack &st, - chillAST_SourceFile *s) { - -} - void chillAST_Node::fixChildInfo() {} -void chillAST_Node::mergeChildInfo(chillAST_Node) { - // TODO if (par) par->add to definition for vardecl/typedecl - // TODO if (par) par->getSourceFile()->addFunc(this); for FuncDecl - // TODO if (par) par->getSourceFile()->addMacro(this); For MacroDecl - // TODO if (parent) parent->addVariableToSymbolTable(this); // should percolate up until something has a symbol table -} - void chillAST_Node::addChild(chillAST_Node *c) { c->parent = this; // check to see if it's already there -- cgit v1.2.3-70-g09d2