}
}
+void AggregateDismantler::visit(FunctionDeclaration &func)
+{
+ func.body.visit(*this);
+}
+
template<typename T>
T ConstantFolder::evaluate_logical(char oper, T left, T right)
for(const auto &kvp: variables)
{
- if(kvp.second.output)
+ if(!kvp.second.referenced)
+ unused_nodes.insert(kvp.first);
+ else if(kvp.second.output)
{
/* The last visible assignments of output variables are used by the
next stage or the API. */
for(AssignmentInfo *a: kvp.second.assignments)
unused_nodes.erase(a->node);
}
-
- if(!kvp.second.output && !kvp.second.referenced)
- {
- // Don't remove variables from inside interface blocks.
- if(!kvp.second.interface_block)
- unused_nodes.insert(kvp.first);
- }
- else if(kvp.second.interface_block)
- // Interface blocks are kept if even one member is used.
- unused_nodes.erase(kvp.second.interface_block);
}
NodeRemover().apply(s, unused_nodes);
{
if(composite_reference)
r_reference.declaration = var.declaration;
- else
+ else if(var.declaration)
referenced(var.declaration, var);
}
{
if(composite_reference)
r_reference.declaration = iface.declaration;
- else
+ else if(iface.declaration)
referenced(iface.declaration, iface);
}
{
SetFlag clear_assignment(assignment_target, false);
SetFlag clear_composite(composite_reference, false);
+ SetForScope<Assignment::Target> clear_reference(r_reference, Assignment::Target());
binary.right->visit(*this);
}
return;
VariableInfo &var_info = variables[&var];
- var_info.interface_block = interface_block;
/* Mark variables as output if they're used by the next stage or the
graphics API. */
- if(interface_block)
- var_info.output = (interface_block->interface=="out" && (interface_block->linked_block || !interface_block->block_name.compare(0, 3, "gl_")));
- else
- var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || !var.name.compare(0, 3, "gl_")));
+ var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || !var.name.compare(0, 3, "gl_")));
+
+ // Linked outputs are automatically referenced.
+ if(var_info.output && var.linked_declaration)
+ var_info.referenced = true;
if(var.init_expression)
{