]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/debug.cpp
Clarify SL::Compiler::optimize return values by using an enum
[libs/gl.git] / source / glsl / debug.cpp
index c29a60ceab724c6b19069538d38aa3ad144b7d29..5397372e611bd7108c3e3da0fc254e4bc9a575b4 100644 (file)
@@ -27,6 +27,9 @@ const std::string &DumpTree::apply(Stage &stage)
                        append(text);
                }
 
+       for(std::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();
        stage.content.visit(*this);
        return formatted;
@@ -171,9 +174,7 @@ void DumpTree::visit(Assignment &assign)
        append(format("Assignment: %s%s", assign.oper, (assign.self_referencing ? " (self-referencing)" : "")));
        begin_sub();
        if(assign.target_declaration)
-       {
                append(format("Target: %%%d %s %s", get_label(*assign.target_declaration), assign.target_declaration->type, assign.target_declaration->name));
-       }
        assign.left->visit(*this);
        last_branch();
        assign.right->visit(*this);
@@ -253,7 +254,9 @@ void DumpTree::visit(VariableDeclaration &var)
        if(!var.precision.empty())
                decl += format("%s ", var.precision);
        decl += format("%s %s", var.type, var.name);
-       if(var.linked_declaration)
+       if(var.source==BUILTIN_SOURCE)
+               decl += " (builtin)";
+       else if(var.linked_declaration)
                decl += " (linked)";
        append(decl);
 
@@ -289,21 +292,29 @@ void DumpTree::visit(InterfaceBlock &block)
                head += format(" %s", block.instance_name);
        if(block.array)
                head += "[]";
-       if(block.linked_block)
+       if(block.source==BUILTIN_SOURCE)
+               head += " (builtin)";
+       else if(block.linked_block)
                head += " (linked)";
        annotated_branch(head, block.members);
 }
 
 void DumpTree::visit(FunctionDeclaration &func)
 {
-       append(format("%%%d %s %s()", get_label(func), func.return_type, func.name));
+       string text = format("%%%d %s %s", get_label(func), func.return_type, func.name);
+       if(func.source==BUILTIN_SOURCE)
+               text += " (builtin)";
+       else if(!func.definition)
+               text += " (undefined)";
+       append(text);
        begin_sub();
        for(NodeArray<VariableDeclaration>::const_iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
                (*i)->visit(*this);
-       if(func.definition)
-               append(format("Definition: %%%d", get_label(*func.definition)));
        last_branch();
-       func.body.visit(*this);
+       if(func.definition!=&func)
+               append(format("Definition: %%%d", get_label(*func.definition)));
+       else
+               func.body.visit(*this);
        end_sub();
 }