inject_block(stage.content, module->shared.content);
DeclarationReorderer().apply(stage);
- BlockResolver().apply(stage);
+
+ // Initial resolving pass
+ BlockHierarchyResolver().apply(stage);
FunctionResolver().apply(stage);
VariableResolver().apply(stage);
+
+ /* All variables local to a stage have been resolved. Resolve non-local
+ variables through interfaces. */
InterfaceGenerator().apply(stage);
VariableResolver().apply(stage);
+
DeclarationReorderer().apply(stage);
FunctionResolver().apply(stage);
ConstantSpecializer().apply(stage, (mode==PROGRAM && specialized ? &spec_values : 0));
ConstantConditionEliminator().apply(stage);
FunctionInliner().apply(stage);
- BlockResolver().apply(stage);
+ BlockHierarchyResolver().apply(stage);
VariableResolver().apply(stage);
+ /* Removing variables or functions may cause things from the previous stage
+ to become unused. */
bool result = UnusedVariableRemover().apply(stage);
result |= UnusedFunctionRemover().apply(stage);