]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/debug.cpp
Use the new append utility function to build GLSL compile errors
[libs/gl.git] / source / glsl / debug.cpp
index b913f5b493a2b2ad550d5f83903abe74ab68affb..06bf1925cea7e4102015f999cd198d3b67f4615c 100644 (file)
@@ -156,12 +156,13 @@ void DumpTree::visit(MemberAccess &memacc)
 
 void DumpTree::visit(UnaryExpression &unary)
 {
-       annotated_branch(format("Unary: %s, %sfix", unary.oper, (unary.prefix ? "pre" : "suff")), *unary.expression);
+       string text = format("Unary: %s, %sfix", unary.oper->token, (unary.oper->type==Operator::PREFIX ? "pre" : "post"));
+       annotated_branch(text, *unary.expression);
 }
 
 void DumpTree::visit(BinaryExpression &binary)
 {
-       append(format("Binary: %s%s", binary.oper, binary.after));
+       append(format("Binary: %s", (binary.oper->token[0]=='[' ? "[]" : binary.oper->token)));
        begin_sub();
        binary.left->visit(*this);
        last_branch();
@@ -171,12 +172,10 @@ void DumpTree::visit(BinaryExpression &binary)
 
 void DumpTree::visit(Assignment &assign)
 {
-       append(format("Assignment: %s%s", assign.oper, (assign.self_referencing ? " (self-referencing)" : "")));
+       append(format("Assignment: %s%s", assign.oper->token, (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);
@@ -256,7 +255,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);
 
@@ -292,21 +293,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)
+               func.body.visit(*this);
+       else if(func.definition)
+               append(format("Definition: %%%d", get_label(*func.definition)));
        end_sub();
 }