/// <summary> /// 実行 /// </summary> /// <param name="arg"></param> /// <returns></returns> protected override GrassFunc Perform(GrassFunc arg) { //追加のローカルスタック Stack <GrassFunc> localStack = new Stack <GrassFunc>(); localStack.Push(arg); foreach (var tuple in _SentenceList.Select((sentence, index) => new { sentence, index })) { if (tuple.sentence.CountUpperCaseW > tuple.index + 1 + _FuncStack.Count || tuple.sentence.CountLowerCaseW > tuple.index + 1 + _FuncStack.Count) { System.Diagnostics.Debug.WriteLine("スタック内関数の指定は正常??"); } GrassFunc funcApp = (tuple.sentence.CountUpperCaseW > tuple.index + 1) ? _FuncStack.Get(tuple.sentence.CountUpperCaseW - tuple.index - 2) : localStack.Get(tuple.sentence.CountUpperCaseW - 1); GrassFunc argApp = (tuple.sentence.CountLowerCaseW > tuple.index + 1) ? _FuncStack.Get(tuple.sentence.CountLowerCaseW - tuple.index - 2) : localStack.Get(tuple.sentence.CountLowerCaseW - 1); //GrassFunc func2 = (funcApp == argApp) ? funcApp.Clone() : funcApp; //localStack.Push(func2.Apply(argApp)); localStack.Push(funcApp.Apply(argApp)); } return(localStack.Peek()); }