mohanson / pywasm

A WebAssembly interpreter written in pure Python
MIT License
450 stars 39 forks source link

Use integer division for popcnt #27

Closed emilyhorsman closed 4 years ago

emilyhorsman commented 4 years ago

Prior to this commit: the 0x1 & a expression will fail after the first iteration when a becomes a float from the /= statement.

e.g.,

                if opcode == convention.i64_popcnt:
                    c = 0
                    for i in range(64):
>                       if 0x1 & a:
E                       TypeError: unsupported operand type(s) for &: 'int' and 'float'

/usr/local/lib/python3.7/site-packages/pywasm/execution.py:958: TypeError
mohanson commented 4 years ago

Thanks for your work! Sometimes dynamic number types is really confusing.