public void CompileDocument(TongCompilerContext.DocumentContext docContext) { var scriptObjects = docContext.ScriptDocument.As <TongScriptObjectTable>(); var scriptObjectMap = scriptObjects.NodeMap; // Find interface nodes foreach (var obj in scriptObjectMap) { delNodeHandler nodeHandler = null; var nodeDefInfo = obj.Value.DomNode.Type.GetTag <SF.Tong.Schema.NodeTypeInfo>(); var curNodeDefInfo = nodeDefInfo; // Search hierarchy for the handler for (; curNodeDefInfo != null; curNodeDefInfo = curNodeDefInfo.Parent) { if (m_NodeHandler.TryGetValue(curNodeDefInfo.Name, out nodeHandler)) { break; } } if (nodeHandler != null) { nodeHandler(docContext, obj.Value); } else { throw new Exception("Don't know how to handle:" + nodeDefInfo.Name); } } }
static bool TraverseInputInternalDFS(HashSet <ScriptGraphNode> traversed, ScriptGraphNode curNode, delNodeHandler handleFunc) { if (curNode == null) { return(true); } if (!traversed.Contains(curNode)) { if (curNode.m_ToThisNodePin != null) { foreach (var itNodePin in curNode.m_ToThisNodePin) { var nodePin = itNodePin.Value; foreach (var link in nodePin.LinkTo) { if (!TraverseInputInternalDFS(traversed, link.Target, handleFunc)) { return(false); } } } } traversed.Add(curNode); } return(handleFunc(curNode)); }
/// <summary> /// Traverse /// </summary> public void TraverseInputDFS(delNodeHandler handleFunc) { var traversed = new HashSet <ScriptGraphNode>(); TraverseInputInternalDFS(traversed, this, handleFunc); }