WASM Python integration milestone - game.py runs in browser
Major milestone for issue #158 (Emscripten/WebAssembly build target): - Python 3.14 successfully initializes and runs in WASM - mcrfpy module loads and works correctly - Game scripts execute with full level generation - Entities (boulders, rats, cyclops, spawn points) placed correctly Key changes: - CMakeLists.txt: Add 2MB stack, Emscripten link options, preload files - platform.h: Add WASM-specific implementations for executable paths - HeadlessTypes.h: Make Texture/Font/Sound stubs return success - CommandLineParser.cpp: Guard filesystem operations for WASM - McRFPy_API.cpp: Add WASM path configuration, debug output - game.py: Make 'code' module import optional (not available in WASM) - wasm_stdlib/: Add minimal Python stdlib for WASM (~4MB) Build with: emmake make (from build-emscripten/) Test with: node mcrogueface.js Next steps: - Integrate VRSFML for actual WebGL rendering - Create HTML page to host WASM build - Test in actual browsers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
07fd12373d
commit
8c3128e29c
222 changed files with 80639 additions and 25 deletions
122
wasm_stdlib/lib/python3.14/opcode.py
Normal file
122
wasm_stdlib/lib/python3.14/opcode.py
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
|
||||
"""
|
||||
opcode module - potentially shared between dis and other modules which
|
||||
operate on bytecodes (e.g. peephole optimizers).
|
||||
"""
|
||||
|
||||
|
||||
__all__ = ["cmp_op", "stack_effect", "hascompare", "opname", "opmap",
|
||||
"HAVE_ARGUMENT", "EXTENDED_ARG", "hasarg", "hasconst", "hasname",
|
||||
"hasjump", "hasjrel", "hasjabs", "hasfree", "haslocal", "hasexc"]
|
||||
|
||||
import builtins
|
||||
import _opcode
|
||||
from _opcode import stack_effect
|
||||
|
||||
from _opcode_metadata import (_specializations, _specialized_opmap, opmap, # noqa: F401
|
||||
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) # noqa: F401
|
||||
EXTENDED_ARG = opmap['EXTENDED_ARG']
|
||||
|
||||
opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
|
||||
for m in (opmap, _specialized_opmap):
|
||||
for op, i in m.items():
|
||||
opname[i] = op
|
||||
|
||||
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
|
||||
|
||||
# These lists are documented as part of the dis module's API
|
||||
hasarg = [op for op in opmap.values() if _opcode.has_arg(op)]
|
||||
hasconst = [op for op in opmap.values() if _opcode.has_const(op)]
|
||||
hasname = [op for op in opmap.values() if _opcode.has_name(op)]
|
||||
hasjump = [op for op in opmap.values() if _opcode.has_jump(op)]
|
||||
hasjrel = hasjump # for backward compatibility
|
||||
hasjabs = []
|
||||
hasfree = [op for op in opmap.values() if _opcode.has_free(op)]
|
||||
haslocal = [op for op in opmap.values() if _opcode.has_local(op)]
|
||||
hasexc = [op for op in opmap.values() if _opcode.has_exc(op)]
|
||||
|
||||
|
||||
_intrinsic_1_descs = _opcode.get_intrinsic1_descs()
|
||||
_intrinsic_2_descs = _opcode.get_intrinsic2_descs()
|
||||
_special_method_names = _opcode.get_special_method_names()
|
||||
_common_constants = [builtins.AssertionError, builtins.NotImplementedError,
|
||||
builtins.tuple, builtins.all, builtins.any]
|
||||
_nb_ops = _opcode.get_nb_ops()
|
||||
|
||||
hascompare = [opmap["COMPARE_OP"]]
|
||||
|
||||
_cache_format = {
|
||||
"LOAD_GLOBAL": {
|
||||
"counter": 1,
|
||||
"index": 1,
|
||||
"module_keys_version": 1,
|
||||
"builtin_keys_version": 1,
|
||||
},
|
||||
"BINARY_OP": {
|
||||
"counter": 1,
|
||||
"descr": 4,
|
||||
},
|
||||
"UNPACK_SEQUENCE": {
|
||||
"counter": 1,
|
||||
},
|
||||
"COMPARE_OP": {
|
||||
"counter": 1,
|
||||
},
|
||||
"CONTAINS_OP": {
|
||||
"counter": 1,
|
||||
},
|
||||
"FOR_ITER": {
|
||||
"counter": 1,
|
||||
},
|
||||
"LOAD_SUPER_ATTR": {
|
||||
"counter": 1,
|
||||
},
|
||||
"LOAD_ATTR": {
|
||||
"counter": 1,
|
||||
"version": 2,
|
||||
"keys_version": 2,
|
||||
"descr": 4,
|
||||
},
|
||||
"STORE_ATTR": {
|
||||
"counter": 1,
|
||||
"version": 2,
|
||||
"index": 1,
|
||||
},
|
||||
"CALL": {
|
||||
"counter": 1,
|
||||
"func_version": 2,
|
||||
},
|
||||
"CALL_KW": {
|
||||
"counter": 1,
|
||||
"func_version": 2,
|
||||
},
|
||||
"STORE_SUBSCR": {
|
||||
"counter": 1,
|
||||
},
|
||||
"SEND": {
|
||||
"counter": 1,
|
||||
},
|
||||
"JUMP_BACKWARD": {
|
||||
"counter": 1,
|
||||
},
|
||||
"TO_BOOL": {
|
||||
"counter": 1,
|
||||
"version": 2,
|
||||
},
|
||||
"POP_JUMP_IF_TRUE": {
|
||||
"counter": 1,
|
||||
},
|
||||
"POP_JUMP_IF_FALSE": {
|
||||
"counter": 1,
|
||||
},
|
||||
"POP_JUMP_IF_NONE": {
|
||||
"counter": 1,
|
||||
},
|
||||
"POP_JUMP_IF_NOT_NONE": {
|
||||
"counter": 1,
|
||||
},
|
||||
}
|
||||
|
||||
_inline_cache_entries = {
|
||||
name : sum(value.values()) for (name, value) in _cache_format.items()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue