private void InterpretMod() { StackFrameMemory stack = PeekCallStack().Memory; int a = stack.PopValInt(); int b = stack.PopValInt(); stack.PushValInt(a % b); }
private void InterpretLogicalNot() { StackFrameMemory stack = PeekCallStack().Memory; int val = stack.PopValInt(); stack.PushValInt(val == 0 ? 1 : 0); }
private void InterpretBool() { StackFrameMemory stack = PeekCallStack().Memory; int val = stack.PopValInt(); stack.PushValInt(val == 0 ? 0 : 1); }
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); }