harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-5507harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-5507Implement a virtual machine (VM) in Rust that executes Python code. The primary structure of this VM is the VirtualMachine struct, which encapsulates several features needed to manage execution context, such as built-in objects, frames, and exception handling.
Initialization:
new method for VirtualMachine, which should create and initialize the VM with a set of default settings (using PySettings).builtins, sys, etc.) are created and linked correctly during initialization.Execution of Python Code:
run_code_obj: This should take a PyCodeRef and a Scope, and execute the given code.push_exception and pop_exception methods.run_frame_full and run_frame methods that handle execution flow and the current frame management.Support for Python Objects:
new_pyobj), manage attribute access (get_attribute, set_attr, del_attr), and handle various types of comparisons and arithmetic operations._add and _mul that handle arithmetic operations.Exception Handling:
ExceptionStack.new_value_error, new_type_error).State Management:
Threading (if applicable):
The completed implementation should reside in the /app/ directory, specifically fulfilling the structure and methods as outlined, ensuring all functionality aligns with Python's interpretation model. The tests provided in tests should pass successfully after the implementation.