summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/chillAST/chillAST_node.hh38
-rw-r--r--src/ast/node.cpp12
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 <stack>
+#include <map>
//! generic node of the actual chillAST, a multiway tree node.
class chillAST_Node {
protected:
- void gatherTypedef(std::map<std::string, std::stack<chillAST_TypedefDecl*>> map, chillAST_TypedefTable* tdt);
- void gatherSymbol(std::map<std::string, std::stack<chillAST_VarDecl*>> map, chillAST_SymbolTable* tdt);
- void gatherRecord(std::map<std::string, std::stack<chillAST_RecordDecl*>> map, chillAST_RecordTable *tdt);
- void gatherOther(chillAST_SourceFile *s);
- void fixReference(std::map<std::string, std::stack<chillAST_Node*>> 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<chillAST_FunctionDecl *> *s);
+ /*!
+ * Add macro definition to the source file
+ * @param s
+ */
+ void gatherMacroDecl(std::vector<chillAST_MacroDefinition *> *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<std::string, std::stack<chillAST_Node*>> 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 <stack>
-void chillAST_Node::fixChildInfo(std::stack<chillAST_TypedefTable *> &tdt, std::stack<chillAST_SymbolTable *> &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