Created a Poset template class. It can store the relationships of a partially ordered set, then generate a topological ordering. It will be used to order the type_def declarations in the CGenerator, as they depend on each other in a poset fashion.
This commit is contained in:
@@ -480,7 +480,7 @@ NodeTree<ASTData>* ASTTransformation::scopeLookup(NodeTree<ASTData>* scope, std:
|
||||
// the last node is actually a body node, as it may not have been generated yet if we're in the body
|
||||
//and this function is recursive or if this is a non-instantiated template function
|
||||
if (types.size() != ((children.size() > 0 && children[children.size()-1]->getDataRef()->type == code_block) ? children.size()-1 : children.size())) {
|
||||
std::cout << "Type sizes do not match between two " << lookup << "(" << types.size() << "," << ((children.size() > 0) ? children.size()-1 : 0) << "), types are: ";
|
||||
std::cout << "Type sizes do not match between two " << lookup << "(" << types.size() << "," << ((children.size() > 0 && children[children.size()-1]->getDataRef()->type == code_block) ? children.size()-1 : children.size()) << "), types are: ";
|
||||
for (auto j : types)
|
||||
std::cout << j.toString() << " ";
|
||||
std::cout << std::endl;
|
||||
|
||||
@@ -43,6 +43,8 @@ std::string CGenerator::generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enc
|
||||
switch (data.type) {
|
||||
case translation_unit:
|
||||
//Do here because we may need the typedefs before the declarations of variables
|
||||
//Note that we need to be careful of the order, though, as some declarations depend on others.
|
||||
//What is this then? It's a poset! Wooo posets!
|
||||
for (int i = 0; i < children.size(); i++)
|
||||
if (children[i]->getDataRef()->type == type_def)
|
||||
output += generate(children[i], enclosingObject) + "\n";
|
||||
|
||||
Reference in New Issue
Block a user