public void ApplyToPipeline(MidPipelineDecl p) { _attributesToKeep.Clear(); _mapOldToNew.Clear(); _mapOldToWrapper.Clear(); _attributeWrappersToKeep.Clear(); // Find all the attributes worth keeping... CollectPipelineInfo(p); // Now go ahead and blow away all the old attributes, // replacing them with shiny new ones!!! _transform = new MidTransform( (e) => CleanupExp((dynamic)e)); foreach (var e in p.Elements) { e.Clear(); } foreach (var a in _attributesToKeep) { if (a.Exp != null) { a.Exp = _transform.Transform(a.Exp); } var newAttr = MapOldToNew(a); } // We copy the attributes array, since otherwise // we end up mutating it by adding new attributes foreach (var e in p.Elements) { foreach (var a in e.Attributes.ToArray()) { _transform.ApplyToAttribute(a); } } foreach (var m in p.Methods) { if (m.Body != null) { m.Body = _transform.Transform(m.Body); } } foreach (var e in p.Elements) { var oldWrappers = e.AttributeWrappers.ToArray(); var newWrappers = (from w in oldWrappers where _attributeWrappersToKeep.Contains(w) select w).ToArray(); e.AttributeWrappers = newWrappers; } }
public void ApplyToPipeline( MidPipelineDecl p ) { _attributesToKeep.Clear(); _mapOldToNew.Clear(); _mapOldToWrapper.Clear(); _attributeWrappersToKeep.Clear(); // Find all the attributes worth keeping... CollectPipelineInfo( p ); // Now go ahead and blow away all the old attributes, // replacing them with shiny new ones!!! _transform = new MidTransform( ( e ) => CleanupExp( (dynamic) e ) ); foreach( var e in p.Elements ) e.Clear(); foreach( var a in _attributesToKeep ) { if( a.Exp != null ) a.Exp = _transform.Transform( a.Exp ); var newAttr = MapOldToNew( a ); } // We copy the attributes array, since otherwise // we end up mutating it by adding new attributes foreach( var e in p.Elements ) foreach( var a in e.Attributes.ToArray() ) _transform.ApplyToAttribute( a ); foreach( var m in p.Methods ) { if( m.Body != null ) m.Body = _transform.Transform( m.Body ); } foreach( var e in p.Elements ) { var oldWrappers = e.AttributeWrappers.ToArray(); var newWrappers = (from w in oldWrappers where _attributeWrappersToKeep.Contains(w) select w).ToArray(); e.AttributeWrappers = newWrappers; } }