Ejemplo n.º 1
0
        private void InterpretMod()
        {
            StackFrameMemory stack = PeekCallStack().Memory;
            int a = stack.PopValInt();
            int b = stack.PopValInt();

            stack.PushValInt(a % b);
        }
Ejemplo n.º 2
0
        private void InterpretLogicalNot()
        {
            StackFrameMemory stack = PeekCallStack().Memory;
            int val = stack.PopValInt();

            stack.PushValInt(val == 0 ? 1 : 0);
        }
Ejemplo n.º 3
0
        private void InterpretBool()
        {
            StackFrameMemory stack = PeekCallStack().Memory;
            int val = stack.PopValInt();

            stack.PushValInt(val == 0 ? 0 : 1);
        }
Ejemplo n.º 4
0
        private void PushCall(VMModule module, StackFrameMemory sourceStack)
        {
            int functionIndex = sourceStack.PopValInt();

            GetFunctionStackSizes(module, functionIndex,
                                  out int returnValueSize,
                                  out int argumentMemorySize,
                                  out int stackSize);

            StackFrame frame = AcquireFrame(stackSize);

            frame.Module   = module;
            frame.Function = functionIndex;
            frame.Memory.CopyFrom(sourceStack, sourceStack.StackPointer - argumentMemorySize, returnValueSize, argumentMemorySize);
            sourceStack.Discard(argumentMemorySize);
            PushCallStack(frame);

            // TODO: PERF: Try to optimize out calls to HandleModuleAdded when we can deduce that the module has already
            // been seen.
            // For calls pushed by the CALL instruction, we know that the module will be the same and that we don't need
            // to call this function.
            _debugger?.HandleModuleAdded(module);
        }