PyVM is a Python Virtual Machine implemented in Rust. For learning purposes.
Not much. Only 39 instruction types are implemented and there are 130 different types of instructions in Python 3.8. Also, not all types are implemented neither built-in functions (but hey, we have the print function).
So basically these are implemented:
- Variables
int,bool,float,strandNonetypes.add,subtract,multiply,true_divideandfloor_divideoperations.<,<=,==,!=,>and>=comparison operations- Only
if/elif/elseandwhilebecauseforrequires more thing to be implemented - Supports only functions with positional arguments
- Global and local scope but not
globalkeyword - Deleting variables (only from local)
The purpose is learning about both Python's Virtual Machine and Rust. Hence the code is ugly and slow but this is my first program in Rust, so this is expected.
- Edit
bytecode_gen/source.py - Run any of the batch files according to the situation:
compile_to_json.bat: Creates a file calledbytecode.jsonthat contains instructions and all that stuff.run.bat: Runs the virtual machine with the instructions frombytecode.jsoncompile_to_json_and_run.bat: Createsbytecode.jsonand runs the virtual machine