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;
}