Ejemplo n.º 1
0
        private EventInfo[][] CreateStateEventList()
        {
            if (_states.Count == 0)
            {
                throw new GenerationException(String.Format("Script must contain a default state"));
            }

            EventInfo[][] outEvents = new EventInfo[_states.Count][];

            for (int i = 0; i < _states.Count; ++i)
            {
                List<EventSymbol> stateEvents = this.FindEventsForState(i);

                if (stateEvents.Count == 0)
                {
                    //find the name of this state
                    foreach (var stateKvp in _states)
                    {
                        if (stateKvp.Value == i)
                        {
                            throw new GenerationException(String.Format("State {0} must contain at least 1 event", stateKvp.Key));
                        }
                    }
                }

                outEvents[i] = new EventInfo[stateEvents.Count];

                for (int j = 0; j < stateEvents.Count; ++j)
                {
                    outEvents[i][j] = stateEvents[j].ToEventInfo();
                }
            }

            return outEvents;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Pushes the given args onto the stack and positions the function pointer
        /// </summary>
        /// <param name="info"></param>
        /// <param name="args"></param>
        public void DoEvent(EventInfo info, PostedEvent triggeringEvent, IList<object> args)
        {
            TopFrame = new StackFrame(info.ToFunctionInfo(), 0);
            Calls.Push(TopFrame);
            
            IP = info.Address;

            Debug.Assert(args.Count == info.NumberOfArguments);
            for (int i = 0; i < args.Count; i++)
            {
                TopFrame.Locals[i] = args[i];
            }

            RunState = Status.Running;
            RunningEvent = triggeringEvent;

            MemInfo.AddCall(TopFrame);
        }