X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fdebug.cpp;h=d49b9a5f142e8a09b29bcc304e7c29056b87f412;hb=4c805f55d89919d6971d600102ab4d6d65d56dc3;hp=5397372e611bd7108c3e3da0fc254e4bc9a575b4;hpb=9ec831710f64a62ad5f2e896a55ae82a3519f29e;p=libs%2Fgl.git diff --git a/source/glsl/debug.cpp b/source/glsl/debug.cpp index 5397372e..d49b9a5f 100644 --- a/source/glsl/debug.cpp +++ b/source/glsl/debug.cpp @@ -14,7 +14,7 @@ const std::string &DumpTree::apply(Stage &stage) tree.push_back(BRANCH); append(format("Version: %d.%02d", stage.required_features.glsl_version.major, stage.required_features.glsl_version.minor)); - for(std::map::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i) + for(std::map::const_iterator i=stage.types.begin(); i!=stage.types.end(); ++i) append(format("Type: %%%d %s", get_label(*i->second), i->first)); set seen_interfaces; @@ -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,7 +172,7 @@ 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)); @@ -235,6 +236,45 @@ void DumpTree::visit(InterfaceLayout &layout) annotated_branch(format("Layout: %s", layout.interface), layout.layout); } +void DumpTree::visit(BasicTypeDeclaration &type) +{ + append(format("%%%d typedef %s", get_label(type), type.name)); + begin_sub(); + if(type.kind!=BasicTypeDeclaration::VECTOR && type.kind!=BasicTypeDeclaration::MATRIX) + last_branch(); + if(type.base_type) + append(format("%s: %%%d %s", (type.kind==BasicTypeDeclaration::ALIAS ? "Alias of" : "Base"), get_label(*type.base_type), type.base_type->name)); + + last_branch(); + if(type.kind==BasicTypeDeclaration::VECTOR) + append(format("Vector: %d", type.size)); + else if(type.kind==BasicTypeDeclaration::MATRIX) + append(format("Matrix: %dx%d", type.size&0xFFFF, type.size>>16)); + end_sub(); +} + +void DumpTree::visit(ImageTypeDeclaration &type) +{ + append(format("%%%d typedef %s", get_label(type), type.name)); + begin_sub(); + + if(!type.shadow && !type.base_type) + last_branch(); + static const char *dims[] = { "1D", "2D", "3D", "Cube" }; + append(format("Dimensions: %s%s", dims[type.dimensions-1], (type.array ? " array" : ""))); + + if(!type.shadow) + last_branch(); + if(type.base_type) + append(format("Element type: %%%d %s", get_label(*type.base_type), type.base_type->name)); + + last_branch(); + if(type.shadow) + append("Shadow"); + + end_sub(); +} + void DumpTree::visit(StructDeclaration &strct) { annotated_branch(format("%%%d struct %s", get_label(strct), strct.name), strct.members); @@ -261,6 +301,11 @@ void DumpTree::visit(VariableDeclaration &var) append(decl); begin_sub(); + if(!var.layout && !var.array && !var.init_expression) + last_branch(); + if(var.type_declaration) + append(format("Type: %%%d %s", get_label(*var.type_declaration), var.type_declaration->name)); + if(!var.array && !var.init_expression) last_branch(); if(var.layout) @@ -311,10 +356,10 @@ void DumpTree::visit(FunctionDeclaration &func) for(NodeArray::const_iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i) (*i)->visit(*this); last_branch(); - if(func.definition!=&func) - append(format("Definition: %%%d", get_label(*func.definition))); - else + if(func.definition==&func) func.body.visit(*this); + else if(func.definition) + append(format("Definition: %%%d", get_label(*func.definition))); end_sub(); }