/// <summary> /// Clones the instance using special context and returns cloned instance. /// </summary> /// <param name="context">Special context for providing references continuity.</param> /// <returns>Cloned instance.</returns> public CodeEntity Clone(Dictionary <object, object> context) { if (context.ContainsKey(this)) { return((CodeEntity)context[this]); } var result = new CodeEntity(); context[this] = result; result.Kind = Kind; result.Name = Name?.Clone(context); result.InheritanceItems = InheritanceItems?.Select(p => p.Clone(context)).ToList(); result.RuleInstance = RuleInstance?.Clone(context); result.InlineTrigger = InlineTrigger?.Clone(context); result.Operator = Operator?.Clone(context); result.Channel = Channel?.Clone(context); result.LinguisticVariable = LinguisticVariable?.Clone(context); result.NamedFunction = NamedFunction?.Clone(context); result.CodeFile = CodeFile; result.ParentCodeEntity = ParentCodeEntity; result.SubItems = SubItems?.Select(p => p.Clone(context)).ToList(); result.AppendAnnotations(this, context); return(result); }
protected void AppendFuction(FunctionValue source, Dictionary <object, object> context) { Arguments = source.Arguments?.Select(p => p.Clone(context)).ToList(); Statements = source.Statements.Select(p => p.CloneAstStatement(context)).ToList(); CompiledFunctionBody = source.CompiledFunctionBody.Clone(context); CodeEntity = source.CodeEntity?.Clone(context); AppendAnnotations(this, context); }