コード例 #1
0
ファイル: LibraryModelProgram.cs プロジェクト: juhan/NModel
        /// <summary>
        /// Adds an <see>ActionMethod</see> entry for <paramref name="startActionLabel"/> in the dictionary.
        /// </summary>
        static void InsertActionMethodStart(Method method, CompoundTerm startActionLabel, ActionMethodFinish/*?*/ finishActionMethod, Dictionary<Symbol, ActionInfo> aInfoMap)
        {
            bool isAtomic = (null == finishActionMethod);
            int[] inParamIndices = ReflectionHelper.GetInputParameterIndices(startActionLabel, method.methodInfo);
            int arity = startActionLabel.Arguments.Count;
            ActionMethod am = new ActionMethodStart(startActionLabel, method, arity, finishActionMethod, inParamIndices);
            ActionKind kind = isAtomic ? ActionKind.Atomic : ActionKind.Start;

            ActionInfo aInfo;
            Symbol startActionSymbol = startActionLabel.Symbol;
            List<ActionMethod> actionMethods = new List<ActionMethod>();
            if (aInfoMap.TryGetValue(startActionSymbol, out aInfo))
            {
                if (aInfo.Arity != arity)
                {
                    throw new ModelProgramUserException("Mismatched number of action arguments");
                }

                // An action composed of several action methods is split if any of its
                // action methods is split.
                if (aInfo.Kind == ActionKind.Start)
                    kind = ActionKind.Start;

                foreach (ActionMethod am1 in aInfo.ActionMethods)
                    actionMethods.Add(am1);
            }

            actionMethods.Add(am);
            aInfoMap[startActionSymbol] = new ActionInfo(arity, null, kind, actionMethods);
        }
コード例 #2
0
ファイル: LibraryModelProgram.cs プロジェクト: juhan/NModel
        /// <summary>
        /// Adds an <see>ActionMethod</see> entry for <paramref name="finishActionLabel"/> in the dictionary.
        /// </summary>
        /// <param name="method"></param>
        /// <param name="finishActionLabel"></param>
        /// <param name="aInfoMap"></param>
        static ActionMethodFinish InsertActionMethodFinish(Method method, CompoundTerm finishActionLabel, Dictionary<Symbol, ActionInfo> aInfoMap)
        {
            int[] outParamIndices = ReflectionHelper.GetOutputParameterIndices(finishActionLabel, method.methodInfo);
            int arity = finishActionLabel.Arguments.Count;
            ActionMethodFinish am = new ActionMethodFinish(finishActionLabel, method, arity, outParamIndices);

            ActionInfo aInfo;
            Symbol finishActionSymbol = finishActionLabel.Symbol;
            List<ActionMethod> actionMethods = new List<ActionMethod>();
            if (aInfoMap.TryGetValue(finishActionSymbol, out aInfo))
            {
                //if (aInfo.Arity != arity)
                //{
                //    throw new ModelProgramUserException("Mismatched number of output action arguments");
                //}
                foreach (ActionMethod am1 in aInfo.ActionMethods)
                    actionMethods.Add(am1);
            }

            actionMethods.Add(am);
            aInfoMap[finishActionSymbol] = new ActionInfo(arity, null, ActionKind.Finish, actionMethods);
            return am;
        }