/// <inheritdoc/> public override void CloneChildren(Node parentNode) { // Clone the child recursively. Node ChildNodeClone = ChildState.CloneNode(); Debug.Assert(ChildNodeClone != null); // Set the clone in the parent. NodeTreeHelperChild.SetChildNode(parentNode, PropertyName, ChildNodeClone); }
/// <summary> /// Replaces a node. /// </summary> /// <param name="operation">Details of the operation performed.</param> public virtual void Replace(IWriteableReplaceOperation operation) { Node ParentNode = Owner.Node; IWriteableBrowsingPlaceholderNodeIndex OldBrowsingIndex = (IWriteableBrowsingPlaceholderNodeIndex)ChildState.ParentIndex; IWriteablePlaceholderNodeState OldChildState = (IWriteablePlaceholderNodeState)ChildState; Node OldNode = OldChildState.Node; NodeTreeHelperChild.SetChildNode(ParentNode, PropertyName, operation.NewNode); IWriteableBrowsingPlaceholderNodeIndex NewBrowsingIndex = CreateBrowsingNodeIndex(operation.NewNode); IWriteablePlaceholderNodeState NewChildState = (IWriteablePlaceholderNodeState)CreateNodeState(NewBrowsingIndex); SetChildState(NewChildState); operation.Update(OldBrowsingIndex, NewBrowsingIndex, OldNode, NewChildState); }
/// <summary></summary> public bool ReplacePhase1Macro(BaseNode.INode node, BaseNode.INode parentNode, string propertyName, IWalkCallbacks <ReplacePhase1MacroContext> callbacks, ReplacePhase1MacroContext context) { bool Result = true; if (node is IClass AsClass) { context.CurrentClass = AsClass; } else if (node is ILibrary || node is IGlobalReplicate) { context.CurrentClass = null; } else if (node is IPreprocessorExpression AsPreprocessorExpression) { bool IsHandled = false; switch (AsPreprocessorExpression.Value) { case BaseNode.PreprocessorMacro.DateAndTime: NodeTreeHelperChild.SetChildNode(parentNode, propertyName, CompilationDateTime); IsHandled = true; break; case BaseNode.PreprocessorMacro.CompilationDiscreteIdentifier: NodeTreeHelperChild.SetChildNode(parentNode, propertyName, CompilationUID); IsHandled = true; break; case BaseNode.PreprocessorMacro.CompilerVersion: NodeTreeHelperChild.SetChildNode(parentNode, propertyName, CompilerVersion); IsHandled = true; break; case BaseNode.PreprocessorMacro.ConformanceToStandard: NodeTreeHelperChild.SetChildNode(parentNode, propertyName, ConformanceToStandard); IsHandled = true; break; case BaseNode.PreprocessorMacro.DiscreteClassIdentifier: Debug.Assert(context.CurrentClass != null); string GlassGuidDigits = context.CurrentClass.ClassGuid.ToString("N", CultureInfo.InvariantCulture) + ":" + "H"; BaseNode.IIdentifier Operator = NodeHelper.CreateSimpleIdentifier("To UUID"); BaseNode.IManifestNumberExpression NumberExpression = NodeHelper.CreateSimpleManifestNumberExpression(GlassGuidDigits); BaseNode.IUnaryOperatorExpression Expression = NodeHelper.CreateUnaryOperatorExpression(Operator, NumberExpression); IExpression ReplacementNode = ToCompilerNode <BaseNode.IUnaryOperatorExpression, IUnaryOperatorExpression>(Expression); NodeTreeHelperChild.SetChildNode(parentNode, propertyName, ReplacementNode); IsHandled = true; break; case BaseNode.PreprocessorMacro.Debugging: NodeTreeHelperChild.SetChildNode(parentNode, propertyName, Debugging); IsHandled = true; break; // Processed in phase 2. case BaseNode.PreprocessorMacro.ClassPath: case BaseNode.PreprocessorMacro.Counter: case BaseNode.PreprocessorMacro.RandomInteger: IsHandled = true; break; } Debug.Assert(IsHandled); } return(Result); }