Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- COM2ExtendedTypeConverter.cs
- ExternalFile.cs
- PhysicalAddress.cs
- Tuple.cs
- ProfessionalColors.cs
- columnmapfactory.cs
- FilterQuery.cs
- SecurityRuntime.cs
- TypeReference.cs
- URLString.cs
- SizeFConverter.cs
- FaultPropagationQuery.cs
- ScriptHandlerFactory.cs
- ZeroOpNode.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- EmptyQuery.cs
- GregorianCalendar.cs
- SafeProcessHandle.cs
- BadImageFormatException.cs
- QuaternionAnimation.cs
- XmlnsCache.cs
- TemplateContent.cs
- DataReceivedEventArgs.cs
- Label.cs
- TextEffect.cs
- X500Name.cs
- MethodCallConverter.cs
- UnsafeNativeMethods.cs
- COM2Properties.cs
- IApplicationTrustManager.cs
- AuthenticationModeHelper.cs
- SamlAuthorityBinding.cs
- Task.cs
- EventMappingSettings.cs
- ActivityExecutorOperation.cs
- ScriptReferenceBase.cs
- CompilationPass2Task.cs
- LineSegment.cs
- CounterCreationDataConverter.cs
- SqlClientFactory.cs
- CustomCategoryAttribute.cs
- Decimal.cs
- NamedPipeAppDomainProtocolHandler.cs
- TableMethodGenerator.cs
- EdmTypeAttribute.cs
- FacetValueContainer.cs
- XmlUtil.cs
- KeyValueConfigurationCollection.cs
- ResourceSetExpression.cs
- ContentType.cs
- BamlRecordHelper.cs
- Int32Rect.cs
- WmpBitmapDecoder.cs
- _NTAuthentication.cs
- DataGridViewCheckBoxColumn.cs
- SequentialActivityDesigner.cs
- SqlRecordBuffer.cs
- Serializer.cs
- AdvancedBindingEditor.cs
- CellNormalizer.cs
- ObfuscationAttribute.cs
- SafeNativeMethodsMilCoreApi.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- SecurityRuntime.cs
- TemplateControlParser.cs
- KeyTime.cs
- RightsManagementEncryptedStream.cs
- VirtualizedCellInfoCollection.cs
- ToolStripItemTextRenderEventArgs.cs
- UriTemplateTable.cs
- FigureHelper.cs
- MetadataPropertyAttribute.cs
- ListenerElementsCollection.cs
- HorizontalAlignConverter.cs
- SiteMapNodeCollection.cs
- PassportAuthenticationModule.cs
- HtmlTableRowCollection.cs
- DisplayNameAttribute.cs
- X509CertificateCollection.cs
- MediaPlayer.cs
- ClassValidator.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- HtmlDocument.cs
- PropertyTabAttribute.cs
- StaticSiteMapProvider.cs
- XmlnsCache.cs
- ResourcesChangeInfo.cs
- dbenumerator.cs
- MimePart.cs
- ComplexPropertyEntry.cs
- VerificationAttribute.cs
- ConfigurationElement.cs
- WaitHandleCannotBeOpenedException.cs
- ValidationError.cs
- SafeViewOfFileHandle.cs
- XmlAttributeHolder.cs
- WorkflowDesignerColors.cs
- TaskFormBase.cs
- ConfigurationManagerHelperFactory.cs
- FontStyles.cs