本文整理汇总了C#中QilNode类的典型用法代码示例。如果您正苦于以下问题:C# QilNode类的具体用法?C# QilNode怎么用?C# QilNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QilNode类属于命名空间,在下文中一共展示了QilNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
/// <summary>
/// Override the Visit method in order to scan for redundant namespaces and compute side-effect bit.
/// </summary>
protected override QilNode Visit(QilNode nd) {
if (nd != null) {
if (this[XmlILOptimization.EliminateNamespaceDecl]) {
// Eliminate redundant namespaces in the tree. Don't perform the scan on an ElementCtor which
// has already been marked as having a redundant namespace.
switch (nd.NodeType) {
case QilNodeType.QilExpression:
// Perform namespace analysis on root expression (xmlns="" is in-scope for this expression)
this.nmspAnalyzer.Analyze(((QilExpression) nd).Root, true);
break;
case QilNodeType.ElementCtor:
if (!XmlILConstructInfo.Read(nd).IsNamespaceInScope)
this.nmspAnalyzer.Analyze(nd, false);
break;
case QilNodeType.DocumentCtor:
this.nmspAnalyzer.Analyze(nd, true);
break;
}
}
}
// Continue visitation
return base.Visit(nd);
}
示例2: QilExpression
//-----------------------------------------------
// Convenience methods
//-----------------------------------------------
public QilExpression QilExpression(QilNode root, QilFactory factory)
{
QilExpression n = new QilExpression(QilNodeType.QilExpression, root, factory);
n.XmlType = _typeCheck.CheckQilExpression(n);
TraceNode(n);
return n;
}
示例3: InvokeElementAvailable
public QilNode InvokeElementAvailable(QilNode n)
{
CheckQName(n);
return XsltInvokeEarlyBound(QName("element-available"),
XsltMethods.ElementAvailable, T.BooleanX, new QilNode[] { n }
);
}
示例4: ConvertReletive2Absolute
public QilNode ConvertReletive2Absolute(QilNode node, QilNode fixup) {
QilDepthChecker.Check(node);
Debug.Assert(node != null);
Debug.Assert(fixup != null);
this.fixup = fixup;
return this.Visit(node);
}
示例5: InvokeIsSameNodeSort
public QilNode InvokeIsSameNodeSort(QilNode n1, QilNode n2) {
CheckNodeNotRtf(n1);
CheckNodeNotRtf(n2);
return XsltInvokeEarlyBound(QName("is-same-node-sort"),
XsltMethods.IsSameNodeSort, T.BooleanX, new QilNode[] { n1, n2 }
);
}
示例6: VisitAssumeReference
//-----------------------------------------------
// QilVisitor methods (manually generated)
//-----------------------------------------------
/// <summary>
/// If a reference is passed to the Visit() method, it is assumed to be the definition.
/// This method assumes it is a reference to a definition.
/// For example, if a Let node is visited, is it the Let definition or a reference to the
/// the Let definition? Without context, it is ambiguous. This method allows a caller
/// to disambiguate.
/// </summary>
protected virtual QilNode VisitAssumeReference(QilNode expr)
{
if (expr is QilReference)
return VisitReference(expr);
return Visit(expr);
}
示例7: VisitChildren
/// <summary>
/// Visit all children of "parent", replacing each child with a copy of each child.
/// </summary>
protected override QilNode VisitChildren(QilNode parent)
{
// Visit children
for (int i = 0; i < parent.Count; i++)
{
QilNode child = parent[i];
// If child is a reference,
if (IsReference(parent, i))
{
// Visit the reference and substitute its copy
parent[i] = VisitReference(child);
// If no substutition found, then use original child
if (parent[i] == null)
parent[i] = child;
}
else
{
// Otherwise, visit the node and substitute its copy
parent[i] = Visit(child);
}
}
return parent;
}
示例8: IsReference
/// <summary>
/// Visit all children of "parent". Take care to avoid circular visits.
/// </summary>
protected virtual bool IsReference(QilNode parent, int childNum) {
QilNode child = parent[childNum];
if (child != null) {
switch (child.NodeType) {
case QilNodeType.For:
case QilNodeType.Let:
case QilNodeType.Parameter:
// Is this a reference or a definition?
switch (parent.NodeType) {
case QilNodeType.Loop:
case QilNodeType.Filter:
case QilNodeType.Sort:
// Second child of these node types is a reference; first child is a definition
return childNum == 1;
case QilNodeType.GlobalVariableList:
case QilNodeType.GlobalParameterList:
case QilNodeType.FormalParameterList:
// All children of definition lists are definitions
return false;
}
// All other cases are references
return true;
case QilNodeType.Function:
// If parent is an Invoke node, then visit a reference to the function
return parent.NodeType == QilNodeType.Invoke;
}
}
return false;
}
示例9: VisitChildren
//-----------------------------------------------
// QilVisitor overrides
//-----------------------------------------------
/// <summary>
/// Visit all children of "parent", replacing each child with a copy of each child.
/// </summary>
protected override QilNode VisitChildren(QilNode parent) {
XmlQueryType oldParentType = parent.XmlType;
bool recalcType = false;
// Visit children
for (int i = 0; i < parent.Count; i++) {
QilNode oldChild = parent[i], newChild;
XmlQueryType oldChildType = oldChild != null ? oldChild.XmlType : null;
// Visit child
if (IsReference(parent, i))
newChild = VisitReference(oldChild);
else
newChild = Visit(oldChild);
// Only replace child and recalculate type if oldChild != newChild or oldChild.XmlType != newChild.XmlType
if ((object) oldChild != (object) newChild || (newChild != null && (object) oldChildType != (object) newChild.XmlType)) {
recalcType = true;
parent[i] = newChild;
}
}
if (recalcType)
RecalculateType(parent, oldParentType);
return parent;
}
示例10: Replace
public QilNode Replace(QilNode expr, QilReference lookFor, QilReference replaceBy)
{
QilDepthChecker.Check(expr);
_lookFor = lookFor;
_replaceBy = replaceBy;
return VisitAssumeReference(expr);
}
示例11: InvokeSystemProperty
public QilNode InvokeSystemProperty(QilNode n)
{
CheckQName(n);
return XsltInvokeEarlyBound(QName("system-property"),
XsltMethods.SystemProperty, T.Choice(T.DoubleX, T.StringX), new QilNode[] { n }
);
}
示例12: IsAnyType
public bool IsAnyType(QilNode n)
{
XmlQueryType xt = n.XmlType;
bool result = !(xt.IsStrict || xt.IsNode);
Debug.Assert(result == (xt.TypeCode == XmlTypeCode.Item || xt.TypeCode == XmlTypeCode.AnyAtomicType), "What else can it be?");
return result;
}
示例13: FindReplacement
/// <summary>
/// Find the replacement for a node
/// </summary>
/// <param name="n">the node to replace</param>
/// <returns>null if no replacement is found</returns>
public QilNode FindReplacement(QilNode n) {
Debug.Assert(s.Count % 2 == 0);
for (int i = s.Count-2; i >= 0; i-=2)
if (s[i] == n)
return (QilNode)s[i+1];
return null;
}
示例14: AfterVisit
/// <summary>
/// Called at the end of Visit().
/// </summary>
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;
}
}
示例15: QilFunction
//-----------------------------------------------
// Constructor
//-----------------------------------------------
/// <summary>
/// Construct a node
/// </summary>
public QilFunction(QilNodeType nodeType, QilNode arguments, QilNode definition, QilNode sideEffects, XmlQueryType resultType)
: base(nodeType) {
this.arguments = arguments;
this.definition = definition;
this.sideEffects = sideEffects;
this.xmlType = resultType;
}