register method
Makes compiler the one forBackend answers for its backend, until
the result is cancelled.
Throws an ArgumentError when another compiler for another backend already writes the same MaterialCompiler.bundleSection: two backends reading one section would read each other's bytes.
Implementation
Registration register(MaterialCompiler compiler) {
for (final other in _compilers) {
if (other.backend != compiler.backend &&
other.bundleSection == compiler.bundleSection) {
throw ArgumentError.value(
compiler.bundleSection,
'compiler',
'is the section the ${other.backend} compiler writes; '
'${compiler.backend} needs one of its own',
);
}
}
_compilers.add(compiler);
return Registration(() => _compilers.remove(compiler));
}