Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / QIL / QilScopedVisitor.cs / 1 / QilScopedVisitor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; namespace System.Xml.Xsl.Qil { ////// Adds iterator and function scoping to the QilVisitor implementation. /// internal class QilScopedVisitor : QilVisitor { //----------------------------------------------- // QilScopedVisitor methods //----------------------------------------------- ////// Called when a variable, parameter, or function enters scope. /// protected virtual void BeginScope(QilNode node) { } ////// Called when a variable, parameter, or function exits scope. /// protected virtual void EndScope(QilNode node) { } ////// Called at the beginning of Visit(). /// protected virtual void BeforeVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Put all global functions, variables, and parameters in scope qil = (QilExpression) node; foreach (QilNode param in qil.GlobalParameterList) BeginScope(param); foreach (QilNode var in qil.GlobalVariableList) BeginScope(var); foreach (QilNode func in qil.FunctionList) BeginScope(func); break; case QilNodeType.Function: // Put all formal arguments in scope foreach (QilNode arg in ((QilFunction) node).Arguments) BeginScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Put loop iterator in scope BeginScope(((QilLoop) node).Variable); break; } } ////// Called at the end of Visit(). /// protected virtual void AfterVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Remove all global functions, variables, and parameters from scope qil = (QilExpression) node; foreach (QilNode func in qil.FunctionList) EndScope(func); foreach (QilNode var in qil.GlobalVariableList) EndScope(var); foreach (QilNode param in qil.GlobalParameterList) EndScope(param); break; case QilNodeType.Function: // Remove all formal arguments from scope foreach (QilNode arg in ((QilFunction) node).Arguments) EndScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Remove loop iterator in scope EndScope(((QilLoop) node).Variable); break; } } //----------------------------------------------- // QilVisitor overrides //----------------------------------------------- ////// Call BeforeVisit() and AfterVisit(). /// protected override QilNode Visit(QilNode n) { QilNode ret; BeforeVisit(n); ret = base.Visit(n); AfterVisit(n); return ret; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; using System.Collections.Generic; namespace System.Xml.Xsl.Qil { ////// Adds iterator and function scoping to the QilVisitor implementation. /// internal class QilScopedVisitor : QilVisitor { //----------------------------------------------- // QilScopedVisitor methods //----------------------------------------------- ////// Called when a variable, parameter, or function enters scope. /// protected virtual void BeginScope(QilNode node) { } ////// Called when a variable, parameter, or function exits scope. /// protected virtual void EndScope(QilNode node) { } ////// Called at the beginning of Visit(). /// protected virtual void BeforeVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Put all global functions, variables, and parameters in scope qil = (QilExpression) node; foreach (QilNode param in qil.GlobalParameterList) BeginScope(param); foreach (QilNode var in qil.GlobalVariableList) BeginScope(var); foreach (QilNode func in qil.FunctionList) BeginScope(func); break; case QilNodeType.Function: // Put all formal arguments in scope foreach (QilNode arg in ((QilFunction) node).Arguments) BeginScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Put loop iterator in scope BeginScope(((QilLoop) node).Variable); break; } } ////// Called at the end of Visit(). /// protected virtual void AfterVisit(QilNode node) { QilExpression qil; switch (node.NodeType) { case QilNodeType.QilExpression: // Remove all global functions, variables, and parameters from scope qil = (QilExpression) node; foreach (QilNode func in qil.FunctionList) EndScope(func); foreach (QilNode var in qil.GlobalVariableList) EndScope(var); foreach (QilNode param in qil.GlobalParameterList) EndScope(param); break; case QilNodeType.Function: // Remove all formal arguments from scope foreach (QilNode arg in ((QilFunction) node).Arguments) EndScope(arg); break; case QilNodeType.Loop: case QilNodeType.Filter: case QilNodeType.Sort: // Remove loop iterator in scope EndScope(((QilLoop) node).Variable); break; } } //----------------------------------------------- // QilVisitor overrides //----------------------------------------------- ////// Call BeforeVisit() and AfterVisit(). /// protected override QilNode Visit(QilNode n) { QilNode ret; BeforeVisit(n); ret = base.Visit(n); AfterVisit(n); return ret; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ItemContainerProviderWrapper.cs
- DataViewManagerListItemTypeDescriptor.cs
- MissingFieldException.cs
- RelationshipConverter.cs
- SoapMessage.cs
- Enumerable.cs
- ColorAnimationUsingKeyFrames.cs
- SignedInfo.cs
- XmlWriterTraceListener.cs
- TreeNodeCollection.cs
- CollectionExtensions.cs
- ObjectDataSourceEventArgs.cs
- ReaderWriterLockWrapper.cs
- InvalidContentTypeException.cs
- DataObjectEventArgs.cs
- SymDocumentType.cs
- HttpException.cs
- DataGridViewCellMouseEventArgs.cs
- ProviderMetadata.cs
- DateTimeOffsetConverter.cs
- CompositeDispatchFormatter.cs
- LazyInitializer.cs
- FlowPanelDesigner.cs
- JoinCqlBlock.cs
- QueryCacheManager.cs
- RoutedPropertyChangedEventArgs.cs
- DecoderFallbackWithFailureFlag.cs
- MouseCaptureWithinProperty.cs
- CardSpaceShim.cs
- UnsafeNativeMethods.cs
- IndependentAnimationStorage.cs
- WebBrowserHelper.cs
- Pair.cs
- ContainsSearchOperator.cs
- DoubleAnimation.cs
- PersistenceTypeAttribute.cs
- SemanticResolver.cs
- PropertyTabChangedEvent.cs
- CollectionConverter.cs
- StylusPointProperty.cs
- LogEntrySerializer.cs
- Point4D.cs
- WebBrowserUriTypeConverter.cs
- ObjectListField.cs
- TimeSpan.cs
- ADMembershipProvider.cs
- ScriptingRoleServiceSection.cs
- TextStore.cs
- M3DUtil.cs
- NodeFunctions.cs
- RequestQueue.cs
- HashMembershipCondition.cs
- DataGridViewButtonColumn.cs
- XmlToDatasetMap.cs
- AnimationClockResource.cs
- Canvas.cs
- ResourceWriter.cs
- MdiWindowListStrip.cs
- XmlQueryType.cs
- DataTrigger.cs
- KnownColorTable.cs
- RuntimeEnvironment.cs
- FileSystemInfo.cs
- Model3DCollection.cs
- PrinterResolution.cs
- WeakRefEnumerator.cs
- SHA256Managed.cs
- SmtpLoginAuthenticationModule.cs
- SystemBrushes.cs
- AccessorTable.cs
- DropSource.cs
- DetectEofStream.cs
- ListSurrogate.cs
- _HelperAsyncResults.cs
- BamlTreeMap.cs
- MimeTypeAttribute.cs
- ProcessStartInfo.cs
- TreeNodeCollection.cs
- Rules.cs
- RIPEMD160.cs
- BinarySerializer.cs
- UpdateCommandGenerator.cs
- XmlSchemaException.cs
- CollectionViewGroup.cs
- ObjectIDGenerator.cs
- wgx_commands.cs
- IndentedWriter.cs
- GridViewItemAutomationPeer.cs
- VisualBrush.cs
- CodeGeneratorOptions.cs
- WS2007FederationHttpBindingCollectionElement.cs
- ServicePoint.cs
- Transform3D.cs
- BatchParser.cs
- TraceListener.cs
- ZipIOLocalFileHeader.cs
- ClientRolePrincipal.cs
- CodeMemberEvent.cs
- SecurityTokenRequirement.cs
- InstanceNotReadyException.cs