/// <summary> /// For now just attach the node and don't bother with node sharing /// </summary> /// <param name="existing">- an existing node in the network. it may be /// an ObjectTypeNode or AlphaNode</param> /// <param name="alpha">The alpha.</param> /// <param name="cond">The cond.</param> protected internal virtual void attachAlphaNode(BaseAlpha existing, BaseAlpha alpha, ICondition cond) { if (alpha != null) { try { BaseAlpha share = null; share = shareAlphaNode(existing, alpha); if (share == null) { existing.addSuccessorNode(alpha, ruleCompiler.Engine, ruleCompiler.Memory); // if the node isn't shared, we Add the node to the Condition // object the node belongs to. cond.addNewAlphaNodes(alpha); } else if (existing != alpha) { // the node is shared, so instead of adding the new node, // we Add the existing node share.incrementUseCount(); cond.addNode(share); ruleCompiler.Memory.removeAlphaMemory(alpha); if (alpha.successorCount() == 1 && alpha.SuccessorNodes[0] is BaseAlpha) { // Get the Current node from the new AlphaNode BaseAlpha nnext = (BaseAlpha)alpha.SuccessorNodes[0]; attachAlphaNode(share, nnext, cond); } } } catch (AssertException e) { // send an event with the correct error CompileMessageEventArgs ce = new CompileMessageEventArgs(this, EventType.ADD_NODE_ERROR); ce.Message = alpha.toPPString(); ruleCompiler.notifyListener(ce); } } }