Remove that ability from Formatter since it makes assumptions about the
state of the nodes, like certain references existing.
std::string DumpTree::apply(Stage &stage)
{
formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type));
std::string DumpTree::apply(Stage &stage)
{
formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type));
- tree.push_back(BRANCH);
append(format("Version: %d.%02d", stage.required_features.glsl_version.major, stage.required_features.glsl_version.minor));
for(std::map<string, TypeDeclaration *>::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i)
append(format("Version: %d.%02d", stage.required_features.glsl_version.major, stage.required_features.glsl_version.minor));
for(std::map<string, TypeDeclaration *>::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i)
void DumpTree::begin_sub()
{
void DumpTree::begin_sub()
{
- tree.back() = (tree.back()==BRANCH_LAST ? EMPTY : STRAIGHT);
+ if(!tree.empty())
+ tree.back() = (tree.back()==BRANCH_LAST ? EMPTY : STRAIGHT);
tree.push_back(BRANCH);
}
tree.push_back(BRANCH);
}
void DumpTree::end_sub()
{
tree.pop_back();
void DumpTree::end_sub()
{
tree.pop_back();
- if(tree.back()==STRAIGHT)
+ if(!tree.empty() && tree.back()==STRAIGHT)
public:
std::string apply(Stage &);
public:
std::string apply(Stage &);
+ std::string apply(Node &n) { n.visit(*this); return formatted; }
private:
void append(const std::string &);
private:
void append(const std::string &);
Formatter();
std::string apply(Stage &);
Formatter();
std::string apply(Stage &);
- std::string apply(Node &n) { n.visit(*this); return formatted; }
private:
void append(const std::string &);
private:
void append(const std::string &);