namespace GL {
namespace SL {
-const std::string &DumpTree::apply(Stage &stage)
+string DumpTree::apply(Stage &stage)
{
formatted = format("Stage: %s\n", Stage::get_stage_name(stage.type));
- tree.push_back(BRANCH);
+ begin_sub();
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)
+ for(map<string, TypeDeclaration *>::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i)
append(format("Type: %%%d %s", get_label(*i->second), i->first));
- for(std::map<string, InterfaceBlock *>::const_iterator i=stage.interface_blocks.begin(); i!=stage.interface_blocks.end(); ++i)
+ for(map<string, InterfaceBlock *>::const_iterator i=stage.interface_blocks.begin(); i!=stage.interface_blocks.end(); ++i)
append(format("Interface block: %%%d %s", get_label(*i->second), i->first));
- for(std::map<string, FunctionDeclaration *>::const_iterator i=stage.functions.begin(); i!=stage.functions.end(); ++i)
+ for(map<string, FunctionDeclaration *>::const_iterator i=stage.functions.begin(); i!=stage.functions.end(); ++i)
append(format("Function: %%%d %s", get_label(*i->second), i->first));
last_branch();
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);
}
void DumpTree::end_sub()
{
tree.pop_back();
- if(tree.back()==STRAIGHT)
+ if(!tree.empty() && tree.back()==STRAIGHT)
tree.back() = BRANCH;
}
append(block, format("Block %s", (block.use_braces ? "{}" : "(inline)")));
begin_sub();
- for(std::map<string, VariableDeclaration *>::const_iterator i=block.variables.begin(); i!=block.variables.end(); ++i)
+ for(map<string, VariableDeclaration *>::const_iterator i=block.variables.begin(); i!=block.variables.end(); ++i)
append(format("Variable: %%%d %s %s", get_label(*i->second), i->second->type, i->first));
for(NodeList<Statement>::const_iterator i=block.body.begin(); i!=block.body.end(); )
string text = "Member access:";
if(memacc.declaration)
text += format(" %%%d", get_label(*memacc.declaration));
- text += format(" .%s -> %s", memacc.member, format_type(memacc.type));
+ text += format(" .%s (%d) -> %s", memacc.member, memacc.index, format_type(memacc.type));
append(memacc, text);
append_subtree(*memacc.left);
}
void DumpTree::visit(InterfaceBlock &iface)
{
- string head;
- if(!iface.instance_name.empty())
- head += format("%%%d ", get_label(iface));
- head += format("%s %s", iface.interface, iface.block_name);
+ string head = format("%%%d %s %s", get_label(iface), iface.interface, iface.block_name);
if(!iface.instance_name.empty())
head += format(" %s", iface.instance_name);
if(iface.array)