示例#1
0
        /// <summary>
        /// Performs initialization of data structure for a newly created thread
        /// It sets up the environment for the first method that runs the thread
        /// </summary>
        /// <param name="threadID">Thread id, which is the guid of the thread object</param>
        /// <param name="startingObject">The object from which the thread is started</param>
        /// <param name="startingMethod">The thread function</param>
        private void InitializeThread(int threadID, VMValue_object startingObject, CILMethod startingMethod)
        {
            this.threadID = threadID;
            currentMethod = startingMethod;
            syncState = SyncState.RUNNING;

            localVariableBlocks.Push(new VMLocalVariableBlock(this, startingMethod));
            if(startingObject != null)
                localVariableBlocks.Peek().AddArgumentFront(startingObject);
            pc = currentMethod.GetFirstInstruction();
        }
示例#2
0
        public CILInstruction CallFunction(CILMethod theMethod)
        {
            ReturnAddress ra = new ReturnAddress(currentMethod, pc);
            returnAddresses.Push(ra);

            VMLocalVariableBlock vBlock = new VMLocalVariableBlock(this, theMethod);
            localVariableBlocks.Push(vBlock);
            // The first argument is the object itself
            for(int i = -1; i < theMethod.ParameterCount; i++)
                vBlock.AddArgumentFront(GetValue(threadStack.Pop()));
            currentMethod = theMethod;

            return theMethod.GetFirstInstruction();
        }