public bool FindReadonlyElement(ValueBase val, out ReadonlyElement res) { foreach (var e in Readonlys) { if (!e.IsMatchByContent(val)) { continue; } res = e; return(true); } res = null; return(false); }
/// <summary> /// 読み込み専用の変数を登録します /// </summary> public ElementBase[] RegisterReadonlyVariable(Variable varbl) { if (varbl.InitialValues.Length == 1) { //単一宣言 - 既存のメモリ領域とできるだけ結合する ReadonlyElement target; if (!FindReadonlyElement(varbl.InitialValues[0], out target)) { target = new ReadonlyElement(); target.Index = Readonlys.Count; Readonlys.Add(target); } target.Content = varbl.InitialValues[0]; target.GroupedVariables.Add(varbl); varbl.AnalyzeResults = new ElementBase[1] { target }; return(varbl.AnalyzeResults); } else { //配列宣言 - 連続したメモリ領域を確保する ElementBase[] res = new ElementBase[varbl.InitialValues.Length]; for (int contentIdx = 0; contentIdx < varbl.InitialValues.Length; contentIdx++) { ReadonlyElement target = new ReadonlyElement(); target.Index = Readonlys.Count; Readonlys.Add(target); target.Content = varbl.InitialValues[contentIdx]; target.GroupedVariables.Add(varbl); res[contentIdx] = target; } varbl.AnalyzeResults = res; return(varbl.AnalyzeResults); } }