public void GetUsedIdents(ScopeChecker.UsedIdents usedIdents) { usedIdents.CurrentNamespace = null; Params.ForEach(param => param.GetUsedIdents(usedIdents)); Commands.ForEach(cmd => cmd.GetUsedIdents(usedIdents)); Declarations.ForEach(decl => { if (decl is ASTProcFuncDecl) { usedIdents.CurrentNamespace = ((ASTProcFuncDecl)decl).Ident; } decl.GetUsedIdents(usedIdents); usedIdents.CurrentNamespace = null; }); }
/// <summary> /// 文字列取得 /// </summary> /// <param name="index">前スペース数</param> /// <returns>文字列</returns> public override string ToString(int index = 0) { var result = new StringBuilder(); var indexSpace = string.Concat(Enumerable.Repeat(" ", index)); foreach (var comment in Comments) { result.Append(indexSpace); result.AppendLine($"{comment}"); } result.Append(indexSpace); result.Append("for("); // 宣言 var declarations = new List <string>(); Declarations.ForEach(items => { var declaration = new StringBuilder(); items.ForEach(item => declaration.Append(item.Name)); declarations.Add(declaration.ToString()); }); result.Append(string.Join(",", declarations.ToArray())); result.Append(";"); for (var i = 0; i < Conditions.Count; i++) { var isSetSpace = true; if (i == Conditions.Count - 1) { isSetSpace = false; } else if (Conditions[i].Name == "." || Conditions[i + 1].Name == ".") { isSetSpace = false; } result.Append($"{Conditions[i].Name}"); if (isSetSpace) { result.Append(" "); } } result.Append(";"); var incrementors = new List <string>(); Incrementors.ForEach(items => { var incrementor = new StringBuilder(); items.ForEach(item => incrementor.Append(item.Name)); incrementors.Add(incrementor.ToString()); }); result.Append(string.Join(",", incrementors.ToArray())); result.AppendLine(")"); result.Append(indexSpace); result.AppendLine("{"); foreach (var statement in Members) { result.AppendLine(statement.ToString(index + 1)); } result.Append(indexSpace); result.AppendLine("}"); return(result.ToString()); }