Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        readonly int[] inputArgumentIndices; // method arg position is index[ith action arg];

        #endregion Fields

        #region Constructors

        // -1 means implicit this param
        // -2 means Any.Value ("_")
        public ActionMethodStart(CompoundTerm actionLabel, Method method, int arity, ActionMethodFinish/*?*/ finishActionMethod, int[] inputArgumentIndices)
            : base(actionLabel, method, arity)
        {
            this.finishActionMethod = finishActionMethod;
            this.inputArgumentIndices = inputArgumentIndices;
        }
Esempio n. 3
0
        /// <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;
        }