public void Align(ProtoCore.Runtime.RuntimeMemory rMem) { if (null == rMem) { return; } mRestorePoint = 0; mStack.Clear(); mRestorePoint = rMem.Stack.Count; //Record the stack elements which is above the frame pointer int nDiff = mRestorePoint - rMem.FramePointer; for (int i = 0; i < nDiff; i++) { mStack.Add(rMem.Pop()); } mRestorePoint = rMem.Stack.Count; mRmem = rMem; return; }
public bool Restore() { if (null == mRmem) { return(false); } //Pop the addtional stack elements added int newStackCount = mRmem.Stack.Count; if (newStackCount > mRestorePoint) { mRmem.Pop(newStackCount - mRestorePoint); } //Restore the old stack elements that is above the frame pointer int count = mStack.Count; for (int i = 0; i < count; i++) { mRmem.Push(mStack[count - 1 - i]); } return(true); }