public override string ToScript() { string result = string.Empty; #region StaticFunctrionPrinting if (((Func)func).isStatic) { if (null != func) { if (((Func)func).isRange) { } else { result += func.ToScript(); } } #region Range if (((Func)func).isRange) { if (null != parameters) { var sortedDict = (from entry in parameters orderby entry.Key ascending select entry) .ToDictionary(pair => pair.Key, pair => pair.Value); IEnumerable iter = sortedDict; int count = 0; if (((Func)func).replicationGuide.Equals("") || ((Func)func).replicationGuide == null) { foreach (Node node in sortedDict.Values) { string arg = string.Empty; count++; if (node != null) { if (node is Block) { arg = (node as Block).LHS; } else { // TODO Jun: Implement a codeblock ToScript function such that it returns the contents, not the name arg = node.ToScript(); } if (count == 3) { if (((Func)func).argTypeRange == 0) { result += arg + ".."; } else if (((Func)func).argTypeRange == 1) { result += "~" + arg + ".."; } else { result += "#" + arg + ".."; } } else { result += arg + ".."; } } else { if (count == 3) { ; } else { result += ProtoCore.DSDefinitions.Keyword.Null + ".."; } } } } else { string[] repGuideforParam = ((Func)func).replicationGuide.Split('¡'); int i = 0; foreach (Node node in sortedDict.Values) { string[] repGuideForNode = repGuideforParam[i++].Split(','); string arg = string.Empty; count++; if (node != null) { if (node is Block) { arg = (node as Block).LHS; } else { // TODO Jun: Implement a codeblock ToScript function such that it returns the contents, not the name arg = node.ToScript(); } if (count == 3) { if (((Func)func).argTypeRange == 0) { result += arg;// + for (int j = 0; j < repGuideForNode.Length - 1; j++) { result += "<" + repGuideForNode[j] + ">"; } result += ".."; if (i == repGuideforParam.Length - 1) { break; } } else if (((Func)func).argTypeRange == 1) { result += "~" + arg;// +".."; for (int j = 0; j < repGuideForNode.Length - 1; j++) { result += "<" + repGuideForNode[j] + ">"; } result += ".."; if (i == repGuideforParam.Length - 1) { break; } } else { result += "#" + arg;// +".."; for (int j = 0; j < repGuideForNode.Length - 1; j++) { result += "<" + repGuideForNode[j] + ">"; } result += ".."; if (i == repGuideforParam.Length - 1) { break; } } } else { result += arg;// +".."; for (int j = 0; j < repGuideForNode.Length - 1; j++) { result += "<" + repGuideForNode[j] + ">"; } result += ".."; } } else { if (count == 3) { ; } else { result += ProtoCore.DSDefinitions.Keyword.Null + ".."; } } } } result = result.Substring(0, result.Length - 2); } } #endregion else { result += "("; if (null != parameters) { var sortedDict = (from entry in parameters orderby entry.Key ascending select entry) .ToDictionary(pair => pair.Key, pair => pair.Value); IEnumerable iter = sortedDict; string[] repGuideforParam = ((Func)func).replicationGuide.Split(GraphToDSCompiler.Constants.ReplicationGuideDelimiter); int n = 0; foreach (Node node in sortedDict.Values) { string arg = string.Empty; if (node != null) { if (node is Block) { arg = (node as Block).LHS + " "; } else { arg = node.ToScript() + " "; } result += " " + arg; if (n < repGuideforParam.Length) { result += SnapshotNode.ParseReplicationGuideText(repGuideforParam[n]); } result += ","; } else { result += " " + ProtoCore.DSDefinitions.Keyword.Null + ","; } n++; } } if (parameters.Count > 0) { result = result.Substring(0, result.Length - 1); } result += " )"; } } #endregion else { if (null != func) { if (null != parameters) { var sortedDict = (from entry in parameters orderby entry.Key ascending select entry) .ToDictionary(pair => pair.Key, pair => pair.Value); IEnumerable iter = sortedDict; int count = 0; if (string.IsNullOrEmpty(((Func)func).replicationGuide)) { foreach (Node node in sortedDict.Values) { string arg = string.Empty; count++; if (node != null) { if (count == 1) { result += node.ToScript() + "." + func.ToScript(); if (!((Func)func).isProperty) { result += "("; } } else { if (node is Block) { arg = (node as Block).LHS + " "; } else { arg = node.ToScript() + " "; } result += " " + arg + ","; } } else { if (count == 1) { result += Constants.kwTempNull + "." + func.ToScript(); if (!((Func)func).isProperty) { result += "("; } } else { result += " " + ProtoCore.DSDefinitions.Keyword.Null + ","; } } } } else { string[] repGuideforParam = ((Func)func).replicationGuide.Split(GraphToDSCompiler.Constants.ReplicationGuideDelimiter); int i = 0; int n = 0; foreach (Node node in sortedDict.Values) { string arg = string.Empty; count++; string[] repGuideForNode = repGuideforParam[i++].Split(','); if (node != null) { if (count == 1) { result += node.ToScript(); result += SnapshotNode.ParseReplicationGuideText(repGuideforParam[n]); result += "." + func.ToScript() + "("; } else { if (node is Block) { arg = (node as Block).LHS + " "; } else { arg = node.ToScript() + " "; } result += " " + arg; result += SnapshotNode.ParseReplicationGuideText(repGuideforParam[n]); result += ","; if (i == repGuideforParam.Length - 1) { break; } } } else { if (count == 1) { result += Constants.kwTempNull + "." + func.ToScript() + "("; } else { result += " " + ProtoCore.DSDefinitions.Keyword.Null + ","; } } n++; } } if (count == 0) { result += func.ToScript(); } } if (result.EndsWith(",")) { result = result.Substring(0, result.Length - 1); } if (!((Func)func).isProperty) { result += " )"; } } } return(result); }
public override string ToScript() { return(left.ToScript() + "=" + right.ToScript()); }
public override string ToScript() { string result = string.Empty; result += "("; if (((Operator)op).replicationGuide.Equals("") || ((Operator)op).replicationGuide == null) { // Handle left string code = string.Empty; if (null != left) { if (left is Block) { result += (left as Block).LHS + " "; } else { // TODO Jun: Implement a codeblock ToScript function such that it returns the contents, not the name result += left.ToScript() + " "; } } else { result += ProtoCore.DSDefinitions.Keyword.Null + " "; } // Handle operator if (null != op) { result += op.ToScript(); } //Handle right if (null != right) { if (right is Block) { result += (right as Block).LHS + " "; } else { result += right.ToScript() + " "; } } else { result += " " + ProtoCore.DSDefinitions.Keyword.Null; } } else { string[] repGuideforParam = ((Operator)op).replicationGuide.Split('¡'); string[] repGuideForLeftNode = repGuideforParam[0].Split(','); string[] repGuideForRightNode = repGuideforParam[1].Split(','); if (null != left) { if (left is Block) { result += (left as Block).LHS + " "; } else { result += left.ToScript() + " "; } //for (int j = 0; j < repGuideForLeftNode.Length - 1; j++) // result += "<" + repGuideForLeftNode[j] + ">"; result += SnapshotNode.ParseReplicationGuideText(repGuideforParam[0]); result += " "; } else { result += ProtoCore.DSDefinitions.Keyword.Null + " "; } if (null != op) { result += op.ToScript(); } if (null != right) { if (right is Block) { result += (right as Block).LHS + " "; } else { result += right.ToScript() + " "; } //for (int j = 0; j < repGuideForRightNode.Length - 1; j++) // result += "<" + repGuideForRightNode[j] + ">"; result += SnapshotNode.ParseReplicationGuideText(repGuideforParam[1]); result += " "; } else { result += " " + ProtoCore.DSDefinitions.Keyword.Null; } } return(result + ")"); }