Exemplo n.º 1
0
        public VM.StackFrame ToStackFrame()
        {
            VM.StackFrame frame = new VM.StackFrame(this.FunctionInfo, this.ReturnAddress);
            frame.Locals = SerializedLSLPrimitive.ToPrimitiveList(this.Locals);

            return(frame);
        }
Exemplo n.º 2
0
        public VM.CompiledScript ToCompiledScript()
        {
            VM.CompiledScript compScript = new VM.CompiledScript();
            compScript.Version  = this.Version;
            compScript.ByteCode = this.ByteCode;

            //const pool, only type that needs changing is the list type
            compScript.ConstPool = SerializedLSLPrimitive.ToPrimitiveList(this.ConstPool);

            if (this.StateEvents != null)
            {
                compScript.StateEvents = new VM.EventInfo[this.StateEvents.Count][];

                for (int i = 0; i < this.StateEvents.Count; i++)
                {
                    compScript.StateEvents[i] = this.StateEvents[i];
                }
            }
            else
            {
                compScript.StateEvents = new VM.EventInfo[0][];
            }



            compScript.NumGlobals = this.NumGlobals;
            compScript.AssetId    = this.AssetId;

            return(compScript);
        }
Exemplo n.º 3
0
        internal VM.PostedEvent ToPostedEvent()
        {
            VM.PostedEvent evt = new VM.PostedEvent();
            evt.EventType = this.EventType;

            evt.Args = SerializedLSLPrimitive.ToPrimitiveList(this.Args);

            evt.DetectVars = this.DetectVars;

            evt.TransitionToState = this.TransitionToState;

            return(evt);
        }
Exemplo n.º 4
0
        public VM.RuntimeState ToRuntimeState()
        {
            VM.RuntimeState state = new VM.RuntimeState();
            state.IP       = this.IP;
            state.LSLState = this.LSLState;
            state.Globals  = SerializedLSLPrimitive.ToPrimitiveList(this.Globals);
            state.Operands = SerializedLSLPrimitive.ToPrimitiveStack(this.Operands);

            if (this.Calls != null)
            {
                state.Calls = new Stack <VM.StackFrame>(this.Calls.Length);
                //calls is a stack, so again push them in reverse order
                for (int i = this.Calls.Length - 1; i >= 0; i--)
                {
                    state.Calls.Push(this.Calls[i].ToStackFrame());
                }
            }
            else
            {
                state.Calls = new Stack <VM.StackFrame>();
            }

            if (state.Calls.Count > 0)
            {
                //DO NOT USE THE SERIALIZED TOPFRAME HERE, IT IS A DIFFERENT REFERENCE THAN
                //state.Calls.Peek!!!
                state.TopFrame = state.Calls.Peek();
            }
            else
            {
                state.TopFrame = null;
            }

            state.MemInfo = this.MemInfo;

            state.EventQueue = new C5.LinkedList <VM.PostedEvent>();
            if (this.EventQueue != null)
            {
                foreach (SerializedPostedEvent evt in this.EventQueue)
                {
                    state.EventQueue.Add(evt.ToPostedEvent());
                }
            }

            state.RunState      = this.RunState;
            state.GeneralEnable = this.Enabled;

            UInt64 currentTickCount = Util.Clock.GetLongTickCount();

            state.StateCapturedOn = currentTickCount;

            Int64 relativeNextWakeup = (Int64)currentTickCount + (Int64)(this.NextWakeup - this.StateCapturedOn).TotalMilliseconds;

            if (relativeNextWakeup < 0)
            {
                relativeNextWakeup = 0;
            }

            state.NextWakeup = (UInt64)relativeNextWakeup;

            Int64 relativeTimerLastScheduledOn = (Int64)currentTickCount + (Int64)(this.TimerLastScheduledOn - this.StateCapturedOn).TotalMilliseconds;

            if (relativeTimerLastScheduledOn < 0)
            {
                relativeTimerLastScheduledOn = 0;
            }

            state.TimerLastScheduledOn = (UInt64)relativeTimerLastScheduledOn;
            state.TimerInterval        = this.TimerInterval;

            if (this.RunningEvent != null)
            {
                state.RunningEvent = this.RunningEvent.ToPostedEvent();
            }

            if (this.ActiveListens != null)
            {
                state.ActiveListens = this.ActiveListens;
            }
            else
            {
                state.ActiveListens = new Dictionary <int, VM.ActiveListen>();
            }

            state.StartParameter = this.StartParameter;

            state.MiscAttributes = new Dictionary <int, object[]>();
            if (this.MiscAttributes != null)
            {
                foreach (KeyValuePair <int, SerializedLSLPrimitive[]> kvp in MiscAttributes)
                {
                    state.MiscAttributes[kvp.Key] = SerializedLSLPrimitive.ToPrimitiveList(kvp.Value);
                }
            }

            state.OtherRuntime         = TotalRuntime;
            state.StartTimeOnSimulator = Util.Clock.GetLongTickCount();

            return(state);
        }