webruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/webruby +36 -0
- data/driver/driver.c +50 -0
- data/driver/main.c +40 -0
- data/lib/webruby/app.rb +13 -0
- data/lib/webruby/config.rb +61 -0
- data/lib/webruby/environment.rb +32 -0
- data/lib/webruby/rake/files.rake +66 -0
- data/lib/webruby/rake/general.rake +22 -0
- data/lib/webruby/rake/mruby.rake +44 -0
- data/lib/webruby/utility.rb +132 -0
- data/lib/webruby.rb +10 -0
- data/modules/emscripten/AUTHORS +89 -0
- data/modules/emscripten/LICENSE +68 -0
- data/modules/emscripten/README.markdown +14 -0
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +61 -0
- data/modules/emscripten/cmake/Platform/Emscripten_unix.cmake +24 -0
- data/modules/emscripten/em++ +12 -0
- data/modules/emscripten/em++.bat +2 -0
- data/modules/emscripten/em-config +24 -0
- data/modules/emscripten/em-config.bat +2 -0
- data/modules/emscripten/emar +24 -0
- data/modules/emscripten/emar.bat +2 -0
- data/modules/emscripten/emcc +1744 -0
- data/modules/emscripten/emcc.bat +2 -0
- data/modules/emscripten/emcc.py +5 -0
- data/modules/emscripten/emconfigure +27 -0
- data/modules/emscripten/emconfigure.bat +2 -0
- data/modules/emscripten/emlibtool +11 -0
- data/modules/emscripten/emlibtool.bat +2 -0
- data/modules/emscripten/emlink.py +293 -0
- data/modules/emscripten/emmake +29 -0
- data/modules/emscripten/emmake.bat +2 -0
- data/modules/emscripten/emranlib +9 -0
- data/modules/emscripten/emranlib.bat +2 -0
- data/modules/emscripten/emscons +20 -0
- data/modules/emscripten/emscripten.py +835 -0
- data/modules/emscripten/patches/README +4 -0
- data/modules/emscripten/patches/series +2 -0
- data/modules/emscripten/scons-tools/closure.py +28 -0
- data/modules/emscripten/scons-tools/emscripten.py +359 -0
- data/modules/emscripten/scons-tools/llvm.py +33 -0
- data/modules/emscripten/src/analyzer.js +1695 -0
- data/modules/emscripten/src/compiler.html +48 -0
- data/modules/emscripten/src/compiler.js +298 -0
- data/modules/emscripten/src/corruptionCheck.js +98 -0
- data/modules/emscripten/src/determinstic.js +20 -0
- data/modules/emscripten/src/embind/embind.js +1677 -0
- data/modules/emscripten/src/embind/emval.js +283 -0
- data/modules/emscripten/src/experimental/allow_loopvars_from_memsetcpy_inasm.diff +97 -0
- data/modules/emscripten/src/experimental/batching.diff +44 -0
- data/modules/emscripten/src/experimental/functypeopt.diff +113 -0
- data/modules/emscripten/src/experimental/multiple_heaps.diff +175 -0
- data/modules/emscripten/src/experimental/noncallgraphprofiling.diff +197 -0
- data/modules/emscripten/src/experimental/optimize_memcpy_for_ta1.diff +124 -0
- data/modules/emscripten/src/experimental/remove__label__s.diff +140 -0
- data/modules/emscripten/src/experimental/renderer_cache_hash.diff +99 -0
- data/modules/emscripten/src/experimental/sdl_key_forwarding.diff +57 -0
- data/modules/emscripten/src/experimental/simplifyGeneratedFunctionsDetection.diff +336 -0
- data/modules/emscripten/src/experimental/stringCache.diff +147 -0
- data/modules/emscripten/src/fastLong.js +299 -0
- data/modules/emscripten/src/framework.js +257 -0
- data/modules/emscripten/src/gl-matrix.js +1952 -0
- data/modules/emscripten/src/headless.js +904 -0
- data/modules/emscripten/src/intertyper.js +1050 -0
- data/modules/emscripten/src/jsifier.js +1827 -0
- data/modules/emscripten/src/library.js +8270 -0
- data/modules/emscripten/src/library_browser.js +911 -0
- data/modules/emscripten/src/library_egl.js +491 -0
- data/modules/emscripten/src/library_gc.js +236 -0
- data/modules/emscripten/src/library_gl.js +4452 -0
- data/modules/emscripten/src/library_glfw.js +576 -0
- data/modules/emscripten/src/library_glut.js +449 -0
- data/modules/emscripten/src/library_jansson.js +320 -0
- data/modules/emscripten/src/library_openal.js +602 -0
- data/modules/emscripten/src/library_sdl.js +2024 -0
- data/modules/emscripten/src/library_strtok_r.c +97 -0
- data/modules/emscripten/src/library_xlib.js +23 -0
- data/modules/emscripten/src/long.js +1609 -0
- data/modules/emscripten/src/modules.js +491 -0
- data/modules/emscripten/src/parseTools.js +2474 -0
- data/modules/emscripten/src/postamble.js +170 -0
- data/modules/emscripten/src/postamble_sharedlib.js +16 -0
- data/modules/emscripten/src/preamble.js +914 -0
- data/modules/emscripten/src/preamble_sharedlib.js +25 -0
- data/modules/emscripten/src/relooper/README.markdown +14 -0
- data/modules/emscripten/src/relooper/Relooper.cpp +1236 -0
- data/modules/emscripten/src/relooper/Relooper.h +250 -0
- data/modules/emscripten/src/relooper/doit.sh +70 -0
- data/modules/emscripten/src/relooper/emscripten/glue.js +57 -0
- data/modules/emscripten/src/relooper/emscripten/test.js +44 -0
- data/modules/emscripten/src/relooper/fuzzer.py +116 -0
- data/modules/emscripten/src/relooper/ministring.h +35 -0
- data/modules/emscripten/src/relooper/paper.pdf +0 -0
- data/modules/emscripten/src/relooper/test.cpp +262 -0
- data/modules/emscripten/src/relooper/test.txt +155 -0
- data/modules/emscripten/src/relooper/test2.c +44 -0
- data/modules/emscripten/src/relooper/test2.txt +12 -0
- data/modules/emscripten/src/relooper/test3.c +42 -0
- data/modules/emscripten/src/relooper/test3.txt +27 -0
- data/modules/emscripten/src/relooper/test4.cpp +40 -0
- data/modules/emscripten/src/relooper/test4.txt +23 -0
- data/modules/emscripten/src/relooper/test5.cpp +40 -0
- data/modules/emscripten/src/relooper/test5.txt +32 -0
- data/modules/emscripten/src/relooper/test6.cpp +31 -0
- data/modules/emscripten/src/relooper/test6.txt +12 -0
- data/modules/emscripten/src/relooper/test_dead.cpp +28 -0
- data/modules/emscripten/src/relooper/test_dead.txt +9 -0
- data/modules/emscripten/src/relooper/test_debug.cpp +30 -0
- data/modules/emscripten/src/relooper/test_debug.txt +128 -0
- data/modules/emscripten/src/relooper/test_fuzz1.cpp +52 -0
- data/modules/emscripten/src/relooper/test_fuzz1.txt +32 -0
- data/modules/emscripten/src/relooper/test_fuzz2.cpp +34 -0
- data/modules/emscripten/src/relooper/test_fuzz2.txt +13 -0
- data/modules/emscripten/src/relooper/test_fuzz3.cpp +36 -0
- data/modules/emscripten/src/relooper/test_fuzz3.txt +9 -0
- data/modules/emscripten/src/relooper/test_fuzz4.cpp +38 -0
- data/modules/emscripten/src/relooper/test_fuzz4.txt +19 -0
- data/modules/emscripten/src/relooper/test_fuzz5.cpp +57 -0
- data/modules/emscripten/src/relooper/test_fuzz5.txt +52 -0
- data/modules/emscripten/src/relooper/test_fuzz6.cpp +322 -0
- data/modules/emscripten/src/relooper/test_fuzz6.txt +108 -0
- data/modules/emscripten/src/relooper/test_inf.cpp +813 -0
- data/modules/emscripten/src/relooper/test_inf.txt +385 -0
- data/modules/emscripten/src/relooper/testit.sh +62 -0
- data/modules/emscripten/src/relooper/updateit.sh +17 -0
- data/modules/emscripten/src/relooper.js +11516 -0
- data/modules/emscripten/src/relooper.js.raw.js +11511 -0
- data/modules/emscripten/src/runtime.js +546 -0
- data/modules/emscripten/src/settings.js +1284 -0
- data/modules/emscripten/src/shell.html +92 -0
- data/modules/emscripten/src/shell.js +153 -0
- data/modules/emscripten/src/shell_sharedlib.js +12 -0
- data/modules/emscripten/src/socket.io.js +3870 -0
- data/modules/emscripten/src/utility.js +379 -0
- data/modules/emscripten/src/wrtcp.js +821 -0
- data/modules/emscripten/system/include/AL/al.h +172 -0
- data/modules/emscripten/system/include/AL/alc.h +84 -0
- data/modules/emscripten/system/include/EGL/egl.h +329 -0
- data/modules/emscripten/system/include/EGL/eglext.h +398 -0
- data/modules/emscripten/system/include/EGL/eglplatform.h +141 -0
- data/modules/emscripten/system/include/GL/freeglut_std.h +628 -0
- data/modules/emscripten/system/include/GL/gl.h +2241 -0
- data/modules/emscripten/system/include/GL/glew.h +6 -0
- data/modules/emscripten/system/include/GL/glext.h +11127 -0
- data/modules/emscripten/system/include/GL/glfw.h +518 -0
- data/modules/emscripten/system/include/GL/glu.h +353 -0
- data/modules/emscripten/system/include/GL/glut.h +21 -0
- data/modules/emscripten/system/include/GLES/gl.h +770 -0
- data/modules/emscripten/system/include/GLES/glext.h +1278 -0
- data/modules/emscripten/system/include/GLES/glplatform.h +30 -0
- data/modules/emscripten/system/include/GLES2/gl2.h +621 -0
- data/modules/emscripten/system/include/GLES2/gl2ext.h +803 -0
- data/modules/emscripten/system/include/GLES2/gl2platform.h +30 -0
- data/modules/emscripten/system/include/KHR/khrplatform.h +277 -0
- data/modules/emscripten/system/include/SDL/COPYING +19 -0
- data/modules/emscripten/system/include/SDL/SDL.h +162 -0
- data/modules/emscripten/system/include/SDL/SDL_assert.h +241 -0
- data/modules/emscripten/system/include/SDL/SDL_atomic.h +318 -0
- data/modules/emscripten/system/include/SDL/SDL_audio.h +509 -0
- data/modules/emscripten/system/include/SDL/SDL_blendmode.h +60 -0
- data/modules/emscripten/system/include/SDL/SDL_clipboard.h +75 -0
- data/modules/emscripten/system/include/SDL/SDL_compat.h +365 -0
- data/modules/emscripten/system/include/SDL/SDL_config.h +48 -0
- data/modules/emscripten/system/include/SDL/SDL_config.h.in +297 -0
- data/modules/emscripten/system/include/SDL/SDL_config_android.h +133 -0
- data/modules/emscripten/system/include/SDL/SDL_config_iphoneos.h +148 -0
- data/modules/emscripten/system/include/SDL/SDL_config_macosx.h +172 -0
- data/modules/emscripten/system/include/SDL/SDL_config_minimal.h +74 -0
- data/modules/emscripten/system/include/SDL/SDL_config_nintendods.h +129 -0
- data/modules/emscripten/system/include/SDL/SDL_config_pandora.h +125 -0
- data/modules/emscripten/system/include/SDL/SDL_config_windows.h +207 -0
- data/modules/emscripten/system/include/SDL/SDL_config_wiz.h +119 -0
- data/modules/emscripten/system/include/SDL/SDL_copying.h +20 -0
- data/modules/emscripten/system/include/SDL/SDL_cpuinfo.h +150 -0
- data/modules/emscripten/system/include/SDL/SDL_endian.h +248 -0
- data/modules/emscripten/system/include/SDL/SDL_error.h +77 -0
- data/modules/emscripten/system/include/SDL/SDL_events.h +639 -0
- data/modules/emscripten/system/include/SDL/SDL_gesture.h +91 -0
- data/modules/emscripten/system/include/SDL/SDL_gfxPrimitives.h +246 -0
- data/modules/emscripten/system/include/SDL/SDL_haptic.h +1200 -0
- data/modules/emscripten/system/include/SDL/SDL_hints.h +206 -0
- data/modules/emscripten/system/include/SDL/SDL_image.h +138 -0
- data/modules/emscripten/system/include/SDL/SDL_input.h +87 -0
- data/modules/emscripten/system/include/SDL/SDL_joystick.h +208 -0
- data/modules/emscripten/system/include/SDL/SDL_keyboard.h +169 -0
- data/modules/emscripten/system/include/SDL/SDL_keycode.h +344 -0
- data/modules/emscripten/system/include/SDL/SDL_loadso.h +85 -0
- data/modules/emscripten/system/include/SDL/SDL_log.h +211 -0
- data/modules/emscripten/system/include/SDL/SDL_main.h +98 -0
- data/modules/emscripten/system/include/SDL/SDL_mixer.h +634 -0
- data/modules/emscripten/system/include/SDL/SDL_mouse.h +213 -0
- data/modules/emscripten/system/include/SDL/SDL_mutex.h +248 -0
- data/modules/emscripten/system/include/SDL/SDL_name.h +11 -0
- data/modules/emscripten/system/include/SDL/SDL_opengl.h +11116 -0
- data/modules/emscripten/system/include/SDL/SDL_opengles.h +38 -0
- data/modules/emscripten/system/include/SDL/SDL_opengles2.h +38 -0
- data/modules/emscripten/system/include/SDL/SDL_pixels.h +423 -0
- data/modules/emscripten/system/include/SDL/SDL_platform.h +160 -0
- data/modules/emscripten/system/include/SDL/SDL_power.h +79 -0
- data/modules/emscripten/system/include/SDL/SDL_quit.h +58 -0
- data/modules/emscripten/system/include/SDL/SDL_rect.h +136 -0
- data/modules/emscripten/system/include/SDL/SDL_render.h +615 -0
- data/modules/emscripten/system/include/SDL/SDL_revision.h +2 -0
- data/modules/emscripten/system/include/SDL/SDL_revision.h.orig +2 -0
- data/modules/emscripten/system/include/SDL/SDL_rotozoom.h +123 -0
- data/modules/emscripten/system/include/SDL/SDL_rwops.h +220 -0
- data/modules/emscripten/system/include/SDL/SDL_scancode.h +398 -0
- data/modules/emscripten/system/include/SDL/SDL_shape.h +147 -0
- data/modules/emscripten/system/include/SDL/SDL_stdinc.h +764 -0
- data/modules/emscripten/system/include/SDL/SDL_surface.h +499 -0
- data/modules/emscripten/system/include/SDL/SDL_syswm.h +241 -0
- data/modules/emscripten/system/include/SDL/SDL_thread.h +182 -0
- data/modules/emscripten/system/include/SDL/SDL_timer.h +108 -0
- data/modules/emscripten/system/include/SDL/SDL_touch.h +124 -0
- data/modules/emscripten/system/include/SDL/SDL_ttf.h +249 -0
- data/modules/emscripten/system/include/SDL/SDL_types.h +29 -0
- data/modules/emscripten/system/include/SDL/SDL_version.h +166 -0
- data/modules/emscripten/system/include/SDL/SDL_video.h +820 -0
- data/modules/emscripten/system/include/SDL/begin_code.h +135 -0
- data/modules/emscripten/system/include/SDL/close_code.h +37 -0
- data/modules/emscripten/system/include/X11/X.h +717 -0
- data/modules/emscripten/system/include/X11/Xatom.h +79 -0
- data/modules/emscripten/system/include/X11/Xfuncproto.h +127 -0
- data/modules/emscripten/system/include/X11/Xlib.h +4023 -0
- data/modules/emscripten/system/include/X11/Xosdefs.h +116 -0
- data/modules/emscripten/system/include/X11/Xutil.h +826 -0
- data/modules/emscripten/system/include/X11/keysym.h +73 -0
- data/modules/emscripten/system/include/X11/keysymdef.h +2389 -0
- data/modules/emscripten/system/include/bsd/float.h +91 -0
- data/modules/emscripten/system/include/bsd/readme.txt +2 -0
- data/modules/emscripten/system/include/bsd/sys/mman.h +180 -0
- data/modules/emscripten/system/include/bsd/sys/utsname.h +70 -0
- data/modules/emscripten/system/include/dlfcn.h +31 -0
- data/modules/emscripten/system/include/emscripten/bind.h +1210 -0
- data/modules/emscripten/system/include/emscripten/emscripten.h +388 -0
- data/modules/emscripten/system/include/emscripten/val.h +311 -0
- data/modules/emscripten/system/include/emscripten/wire.h +393 -0
- data/modules/emscripten/system/include/err.h +95 -0
- data/modules/emscripten/system/include/execinfo.h +44 -0
- data/modules/emscripten/system/include/features.h +3 -0
- data/modules/emscripten/system/include/gc.h +70 -0
- data/modules/emscripten/system/include/gfx/png.h +3798 -0
- data/modules/emscripten/system/include/gfx/pngconf.h +1665 -0
- data/modules/emscripten/system/include/gfx/tiff.h +654 -0
- data/modules/emscripten/system/include/gfx/tiffconf.h +104 -0
- data/modules/emscripten/system/include/gfx/tiffio.h +526 -0
- data/modules/emscripten/system/include/gfx/tiffvers.h +9 -0
- data/modules/emscripten/system/include/jansson.h +323 -0
- data/modules/emscripten/system/include/jansson_config.h +54 -0
- data/modules/emscripten/system/include/libc/_ansi.h +135 -0
- data/modules/emscripten/system/include/libc/_syslist.h +40 -0
- data/modules/emscripten/system/include/libc/alloca.h +21 -0
- data/modules/emscripten/system/include/libc/ar.h +69 -0
- data/modules/emscripten/system/include/libc/argz.h +33 -0
- data/modules/emscripten/system/include/libc/assert.h +46 -0
- data/modules/emscripten/system/include/libc/complex.h +124 -0
- data/modules/emscripten/system/include/libc/ctype.h +196 -0
- data/modules/emscripten/system/include/libc/dirent.h +16 -0
- data/modules/emscripten/system/include/libc/endian.h +3 -0
- data/modules/emscripten/system/include/libc/envlock.h +15 -0
- data/modules/emscripten/system/include/libc/envz.h +16 -0
- data/modules/emscripten/system/include/libc/errno.h +11 -0
- data/modules/emscripten/system/include/libc/fastmath.h +13 -0
- data/modules/emscripten/system/include/libc/fcntl.h +1 -0
- data/modules/emscripten/system/include/libc/fnmatch.h +55 -0
- data/modules/emscripten/system/include/libc/getopt.h +196 -0
- data/modules/emscripten/system/include/libc/glob.h +89 -0
- data/modules/emscripten/system/include/libc/grp.h +94 -0
- data/modules/emscripten/system/include/libc/iconv.h +62 -0
- data/modules/emscripten/system/include/libc/ieeefp.h +256 -0
- data/modules/emscripten/system/include/libc/ifaddrs.h +64 -0
- data/modules/emscripten/system/include/libc/inttypes.h +290 -0
- data/modules/emscripten/system/include/libc/iso646.h +43 -0
- data/modules/emscripten/system/include/libc/langinfo.h +316 -0
- data/modules/emscripten/system/include/libc/libgen.h +23 -0
- data/modules/emscripten/system/include/libc/limits.h +155 -0
- data/modules/emscripten/system/include/libc/locale.h +80 -0
- data/modules/emscripten/system/include/libc/machine/_default_types.h +121 -0
- data/modules/emscripten/system/include/libc/machine/_types.h +8 -0
- data/modules/emscripten/system/include/libc/machine/ansi.h +1 -0
- data/modules/emscripten/system/include/libc/machine/endian.h +31 -0
- data/modules/emscripten/system/include/libc/machine/fastmath.h +100 -0
- data/modules/emscripten/system/include/libc/machine/ieeefp.h +376 -0
- data/modules/emscripten/system/include/libc/machine/malloc.h +8 -0
- data/modules/emscripten/system/include/libc/machine/param.h +1 -0
- data/modules/emscripten/system/include/libc/machine/setjmp-dj.h +43 -0
- data/modules/emscripten/system/include/libc/machine/setjmp.h +361 -0
- data/modules/emscripten/system/include/libc/machine/stdlib.h +8 -0
- data/modules/emscripten/system/include/libc/machine/termios.h +1 -0
- data/modules/emscripten/system/include/libc/machine/time.h +19 -0
- data/modules/emscripten/system/include/libc/machine/types.h +30 -0
- data/modules/emscripten/system/include/libc/malloc.h +169 -0
- data/modules/emscripten/system/include/libc/math.h +594 -0
- data/modules/emscripten/system/include/libc/newlib.h +2 -0
- data/modules/emscripten/system/include/libc/paths.h +7 -0
- data/modules/emscripten/system/include/libc/process.h +44 -0
- data/modules/emscripten/system/include/libc/pthread.h +362 -0
- data/modules/emscripten/system/include/libc/pwd.h +78 -0
- data/modules/emscripten/system/include/libc/readme.txt +3 -0
- data/modules/emscripten/system/include/libc/reent.h +183 -0
- data/modules/emscripten/system/include/libc/regdef.h +7 -0
- data/modules/emscripten/system/include/libc/regex.h +102 -0
- data/modules/emscripten/system/include/libc/sched.h +97 -0
- data/modules/emscripten/system/include/libc/search.h +59 -0
- data/modules/emscripten/system/include/libc/setjmp.h +20 -0
- data/modules/emscripten/system/include/libc/signal.h +30 -0
- data/modules/emscripten/system/include/libc/stdarg.h +50 -0
- data/modules/emscripten/system/include/libc/stddef.h +64 -0
- data/modules/emscripten/system/include/libc/stdint.h +493 -0
- data/modules/emscripten/system/include/libc/stdio.h +694 -0
- data/modules/emscripten/system/include/libc/stdlib.h +230 -0
- data/modules/emscripten/system/include/libc/string.h +105 -0
- data/modules/emscripten/system/include/libc/strings.h +35 -0
- data/modules/emscripten/system/include/libc/sys/_default_fcntl.h +223 -0
- data/modules/emscripten/system/include/libc/sys/_types.h +93 -0
- data/modules/emscripten/system/include/libc/sys/cdefs.h +123 -0
- data/modules/emscripten/system/include/libc/sys/config.h +255 -0
- data/modules/emscripten/system/include/libc/sys/custom_file.h +2 -0
- data/modules/emscripten/system/include/libc/sys/dir.h +10 -0
- data/modules/emscripten/system/include/libc/sys/dirent.h +58 -0
- data/modules/emscripten/system/include/libc/sys/errno.h +190 -0
- data/modules/emscripten/system/include/libc/sys/fcntl.h +4 -0
- data/modules/emscripten/system/include/libc/sys/features.h +212 -0
- data/modules/emscripten/system/include/libc/sys/file.h +2 -0
- data/modules/emscripten/system/include/libc/sys/iconvnls.h +77 -0
- data/modules/emscripten/system/include/libc/sys/lock.h +24 -0
- data/modules/emscripten/system/include/libc/sys/param.h +25 -0
- data/modules/emscripten/system/include/libc/sys/queue.h +471 -0
- data/modules/emscripten/system/include/libc/sys/reent.h +843 -0
- data/modules/emscripten/system/include/libc/sys/resource.h +59 -0
- data/modules/emscripten/system/include/libc/sys/sched.h +67 -0
- data/modules/emscripten/system/include/libc/sys/signal.h +314 -0
- data/modules/emscripten/system/include/libc/sys/stat.h +222 -0
- data/modules/emscripten/system/include/libc/sys/stdio.h +27 -0
- data/modules/emscripten/system/include/libc/sys/string.h +2 -0
- data/modules/emscripten/system/include/libc/sys/syslimits.h +65 -0
- data/modules/emscripten/system/include/libc/sys/termios.h +280 -0
- data/modules/emscripten/system/include/libc/sys/time.h +85 -0
- data/modules/emscripten/system/include/libc/sys/timeb.h +39 -0
- data/modules/emscripten/system/include/libc/sys/times.h +28 -0
- data/modules/emscripten/system/include/libc/sys/ttydefaults.h +97 -0
- data/modules/emscripten/system/include/libc/sys/types.h +481 -0
- data/modules/emscripten/system/include/libc/sys/unistd.h +514 -0
- data/modules/emscripten/system/include/libc/sys/utime.h +26 -0
- data/modules/emscripten/system/include/libc/sys/wait.h +40 -0
- data/modules/emscripten/system/include/libc/tar.h +39 -0
- data/modules/emscripten/system/include/libc/termios.h +7 -0
- data/modules/emscripten/system/include/libc/time.h +273 -0
- data/modules/emscripten/system/include/libc/unctrl.h +46 -0
- data/modules/emscripten/system/include/libc/unistd.h +6 -0
- data/modules/emscripten/system/include/libc/utime.h +12 -0
- data/modules/emscripten/system/include/libc/utmp.h +8 -0
- data/modules/emscripten/system/include/libc/wchar.h +194 -0
- data/modules/emscripten/system/include/libc/wctype.h +47 -0
- data/modules/emscripten/system/include/libc/wordexp.h +53 -0
- data/modules/emscripten/system/include/libcxx/CREDITS.TXT +91 -0
- data/modules/emscripten/system/include/libcxx/LICENSE.txt +76 -0
- data/modules/emscripten/system/include/libcxx/__bit_reference +1268 -0
- data/modules/emscripten/system/include/libcxx/__config +485 -0
- data/modules/emscripten/system/include/libcxx/__debug +193 -0
- data/modules/emscripten/system/include/libcxx/__functional_03 +2130 -0
- data/modules/emscripten/system/include/libcxx/__functional_base +437 -0
- data/modules/emscripten/system/include/libcxx/__functional_base_03 +1087 -0
- data/modules/emscripten/system/include/libcxx/__hash_table +1945 -0
- data/modules/emscripten/system/include/libcxx/__locale +1435 -0
- data/modules/emscripten/system/include/libcxx/__mutex_base +438 -0
- data/modules/emscripten/system/include/libcxx/__split_buffer +654 -0
- data/modules/emscripten/system/include/libcxx/__sso_allocator +77 -0
- data/modules/emscripten/system/include/libcxx/__std_stream +317 -0
- data/modules/emscripten/system/include/libcxx/__tree +2293 -0
- data/modules/emscripten/system/include/libcxx/__tuple +305 -0
- data/modules/emscripten/system/include/libcxx/__tuple_03 +27 -0
- data/modules/emscripten/system/include/libcxx/__undef_min_max +19 -0
- data/modules/emscripten/system/include/libcxx/algorithm +5458 -0
- data/modules/emscripten/system/include/libcxx/array +341 -0
- data/modules/emscripten/system/include/libcxx/atomic +1521 -0
- data/modules/emscripten/system/include/libcxx/bitset +1081 -0
- data/modules/emscripten/system/include/libcxx/cassert +25 -0
- data/modules/emscripten/system/include/libcxx/ccomplex +29 -0
- data/modules/emscripten/system/include/libcxx/cctype +164 -0
- data/modules/emscripten/system/include/libcxx/cerrno +393 -0
- data/modules/emscripten/system/include/libcxx/cfenv +82 -0
- data/modules/emscripten/system/include/libcxx/cfloat +78 -0
- data/modules/emscripten/system/include/libcxx/chrono +898 -0
- data/modules/emscripten/system/include/libcxx/cinttypes +259 -0
- data/modules/emscripten/system/include/libcxx/ciso646 +25 -0
- data/modules/emscripten/system/include/libcxx/climits +48 -0
- data/modules/emscripten/system/include/libcxx/clocale +53 -0
- data/modules/emscripten/system/include/libcxx/cmath +1683 -0
- data/modules/emscripten/system/include/libcxx/codecvt +547 -0
- data/modules/emscripten/system/include/libcxx/complex +1526 -0
- data/modules/emscripten/system/include/libcxx/complex.h +35 -0
- data/modules/emscripten/system/include/libcxx/condition_variable +256 -0
- data/modules/emscripten/system/include/libcxx/csetjmp +52 -0
- data/modules/emscripten/system/include/libcxx/csignal +58 -0
- data/modules/emscripten/system/include/libcxx/cstdarg +48 -0
- data/modules/emscripten/system/include/libcxx/cstdbool +32 -0
- data/modules/emscripten/system/include/libcxx/cstddef +103 -0
- data/modules/emscripten/system/include/libcxx/cstdint +191 -0
- data/modules/emscripten/system/include/libcxx/cstdio +175 -0
- data/modules/emscripten/system/include/libcxx/cstdlib +172 -0
- data/modules/emscripten/system/include/libcxx/cstring +112 -0
- data/modules/emscripten/system/include/libcxx/ctgmath +29 -0
- data/modules/emscripten/system/include/libcxx/ctime +72 -0
- data/modules/emscripten/system/include/libcxx/cwchar +208 -0
- data/modules/emscripten/system/include/libcxx/cwctype +213 -0
- data/modules/emscripten/system/include/libcxx/deque +2846 -0
- data/modules/emscripten/system/include/libcxx/exception +250 -0
- data/modules/emscripten/system/include/libcxx/ext/__hash +46 -0
- data/modules/emscripten/system/include/libcxx/ext/hash_map +1003 -0
- data/modules/emscripten/system/include/libcxx/ext/hash_set +657 -0
- data/modules/emscripten/system/include/libcxx/forward_list +1636 -0
- data/modules/emscripten/system/include/libcxx/fstream +1415 -0
- data/modules/emscripten/system/include/libcxx/functional +2063 -0
- data/modules/emscripten/system/include/libcxx/future +2505 -0
- data/modules/emscripten/system/include/libcxx/initializer_list +105 -0
- data/modules/emscripten/system/include/libcxx/iomanip +504 -0
- data/modules/emscripten/system/include/libcxx/ios +988 -0
- data/modules/emscripten/system/include/libcxx/iosfwd +194 -0
- data/modules/emscripten/system/include/libcxx/iostream +60 -0
- data/modules/emscripten/system/include/libcxx/istream +1713 -0
- data/modules/emscripten/system/include/libcxx/iterator +1869 -0
- data/modules/emscripten/system/include/libcxx/limits +809 -0
- data/modules/emscripten/system/include/libcxx/list +2275 -0
- data/modules/emscripten/system/include/libcxx/locale +4591 -0
- data/modules/emscripten/system/include/libcxx/map +1924 -0
- data/modules/emscripten/system/include/libcxx/memory +5437 -0
- data/modules/emscripten/system/include/libcxx/mutex +566 -0
- data/modules/emscripten/system/include/libcxx/new +117 -0
- data/modules/emscripten/system/include/libcxx/numeric +197 -0
- data/modules/emscripten/system/include/libcxx/ostream +1286 -0
- data/modules/emscripten/system/include/libcxx/queue +717 -0
- data/modules/emscripten/system/include/libcxx/random +6750 -0
- data/modules/emscripten/system/include/libcxx/ratio +487 -0
- data/modules/emscripten/system/include/libcxx/readme.txt +1 -0
- data/modules/emscripten/system/include/libcxx/regex +6439 -0
- data/modules/emscripten/system/include/libcxx/scoped_allocator +578 -0
- data/modules/emscripten/system/include/libcxx/set +1025 -0
- data/modules/emscripten/system/include/libcxx/sstream +888 -0
- data/modules/emscripten/system/include/libcxx/stack +292 -0
- data/modules/emscripten/system/include/libcxx/stdexcept +162 -0
- data/modules/emscripten/system/include/libcxx/streambuf +564 -0
- data/modules/emscripten/system/include/libcxx/string +3987 -0
- data/modules/emscripten/system/include/libcxx/strstream +400 -0
- data/modules/emscripten/system/include/libcxx/support/solaris/floatingpoint.h +5 -0
- data/modules/emscripten/system/include/libcxx/support/solaris/wchar.h +38 -0
- data/modules/emscripten/system/include/libcxx/support/solaris/xlocale.h +146 -0
- data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +79 -0
- data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +116 -0
- data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +113 -0
- data/modules/emscripten/system/include/libcxx/support/win32/support.h +115 -0
- data/modules/emscripten/system/include/libcxx/system_error +636 -0
- data/modules/emscripten/system/include/libcxx/tgmath.h +29 -0
- data/modules/emscripten/system/include/libcxx/thread +459 -0
- data/modules/emscripten/system/include/libcxx/tuple +1092 -0
- data/modules/emscripten/system/include/libcxx/type_traits +3040 -0
- data/modules/emscripten/system/include/libcxx/typeindex +103 -0
- data/modules/emscripten/system/include/libcxx/typeinfo +124 -0
- data/modules/emscripten/system/include/libcxx/unordered_map +1864 -0
- data/modules/emscripten/system/include/libcxx/unordered_set +1144 -0
- data/modules/emscripten/system/include/libcxx/utility +583 -0
- data/modules/emscripten/system/include/libcxx/valarray +4779 -0
- data/modules/emscripten/system/include/libcxx/vector +3228 -0
- data/modules/emscripten/system/include/memory.h +10 -0
- data/modules/emscripten/system/include/mntent.h +23 -0
- data/modules/emscripten/system/include/net/arpa/inet.h +32 -0
- data/modules/emscripten/system/include/net/arpa/nameser.h +535 -0
- data/modules/emscripten/system/include/net/arpa/nameser_compat.h +187 -0
- data/modules/emscripten/system/include/net/if.h +87 -0
- data/modules/emscripten/system/include/net/netinet/in.h +166 -0
- data/modules/emscripten/system/include/net/netinet/tcp.h +246 -0
- data/modules/emscripten/system/include/net/resolv.h +389 -0
- data/modules/emscripten/system/include/netdb.h +94 -0
- data/modules/emscripten/system/include/nl_types.h +19 -0
- data/modules/emscripten/system/include/poll.h +3 -0
- data/modules/emscripten/system/include/pty.h +6 -0
- data/modules/emscripten/system/include/semaphore.h +31 -0
- data/modules/emscripten/system/include/spawn.h +105 -0
- data/modules/emscripten/system/include/stdbool.h +16 -0
- data/modules/emscripten/system/include/sys/bitypes.h +3 -0
- data/modules/emscripten/system/include/sys/io.h +14 -0
- data/modules/emscripten/system/include/sys/ioctl.h +26 -0
- data/modules/emscripten/system/include/sys/poll.h +31 -0
- data/modules/emscripten/system/include/sys/select.h +14 -0
- data/modules/emscripten/system/include/sys/socket.h +101 -0
- data/modules/emscripten/system/include/sys/socketvar.h +3 -0
- data/modules/emscripten/system/include/sys/statvfs.h +32 -0
- data/modules/emscripten/system/include/sys/sysctl.h +14 -0
- data/modules/emscripten/system/include/sys/uio.h +22 -0
- data/modules/emscripten/system/include/sys/un.h +66 -0
- data/modules/emscripten/system/include/sysexits.h +108 -0
- data/modules/emscripten/system/include/unwind.h +154 -0
- data/modules/emscripten/system/include/xlocale.h +47 -0
- data/modules/emscripten/system/include/zconf.h +428 -0
- data/modules/emscripten/system/include/zlib.h +1613 -0
- data/modules/emscripten/system/lib/compiler-rt/LICENSE.TXT +97 -0
- data/modules/emscripten/system/lib/compiler-rt/divdi3.c +47 -0
- data/modules/emscripten/system/lib/compiler-rt/int_endianness.h +116 -0
- data/modules/emscripten/system/lib/compiler-rt/int_lib.h +46 -0
- data/modules/emscripten/system/lib/compiler-rt/int_math.h +67 -0
- data/modules/emscripten/system/lib/compiler-rt/int_types.h +140 -0
- data/modules/emscripten/system/lib/compiler-rt/int_util.h +29 -0
- data/modules/emscripten/system/lib/compiler-rt/muldi3.c +56 -0
- data/modules/emscripten/system/lib/compiler-rt/readme.txt +20 -0
- data/modules/emscripten/system/lib/compiler-rt/udivdi3.c +36 -0
- data/modules/emscripten/system/lib/compiler-rt/udivmoddi4.c +251 -0
- data/modules/emscripten/system/lib/debugging.cpp +24 -0
- data/modules/emscripten/system/lib/dlmalloc.c +6299 -0
- data/modules/emscripten/system/lib/embind/bind.cpp +63 -0
- data/modules/emscripten/system/lib/libc/gen/err.c +49 -0
- data/modules/emscripten/system/lib/libc/gen/errx.c +49 -0
- data/modules/emscripten/system/lib/libc/gen/verr.c +58 -0
- data/modules/emscripten/system/lib/libc/gen/verrx.c +51 -0
- data/modules/emscripten/system/lib/libc/gen/vwarn.c +55 -0
- data/modules/emscripten/system/lib/libc/gen/vwarnx.c +48 -0
- data/modules/emscripten/system/lib/libc/gen/warn.c +49 -0
- data/modules/emscripten/system/lib/libc/gen/warnx.c +49 -0
- data/modules/emscripten/system/lib/libc/musl/COPYRIGHT +92 -0
- data/modules/emscripten/system/lib/libc/musl/readme.txt +1 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/alpha.h +125 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalnum.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalpha.c +14 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswblank.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswcntrl.c +10 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswctype.c +63 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswdigit.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswgraph.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswlower.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswprint.c +19 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswpunct.c +12 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswspace.c +19 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswupper.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/iswxdigit.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/nonspacing.h +62 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/punct.h +109 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/towctrans.c +268 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wcswidth.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wctrans.c +16 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wcwidth.c +29 -0
- data/modules/emscripten/system/lib/libc/musl/src/ctype/wide.h +42 -0
- data/modules/emscripten/system/lib/libc/musl/src/internal/libc.c +22 -0
- data/modules/emscripten/system/lib/libc/musl/src/internal/libc.h +71 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/btowc.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.c +38 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.h +22 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mblen.c +17 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrlen.c +18 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrtowc.c +57 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsinit.c +17 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsnrtowcs.c +65 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsrtowcs.c +100 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbstowcs.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbtowc.c +53 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcrtomb.c +38 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsnrtombs.c +52 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsrtombs.c +58 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcstombs.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctob.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctomb.c +18 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcpcpy.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcpncpy.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscat.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcschr.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscmp.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscpy.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcscspn.c +10 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsdup.c +11 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcslen.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp_l.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncat.c +10 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncmp.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsncpy.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsnlen.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcspbrk.c +7 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsrchr.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsspn.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcsstr.c +108 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcstok.c +12 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wcswcs.c +6 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemchr.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemcmp.c +8 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemcpy.c +9 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemmove.c +12 -0
- data/modules/emscripten/system/lib/libc/musl/src/string/wmemset.c +9 -0
- data/modules/emscripten/system/lib/libc/stdlib/getopt_long.c +511 -0
- data/modules/emscripten/system/lib/libc/stdlib/strtod.c +305 -0
- data/modules/emscripten/system/lib/libc.symbols +81 -0
- data/modules/emscripten/system/lib/libcextra.symbols +61 -0
- data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +91 -0
- data/modules/emscripten/system/lib/libcxx/LICENSE.txt +76 -0
- data/modules/emscripten/system/lib/libcxx/algorithm.cpp +83 -0
- data/modules/emscripten/system/lib/libcxx/bind.cpp +30 -0
- data/modules/emscripten/system/lib/libcxx/chrono.cpp +132 -0
- data/modules/emscripten/system/lib/libcxx/condition_variable.cpp +81 -0
- data/modules/emscripten/system/lib/libcxx/debug.cpp +504 -0
- data/modules/emscripten/system/lib/libcxx/exception.cpp +226 -0
- data/modules/emscripten/system/lib/libcxx/future.cpp +285 -0
- data/modules/emscripten/system/lib/libcxx/hash.cpp +564 -0
- data/modules/emscripten/system/lib/libcxx/ios.cpp +455 -0
- data/modules/emscripten/system/lib/libcxx/iostream.cpp +68 -0
- data/modules/emscripten/system/lib/libcxx/locale.cpp +6093 -0
- data/modules/emscripten/system/lib/libcxx/memory.cpp +223 -0
- data/modules/emscripten/system/lib/libcxx/mutex.cpp +250 -0
- data/modules/emscripten/system/lib/libcxx/new.cpp +205 -0
- data/modules/emscripten/system/lib/libcxx/random.cpp +48 -0
- data/modules/emscripten/system/lib/libcxx/readme.txt +1 -0
- data/modules/emscripten/system/lib/libcxx/regex.cpp +325 -0
- data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +196 -0
- data/modules/emscripten/system/lib/libcxx/string.cpp +687 -0
- data/modules/emscripten/system/lib/libcxx/strstream.cpp +329 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/README +4 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/mbsnrtowcs.inc +76 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/wcsnrtombs.inc +93 -0
- data/modules/emscripten/system/lib/libcxx/support/solaris/xlocale.c +245 -0
- data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +94 -0
- data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +70 -0
- data/modules/emscripten/system/lib/libcxx/symbols +2927 -0
- data/modules/emscripten/system/lib/libcxx/system_error.cpp +201 -0
- data/modules/emscripten/system/lib/libcxx/thread.cpp +208 -0
- data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +60 -0
- data/modules/emscripten/system/lib/libcxx/utility.cpp +17 -0
- data/modules/emscripten/system/lib/libcxx/valarray.cpp +54 -0
- data/modules/emscripten/system/lib/libcxxabi/CREDITS.TXT +38 -0
- data/modules/emscripten/system/lib/libcxxabi/LICENSE.TXT +76 -0
- data/modules/emscripten/system/lib/libcxxabi/include/cxa_demangle.h +167 -0
- data/modules/emscripten/system/lib/libcxxabi/include/cxxabi.h +175 -0
- data/modules/emscripten/system/lib/libcxxabi/lib/buildit +99 -0
- data/modules/emscripten/system/lib/libcxxabi/readme.txt +1 -0
- data/modules/emscripten/system/lib/libcxxabi/src/abort_message.cpp +50 -0
- data/modules/emscripten/system/lib/libcxxabi/src/abort_message.h +33 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_aux_runtime.cpp +34 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_demangle.cpp +11036 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.cpp +622 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.hpp +123 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception_storage.cpp +91 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_guard.cpp +231 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.cpp +125 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.hpp +54 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_new_delete.cpp +242 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_personality.cpp +1055 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_unexpected.cpp +27 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_vector.cpp +367 -0
- data/modules/emscripten/system/lib/libcxxabi/src/cxa_virtual.cpp +31 -0
- data/modules/emscripten/system/lib/libcxxabi/src/exception.cpp +41 -0
- data/modules/emscripten/system/lib/libcxxabi/src/fallback_malloc.ipp +174 -0
- data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.cpp +1146 -0
- data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.h +248 -0
- data/modules/emscripten/system/lib/libcxxabi/src/stdexcept.cpp +169 -0
- data/modules/emscripten/system/lib/libcxxabi/src/typeinfo.cpp +53 -0
- data/modules/emscripten/system/lib/libcxxabi/symbols +236 -0
- data/modules/emscripten/system/lib/sdl.cpp +13 -0
- data/modules/emscripten/system/lib/sdl.symbols +1 -0
- data/modules/emscripten/tests/hello_world.js +92 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/CppHeaderParser.py +2347 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/__init__.py +4 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/doc/CppHeaderParser.html +657 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/SampleClass.h +147 -0
- data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/readSampleClass.py +74 -0
- data/modules/emscripten/third_party/CppHeaderParser/PKG-INFO +249 -0
- data/modules/emscripten/third_party/CppHeaderParser/README.html +544 -0
- data/modules/emscripten/third_party/CppHeaderParser/README.txt +226 -0
- data/modules/emscripten/third_party/CppHeaderParser/setup.py +43 -0
- data/modules/emscripten/third_party/ansidecl.h +371 -0
- data/modules/emscripten/third_party/closure-compiler/COPYING +202 -0
- data/modules/emscripten/third_party/closure-compiler/README +292 -0
- data/modules/emscripten/third_party/closure-compiler/compiler.jar +0 -0
- data/modules/emscripten/third_party/closure-compiler/readme.txt +3 -0
- data/modules/emscripten/third_party/cp-demangle.h +161 -0
- data/modules/emscripten/third_party/demangle.h +549 -0
- data/modules/emscripten/third_party/demangler.py +49 -0
- data/modules/emscripten/third_party/gcc_demangler.c +4226 -0
- data/modules/emscripten/third_party/gcc_demangler.js +21282 -0
- data/modules/emscripten/third_party/jni/emjvm.cpp +133 -0
- data/modules/emscripten/third_party/jni/emjvm.h +8 -0
- data/modules/emscripten/third_party/jni/emjvm.js +185 -0
- data/modules/emscripten/third_party/jni/jni.h +1154 -0
- data/modules/emscripten/third_party/libiberty.h +634 -0
- data/modules/emscripten/third_party/lzma.js/README.markdown +37 -0
- data/modules/emscripten/third_party/lzma.js/doit.sh +37 -0
- data/modules/emscripten/third_party/lzma.js/lzip/AUTHORS +7 -0
- data/modules/emscripten/third_party/lzma.js/lzip/COPYING +676 -0
- data/modules/emscripten/third_party/lzma.js/lzip/ChangeLog +201 -0
- data/modules/emscripten/third_party/lzma.js/lzip/INSTALL +56 -0
- data/modules/emscripten/third_party/lzma.js/lzip/Makefile +160 -0
- data/modules/emscripten/third_party/lzma.js/lzip/Makefile.in +138 -0
- data/modules/emscripten/third_party/lzma.js/lzip/NEWS +22 -0
- data/modules/emscripten/third_party/lzma.js/lzip/README +77 -0
- data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.cc +204 -0
- data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.h +106 -0
- data/modules/emscripten/third_party/lzma.js/lzip/configure +192 -0
- data/modules/emscripten/third_party/lzma.js/lzip/decoder.cc +252 -0
- data/modules/emscripten/third_party/lzma.js/lzip/decoder.h +268 -0
- data/modules/emscripten/third_party/lzma.js/lzip/encoder.cc +643 -0
- data/modules/emscripten/third_party/lzma.js/lzip/encoder.h +582 -0
- data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.cc +378 -0
- data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.h +171 -0
- data/modules/emscripten/third_party/lzma.js/lzip/lzip.h +264 -0
- data/modules/emscripten/third_party/lzma.js/lzip/main.cc +545 -0
- data/modules/emscripten/third_party/lzma.js/lzma-decoder.js +27 -0
- data/modules/emscripten/third_party/lzma.js/lzma-full.js +27 -0
- data/modules/emscripten/third_party/lzma.js/native_test.sh +5 -0
- data/modules/emscripten/third_party/lzma.js/post.js +13 -0
- data/modules/emscripten/third_party/lzma.js/pre.js +13 -0
- data/modules/emscripten/third_party/lzma.js/test-decoder.js +39 -0
- data/modules/emscripten/third_party/lzma.js/test-full.html +9 -0
- data/modules/emscripten/third_party/lzma.js/test-full.js +78 -0
- data/modules/emscripten/third_party/ply/ANNOUNCE +40 -0
- data/modules/emscripten/third_party/ply/CHANGES +1093 -0
- data/modules/emscripten/third_party/ply/PKG-INFO +22 -0
- data/modules/emscripten/third_party/ply/README +271 -0
- data/modules/emscripten/third_party/ply/TODO +16 -0
- data/modules/emscripten/third_party/ply/doc/internal.html +874 -0
- data/modules/emscripten/third_party/ply/doc/makedoc.py +194 -0
- data/modules/emscripten/third_party/ply/doc/ply.html +3262 -0
- data/modules/emscripten/third_party/ply/example/BASIC/README +79 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basic.py +71 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basiclex.py +74 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basiclog.py +79 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basinterp.py +441 -0
- data/modules/emscripten/third_party/ply/example/BASIC/basparse.py +424 -0
- data/modules/emscripten/third_party/ply/example/BASIC/dim.bas +14 -0
- data/modules/emscripten/third_party/ply/example/BASIC/func.bas +5 -0
- data/modules/emscripten/third_party/ply/example/BASIC/gcd.bas +22 -0
- data/modules/emscripten/third_party/ply/example/BASIC/gosub.bas +13 -0
- data/modules/emscripten/third_party/ply/example/BASIC/hello.bas +4 -0
- data/modules/emscripten/third_party/ply/example/BASIC/linear.bas +17 -0
- data/modules/emscripten/third_party/ply/example/BASIC/maxsin.bas +12 -0
- data/modules/emscripten/third_party/ply/example/BASIC/powers.bas +13 -0
- data/modules/emscripten/third_party/ply/example/BASIC/rand.bas +4 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sales.bas +20 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sears.bas +18 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sqrt1.bas +5 -0
- data/modules/emscripten/third_party/ply/example/BASIC/sqrt2.bas +4 -0
- data/modules/emscripten/third_party/ply/example/GardenSnake/GardenSnake.py +709 -0
- data/modules/emscripten/third_party/ply/example/GardenSnake/README +5 -0
- data/modules/emscripten/third_party/ply/example/README +10 -0
- data/modules/emscripten/third_party/ply/example/ansic/README +2 -0
- data/modules/emscripten/third_party/ply/example/ansic/clex.py +164 -0
- data/modules/emscripten/third_party/ply/example/ansic/cparse.py +863 -0
- data/modules/emscripten/third_party/ply/example/calc/calc.py +107 -0
- data/modules/emscripten/third_party/ply/example/calcdebug/calc.py +113 -0
- data/modules/emscripten/third_party/ply/example/classcalc/calc.py +157 -0
- data/modules/emscripten/third_party/ply/example/cleanup.sh +2 -0
- data/modules/emscripten/third_party/ply/example/closurecalc/calc.py +130 -0
- data/modules/emscripten/third_party/ply/example/hedit/hedit.py +48 -0
- data/modules/emscripten/third_party/ply/example/newclasscalc/calc.py +160 -0
- data/modules/emscripten/third_party/ply/example/optcalc/README +9 -0
- data/modules/emscripten/third_party/ply/example/optcalc/calc.py +119 -0
- data/modules/emscripten/third_party/ply/example/unicalc/calc.py +117 -0
- data/modules/emscripten/third_party/ply/example/yply/README +41 -0
- data/modules/emscripten/third_party/ply/example/yply/ylex.py +112 -0
- data/modules/emscripten/third_party/ply/example/yply/yparse.py +217 -0
- data/modules/emscripten/third_party/ply/example/yply/yply.py +53 -0
- data/modules/emscripten/third_party/ply/ply/__init__.py +4 -0
- data/modules/emscripten/third_party/ply/ply/cpp.py +898 -0
- data/modules/emscripten/third_party/ply/ply/ctokens.py +133 -0
- data/modules/emscripten/third_party/ply/ply/lex.py +1058 -0
- data/modules/emscripten/third_party/ply/ply/yacc.py +3276 -0
- data/modules/emscripten/third_party/ply/setup.py +31 -0
- data/modules/emscripten/third_party/ply/test/README +7 -0
- data/modules/emscripten/third_party/ply/test/calclex.py +49 -0
- data/modules/emscripten/third_party/ply/test/cleanup.sh +4 -0
- data/modules/emscripten/third_party/ply/test/lex_closure.py +54 -0
- data/modules/emscripten/third_party/ply/test/lex_doc1.py +26 -0
- data/modules/emscripten/third_party/ply/test/lex_dup1.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_dup2.py +33 -0
- data/modules/emscripten/third_party/ply/test/lex_dup3.py +31 -0
- data/modules/emscripten/third_party/ply/test/lex_empty.py +20 -0
- data/modules/emscripten/third_party/ply/test/lex_error1.py +24 -0
- data/modules/emscripten/third_party/ply/test/lex_error2.py +26 -0
- data/modules/emscripten/third_party/ply/test/lex_error3.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_error4.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_hedit.py +47 -0
- data/modules/emscripten/third_party/ply/test/lex_ignore.py +31 -0
- data/modules/emscripten/third_party/ply/test/lex_ignore2.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_literal1.py +25 -0
- data/modules/emscripten/third_party/ply/test/lex_literal2.py +25 -0
- data/modules/emscripten/third_party/ply/test/lex_many_tokens.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_module.py +10 -0
- data/modules/emscripten/third_party/ply/test/lex_module_import.py +42 -0
- data/modules/emscripten/third_party/ply/test/lex_object.py +55 -0
- data/modules/emscripten/third_party/ply/test/lex_opt_alias.py +54 -0
- data/modules/emscripten/third_party/ply/test/lex_optimize.py +50 -0
- data/modules/emscripten/third_party/ply/test/lex_optimize2.py +50 -0
- data/modules/emscripten/third_party/ply/test/lex_optimize3.py +52 -0
- data/modules/emscripten/third_party/ply/test/lex_re1.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_re2.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_re3.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_rule1.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_rule2.py +29 -0
- data/modules/emscripten/third_party/ply/test/lex_rule3.py +27 -0
- data/modules/emscripten/third_party/ply/test/lex_state1.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state2.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state3.py +42 -0
- data/modules/emscripten/third_party/ply/test/lex_state4.py +41 -0
- data/modules/emscripten/third_party/ply/test/lex_state5.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state_noerror.py +39 -0
- data/modules/emscripten/third_party/ply/test/lex_state_norule.py +40 -0
- data/modules/emscripten/third_party/ply/test/lex_state_try.py +45 -0
- data/modules/emscripten/third_party/ply/test/lex_token1.py +19 -0
- data/modules/emscripten/third_party/ply/test/lex_token2.py +22 -0
- data/modules/emscripten/third_party/ply/test/lex_token3.py +24 -0
- data/modules/emscripten/third_party/ply/test/lex_token4.py +26 -0
- data/modules/emscripten/third_party/ply/test/lex_token5.py +31 -0
- data/modules/emscripten/third_party/ply/test/lex_token_dup.py +29 -0
- data/modules/emscripten/third_party/ply/test/testlex.py +606 -0
- data/modules/emscripten/third_party/ply/test/testyacc.py +347 -0
- data/modules/emscripten/third_party/ply/test/yacc_badargs.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badid.py +77 -0
- data/modules/emscripten/third_party/ply/test/yacc_badprec.py +64 -0
- data/modules/emscripten/third_party/ply/test/yacc_badprec2.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badprec3.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badrule.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_badtok.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_dup.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_error1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_error2.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_error3.py +67 -0
- data/modules/emscripten/third_party/ply/test/yacc_error4.py +72 -0
- data/modules/emscripten/third_party/ply/test/yacc_inf.py +56 -0
- data/modules/emscripten/third_party/ply/test/yacc_literal.py +69 -0
- data/modules/emscripten/third_party/ply/test/yacc_misplaced.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_missing1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_nested.py +33 -0
- data/modules/emscripten/third_party/ply/test/yacc_nodoc.py +67 -0
- data/modules/emscripten/third_party/ply/test/yacc_noerror.py +66 -0
- data/modules/emscripten/third_party/ply/test/yacc_nop.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_notfunc.py +66 -0
- data/modules/emscripten/third_party/ply/test/yacc_notok.py +67 -0
- data/modules/emscripten/third_party/ply/test/yacc_prec1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_rr.py +72 -0
- data/modules/emscripten/third_party/ply/test/yacc_rr_unused.py +30 -0
- data/modules/emscripten/third_party/ply/test/yacc_simple.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_sr.py +63 -0
- data/modules/emscripten/third_party/ply/test/yacc_term1.py +68 -0
- data/modules/emscripten/third_party/ply/test/yacc_unused.py +77 -0
- data/modules/emscripten/third_party/ply/test/yacc_unused_rule.py +72 -0
- data/modules/emscripten/third_party/ply/test/yacc_uprec.py +63 -0
- data/modules/emscripten/third_party/ply/test/yacc_uprec2.py +63 -0
- data/modules/emscripten/third_party/readme.txt +7 -0
- data/modules/emscripten/third_party/websockify/CHANGES.txt +23 -0
- data/modules/emscripten/third_party/websockify/LICENSE.txt +16 -0
- data/modules/emscripten/third_party/websockify/MANIFEST.in +1 -0
- data/modules/emscripten/third_party/websockify/Makefile +11 -0
- data/modules/emscripten/third_party/websockify/README.md +168 -0
- data/modules/emscripten/third_party/websockify/Windows/Windows Service Readme.txt +39 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Program.cs +24 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs +61 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.cs +19 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.resx +129 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs +36 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.Designer.cs +37 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.cs +41 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj +75 -0
- data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.sln +20 -0
- data/modules/emscripten/third_party/websockify/docs/LICENSE.GPL-3 +621 -0
- data/modules/emscripten/third_party/websockify/docs/LICENSE.LGPL-3 +165 -0
- data/modules/emscripten/third_party/websockify/docs/LICENSE.MPL-2.0 +373 -0
- data/modules/emscripten/third_party/websockify/docs/TODO +9 -0
- data/modules/emscripten/third_party/websockify/docs/flash_policy.txt +4 -0
- data/modules/emscripten/third_party/websockify/docs/latency_results.txt +114 -0
- data/modules/emscripten/third_party/websockify/docs/notes +17 -0
- data/modules/emscripten/third_party/websockify/docs/release.txt +9 -0
- data/modules/emscripten/third_party/websockify/docs/websockify.1 +110 -0
- data/modules/emscripten/third_party/websockify/include/VT100.js +919 -0
- data/modules/emscripten/third_party/websockify/include/base64.js +114 -0
- data/modules/emscripten/third_party/websockify/include/keysym.js +99 -0
- data/modules/emscripten/third_party/websockify/include/util.js +359 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/README.txt +109 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/WebSocketMain.swf +0 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/swfobject.js +4 -0
- data/modules/emscripten/third_party/websockify/include/web-socket-js/web_socket.js +391 -0
- data/modules/emscripten/third_party/websockify/include/websock.js +422 -0
- data/modules/emscripten/third_party/websockify/include/webutil.js +216 -0
- data/modules/emscripten/third_party/websockify/include/wsirc.js +235 -0
- data/modules/emscripten/third_party/websockify/include/wstelnet.js +335 -0
- data/modules/emscripten/third_party/websockify/other/Makefile +14 -0
- data/modules/emscripten/third_party/websockify/other/README.md +51 -0
- data/modules/emscripten/third_party/websockify/other/launch.sh +108 -0
- data/modules/emscripten/third_party/websockify/other/project.clj +13 -0
- data/modules/emscripten/third_party/websockify/other/websocket.c +802 -0
- data/modules/emscripten/third_party/websockify/other/websocket.h +84 -0
- data/modules/emscripten/third_party/websockify/other/websocket.rb +456 -0
- data/modules/emscripten/third_party/websockify/other/websockify.c +385 -0
- data/modules/emscripten/third_party/websockify/other/websockify.clj +233 -0
- data/modules/emscripten/third_party/websockify/other/websockify.js +196 -0
- data/modules/emscripten/third_party/websockify/other/websockify.rb +171 -0
- data/modules/emscripten/third_party/websockify/other/wswrap +22 -0
- data/modules/emscripten/third_party/websockify/rebind +18 -0
- data/modules/emscripten/third_party/websockify/rebind.c +94 -0
- data/modules/emscripten/third_party/websockify/run +5 -0
- data/modules/emscripten/third_party/websockify/setup.py +30 -0
- data/modules/emscripten/third_party/websockify/tests/b64_vs_utf8.py +29 -0
- data/modules/emscripten/third_party/websockify/tests/base64.html +91 -0
- data/modules/emscripten/third_party/websockify/tests/base64.js +12 -0
- data/modules/emscripten/third_party/websockify/tests/echo.html +148 -0
- data/modules/emscripten/third_party/websockify/tests/echo.py +75 -0
- data/modules/emscripten/third_party/websockify/tests/echo.rb +62 -0
- data/modules/emscripten/third_party/websockify/tests/latency.html +290 -0
- data/modules/emscripten/third_party/websockify/tests/latency.py +75 -0
- data/modules/emscripten/third_party/websockify/tests/load.html +250 -0
- data/modules/emscripten/third_party/websockify/tests/load.py +167 -0
- data/modules/emscripten/third_party/websockify/tests/plain_echo.html +168 -0
- data/modules/emscripten/third_party/websockify/tests/simple.html +68 -0
- data/modules/emscripten/third_party/websockify/tests/utf8-list.py +22 -0
- data/modules/emscripten/third_party/websockify/websockify/__init__.py +2 -0
- data/modules/emscripten/third_party/websockify/websockify/websocket.py +982 -0
- data/modules/emscripten/third_party/websockify/websockify/websocketproxy.py +393 -0
- data/modules/emscripten/third_party/websockify/websockify.py +5 -0
- data/modules/emscripten/third_party/websockify/wsirc.html +99 -0
- data/modules/emscripten/third_party/websockify/wstelnet.html +74 -0
- data/modules/emscripten/tools/__init__.py +0 -0
- data/modules/emscripten/tools/__init__.pyc +0 -0
- data/modules/emscripten/tools/autodebugger.py +289 -0
- data/modules/emscripten/tools/autodebugger_c.py +37 -0
- data/modules/emscripten/tools/autodebugger_indenter.py +18 -0
- data/modules/emscripten/tools/autodebugger_js.py +47 -0
- data/modules/emscripten/tools/autodediffer.py +60 -0
- data/modules/emscripten/tools/bindings_generator.py +832 -0
- data/modules/emscripten/tools/bisect_pair.py +88 -0
- data/modules/emscripten/tools/cache.py +198 -0
- data/modules/emscripten/tools/cache.pyc +0 -0
- data/modules/emscripten/tools/clean_webconsole.py +34 -0
- data/modules/emscripten/tools/crunch-worker.js +124 -0
- data/modules/emscripten/tools/diff_autodebugger.py +15 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +5129 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +6861 -0
- data/modules/emscripten/tools/eliminator/eliminator-test-output.js +6122 -0
- data/modules/emscripten/tools/eliminator/eliminator-test.js +8856 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.html +888 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.org +463 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/bin/uglifyjs +317 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/docstyle.css +75 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/object-ast.js +75 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js +1363 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/process.js +2005 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/squeeze-more.js +51 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/package.json +22 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/beautify.js +28 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/testparser.js +402 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/mangle.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/with.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +16 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/mangle.js +5 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/with.js +2 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/scripts.js +55 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/hoist.js +33 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument.js +97 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument2.js +138 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/test.js +16 -0
- data/modules/emscripten/tools/eliminator/node_modules/uglify-js/uglify-js.js +17 -0
- data/modules/emscripten/tools/eliminator/safe-eliminator-test-output.js +85 -0
- data/modules/emscripten/tools/eliminator/safe-eliminator-test.js +103 -0
- data/modules/emscripten/tools/emconfiguren.py +19 -0
- data/modules/emscripten/tools/emmaken.py +230 -0
- data/modules/emscripten/tools/emmakenxx.py +18 -0
- data/modules/emscripten/tools/exec_llvm.py +50 -0
- data/modules/emscripten/tools/file2json.py +49 -0
- data/modules/emscripten/tools/file_packager.py +649 -0
- data/modules/emscripten/tools/find_bigfuncs.py +23 -0
- data/modules/emscripten/tools/find_bigis.py +18 -0
- data/modules/emscripten/tools/fix_closure.py +88 -0
- data/modules/emscripten/tools/ie7_fix.py +14 -0
- data/modules/emscripten/tools/js-optimizer.js +3440 -0
- data/modules/emscripten/tools/js_optimizer.py +341 -0
- data/modules/emscripten/tools/js_optimizer.pyc +0 -0
- data/modules/emscripten/tools/jsrun.py +27 -0
- data/modules/emscripten/tools/jsrun.pyc +0 -0
- data/modules/emscripten/tools/ll-strip.py +56 -0
- data/modules/emscripten/tools/make_file.py +19 -0
- data/modules/emscripten/tools/make_minigzip.py +13 -0
- data/modules/emscripten/tools/namespacer.py +95 -0
- data/modules/emscripten/tools/nativize_llvm.py +34 -0
- data/modules/emscripten/tools/node_modules/source-map/CHANGELOG.md +58 -0
- data/modules/emscripten/tools/node_modules/source-map/LICENSE +28 -0
- data/modules/emscripten/tools/node_modules/source-map/Makefile.dryice.js +166 -0
- data/modules/emscripten/tools/node_modules/source-map/README.md +347 -0
- data/modules/emscripten/tools/node_modules/source-map/build/assert-shim.js +56 -0
- data/modules/emscripten/tools/node_modules/source-map/build/mini-require.js +152 -0
- data/modules/emscripten/tools/node_modules/source-map/build/prefix-source-map.jsm +20 -0
- data/modules/emscripten/tools/node_modules/source-map/build/prefix-utils.jsm +18 -0
- data/modules/emscripten/tools/node_modules/source-map/build/suffix-browser.js +8 -0
- data/modules/emscripten/tools/node_modules/source-map/build/suffix-source-map.jsm +6 -0
- data/modules/emscripten/tools/node_modules/source-map/build/suffix-utils.jsm +21 -0
- data/modules/emscripten/tools/node_modules/source-map/build/test-prefix.js +8 -0
- data/modules/emscripten/tools/node_modules/source-map/build/test-suffix.js +3 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/array-set.js +96 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js +42 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/binary-search.js +81 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-consumer.js +430 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-generator.js +381 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-node.js +353 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map/util.js +117 -0
- data/modules/emscripten/tools/node_modules/source-map/lib/source-map.js +8 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/README.md +119 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
- data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/package.json +33 -0
- data/modules/emscripten/tools/node_modules/source-map/package.json +74 -0
- data/modules/emscripten/tools/node_modules/source-map/test/run-tests.js +73 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-api.js +26 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-array-set.js +71 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64.js +35 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-consumer.js +306 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-generator.js +391 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-node.js +282 -0
- data/modules/emscripten/tools/node_modules/source-map/test/source-map/util.js +152 -0
- data/modules/emscripten/tools/reproduceriter.js +216 -0
- data/modules/emscripten/tools/reproduceriter.py +160 -0
- data/modules/emscripten/tools/response_file.py +28 -0
- data/modules/emscripten/tools/response_file.pyc +0 -0
- data/modules/emscripten/tools/scan_js.py +20 -0
- data/modules/emscripten/tools/scan_ll.py +18 -0
- data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/__init__.py +3 -0
- data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/emscripten.py +46 -0
- data/modules/emscripten/tools/settings_template_readonly.py +47 -0
- data/modules/emscripten/tools/shared.py +1437 -0
- data/modules/emscripten/tools/shared.pyc +0 -0
- data/modules/emscripten/tools/source-maps/sourcemap2json.js +15 -0
- data/modules/emscripten/tools/source-maps/sourcemapper.js +177 -0
- data/modules/emscripten/tools/split.py +97 -0
- data/modules/emscripten/tools/tempfiles.py +40 -0
- data/modules/emscripten/tools/tempfiles.pyc +0 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-last-output.js +75 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-last.js +91 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline-output.js +570 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-outline.js +606 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +540 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +550 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs-min-output.js +36 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs-min.js +37 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs-output.js +106 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-regs.js +110 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-relocate-output.js +9 -0
- data/modules/emscripten/tools/test-js-optimizer-asm-relocate.js +12 -0
- data/modules/emscripten/tools/test-js-optimizer-output.js +291 -0
- data/modules/emscripten/tools/test-js-optimizer-regs-output.js +232 -0
- data/modules/emscripten/tools/test-js-optimizer-regs.js +237 -0
- data/modules/emscripten/tools/test-js-optimizer-t2-output.js +91 -0
- data/modules/emscripten/tools/test-js-optimizer-t2.js +92 -0
- data/modules/emscripten/tools/test-js-optimizer-t2c-output.js +17 -0
- data/modules/emscripten/tools/test-js-optimizer-t2c.js +18 -0
- data/modules/emscripten/tools/test-js-optimizer-t3-output.js +49 -0
- data/modules/emscripten/tools/test-js-optimizer-t3.js +50 -0
- data/modules/emscripten/tools/test-js-optimizer.js +401 -0
- data/modules/mruby/AUTHORS +18 -0
- data/modules/mruby/CONTRIBUTING.md +65 -0
- data/modules/mruby/ChangeLog +15 -0
- data/modules/mruby/INSTALL +29 -0
- data/modules/mruby/LEGAL +6 -0
- data/modules/mruby/MITL +20 -0
- data/modules/mruby/Makefile +18 -0
- data/modules/mruby/NEWS +13 -0
- data/modules/mruby/README.md +116 -0
- data/modules/mruby/Rakefile +114 -0
- data/modules/mruby/TODO +11 -0
- data/modules/mruby/benchmark/ao-render.rb +315 -0
- data/modules/mruby/benchmark/bm_so_lists.rb +47 -0
- data/modules/mruby/benchmark/fib39.rb +8 -0
- data/modules/mruby/build_config.rb +88 -0
- data/modules/mruby/doc/compile/README.md +376 -0
- data/modules/mruby/doc/mrbgems/README.md +254 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/README.md +4 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake +23 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +5 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +20 -0
- data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/test/example.rb +7 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/README.md +4 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/mrbgem.rake +23 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/src/example.c +20 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/test/example.c +7 -0
- data/modules/mruby/examples/mrbgems/c_extension_example/test/example.rb +3 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/README.md +4 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake +23 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +5 -0
- data/modules/mruby/examples/mrbgems/ruby_extension_example/test/example.rb +3 -0
- data/modules/mruby/examples/targets/ArduinoDue.rb +65 -0
- data/modules/mruby/examples/targets/chipKitMax32.rb +68 -0
- data/modules/mruby/include/mrbconf.h +87 -0
- data/modules/mruby/include/mruby/array.h +63 -0
- data/modules/mruby/include/mruby/class.h +75 -0
- data/modules/mruby/include/mruby/compile.h +176 -0
- data/modules/mruby/include/mruby/data.h +53 -0
- data/modules/mruby/include/mruby/dump.h +151 -0
- data/modules/mruby/include/mruby/gc.h +17 -0
- data/modules/mruby/include/mruby/hash.h +54 -0
- data/modules/mruby/include/mruby/irep.h +40 -0
- data/modules/mruby/include/mruby/khash.h +257 -0
- data/modules/mruby/include/mruby/numeric.h +32 -0
- data/modules/mruby/include/mruby/proc.h +62 -0
- data/modules/mruby/include/mruby/range.h +35 -0
- data/modules/mruby/include/mruby/string.h +78 -0
- data/modules/mruby/include/mruby/value.h +483 -0
- data/modules/mruby/include/mruby/variable.h +78 -0
- data/modules/mruby/include/mruby.h +388 -0
- data/modules/mruby/minirake +477 -0
- data/modules/mruby/mrbgems/default.gembox +61 -0
- data/modules/mruby/mrbgems/full-core.gembox +9 -0
- data/modules/mruby/mrbgems/mruby-array-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +204 -0
- data/modules/mruby/mrbgems/mruby-array-ext/src/array.c +140 -0
- data/modules/mruby/mrbgems/mruby-array-ext/test/array.rb +109 -0
- data/modules/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +5 -0
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +365 -0
- data/modules/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +5 -0
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +243 -0
- data/modules/mruby/mrbgems/mruby-enum-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +164 -0
- data/modules/mruby/mrbgems/mruby-enum-ext/test/enum.rb +44 -0
- data/modules/mruby/mrbgems/mruby-eval/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-eval/src/eval.c +23 -0
- data/modules/mruby/mrbgems/mruby-fiber/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +251 -0
- data/modules/mruby/mrbgems/mruby-fiber/test/fiber.rb +64 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +13 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +62 -0
- data/modules/mruby/mrbgems/mruby-hash-ext/test/hash.rb +26 -0
- data/modules/mruby/mrbgems/mruby-math/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-math/src/math.c +685 -0
- data/modules/mruby/mrbgems/mruby-math/test/math.rb +136 -0
- data/modules/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +31 -0
- data/modules/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +10 -0
- data/modules/mruby/mrbgems/mruby-object-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-object-ext/src/object.c +108 -0
- data/modules/mruby/mrbgems/mruby-object-ext/test/nil.rb +11 -0
- data/modules/mruby/mrbgems/mruby-object-ext/test/object.rb +9 -0
- data/modules/mruby/mrbgems/mruby-objectspace/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +117 -0
- data/modules/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +38 -0
- data/modules/mruby/mrbgems/mruby-print/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-print/mrblib/print.rb +64 -0
- data/modules/mruby/mrbgems/mruby-print/src/print.c +44 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/mrblib/proc.rb +40 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/src/proc.c +97 -0
- data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.rb +41 -0
- data/modules/mruby/mrbgems/mruby-random/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.c +193 -0
- data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.h +48 -0
- data/modules/mruby/mrbgems/mruby-random/src/random.c +231 -0
- data/modules/mruby/mrbgems/mruby-random/src/random.h +12 -0
- data/modules/mruby/mrbgems/mruby-random/test/random.rb +32 -0
- data/modules/mruby/mrbgems/mruby-range-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-range-ext/src/range.c +141 -0
- data/modules/mruby/mrbgems/mruby-range-ext/test/range.rb +20 -0
- data/modules/mruby/mrbgems/mruby-sprintf/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-sprintf/src/kernel.c +30 -0
- data/modules/mruby/mrbgems/mruby-sprintf/src/sprintf.c +1102 -0
- data/modules/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +3 -0
- data/modules/mruby/mrbgems/mruby-string-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +52 -0
- data/modules/mruby/mrbgems/mruby-string-ext/src/string.c +175 -0
- data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +112 -0
- data/modules/mruby/mrbgems/mruby-struct/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-struct/mrblib/struct.rb +50 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +818 -0
- data/modules/mruby/mrbgems/mruby-struct/test/struct.rb +77 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +9 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +55 -0
- data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +12 -0
- data/modules/mruby/mrbgems/mruby-time/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-time/src/time.c +749 -0
- data/modules/mruby/mrbgems/mruby-time/test/time.rb +201 -0
- data/modules/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb +11 -0
- data/modules/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb +24 -0
- data/modules/mruby/mrblib/array.rb +111 -0
- data/modules/mruby/mrblib/class.rb +26 -0
- data/modules/mruby/mrblib/compar.rb +104 -0
- data/modules/mruby/mrblib/enum.rb +398 -0
- data/modules/mruby/mrblib/error.rb +66 -0
- data/modules/mruby/mrblib/hash.rb +193 -0
- data/modules/mruby/mrblib/init_mrblib.c +14 -0
- data/modules/mruby/mrblib/kernel.rb +46 -0
- data/modules/mruby/mrblib/mrblib.rake +18 -0
- data/modules/mruby/mrblib/numeric.rb +101 -0
- data/modules/mruby/mrblib/print.rb +18 -0
- data/modules/mruby/mrblib/range.rb +40 -0
- data/modules/mruby/mrblib/string.rb +145 -0
- data/modules/mruby/src/array.c +1150 -0
- data/modules/mruby/src/backtrace.c +73 -0
- data/modules/mruby/src/class.c +1942 -0
- data/modules/mruby/src/codegen.c +2864 -0
- data/modules/mruby/src/compar.c +13 -0
- data/modules/mruby/src/crc.c +38 -0
- data/modules/mruby/src/dump.c +542 -0
- data/modules/mruby/src/enum.c +14 -0
- data/modules/mruby/src/error.c +454 -0
- data/modules/mruby/src/error.h +18 -0
- data/modules/mruby/src/etc.c +204 -0
- data/modules/mruby/src/gc.c +1542 -0
- data/modules/mruby/src/hash.c +1261 -0
- data/modules/mruby/src/init.c +62 -0
- data/modules/mruby/src/kernel.c +1105 -0
- data/modules/mruby/src/keywords +50 -0
- data/modules/mruby/src/lex.def +212 -0
- data/modules/mruby/src/load.c +629 -0
- data/modules/mruby/src/mruby_core.rake +28 -0
- data/modules/mruby/src/node.h +117 -0
- data/modules/mruby/src/numeric.c +1418 -0
- data/modules/mruby/src/object.c +593 -0
- data/modules/mruby/src/opcode.h +160 -0
- data/modules/mruby/src/parse.y +6050 -0
- data/modules/mruby/src/pool.c +190 -0
- data/modules/mruby/src/print.c +71 -0
- data/modules/mruby/src/proc.c +209 -0
- data/modules/mruby/src/range.c +442 -0
- data/modules/mruby/src/re.h +13 -0
- data/modules/mruby/src/state.c +200 -0
- data/modules/mruby/src/string.c +2580 -0
- data/modules/mruby/src/symbol.c +456 -0
- data/modules/mruby/src/value_array.h +27 -0
- data/modules/mruby/src/variable.c +1147 -0
- data/modules/mruby/src/vm.c +2129 -0
- data/modules/mruby/tasks/libmruby.rake +18 -0
- data/modules/mruby/tasks/mrbgem_spec.rake +297 -0
- data/modules/mruby/tasks/mrbgems.rake +85 -0
- data/modules/mruby/tasks/mrbgems_test.rake +88 -0
- data/modules/mruby/tasks/mruby_build.rake +211 -0
- data/modules/mruby/tasks/mruby_build_commands.rake +287 -0
- data/modules/mruby/tasks/mruby_build_gem.rake +67 -0
- data/modules/mruby/tasks/ruby_ext.rake +70 -0
- data/modules/mruby/tasks/toolchains/androideabi.rake +126 -0
- data/modules/mruby/tasks/toolchains/clang.rake +8 -0
- data/modules/mruby/tasks/toolchains/gcc.rake +21 -0
- data/modules/mruby/tasks/toolchains/vs2010.rake +3 -0
- data/modules/mruby/tasks/toolchains/vs2012.rake +44 -0
- data/modules/mruby/test/README.md +7 -0
- data/modules/mruby/test/assert.rb +238 -0
- data/modules/mruby/test/driver.c +118 -0
- data/modules/mruby/test/init_mrbtest.c +24 -0
- data/modules/mruby/test/mrbtest.rake +47 -0
- data/modules/mruby/test/report.rb +4 -0
- data/modules/mruby/test/t/argumenterror.rb +21 -0
- data/modules/mruby/test/t/array.rb +309 -0
- data/modules/mruby/test/t/basicobject.rb +11 -0
- data/modules/mruby/test/t/bs_block.rb +489 -0
- data/modules/mruby/test/t/bs_literal.rb +38 -0
- data/modules/mruby/test/t/class.rb +219 -0
- data/modules/mruby/test/t/comparable.rb +72 -0
- data/modules/mruby/test/t/enumerable.rb +108 -0
- data/modules/mruby/test/t/exception.rb +337 -0
- data/modules/mruby/test/t/false.rb +33 -0
- data/modules/mruby/test/t/float.rb +145 -0
- data/modules/mruby/test/t/gc.rb +45 -0
- data/modules/mruby/test/t/hash.rb +310 -0
- data/modules/mruby/test/t/indexerror.rb +10 -0
- data/modules/mruby/test/t/integer.rb +222 -0
- data/modules/mruby/test/t/kernel.rb +425 -0
- data/modules/mruby/test/t/literals.rb +287 -0
- data/modules/mruby/test/t/localjumperror.rb +13 -0
- data/modules/mruby/test/t/methods.rb +109 -0
- data/modules/mruby/test/t/module.rb +344 -0
- data/modules/mruby/test/t/nameerror.rb +32 -0
- data/modules/mruby/test/t/nil.rb +29 -0
- data/modules/mruby/test/t/nomethoderror.rb +13 -0
- data/modules/mruby/test/t/numeric.rb +29 -0
- data/modules/mruby/test/t/object.rb +11 -0
- data/modules/mruby/test/t/proc.rb +56 -0
- data/modules/mruby/test/t/range.rb +82 -0
- data/modules/mruby/test/t/rangeerror.rb +10 -0
- data/modules/mruby/test/t/regexperror.rb +4 -0
- data/modules/mruby/test/t/runtimeerror.rb +6 -0
- data/modules/mruby/test/t/standarderror.rb +10 -0
- data/modules/mruby/test/t/string.rb +483 -0
- data/modules/mruby/test/t/symbol.rb +27 -0
- data/modules/mruby/test/t/syntax.rb +67 -0
- data/modules/mruby/test/t/true.rb +33 -0
- data/modules/mruby/test/t/typeerror.rb +11 -0
- data/modules/mruby/tools/mrbc/mrbc.c +318 -0
- data/modules/mruby/tools/mrbc/mrbc.rake +14 -0
- data/modules/mruby/travis_config.rb +6 -0
- data/modules/mrubymix/LICENSE +21 -0
- data/modules/mrubymix/README.md +6 -0
- data/modules/mrubymix/bin/mrubymix +29 -0
- data/modules/mrubymix/lib/mrubymix.rb +93 -0
- data/modules/mrubymix/mrubymix.gemspec +13 -0
- data/scripts/gen_gems_config.rb +185 -0
- data/scripts/gen_post.rb +104 -0
- data/templates/minimal/Rakefile +36 -0
- data/templates/minimal/app/app.rb +3 -0
- metadata +1408 -0
|
@@ -0,0 +1,2864 @@
|
|
|
1
|
+
/*
|
|
2
|
+
** codegen.c - mruby code generator
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include <ctype.h>
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
#include <string.h>
|
|
10
|
+
#include "mruby.h"
|
|
11
|
+
#include "mruby/compile.h"
|
|
12
|
+
#include "mruby/irep.h"
|
|
13
|
+
#include "mruby/numeric.h"
|
|
14
|
+
#include "mruby/string.h"
|
|
15
|
+
#include "node.h"
|
|
16
|
+
#include "opcode.h"
|
|
17
|
+
#include "re.h"
|
|
18
|
+
|
|
19
|
+
typedef mrb_ast_node node;
|
|
20
|
+
typedef struct mrb_parser_state parser_state;
|
|
21
|
+
|
|
22
|
+
enum looptype {
|
|
23
|
+
LOOP_NORMAL,
|
|
24
|
+
LOOP_BLOCK,
|
|
25
|
+
LOOP_FOR,
|
|
26
|
+
LOOP_BEGIN,
|
|
27
|
+
LOOP_RESCUE,
|
|
28
|
+
} type;
|
|
29
|
+
|
|
30
|
+
struct loopinfo {
|
|
31
|
+
enum looptype type;
|
|
32
|
+
int pc1, pc2, pc3, acc;
|
|
33
|
+
int ensure_level;
|
|
34
|
+
struct loopinfo *prev;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
typedef struct scope {
|
|
38
|
+
mrb_state *mrb;
|
|
39
|
+
mrb_pool *mpool;
|
|
40
|
+
jmp_buf jmp;
|
|
41
|
+
|
|
42
|
+
struct scope *prev;
|
|
43
|
+
|
|
44
|
+
node *lv;
|
|
45
|
+
|
|
46
|
+
int sp;
|
|
47
|
+
int pc;
|
|
48
|
+
int lastlabel;
|
|
49
|
+
int ainfo:15;
|
|
50
|
+
mrb_bool mscope:1;
|
|
51
|
+
|
|
52
|
+
struct loopinfo *loop;
|
|
53
|
+
int ensure_level;
|
|
54
|
+
char *filename;
|
|
55
|
+
short lineno;
|
|
56
|
+
|
|
57
|
+
mrb_code *iseq;
|
|
58
|
+
short *lines;
|
|
59
|
+
int icapa;
|
|
60
|
+
|
|
61
|
+
mrb_irep *irep;
|
|
62
|
+
size_t pcapa;
|
|
63
|
+
int scapa;
|
|
64
|
+
|
|
65
|
+
int nlocals;
|
|
66
|
+
int nregs;
|
|
67
|
+
int ai;
|
|
68
|
+
|
|
69
|
+
int idx;
|
|
70
|
+
} codegen_scope;
|
|
71
|
+
|
|
72
|
+
static codegen_scope* scope_new(mrb_state *mrb, codegen_scope *prev, node *lv);
|
|
73
|
+
static void scope_finish(codegen_scope *s);
|
|
74
|
+
static struct loopinfo *loop_push(codegen_scope *s, enum looptype t);
|
|
75
|
+
static void loop_break(codegen_scope *s, node *tree);
|
|
76
|
+
static void loop_pop(codegen_scope *s, int val);
|
|
77
|
+
|
|
78
|
+
static void gen_assignment(codegen_scope *s, node *node, int sp, int val);
|
|
79
|
+
static void gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val);
|
|
80
|
+
|
|
81
|
+
static void codegen(codegen_scope *s, node *tree, int val);
|
|
82
|
+
|
|
83
|
+
static void
|
|
84
|
+
codegen_error(codegen_scope *s, const char *message)
|
|
85
|
+
{
|
|
86
|
+
if (!s) return;
|
|
87
|
+
while (s->prev) {
|
|
88
|
+
mrb_pool_close(s->mpool);
|
|
89
|
+
s = s->prev;
|
|
90
|
+
}
|
|
91
|
+
mrb_pool_close(s->mpool);
|
|
92
|
+
#ifdef ENABLE_STDIO
|
|
93
|
+
if (s->filename && s->lineno) {
|
|
94
|
+
fprintf(stderr, "codegen error:%s:%d: %s\n", s->filename, s->lineno, message);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
fprintf(stderr, "codegen error: %s\n", message);
|
|
98
|
+
}
|
|
99
|
+
#endif
|
|
100
|
+
longjmp(s->jmp, 1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static void*
|
|
104
|
+
codegen_palloc(codegen_scope *s, size_t len)
|
|
105
|
+
{
|
|
106
|
+
void *p = mrb_pool_alloc(s->mpool, len);
|
|
107
|
+
|
|
108
|
+
if (!p) codegen_error(s, "pool memory allocation");
|
|
109
|
+
return p;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
void*
|
|
113
|
+
codegen_malloc(codegen_scope *s, size_t len)
|
|
114
|
+
{
|
|
115
|
+
void *p = mrb_malloc(s->mrb, len);
|
|
116
|
+
|
|
117
|
+
if (!p) codegen_error(s, "mrb_malloc");
|
|
118
|
+
return p;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void*
|
|
122
|
+
codegen_realloc(codegen_scope *s, void *p, size_t len)
|
|
123
|
+
{
|
|
124
|
+
p = mrb_realloc(s->mrb, p, len);
|
|
125
|
+
|
|
126
|
+
if (!p && len > 0) codegen_error(s, "mrb_realloc");
|
|
127
|
+
return p;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static int
|
|
131
|
+
new_label(codegen_scope *s)
|
|
132
|
+
{
|
|
133
|
+
s->lastlabel = s->pc;
|
|
134
|
+
return s->pc;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
static inline void
|
|
138
|
+
genop(codegen_scope *s, mrb_code i)
|
|
139
|
+
{
|
|
140
|
+
if (s->pc == s->icapa) {
|
|
141
|
+
s->icapa *= 2;
|
|
142
|
+
s->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->icapa);
|
|
143
|
+
if (s->lines) {
|
|
144
|
+
s->lines = (short*)codegen_realloc(s, s->lines, sizeof(short)*s->icapa);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
s->iseq[s->pc] = i;
|
|
148
|
+
if (s->lines) {
|
|
149
|
+
s->lines[s->pc] = s->lineno;
|
|
150
|
+
}
|
|
151
|
+
s->pc++;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
#define NOVAL 0
|
|
155
|
+
#define VAL 1
|
|
156
|
+
|
|
157
|
+
static void
|
|
158
|
+
genop_peep(codegen_scope *s, mrb_code i, int val)
|
|
159
|
+
{
|
|
160
|
+
/* peephole optimization */
|
|
161
|
+
if (s->lastlabel != s->pc && s->pc > 0) {
|
|
162
|
+
mrb_code i0 = s->iseq[s->pc-1];
|
|
163
|
+
int c1 = GET_OPCODE(i);
|
|
164
|
+
int c0 = GET_OPCODE(i0);
|
|
165
|
+
|
|
166
|
+
switch (c1) {
|
|
167
|
+
case OP_MOVE:
|
|
168
|
+
if (GETARG_A(i) == GETARG_B(i)) {
|
|
169
|
+
/* skip useless OP_MOVE */
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (val) break;
|
|
173
|
+
switch (c0) {
|
|
174
|
+
case OP_MOVE:
|
|
175
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i) == GETARG_B(i0) && GETARG_A(i) >= s->nlocals) {
|
|
176
|
+
/* skip swapping OP_MOVE */
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
|
|
180
|
+
s->iseq[s->pc-1] = MKOP_AB(OP_MOVE, GETARG_A(i), GETARG_B(i0));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case OP_LOADI:
|
|
185
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
|
|
186
|
+
s->iseq[s->pc-1] = MKOP_AsBx(OP_LOADI, GETARG_A(i), GETARG_sBx(i0));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case OP_ARRAY:
|
|
191
|
+
case OP_HASH:
|
|
192
|
+
case OP_RANGE:
|
|
193
|
+
case OP_AREF:
|
|
194
|
+
case OP_GETUPVAR:
|
|
195
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
|
|
196
|
+
s->iseq[s->pc-1] = MKOP_ABC(c0, GETARG_A(i), GETARG_B(i0), GETARG_C(i0));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case OP_LOADSYM:
|
|
201
|
+
case OP_GETGLOBAL:
|
|
202
|
+
case OP_GETIV:
|
|
203
|
+
case OP_GETCV:
|
|
204
|
+
case OP_GETCONST:
|
|
205
|
+
case OP_GETSPECIAL:
|
|
206
|
+
case OP_LOADL:
|
|
207
|
+
case OP_STRING:
|
|
208
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
|
|
209
|
+
s->iseq[s->pc-1] = MKOP_ABx(c0, GETARG_A(i), GETARG_Bx(i0));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case OP_SCLASS:
|
|
214
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
|
|
215
|
+
s->iseq[s->pc-1] = MKOP_AB(c0, GETARG_A(i), GETARG_B(i0));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
case OP_LOADNIL:
|
|
220
|
+
case OP_LOADSELF:
|
|
221
|
+
case OP_LOADT:
|
|
222
|
+
case OP_LOADF:
|
|
223
|
+
case OP_OCLASS:
|
|
224
|
+
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
|
|
225
|
+
s->iseq[s->pc-1] = MKOP_A(c0, GETARG_A(i));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
default:
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case OP_SETIV:
|
|
234
|
+
case OP_SETCV:
|
|
235
|
+
case OP_SETCONST:
|
|
236
|
+
case OP_SETMCNST:
|
|
237
|
+
case OP_SETGLOBAL:
|
|
238
|
+
if (val) break;
|
|
239
|
+
if (c0 == OP_MOVE) {
|
|
240
|
+
if (GETARG_A(i) == GETARG_A(i0)) {
|
|
241
|
+
s->iseq[s->pc-1] = MKOP_ABx(c1, GETARG_B(i0), GETARG_Bx(i));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
case OP_SETUPVAR:
|
|
247
|
+
if (val) break;
|
|
248
|
+
if (c0 == OP_MOVE) {
|
|
249
|
+
if (GETARG_A(i) == GETARG_A(i0)) {
|
|
250
|
+
s->iseq[s->pc-1] = MKOP_ABC(c1, GETARG_B(i0), GETARG_B(i), GETARG_C(i));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case OP_EPOP:
|
|
256
|
+
if (c0 == OP_EPOP) {
|
|
257
|
+
s->iseq[s->pc-1] = MKOP_A(OP_EPOP, GETARG_A(i0)+GETARG_A(i));
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
case OP_POPERR:
|
|
262
|
+
if (c0 == OP_POPERR) {
|
|
263
|
+
s->iseq[s->pc-1] = MKOP_A(OP_POPERR, GETARG_A(i0)+GETARG_A(i));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
case OP_RETURN:
|
|
268
|
+
switch (c0) {
|
|
269
|
+
case OP_RETURN:
|
|
270
|
+
return;
|
|
271
|
+
case OP_MOVE:
|
|
272
|
+
s->iseq[s->pc-1] = MKOP_AB(OP_RETURN, GETARG_B(i0), OP_R_NORMAL);
|
|
273
|
+
return;
|
|
274
|
+
case OP_LOADI:
|
|
275
|
+
s->iseq[s->pc-1] = MKOP_AsBx(OP_LOADI, 0, GETARG_sBx(i0));
|
|
276
|
+
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
277
|
+
return;
|
|
278
|
+
case OP_ARRAY:
|
|
279
|
+
case OP_HASH:
|
|
280
|
+
case OP_RANGE:
|
|
281
|
+
case OP_AREF:
|
|
282
|
+
case OP_GETUPVAR:
|
|
283
|
+
s->iseq[s->pc-1] = MKOP_ABC(c0, 0, GETARG_B(i0), GETARG_C(i0));
|
|
284
|
+
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
285
|
+
return;
|
|
286
|
+
case OP_SETIV:
|
|
287
|
+
case OP_SETCV:
|
|
288
|
+
case OP_SETCONST:
|
|
289
|
+
case OP_SETMCNST:
|
|
290
|
+
case OP_SETUPVAR:
|
|
291
|
+
case OP_SETGLOBAL:
|
|
292
|
+
s->pc--;
|
|
293
|
+
genop_peep(s, i0, NOVAL);
|
|
294
|
+
i0 = s->iseq[s->pc-1];
|
|
295
|
+
genop(s, MKOP_AB(OP_RETURN, GETARG_A(i0), OP_R_NORMAL));
|
|
296
|
+
return;
|
|
297
|
+
case OP_LOADSYM:
|
|
298
|
+
case OP_GETGLOBAL:
|
|
299
|
+
case OP_GETIV:
|
|
300
|
+
case OP_GETCV:
|
|
301
|
+
case OP_GETCONST:
|
|
302
|
+
case OP_GETSPECIAL:
|
|
303
|
+
case OP_LOADL:
|
|
304
|
+
case OP_STRING:
|
|
305
|
+
s->iseq[s->pc-1] = MKOP_ABx(c0, 0, GETARG_Bx(i0));
|
|
306
|
+
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
307
|
+
return;
|
|
308
|
+
case OP_SCLASS:
|
|
309
|
+
s->iseq[s->pc-1] = MKOP_AB(c0, GETARG_A(i), GETARG_B(i0));
|
|
310
|
+
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
311
|
+
return;
|
|
312
|
+
case OP_LOADNIL:
|
|
313
|
+
case OP_LOADSELF:
|
|
314
|
+
case OP_LOADT:
|
|
315
|
+
case OP_LOADF:
|
|
316
|
+
case OP_OCLASS:
|
|
317
|
+
s->iseq[s->pc-1] = MKOP_A(c0, 0);
|
|
318
|
+
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
319
|
+
return;
|
|
320
|
+
#if 0
|
|
321
|
+
case OP_SEND:
|
|
322
|
+
if (GETARG_B(i) == OP_R_NORMAL && GETARG_A(i) == GETARG_A(i0)) {
|
|
323
|
+
s->iseq[s->pc-1] = MKOP_ABC(OP_TAILCALL, GETARG_A(i0), GETARG_B(i0), GETARG_C(i0));
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
#endif
|
|
328
|
+
default:
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
case OP_ADD:
|
|
333
|
+
case OP_SUB:
|
|
334
|
+
if (c0 == OP_LOADI) {
|
|
335
|
+
int c = GETARG_sBx(i0);
|
|
336
|
+
|
|
337
|
+
if (c1 == OP_SUB) c = -c;
|
|
338
|
+
if (c > 127 || c < -127) break;
|
|
339
|
+
if (0 <= c)
|
|
340
|
+
s->iseq[s->pc-1] = MKOP_ABC(OP_ADDI, GETARG_A(i), GETARG_B(i), c);
|
|
341
|
+
else
|
|
342
|
+
s->iseq[s->pc-1] = MKOP_ABC(OP_SUBI, GETARG_A(i), GETARG_B(i), -c);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
case OP_STRCAT:
|
|
346
|
+
if (c0 == OP_STRING) {
|
|
347
|
+
int i = GETARG_Bx(i0);
|
|
348
|
+
|
|
349
|
+
if (mrb_type(s->irep->pool[i]) == MRB_TT_STRING &&
|
|
350
|
+
RSTRING_LEN(s->irep->pool[i]) == 0) {
|
|
351
|
+
s->pc--;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
356
|
+
default:
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
genop(s, i);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
static void
|
|
364
|
+
scope_error(codegen_scope *s)
|
|
365
|
+
{
|
|
366
|
+
exit(EXIT_FAILURE);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
static inline void
|
|
370
|
+
dispatch(codegen_scope *s, int pc)
|
|
371
|
+
{
|
|
372
|
+
int diff = s->pc - pc;
|
|
373
|
+
mrb_code i = s->iseq[pc];
|
|
374
|
+
int c = GET_OPCODE(i);
|
|
375
|
+
|
|
376
|
+
s->lastlabel = s->pc;
|
|
377
|
+
switch (c) {
|
|
378
|
+
case OP_JMP:
|
|
379
|
+
case OP_JMPIF:
|
|
380
|
+
case OP_JMPNOT:
|
|
381
|
+
case OP_ONERR:
|
|
382
|
+
break;
|
|
383
|
+
default:
|
|
384
|
+
#ifdef ENABLE_STDIO
|
|
385
|
+
fprintf(stderr, "bug: dispatch on non JMP op\n");
|
|
386
|
+
#endif
|
|
387
|
+
scope_error(s);
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
s->iseq[pc] = MKOP_AsBx(c, GETARG_A(i), diff);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
static void
|
|
394
|
+
dispatch_linked(codegen_scope *s, int pc)
|
|
395
|
+
{
|
|
396
|
+
mrb_code i;
|
|
397
|
+
int pos;
|
|
398
|
+
|
|
399
|
+
if (!pc) return;
|
|
400
|
+
for (;;) {
|
|
401
|
+
i = s->iseq[pc];
|
|
402
|
+
pos = GETARG_sBx(i);
|
|
403
|
+
dispatch(s, pc);
|
|
404
|
+
if (!pos) break;
|
|
405
|
+
pc = pos;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
#define nregs_update do {if (s->sp > s->nregs) s->nregs = s->sp;} while (0)
|
|
410
|
+
static void
|
|
411
|
+
push_(codegen_scope *s)
|
|
412
|
+
{
|
|
413
|
+
if (s->sp > 511) {
|
|
414
|
+
codegen_error(s, "too complex expression");
|
|
415
|
+
}
|
|
416
|
+
s->sp++;
|
|
417
|
+
nregs_update;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
#define push() push_(s)
|
|
421
|
+
#define pop_(s) ((s)->sp--)
|
|
422
|
+
#define pop() pop_(s)
|
|
423
|
+
#define pop_n(n) (s->sp-=(n))
|
|
424
|
+
#define cursp() (s->sp)
|
|
425
|
+
|
|
426
|
+
static inline int
|
|
427
|
+
new_lit(codegen_scope *s, mrb_value val)
|
|
428
|
+
{
|
|
429
|
+
size_t i;
|
|
430
|
+
|
|
431
|
+
switch (mrb_type(val)) {
|
|
432
|
+
case MRB_TT_STRING:
|
|
433
|
+
for (i=0; i<s->irep->plen; i++) {
|
|
434
|
+
mrb_value pv = s->irep->pool[i];
|
|
435
|
+
mrb_int len;
|
|
436
|
+
|
|
437
|
+
if (mrb_type(pv) != MRB_TT_STRING) continue;
|
|
438
|
+
if ((len = RSTRING_LEN(pv)) != RSTRING_LEN(val)) continue;
|
|
439
|
+
if (memcmp(RSTRING_PTR(pv), RSTRING_PTR(val), len) == 0)
|
|
440
|
+
return i;
|
|
441
|
+
}
|
|
442
|
+
break;
|
|
443
|
+
case MRB_TT_FLOAT:
|
|
444
|
+
default:
|
|
445
|
+
for (i=0; i<s->irep->plen; i++) {
|
|
446
|
+
if (mrb_obj_equal(s->mrb, s->irep->pool[i], val)) return i;
|
|
447
|
+
}
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (s->irep->plen == s->pcapa) {
|
|
452
|
+
s->pcapa *= 2;
|
|
453
|
+
s->irep->pool = (mrb_value *)codegen_realloc(s, s->irep->pool, sizeof(mrb_value)*s->pcapa);
|
|
454
|
+
}
|
|
455
|
+
s->irep->pool[s->irep->plen] = val;
|
|
456
|
+
i = s->irep->plen++;
|
|
457
|
+
|
|
458
|
+
return i;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
static inline int
|
|
462
|
+
new_msym(codegen_scope *s, mrb_sym sym)
|
|
463
|
+
{
|
|
464
|
+
size_t i, len;
|
|
465
|
+
|
|
466
|
+
len = s->irep->slen;
|
|
467
|
+
if (len > 256) len = 256;
|
|
468
|
+
for (i=0; i<len; i++) {
|
|
469
|
+
if (s->irep->syms[i] == sym) return i;
|
|
470
|
+
if (s->irep->syms[i] == 0) break;
|
|
471
|
+
}
|
|
472
|
+
if (i == 256) {
|
|
473
|
+
codegen_error(s, "too many symbols (max 256)");
|
|
474
|
+
}
|
|
475
|
+
s->irep->syms[i] = sym;
|
|
476
|
+
if (i == s->irep->slen) s->irep->slen++;
|
|
477
|
+
return i;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
static inline int
|
|
481
|
+
new_sym(codegen_scope *s, mrb_sym sym)
|
|
482
|
+
{
|
|
483
|
+
size_t i;
|
|
484
|
+
|
|
485
|
+
for (i=0; i<s->irep->slen; i++) {
|
|
486
|
+
if (s->irep->syms[i] == sym) return i;
|
|
487
|
+
}
|
|
488
|
+
if (s->irep->slen > 125 && s->irep->slen < 256) {
|
|
489
|
+
s->irep->syms = (mrb_sym *)codegen_realloc(s, s->irep->syms, sizeof(mrb_sym)*65536);
|
|
490
|
+
for (i = 0; i < 256 - s->irep->slen; i++) {
|
|
491
|
+
static const mrb_sym mrb_sym_zero = { 0 };
|
|
492
|
+
s->irep->syms[i + s->irep->slen] = mrb_sym_zero;
|
|
493
|
+
}
|
|
494
|
+
s->irep->slen = 256;
|
|
495
|
+
}
|
|
496
|
+
s->irep->syms[s->irep->slen] = sym;
|
|
497
|
+
return s->irep->slen++;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
static int
|
|
501
|
+
node_len(node *tree)
|
|
502
|
+
{
|
|
503
|
+
int n = 0;
|
|
504
|
+
|
|
505
|
+
while (tree) {
|
|
506
|
+
n++;
|
|
507
|
+
tree = tree->cdr;
|
|
508
|
+
}
|
|
509
|
+
return n;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
#define sym(x) ((mrb_sym)(intptr_t)(x))
|
|
513
|
+
#define lv_name(lv) sym((lv)->car)
|
|
514
|
+
static int
|
|
515
|
+
lv_idx(codegen_scope *s, mrb_sym id)
|
|
516
|
+
{
|
|
517
|
+
node *lv = s->lv;
|
|
518
|
+
int n = 1;
|
|
519
|
+
|
|
520
|
+
while (lv) {
|
|
521
|
+
if (lv_name(lv) == id) return n;
|
|
522
|
+
n++;
|
|
523
|
+
lv = lv->cdr;
|
|
524
|
+
}
|
|
525
|
+
return 0;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
static void
|
|
529
|
+
for_body(codegen_scope *s, node *tree)
|
|
530
|
+
{
|
|
531
|
+
codegen_scope *prev = s;
|
|
532
|
+
int idx, base = s->idx;
|
|
533
|
+
struct loopinfo *lp;
|
|
534
|
+
node *n2;
|
|
535
|
+
mrb_code c;
|
|
536
|
+
|
|
537
|
+
// generate receiver
|
|
538
|
+
codegen(s, tree->cdr->car, VAL);
|
|
539
|
+
// generate loop-block
|
|
540
|
+
s = scope_new(s->mrb, s, tree->car);
|
|
541
|
+
idx = s->idx;
|
|
542
|
+
|
|
543
|
+
lp = loop_push(s, LOOP_FOR);
|
|
544
|
+
lp->pc1 = new_label(s);
|
|
545
|
+
|
|
546
|
+
// generate loop variable
|
|
547
|
+
n2 = tree->car;
|
|
548
|
+
if (n2->car && !n2->car->cdr && !n2->cdr) {
|
|
549
|
+
genop(s, MKOP_Ax(OP_ENTER, 0x40000));
|
|
550
|
+
gen_assignment(s, n2->car->car, 1, NOVAL);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
genop(s, MKOP_Ax(OP_ENTER, 0x40000));
|
|
554
|
+
gen_vmassignment(s, n2, 1, VAL);
|
|
555
|
+
}
|
|
556
|
+
codegen(s, tree->cdr->cdr->car, VAL);
|
|
557
|
+
pop();
|
|
558
|
+
if (s->pc > 0) {
|
|
559
|
+
c = s->iseq[s->pc-1];
|
|
560
|
+
if (GET_OPCODE(c) != OP_RETURN || GETARG_B(c) != OP_R_NORMAL || s->pc == s->lastlabel)
|
|
561
|
+
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
|
|
562
|
+
}
|
|
563
|
+
loop_pop(s, NOVAL);
|
|
564
|
+
scope_finish(s);
|
|
565
|
+
s = prev;
|
|
566
|
+
genop(s, MKOP_Abc(OP_LAMBDA, cursp(), idx - base, OP_L_BLOCK));
|
|
567
|
+
pop();
|
|
568
|
+
idx = new_msym(s, mrb_intern2(s->mrb, "each", 4));
|
|
569
|
+
genop(s, MKOP_ABC(OP_SENDB, cursp(), idx, 0));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
static int
|
|
573
|
+
lambda_body(codegen_scope *s, node *tree, int blk)
|
|
574
|
+
{
|
|
575
|
+
int idx, base = s->idx;
|
|
576
|
+
mrb_code c;
|
|
577
|
+
|
|
578
|
+
s = scope_new(s->mrb, s, tree->car);
|
|
579
|
+
idx = s->idx;
|
|
580
|
+
s->mscope = !blk;
|
|
581
|
+
|
|
582
|
+
if (blk) {
|
|
583
|
+
struct loopinfo *lp = loop_push(s, LOOP_BLOCK);
|
|
584
|
+
lp->pc1 = new_label(s);
|
|
585
|
+
}
|
|
586
|
+
tree = tree->cdr;
|
|
587
|
+
if (tree->car) {
|
|
588
|
+
mrb_aspec a;
|
|
589
|
+
int ma, oa, ra, pa, ka, kd, ba;
|
|
590
|
+
int pos, i;
|
|
591
|
+
node *n, *opt;
|
|
592
|
+
|
|
593
|
+
ma = node_len(tree->car->car);
|
|
594
|
+
n = tree->car->car;
|
|
595
|
+
while (n) {
|
|
596
|
+
n = n->cdr;
|
|
597
|
+
}
|
|
598
|
+
oa = node_len(tree->car->cdr->car);
|
|
599
|
+
ra = tree->car->cdr->cdr->car ? 1 : 0;
|
|
600
|
+
pa = node_len(tree->car->cdr->cdr->cdr->car);
|
|
601
|
+
ka = kd = 0;
|
|
602
|
+
ba = tree->car->cdr->cdr->cdr->cdr ? 1 : 0;
|
|
603
|
+
|
|
604
|
+
a = ((mrb_aspec)(ma & 0x1f) << 18)
|
|
605
|
+
| ((mrb_aspec)(oa & 0x1f) << 13)
|
|
606
|
+
| ((ra & 1) << 12)
|
|
607
|
+
| ((pa & 0x1f) << 7)
|
|
608
|
+
| ((ka & 0x1f) << 2)
|
|
609
|
+
| ((kd & 1)<< 1)
|
|
610
|
+
| (ba & 1);
|
|
611
|
+
s->ainfo = (((ma+oa) & 0x3f) << 6) /* (12bits = 6:1:5) */
|
|
612
|
+
| ((ra & 1) << 5)
|
|
613
|
+
| (pa & 0x1f);
|
|
614
|
+
genop(s, MKOP_Ax(OP_ENTER, a));
|
|
615
|
+
pos = new_label(s);
|
|
616
|
+
for (i=0; i<oa; i++) {
|
|
617
|
+
new_label(s);
|
|
618
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
619
|
+
}
|
|
620
|
+
if (oa > 0) {
|
|
621
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
622
|
+
}
|
|
623
|
+
opt = tree->car->cdr->car;
|
|
624
|
+
i = 0;
|
|
625
|
+
while (opt) {
|
|
626
|
+
int idx;
|
|
627
|
+
|
|
628
|
+
dispatch(s, pos+i);
|
|
629
|
+
codegen(s, opt->car->cdr, VAL);
|
|
630
|
+
idx = lv_idx(s, (mrb_sym)(intptr_t)opt->car->car);
|
|
631
|
+
pop();
|
|
632
|
+
genop_peep(s, MKOP_AB(OP_MOVE, idx, cursp()), NOVAL);
|
|
633
|
+
i++;
|
|
634
|
+
opt = opt->cdr;
|
|
635
|
+
}
|
|
636
|
+
if (oa > 0) {
|
|
637
|
+
dispatch(s, pos+i);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
codegen(s, tree->cdr->car, VAL);
|
|
641
|
+
pop();
|
|
642
|
+
if (s->pc > 0) {
|
|
643
|
+
c = s->iseq[s->pc-1];
|
|
644
|
+
if (GET_OPCODE(c) != OP_RETURN || GETARG_B(c) != OP_R_NORMAL || s->pc == s->lastlabel) {
|
|
645
|
+
if (s->nregs == 0) {
|
|
646
|
+
genop(s, MKOP_A(OP_LOADNIL, 0));
|
|
647
|
+
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
if (blk) {
|
|
655
|
+
loop_pop(s, NOVAL);
|
|
656
|
+
}
|
|
657
|
+
scope_finish(s);
|
|
658
|
+
|
|
659
|
+
return idx - base;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
static int
|
|
663
|
+
scope_body(codegen_scope *s, node *tree)
|
|
664
|
+
{
|
|
665
|
+
codegen_scope *scope = scope_new(s->mrb, s, tree->car);
|
|
666
|
+
int idx = scope->idx;
|
|
667
|
+
|
|
668
|
+
codegen(scope, tree->cdr, VAL);
|
|
669
|
+
if (!s->iseq) {
|
|
670
|
+
genop(scope, MKOP_A(OP_STOP, 0));
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
if (scope->nregs == 0) {
|
|
674
|
+
genop(scope, MKOP_A(OP_LOADNIL, 0));
|
|
675
|
+
genop(scope, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
genop_peep(scope, MKOP_AB(OP_RETURN, scope->sp, OP_R_NORMAL), NOVAL);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
scope_finish(scope);
|
|
682
|
+
|
|
683
|
+
return idx - s->idx;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
static mrb_bool
|
|
687
|
+
nosplat(node *t)
|
|
688
|
+
{
|
|
689
|
+
while (t) {
|
|
690
|
+
if ((intptr_t)t->car->car == NODE_SPLAT) return FALSE;
|
|
691
|
+
t = t->cdr;
|
|
692
|
+
}
|
|
693
|
+
return TRUE;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
static mrb_sym
|
|
697
|
+
attrsym(codegen_scope *s, mrb_sym a)
|
|
698
|
+
{
|
|
699
|
+
const char *name;
|
|
700
|
+
size_t len;
|
|
701
|
+
char *name2;
|
|
702
|
+
|
|
703
|
+
name = mrb_sym2name_len(s->mrb, a, &len);
|
|
704
|
+
name2 = (char *)codegen_palloc(s, len+1);
|
|
705
|
+
memcpy(name2, name, len);
|
|
706
|
+
name2[len] = '=';
|
|
707
|
+
name2[len+1] = '\0';
|
|
708
|
+
|
|
709
|
+
return mrb_intern2(s->mrb, name2, len+1);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
static int
|
|
713
|
+
gen_values(codegen_scope *s, node *t, int val)
|
|
714
|
+
{
|
|
715
|
+
int n = 0;
|
|
716
|
+
|
|
717
|
+
while (t) {
|
|
718
|
+
if (n >= 127 || (intptr_t)t->car->car == NODE_SPLAT) { // splat mode
|
|
719
|
+
if (val) {
|
|
720
|
+
pop_n(n);
|
|
721
|
+
genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), n));
|
|
722
|
+
push();
|
|
723
|
+
codegen(s, t->car, VAL);
|
|
724
|
+
pop(); pop();
|
|
725
|
+
genop(s, MKOP_AB(OP_ARYCAT, cursp(), cursp()+1));
|
|
726
|
+
t = t->cdr;
|
|
727
|
+
while (t) {
|
|
728
|
+
push();
|
|
729
|
+
codegen(s, t->car, VAL);
|
|
730
|
+
pop(); pop();
|
|
731
|
+
if ((intptr_t)t->car->car == NODE_SPLAT) {
|
|
732
|
+
genop(s, MKOP_AB(OP_ARYCAT, cursp(), cursp()+1));
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
genop(s, MKOP_AB(OP_ARYPUSH, cursp(), cursp()+1));
|
|
736
|
+
}
|
|
737
|
+
t = t->cdr;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
codegen(s, t->car->cdr, NOVAL);
|
|
742
|
+
t = t->cdr;
|
|
743
|
+
while (t) {
|
|
744
|
+
codegen(s, t->car, NOVAL);
|
|
745
|
+
t = t->cdr;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return -1;
|
|
749
|
+
}
|
|
750
|
+
// normal (no splat) mode
|
|
751
|
+
codegen(s, t->car, val);
|
|
752
|
+
n++;
|
|
753
|
+
t = t->cdr;
|
|
754
|
+
}
|
|
755
|
+
return n;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
#define CALL_MAXARGS 127
|
|
759
|
+
|
|
760
|
+
static void
|
|
761
|
+
gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val)
|
|
762
|
+
{
|
|
763
|
+
mrb_sym sym = name ? name : sym(tree->cdr->car);
|
|
764
|
+
int idx;
|
|
765
|
+
int n = 0, noop = 0, sendv = 0, blk = 0;
|
|
766
|
+
|
|
767
|
+
codegen(s, tree->car, VAL); /* receiver */
|
|
768
|
+
idx = new_msym(s, sym);
|
|
769
|
+
tree = tree->cdr->cdr->car;
|
|
770
|
+
if (tree) {
|
|
771
|
+
n = gen_values(s, tree->car, VAL);
|
|
772
|
+
if (n < 0) {
|
|
773
|
+
n = noop = sendv = 1;
|
|
774
|
+
push();
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if (sp) {
|
|
778
|
+
if (sendv) {
|
|
779
|
+
pop();
|
|
780
|
+
genop(s, MKOP_AB(OP_ARYPUSH, cursp(), sp));
|
|
781
|
+
push();
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
genop(s, MKOP_AB(OP_MOVE, cursp(), sp));
|
|
785
|
+
push();
|
|
786
|
+
n++;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (tree && tree->cdr) {
|
|
790
|
+
noop = 1;
|
|
791
|
+
codegen(s, tree->cdr, VAL);
|
|
792
|
+
pop();
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
blk = cursp();
|
|
796
|
+
}
|
|
797
|
+
pop_n(n+1);
|
|
798
|
+
{
|
|
799
|
+
size_t len;
|
|
800
|
+
const char *name = mrb_sym2name_len(s->mrb, sym, &len);
|
|
801
|
+
|
|
802
|
+
if (!noop && len == 1 && name[0] == '+') {
|
|
803
|
+
genop_peep(s, MKOP_ABC(OP_ADD, cursp(), idx, n), val);
|
|
804
|
+
}
|
|
805
|
+
else if (!noop && len == 1 && name[0] == '-') {
|
|
806
|
+
genop_peep(s, MKOP_ABC(OP_SUB, cursp(), idx, n), val);
|
|
807
|
+
}
|
|
808
|
+
else if (!noop && len == 1 && name[0] == '*') {
|
|
809
|
+
genop(s, MKOP_ABC(OP_MUL, cursp(), idx, n));
|
|
810
|
+
}
|
|
811
|
+
else if (!noop && len == 1 && name[0] == '/') {
|
|
812
|
+
genop(s, MKOP_ABC(OP_DIV, cursp(), idx, n));
|
|
813
|
+
}
|
|
814
|
+
else if (!noop && len == 1 && name[0] == '<') {
|
|
815
|
+
genop(s, MKOP_ABC(OP_LT, cursp(), idx, n));
|
|
816
|
+
}
|
|
817
|
+
else if (!noop && len == 2 && name[0] == '<' && name[1] == '=') {
|
|
818
|
+
genop(s, MKOP_ABC(OP_LE, cursp(), idx, n));
|
|
819
|
+
}
|
|
820
|
+
else if (!noop && len == 1 && name[0] == '>') {
|
|
821
|
+
genop(s, MKOP_ABC(OP_GT, cursp(), idx, n));
|
|
822
|
+
}
|
|
823
|
+
else if (!noop && len == 2 && name[0] == '>' && name[1] == '=') {
|
|
824
|
+
genop(s, MKOP_ABC(OP_GE, cursp(), idx, n));
|
|
825
|
+
}
|
|
826
|
+
else if (!noop && len == 2 && name[0] == '=' && name[1] == '=') {
|
|
827
|
+
genop(s, MKOP_ABC(OP_EQ, cursp(), idx, n));
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
if (sendv) n = CALL_MAXARGS;
|
|
831
|
+
if (blk > 0) { /* no block */
|
|
832
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), idx, n));
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
genop(s, MKOP_ABC(OP_SENDB, cursp(), idx, n));
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (val) {
|
|
840
|
+
push();
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
static void
|
|
845
|
+
gen_assignment(codegen_scope *s, node *node, int sp, int val)
|
|
846
|
+
{
|
|
847
|
+
int idx;
|
|
848
|
+
int type = (intptr_t)node->car;
|
|
849
|
+
|
|
850
|
+
node = node->cdr;
|
|
851
|
+
switch ((intptr_t)type) {
|
|
852
|
+
case NODE_GVAR:
|
|
853
|
+
idx = new_sym(s, sym(node));
|
|
854
|
+
genop_peep(s, MKOP_ABx(OP_SETGLOBAL, sp, idx), val);
|
|
855
|
+
break;
|
|
856
|
+
case NODE_LVAR:
|
|
857
|
+
idx = lv_idx(s, sym(node));
|
|
858
|
+
if (idx > 0) {
|
|
859
|
+
if (idx != sp) {
|
|
860
|
+
genop_peep(s, MKOP_AB(OP_MOVE, idx, sp), val);
|
|
861
|
+
}
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
else { /* upvar */
|
|
865
|
+
int lv = 0;
|
|
866
|
+
codegen_scope *up = s->prev;
|
|
867
|
+
|
|
868
|
+
while (up) {
|
|
869
|
+
idx = lv_idx(up, sym(node));
|
|
870
|
+
if (idx > 0) {
|
|
871
|
+
genop_peep(s, MKOP_ABC(OP_SETUPVAR, sp, idx, lv), val);
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
lv++;
|
|
875
|
+
up = up->prev;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
break;
|
|
879
|
+
case NODE_IVAR:
|
|
880
|
+
idx = new_sym(s, sym(node));
|
|
881
|
+
genop_peep(s, MKOP_ABx(OP_SETIV, sp, idx), val);
|
|
882
|
+
break;
|
|
883
|
+
case NODE_CVAR:
|
|
884
|
+
idx = new_sym(s, sym(node));
|
|
885
|
+
genop_peep(s, MKOP_ABx(OP_SETCV, sp, idx), val);
|
|
886
|
+
break;
|
|
887
|
+
case NODE_CONST:
|
|
888
|
+
idx = new_sym(s, sym(node));
|
|
889
|
+
genop_peep(s, MKOP_ABx(OP_SETCONST, sp, idx), val);
|
|
890
|
+
break;
|
|
891
|
+
case NODE_COLON2:
|
|
892
|
+
idx = new_sym(s, sym(node->cdr));
|
|
893
|
+
genop_peep(s, MKOP_AB(OP_MOVE, cursp(), sp), NOVAL);
|
|
894
|
+
push();
|
|
895
|
+
codegen(s, node->car, VAL);
|
|
896
|
+
pop_n(2);
|
|
897
|
+
genop_peep(s, MKOP_ABx(OP_SETMCNST, cursp(), idx), val);
|
|
898
|
+
break;
|
|
899
|
+
|
|
900
|
+
case NODE_CALL:
|
|
901
|
+
push();
|
|
902
|
+
gen_call(s, node, attrsym(s, sym(node->cdr->car)), sp, NOVAL);
|
|
903
|
+
pop();
|
|
904
|
+
if (val) {
|
|
905
|
+
genop_peep(s, MKOP_AB(OP_MOVE, cursp(), sp), val);
|
|
906
|
+
}
|
|
907
|
+
break;
|
|
908
|
+
|
|
909
|
+
default:
|
|
910
|
+
#ifdef ENABLE_STDIO
|
|
911
|
+
printf("unknown lhs %d\n", type);
|
|
912
|
+
#endif
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
if (val) push();
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
static void
|
|
919
|
+
gen_vmassignment(codegen_scope *s, node *tree, int rhs, int val)
|
|
920
|
+
{
|
|
921
|
+
int n = 0, post = 0;
|
|
922
|
+
node *t, *p;
|
|
923
|
+
|
|
924
|
+
if (tree->car) { /* pre */
|
|
925
|
+
t = tree->car;
|
|
926
|
+
n = 0;
|
|
927
|
+
while (t) {
|
|
928
|
+
genop(s, MKOP_ABC(OP_AREF, cursp(), rhs, n));
|
|
929
|
+
gen_assignment(s, t->car, cursp(), NOVAL);
|
|
930
|
+
n++;
|
|
931
|
+
t = t->cdr;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
t = tree->cdr;
|
|
935
|
+
if (t) {
|
|
936
|
+
if (t->cdr) { /* post count */
|
|
937
|
+
p = t->cdr->car;
|
|
938
|
+
while (p) {
|
|
939
|
+
post++;
|
|
940
|
+
p = p->cdr;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (val) {
|
|
944
|
+
genop(s, MKOP_AB(OP_MOVE, cursp(), rhs));
|
|
945
|
+
push();
|
|
946
|
+
}
|
|
947
|
+
pop();
|
|
948
|
+
genop(s, MKOP_ABC(OP_APOST, cursp(), n, post));
|
|
949
|
+
n = 1;
|
|
950
|
+
if (t->car) { /* rest */
|
|
951
|
+
gen_assignment(s, t->car, cursp(), NOVAL);
|
|
952
|
+
}
|
|
953
|
+
if (t->cdr && t->cdr->car) {
|
|
954
|
+
t = t->cdr->car;
|
|
955
|
+
while (t) {
|
|
956
|
+
gen_assignment(s, t->car, cursp()+n, NOVAL);
|
|
957
|
+
t = t->cdr;
|
|
958
|
+
n++;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
static void
|
|
965
|
+
gen_send_intern(codegen_scope *s)
|
|
966
|
+
{
|
|
967
|
+
pop();
|
|
968
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern2(s->mrb, "intern", 6)), 0));
|
|
969
|
+
push();
|
|
970
|
+
}
|
|
971
|
+
static void
|
|
972
|
+
gen_literal_array(codegen_scope *s, node *tree, int sym, int val)
|
|
973
|
+
{
|
|
974
|
+
if (val) {
|
|
975
|
+
int i = 0, j = 0;
|
|
976
|
+
|
|
977
|
+
while (tree) {
|
|
978
|
+
switch ((intptr_t)tree->car->car) {
|
|
979
|
+
case NODE_STR:
|
|
980
|
+
if ((tree->cdr == NULL) && ((intptr_t)tree->car->cdr->cdr == 0))
|
|
981
|
+
break;
|
|
982
|
+
/* fall through */
|
|
983
|
+
case NODE_BEGIN:
|
|
984
|
+
codegen(s, tree->car, VAL);
|
|
985
|
+
++j;
|
|
986
|
+
break;
|
|
987
|
+
|
|
988
|
+
case NODE_LITERAL_DELIM:
|
|
989
|
+
if (j > 0) {
|
|
990
|
+
j = 0;
|
|
991
|
+
++i;
|
|
992
|
+
if (sym)
|
|
993
|
+
gen_send_intern(s);
|
|
994
|
+
}
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
if (j >= 2) {
|
|
998
|
+
pop(); pop();
|
|
999
|
+
genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
|
|
1000
|
+
push();
|
|
1001
|
+
j = 1;
|
|
1002
|
+
}
|
|
1003
|
+
tree = tree->cdr;
|
|
1004
|
+
}
|
|
1005
|
+
if (j > 0) {
|
|
1006
|
+
++i;
|
|
1007
|
+
if (sym)
|
|
1008
|
+
gen_send_intern(s);
|
|
1009
|
+
}
|
|
1010
|
+
pop_n(i);
|
|
1011
|
+
genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), i));
|
|
1012
|
+
push();
|
|
1013
|
+
}
|
|
1014
|
+
else {
|
|
1015
|
+
while (tree) {
|
|
1016
|
+
switch ((intptr_t)tree->car->car) {
|
|
1017
|
+
case NODE_BEGIN: case NODE_BLOCK:
|
|
1018
|
+
codegen(s, tree->car, NOVAL);
|
|
1019
|
+
}
|
|
1020
|
+
tree = tree->cdr;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
static void
|
|
1026
|
+
raise_error(codegen_scope *s, const char *msg)
|
|
1027
|
+
{
|
|
1028
|
+
int idx = new_lit(s, mrb_str_new_cstr(s->mrb, msg));
|
|
1029
|
+
|
|
1030
|
+
genop(s, MKOP_ABx(OP_ERR, 1, idx));
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
static double
|
|
1034
|
+
readint_float(codegen_scope *s, const char *p, int base)
|
|
1035
|
+
{
|
|
1036
|
+
const char *e = p + strlen(p);
|
|
1037
|
+
double f = 0;
|
|
1038
|
+
int n;
|
|
1039
|
+
|
|
1040
|
+
if (*p == '+') p++;
|
|
1041
|
+
while (p < e) {
|
|
1042
|
+
char c = *p;
|
|
1043
|
+
c = tolower((unsigned char)c);
|
|
1044
|
+
for (n=0; n<base; n++) {
|
|
1045
|
+
if (mrb_digitmap[n] == c) {
|
|
1046
|
+
f *= base;
|
|
1047
|
+
f += n;
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (n == base) {
|
|
1052
|
+
codegen_error(s, "malformed readint input");
|
|
1053
|
+
}
|
|
1054
|
+
p++;
|
|
1055
|
+
}
|
|
1056
|
+
return f;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
static mrb_int
|
|
1060
|
+
readint_mrb_int(codegen_scope *s, const char *p, int base, int neg, int *overflow)
|
|
1061
|
+
{
|
|
1062
|
+
const char *e = p + strlen(p);
|
|
1063
|
+
mrb_int result = 0;
|
|
1064
|
+
int n;
|
|
1065
|
+
|
|
1066
|
+
if (*p == '+') p++;
|
|
1067
|
+
while (p < e) {
|
|
1068
|
+
char c = *p;
|
|
1069
|
+
c = tolower((unsigned char)c);
|
|
1070
|
+
for (n=0; n<base; n++) {
|
|
1071
|
+
if (mrb_digitmap[n] == c) {
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (n == base) {
|
|
1076
|
+
codegen_error(s, "malformed readint input");
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
if (neg) {
|
|
1080
|
+
if ((MRB_INT_MIN + n)/base > result) {
|
|
1081
|
+
*overflow = TRUE;
|
|
1082
|
+
return 0;
|
|
1083
|
+
}
|
|
1084
|
+
result *= base;
|
|
1085
|
+
result -= n;
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
if ((MRB_INT_MAX - n)/base < result) {
|
|
1089
|
+
*overflow = TRUE;
|
|
1090
|
+
return 0;
|
|
1091
|
+
}
|
|
1092
|
+
result *= base;
|
|
1093
|
+
result += n;
|
|
1094
|
+
}
|
|
1095
|
+
p++;
|
|
1096
|
+
}
|
|
1097
|
+
*overflow = FALSE;
|
|
1098
|
+
return result;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
static void
|
|
1102
|
+
codegen(codegen_scope *s, node *tree, int val)
|
|
1103
|
+
{
|
|
1104
|
+
int nt;
|
|
1105
|
+
|
|
1106
|
+
if (!tree) return;
|
|
1107
|
+
nt = (intptr_t)tree->car;
|
|
1108
|
+
s->lineno = tree->lineno;
|
|
1109
|
+
tree = tree->cdr;
|
|
1110
|
+
switch (nt) {
|
|
1111
|
+
case NODE_BEGIN:
|
|
1112
|
+
if (val && !tree) {
|
|
1113
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1114
|
+
push();
|
|
1115
|
+
}
|
|
1116
|
+
while (tree) {
|
|
1117
|
+
codegen(s, tree->car, tree->cdr ? NOVAL : val);
|
|
1118
|
+
tree = tree->cdr;
|
|
1119
|
+
}
|
|
1120
|
+
break;
|
|
1121
|
+
|
|
1122
|
+
case NODE_RESCUE:
|
|
1123
|
+
{
|
|
1124
|
+
int onerr, noexc, exend, pos1, pos2, tmp;
|
|
1125
|
+
struct loopinfo *lp;
|
|
1126
|
+
|
|
1127
|
+
onerr = new_label(s);
|
|
1128
|
+
genop(s, MKOP_Bx(OP_ONERR, 0));
|
|
1129
|
+
lp = loop_push(s, LOOP_BEGIN);
|
|
1130
|
+
lp->pc1 = onerr;
|
|
1131
|
+
if (tree->car) {
|
|
1132
|
+
codegen(s, tree->car, val);
|
|
1133
|
+
if (val) pop();
|
|
1134
|
+
}
|
|
1135
|
+
lp->type = LOOP_RESCUE;
|
|
1136
|
+
noexc = new_label(s);
|
|
1137
|
+
genop(s, MKOP_Bx(OP_JMP, 0));
|
|
1138
|
+
dispatch(s, onerr);
|
|
1139
|
+
tree = tree->cdr;
|
|
1140
|
+
exend = 0;
|
|
1141
|
+
pos1 = 0;
|
|
1142
|
+
if (tree->car) {
|
|
1143
|
+
node *n2 = tree->car;
|
|
1144
|
+
int exc = cursp();
|
|
1145
|
+
|
|
1146
|
+
genop(s, MKOP_A(OP_RESCUE, exc));
|
|
1147
|
+
push();
|
|
1148
|
+
while (n2) {
|
|
1149
|
+
node *n3 = n2->car;
|
|
1150
|
+
node *n4 = n3->car;
|
|
1151
|
+
|
|
1152
|
+
if (pos1) dispatch(s, pos1);
|
|
1153
|
+
pos2 = 0;
|
|
1154
|
+
do {
|
|
1155
|
+
if (n4) {
|
|
1156
|
+
codegen(s, n4->car, VAL);
|
|
1157
|
+
}
|
|
1158
|
+
else {
|
|
1159
|
+
genop(s, MKOP_ABx(OP_GETCONST, cursp(), new_msym(s, mrb_intern2(s->mrb, "StandardError", 13))));
|
|
1160
|
+
push();
|
|
1161
|
+
}
|
|
1162
|
+
genop(s, MKOP_AB(OP_MOVE, cursp(), exc));
|
|
1163
|
+
pop();
|
|
1164
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern2(s->mrb, "===", 3)), 1));
|
|
1165
|
+
tmp = new_label(s);
|
|
1166
|
+
genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2));
|
|
1167
|
+
pos2 = tmp;
|
|
1168
|
+
if (n4) {
|
|
1169
|
+
n4 = n4->cdr;
|
|
1170
|
+
}
|
|
1171
|
+
} while (n4);
|
|
1172
|
+
pos1 = new_label(s);
|
|
1173
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
1174
|
+
dispatch_linked(s, pos2);
|
|
1175
|
+
|
|
1176
|
+
pop();
|
|
1177
|
+
if (n3->cdr->car) {
|
|
1178
|
+
gen_assignment(s, n3->cdr->car, exc, NOVAL);
|
|
1179
|
+
}
|
|
1180
|
+
if (n3->cdr->cdr->car) {
|
|
1181
|
+
codegen(s, n3->cdr->cdr->car, val);
|
|
1182
|
+
if (val) pop();
|
|
1183
|
+
}
|
|
1184
|
+
tmp = new_label(s);
|
|
1185
|
+
genop(s, MKOP_sBx(OP_JMP, exend));
|
|
1186
|
+
exend = tmp;
|
|
1187
|
+
n2 = n2->cdr;
|
|
1188
|
+
push();
|
|
1189
|
+
}
|
|
1190
|
+
if (pos1) {
|
|
1191
|
+
dispatch(s, pos1);
|
|
1192
|
+
genop(s, MKOP_A(OP_RAISE, exc));
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
pop();
|
|
1196
|
+
tree = tree->cdr;
|
|
1197
|
+
dispatch(s, noexc);
|
|
1198
|
+
genop(s, MKOP_A(OP_POPERR, 1));
|
|
1199
|
+
if (tree->car) {
|
|
1200
|
+
codegen(s, tree->car, val);
|
|
1201
|
+
}
|
|
1202
|
+
else if (val) {
|
|
1203
|
+
push();
|
|
1204
|
+
}
|
|
1205
|
+
dispatch_linked(s, exend);
|
|
1206
|
+
loop_pop(s, NOVAL);
|
|
1207
|
+
}
|
|
1208
|
+
break;
|
|
1209
|
+
|
|
1210
|
+
case NODE_ENSURE:
|
|
1211
|
+
{
|
|
1212
|
+
int idx;
|
|
1213
|
+
int epush = s->pc;
|
|
1214
|
+
|
|
1215
|
+
genop(s, MKOP_Bx(OP_EPUSH, 0));
|
|
1216
|
+
s->ensure_level++;
|
|
1217
|
+
codegen(s, tree->car, val);
|
|
1218
|
+
idx = scope_body(s, tree->cdr);
|
|
1219
|
+
s->iseq[epush] = MKOP_Bx(OP_EPUSH, idx);
|
|
1220
|
+
s->ensure_level--;
|
|
1221
|
+
genop_peep(s, MKOP_A(OP_EPOP, 1), NOVAL);
|
|
1222
|
+
}
|
|
1223
|
+
break;
|
|
1224
|
+
|
|
1225
|
+
case NODE_LAMBDA:
|
|
1226
|
+
{
|
|
1227
|
+
int idx = lambda_body(s, tree, 1);
|
|
1228
|
+
|
|
1229
|
+
genop(s, MKOP_Abc(OP_LAMBDA, cursp(), idx, OP_L_LAMBDA));
|
|
1230
|
+
push();
|
|
1231
|
+
}
|
|
1232
|
+
break;
|
|
1233
|
+
|
|
1234
|
+
case NODE_BLOCK:
|
|
1235
|
+
{
|
|
1236
|
+
int idx = lambda_body(s, tree, 1);
|
|
1237
|
+
|
|
1238
|
+
genop(s, MKOP_Abc(OP_LAMBDA, cursp(), idx, OP_L_BLOCK));
|
|
1239
|
+
push();
|
|
1240
|
+
}
|
|
1241
|
+
break;
|
|
1242
|
+
|
|
1243
|
+
case NODE_IF:
|
|
1244
|
+
{
|
|
1245
|
+
int pos1, pos2;
|
|
1246
|
+
node *e = tree->cdr->cdr->car;
|
|
1247
|
+
|
|
1248
|
+
codegen(s, tree->car, VAL);
|
|
1249
|
+
pop();
|
|
1250
|
+
pos1 = new_label(s);
|
|
1251
|
+
genop(s, MKOP_AsBx(OP_JMPNOT, cursp(), 0));
|
|
1252
|
+
|
|
1253
|
+
codegen(s, tree->cdr->car, val);
|
|
1254
|
+
if (val && !(tree->cdr->car)) {
|
|
1255
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1256
|
+
push();
|
|
1257
|
+
}
|
|
1258
|
+
if (e) {
|
|
1259
|
+
if (val) pop();
|
|
1260
|
+
pos2 = new_label(s);
|
|
1261
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
1262
|
+
dispatch(s, pos1);
|
|
1263
|
+
codegen(s, e, val);
|
|
1264
|
+
dispatch(s, pos2);
|
|
1265
|
+
}
|
|
1266
|
+
else {
|
|
1267
|
+
if (val) {
|
|
1268
|
+
pop();
|
|
1269
|
+
pos2 = new_label(s);
|
|
1270
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
1271
|
+
dispatch(s, pos1);
|
|
1272
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1273
|
+
dispatch(s, pos2);
|
|
1274
|
+
push();
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
dispatch(s, pos1);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
break;
|
|
1282
|
+
|
|
1283
|
+
case NODE_AND:
|
|
1284
|
+
{
|
|
1285
|
+
int pos;
|
|
1286
|
+
|
|
1287
|
+
codegen(s, tree->car, VAL);
|
|
1288
|
+
pos = new_label(s);
|
|
1289
|
+
pop();
|
|
1290
|
+
genop(s, MKOP_AsBx(OP_JMPNOT, cursp(), 0));
|
|
1291
|
+
codegen(s, tree->cdr, val);
|
|
1292
|
+
dispatch(s, pos);
|
|
1293
|
+
}
|
|
1294
|
+
break;
|
|
1295
|
+
|
|
1296
|
+
case NODE_OR:
|
|
1297
|
+
{
|
|
1298
|
+
int pos;
|
|
1299
|
+
|
|
1300
|
+
codegen(s, tree->car, VAL);
|
|
1301
|
+
pos = new_label(s);
|
|
1302
|
+
pop();
|
|
1303
|
+
genop(s, MKOP_AsBx(OP_JMPIF, cursp(), 0));
|
|
1304
|
+
codegen(s, tree->cdr, val);
|
|
1305
|
+
dispatch(s, pos);
|
|
1306
|
+
}
|
|
1307
|
+
break;
|
|
1308
|
+
|
|
1309
|
+
case NODE_WHILE:
|
|
1310
|
+
{
|
|
1311
|
+
struct loopinfo *lp = loop_push(s, LOOP_NORMAL);
|
|
1312
|
+
|
|
1313
|
+
lp->pc1 = new_label(s);
|
|
1314
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
1315
|
+
lp->pc2 = new_label(s);
|
|
1316
|
+
codegen(s, tree->cdr, NOVAL);
|
|
1317
|
+
dispatch(s, lp->pc1);
|
|
1318
|
+
codegen(s, tree->car, VAL);
|
|
1319
|
+
pop();
|
|
1320
|
+
genop(s, MKOP_AsBx(OP_JMPIF, cursp(), lp->pc2 - s->pc));
|
|
1321
|
+
|
|
1322
|
+
loop_pop(s, val);
|
|
1323
|
+
}
|
|
1324
|
+
break;
|
|
1325
|
+
|
|
1326
|
+
case NODE_UNTIL:
|
|
1327
|
+
{
|
|
1328
|
+
struct loopinfo *lp = loop_push(s, LOOP_NORMAL);
|
|
1329
|
+
|
|
1330
|
+
lp->pc1 = new_label(s);
|
|
1331
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
1332
|
+
lp->pc2 = new_label(s);
|
|
1333
|
+
codegen(s, tree->cdr, NOVAL);
|
|
1334
|
+
dispatch(s, lp->pc1);
|
|
1335
|
+
codegen(s, tree->car, VAL);
|
|
1336
|
+
pop();
|
|
1337
|
+
genop(s, MKOP_AsBx(OP_JMPNOT, cursp(), lp->pc2 - s->pc));
|
|
1338
|
+
|
|
1339
|
+
loop_pop(s, val);
|
|
1340
|
+
}
|
|
1341
|
+
break;
|
|
1342
|
+
|
|
1343
|
+
case NODE_FOR:
|
|
1344
|
+
for_body(s, tree);
|
|
1345
|
+
if (val) push();
|
|
1346
|
+
break;
|
|
1347
|
+
|
|
1348
|
+
case NODE_CASE:
|
|
1349
|
+
{
|
|
1350
|
+
int head = 0;
|
|
1351
|
+
int pos1, pos2, pos3, tmp;
|
|
1352
|
+
node *n;
|
|
1353
|
+
|
|
1354
|
+
pos3 = 0;
|
|
1355
|
+
if (tree->car) {
|
|
1356
|
+
head = cursp();
|
|
1357
|
+
codegen(s, tree->car, VAL);
|
|
1358
|
+
}
|
|
1359
|
+
tree = tree->cdr;
|
|
1360
|
+
while (tree) {
|
|
1361
|
+
n = tree->car->car;
|
|
1362
|
+
pos1 = pos2 = 0;
|
|
1363
|
+
while (n) {
|
|
1364
|
+
codegen(s, n->car, VAL);
|
|
1365
|
+
if (head) {
|
|
1366
|
+
genop(s, MKOP_AB(OP_MOVE, cursp(), head));
|
|
1367
|
+
pop();
|
|
1368
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern2(s->mrb, "===", 3)), 1));
|
|
1369
|
+
}
|
|
1370
|
+
else {
|
|
1371
|
+
pop();
|
|
1372
|
+
}
|
|
1373
|
+
tmp = new_label(s);
|
|
1374
|
+
genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2));
|
|
1375
|
+
pos2 = tmp;
|
|
1376
|
+
n = n->cdr;
|
|
1377
|
+
}
|
|
1378
|
+
if (tree->car->car) {
|
|
1379
|
+
pos1 = new_label(s);
|
|
1380
|
+
genop(s, MKOP_sBx(OP_JMP, 0));
|
|
1381
|
+
dispatch_linked(s, pos2);
|
|
1382
|
+
}
|
|
1383
|
+
codegen(s, tree->car->cdr, val);
|
|
1384
|
+
if (val) pop();
|
|
1385
|
+
tmp = new_label(s);
|
|
1386
|
+
genop(s, MKOP_sBx(OP_JMP, pos3));
|
|
1387
|
+
pos3 = tmp;
|
|
1388
|
+
if (pos1) dispatch(s, pos1);
|
|
1389
|
+
tree = tree->cdr;
|
|
1390
|
+
}
|
|
1391
|
+
if (val) {
|
|
1392
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1393
|
+
push();
|
|
1394
|
+
}
|
|
1395
|
+
if (pos3) dispatch_linked(s, pos3);
|
|
1396
|
+
}
|
|
1397
|
+
break;
|
|
1398
|
+
|
|
1399
|
+
case NODE_SCOPE:
|
|
1400
|
+
scope_body(s, tree);
|
|
1401
|
+
break;
|
|
1402
|
+
|
|
1403
|
+
case NODE_FCALL:
|
|
1404
|
+
case NODE_CALL:
|
|
1405
|
+
gen_call(s, tree, 0, 0, val);
|
|
1406
|
+
break;
|
|
1407
|
+
|
|
1408
|
+
case NODE_DOT2:
|
|
1409
|
+
codegen(s, tree->car, val);
|
|
1410
|
+
codegen(s, tree->cdr, val);
|
|
1411
|
+
if (val) {
|
|
1412
|
+
pop(); pop();
|
|
1413
|
+
genop(s, MKOP_ABC(OP_RANGE, cursp(), cursp(), 0));
|
|
1414
|
+
push();
|
|
1415
|
+
}
|
|
1416
|
+
break;
|
|
1417
|
+
|
|
1418
|
+
case NODE_DOT3:
|
|
1419
|
+
codegen(s, tree->car, val);
|
|
1420
|
+
codegen(s, tree->cdr, val);
|
|
1421
|
+
if (val) {
|
|
1422
|
+
pop(); pop();
|
|
1423
|
+
genop(s, MKOP_ABC(OP_RANGE, cursp(), cursp(), 1));
|
|
1424
|
+
push();
|
|
1425
|
+
}
|
|
1426
|
+
break;
|
|
1427
|
+
|
|
1428
|
+
case NODE_COLON2:
|
|
1429
|
+
{
|
|
1430
|
+
int sym = new_sym(s, sym(tree->cdr));
|
|
1431
|
+
|
|
1432
|
+
codegen(s, tree->car, VAL);
|
|
1433
|
+
pop();
|
|
1434
|
+
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
|
|
1435
|
+
if (val) push();
|
|
1436
|
+
}
|
|
1437
|
+
break;
|
|
1438
|
+
|
|
1439
|
+
case NODE_COLON3:
|
|
1440
|
+
{
|
|
1441
|
+
int sym = new_sym(s, sym(tree));
|
|
1442
|
+
|
|
1443
|
+
genop(s, MKOP_A(OP_OCLASS, cursp()));
|
|
1444
|
+
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
|
|
1445
|
+
if (val) push();
|
|
1446
|
+
}
|
|
1447
|
+
break;
|
|
1448
|
+
|
|
1449
|
+
case NODE_ARRAY:
|
|
1450
|
+
{
|
|
1451
|
+
int n;
|
|
1452
|
+
|
|
1453
|
+
n = gen_values(s, tree, val);
|
|
1454
|
+
if (n >= 0) {
|
|
1455
|
+
if (val) {
|
|
1456
|
+
pop_n(n);
|
|
1457
|
+
genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), n));
|
|
1458
|
+
push();
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
else if (val) {
|
|
1462
|
+
push();
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
break;
|
|
1466
|
+
|
|
1467
|
+
case NODE_HASH:
|
|
1468
|
+
{
|
|
1469
|
+
int len = 0;
|
|
1470
|
+
|
|
1471
|
+
while (tree) {
|
|
1472
|
+
codegen(s, tree->car->car, val);
|
|
1473
|
+
codegen(s, tree->car->cdr, val);
|
|
1474
|
+
len++;
|
|
1475
|
+
tree = tree->cdr;
|
|
1476
|
+
}
|
|
1477
|
+
if (val) {
|
|
1478
|
+
pop_n(len*2);
|
|
1479
|
+
genop(s, MKOP_ABC(OP_HASH, cursp(), cursp(), len));
|
|
1480
|
+
push();
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
break;
|
|
1484
|
+
|
|
1485
|
+
case NODE_SPLAT:
|
|
1486
|
+
codegen(s, tree, VAL);
|
|
1487
|
+
break;
|
|
1488
|
+
|
|
1489
|
+
case NODE_ASGN:
|
|
1490
|
+
codegen(s, tree->cdr, VAL);
|
|
1491
|
+
pop();
|
|
1492
|
+
gen_assignment(s, tree->car, cursp(), val);
|
|
1493
|
+
break;
|
|
1494
|
+
|
|
1495
|
+
case NODE_MASGN:
|
|
1496
|
+
{
|
|
1497
|
+
int len = 0, n = 0, post = 0;
|
|
1498
|
+
node *t = tree->cdr, *p;
|
|
1499
|
+
int rhs = cursp();
|
|
1500
|
+
|
|
1501
|
+
if ((intptr_t)t->car == NODE_ARRAY && nosplat(t->cdr)) {
|
|
1502
|
+
// fixed rhs
|
|
1503
|
+
t = t->cdr;
|
|
1504
|
+
while (t) {
|
|
1505
|
+
codegen(s, t->car, VAL);
|
|
1506
|
+
len++;
|
|
1507
|
+
t = t->cdr;
|
|
1508
|
+
}
|
|
1509
|
+
tree = tree->car;
|
|
1510
|
+
if (tree->car) { /* pre */
|
|
1511
|
+
t = tree->car;
|
|
1512
|
+
n = 0;
|
|
1513
|
+
while (t) {
|
|
1514
|
+
gen_assignment(s, t->car, rhs+n, NOVAL);
|
|
1515
|
+
n++;
|
|
1516
|
+
t = t->cdr;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
t = tree->cdr;
|
|
1520
|
+
if (t) {
|
|
1521
|
+
if (t->cdr) { /* post count */
|
|
1522
|
+
p = t->cdr->car;
|
|
1523
|
+
while (p) {
|
|
1524
|
+
post++;
|
|
1525
|
+
p = p->cdr;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
if (t->car) { /* rest (len - pre - post) */
|
|
1529
|
+
int rn = len - post - n;
|
|
1530
|
+
|
|
1531
|
+
genop(s, MKOP_ABC(OP_ARRAY, cursp(), rhs+n, rn));
|
|
1532
|
+
gen_assignment(s, t->car, cursp(), NOVAL);
|
|
1533
|
+
n += rn;
|
|
1534
|
+
}
|
|
1535
|
+
if (t->cdr && t->cdr->car) {
|
|
1536
|
+
t = t->cdr->car;
|
|
1537
|
+
while (n<len) {
|
|
1538
|
+
gen_assignment(s, t->car, rhs+n, NOVAL);
|
|
1539
|
+
t = t->cdr;
|
|
1540
|
+
n++;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
pop_n(len);
|
|
1545
|
+
if (val) {
|
|
1546
|
+
genop(s, MKOP_ABC(OP_ARRAY, rhs, rhs, len));
|
|
1547
|
+
push();
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
else {
|
|
1551
|
+
// variable rhs
|
|
1552
|
+
codegen(s, t, VAL);
|
|
1553
|
+
gen_vmassignment(s, tree->car, rhs, val);
|
|
1554
|
+
if (!val) pop();
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
break;
|
|
1558
|
+
|
|
1559
|
+
case NODE_OP_ASGN:
|
|
1560
|
+
{
|
|
1561
|
+
mrb_sym sym = sym(tree->cdr->car);
|
|
1562
|
+
size_t len;
|
|
1563
|
+
const char *name = mrb_sym2name_len(s->mrb, sym, &len);
|
|
1564
|
+
int idx;
|
|
1565
|
+
|
|
1566
|
+
codegen(s, tree->car, VAL);
|
|
1567
|
+
if (len == 2 &&
|
|
1568
|
+
((name[0] == '|' && name[1] == '|') ||
|
|
1569
|
+
(name[0] == '&' && name[1] == '&'))) {
|
|
1570
|
+
int pos;
|
|
1571
|
+
|
|
1572
|
+
pop();
|
|
1573
|
+
pos = new_label(s);
|
|
1574
|
+
genop(s, MKOP_AsBx(name[0] == '|' ? OP_JMPIF : OP_JMPNOT, cursp(), 0));
|
|
1575
|
+
codegen(s, tree->cdr->cdr->car, VAL);
|
|
1576
|
+
pop();
|
|
1577
|
+
gen_assignment(s, tree->car, cursp(), val);
|
|
1578
|
+
dispatch(s, pos);
|
|
1579
|
+
break;
|
|
1580
|
+
}
|
|
1581
|
+
codegen(s, tree->cdr->cdr->car, VAL);
|
|
1582
|
+
pop(); pop();
|
|
1583
|
+
|
|
1584
|
+
idx = new_msym(s, sym);
|
|
1585
|
+
if (len == 1 && name[0] == '+') {
|
|
1586
|
+
genop_peep(s, MKOP_ABC(OP_ADD, cursp(), idx, 1), val);
|
|
1587
|
+
}
|
|
1588
|
+
else if (len == 1 && name[0] == '-') {
|
|
1589
|
+
genop_peep(s, MKOP_ABC(OP_SUB, cursp(), idx, 1), val);
|
|
1590
|
+
}
|
|
1591
|
+
else if (len == 1 && name[0] == '*') {
|
|
1592
|
+
genop(s, MKOP_ABC(OP_MUL, cursp(), idx, 1));
|
|
1593
|
+
}
|
|
1594
|
+
else if (len == 1 && name[0] == '/') {
|
|
1595
|
+
genop(s, MKOP_ABC(OP_DIV, cursp(), idx, 1));
|
|
1596
|
+
}
|
|
1597
|
+
else if (len == 1 && name[0] == '<') {
|
|
1598
|
+
genop(s, MKOP_ABC(OP_LT, cursp(), idx, 1));
|
|
1599
|
+
}
|
|
1600
|
+
else if (len == 2 && name[0] == '<' && name[1] == '=') {
|
|
1601
|
+
genop(s, MKOP_ABC(OP_LE, cursp(), idx, 1));
|
|
1602
|
+
}
|
|
1603
|
+
else if (len == 1 && name[0] == '>') {
|
|
1604
|
+
genop(s, MKOP_ABC(OP_GT, cursp(), idx, 1));
|
|
1605
|
+
}
|
|
1606
|
+
else if (len == 2 && name[0] == '>' && name[1] == '=') {
|
|
1607
|
+
genop(s, MKOP_ABC(OP_GE, cursp(), idx, 1));
|
|
1608
|
+
}
|
|
1609
|
+
else {
|
|
1610
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), idx, 1));
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
gen_assignment(s, tree->car, cursp(), val);
|
|
1614
|
+
break;
|
|
1615
|
+
|
|
1616
|
+
case NODE_SUPER:
|
|
1617
|
+
{
|
|
1618
|
+
int n = 0, noop = 0, sendv = 0;
|
|
1619
|
+
|
|
1620
|
+
push(); /* room for receiver */
|
|
1621
|
+
if (tree) {
|
|
1622
|
+
node *args = tree->car;
|
|
1623
|
+
if (args) {
|
|
1624
|
+
n = gen_values(s, args, VAL);
|
|
1625
|
+
if (n < 0) {
|
|
1626
|
+
n = noop = sendv = 1;
|
|
1627
|
+
push();
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
if (tree && tree->cdr) {
|
|
1632
|
+
codegen(s, tree->cdr, VAL);
|
|
1633
|
+
pop();
|
|
1634
|
+
}
|
|
1635
|
+
else {
|
|
1636
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1637
|
+
}
|
|
1638
|
+
pop_n(n+1);
|
|
1639
|
+
if (sendv) n = CALL_MAXARGS;
|
|
1640
|
+
genop(s, MKOP_ABC(OP_SUPER, cursp(), 0, n));
|
|
1641
|
+
if (val) push();
|
|
1642
|
+
}
|
|
1643
|
+
break;
|
|
1644
|
+
|
|
1645
|
+
case NODE_ZSUPER:
|
|
1646
|
+
{
|
|
1647
|
+
codegen_scope *s2 = s;
|
|
1648
|
+
int lv = 0, ainfo = 0;
|
|
1649
|
+
|
|
1650
|
+
push(); /* room for receiver */
|
|
1651
|
+
while (!s2->mscope) {
|
|
1652
|
+
lv++;
|
|
1653
|
+
s2 = s2->prev;
|
|
1654
|
+
if (!s2) break;
|
|
1655
|
+
}
|
|
1656
|
+
if (s2) ainfo = s2->ainfo;
|
|
1657
|
+
genop(s, MKOP_ABx(OP_ARGARY, cursp(), (ainfo<<4)|(lv & 0xf)));
|
|
1658
|
+
if (tree && tree->cdr) {
|
|
1659
|
+
push();
|
|
1660
|
+
codegen(s, tree->cdr, VAL);
|
|
1661
|
+
pop_n(2);
|
|
1662
|
+
}
|
|
1663
|
+
pop();
|
|
1664
|
+
genop(s, MKOP_ABC(OP_SUPER, cursp(), 0, CALL_MAXARGS));
|
|
1665
|
+
if (val) push();
|
|
1666
|
+
}
|
|
1667
|
+
break;
|
|
1668
|
+
|
|
1669
|
+
case NODE_RETURN:
|
|
1670
|
+
if (tree) {
|
|
1671
|
+
codegen(s, tree, VAL);
|
|
1672
|
+
pop();
|
|
1673
|
+
}
|
|
1674
|
+
else {
|
|
1675
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1676
|
+
}
|
|
1677
|
+
if (s->loop) {
|
|
1678
|
+
genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_RETURN));
|
|
1679
|
+
}
|
|
1680
|
+
else {
|
|
1681
|
+
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
|
|
1682
|
+
}
|
|
1683
|
+
if (val) push();
|
|
1684
|
+
break;
|
|
1685
|
+
|
|
1686
|
+
case NODE_YIELD:
|
|
1687
|
+
{
|
|
1688
|
+
codegen_scope *s2 = s;
|
|
1689
|
+
int lv = 0, ainfo = 0;
|
|
1690
|
+
int n = 0, sendv = 0;
|
|
1691
|
+
|
|
1692
|
+
while (!s2->mscope) {
|
|
1693
|
+
lv++;
|
|
1694
|
+
s2 = s2->prev;
|
|
1695
|
+
if (!s2) break;
|
|
1696
|
+
}
|
|
1697
|
+
if (s2) ainfo = s2->ainfo;
|
|
1698
|
+
genop(s, MKOP_ABx(OP_BLKPUSH, cursp(), (ainfo<<4)|(lv & 0xf)));
|
|
1699
|
+
push();
|
|
1700
|
+
if (tree) {
|
|
1701
|
+
n = gen_values(s, tree, VAL);
|
|
1702
|
+
if (n < 0) {
|
|
1703
|
+
n = sendv = 1;
|
|
1704
|
+
push();
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
pop_n(n+1);
|
|
1708
|
+
if (sendv) n = CALL_MAXARGS;
|
|
1709
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern2(s->mrb, "call", 4)), n));
|
|
1710
|
+
if (val) push();
|
|
1711
|
+
}
|
|
1712
|
+
break;
|
|
1713
|
+
|
|
1714
|
+
case NODE_BREAK:
|
|
1715
|
+
loop_break(s, tree);
|
|
1716
|
+
if (val) push();
|
|
1717
|
+
break;
|
|
1718
|
+
|
|
1719
|
+
case NODE_NEXT:
|
|
1720
|
+
if (!s->loop) {
|
|
1721
|
+
raise_error(s, "unexpected next");
|
|
1722
|
+
}
|
|
1723
|
+
else if (s->loop->type == LOOP_NORMAL) {
|
|
1724
|
+
if (s->ensure_level > s->loop->ensure_level) {
|
|
1725
|
+
genop_peep(s, MKOP_A(OP_EPOP, s->ensure_level - s->loop->ensure_level), NOVAL);
|
|
1726
|
+
}
|
|
1727
|
+
codegen(s, tree, NOVAL);
|
|
1728
|
+
genop(s, MKOP_sBx(OP_JMP, s->loop->pc1 - s->pc));
|
|
1729
|
+
}
|
|
1730
|
+
else {
|
|
1731
|
+
if (tree) {
|
|
1732
|
+
codegen(s, tree, VAL);
|
|
1733
|
+
pop();
|
|
1734
|
+
}
|
|
1735
|
+
else {
|
|
1736
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
1737
|
+
}
|
|
1738
|
+
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
|
|
1739
|
+
}
|
|
1740
|
+
if (val) push();
|
|
1741
|
+
break;
|
|
1742
|
+
|
|
1743
|
+
case NODE_REDO:
|
|
1744
|
+
if (!s->loop) {
|
|
1745
|
+
raise_error(s, "unexpected redo");
|
|
1746
|
+
}
|
|
1747
|
+
else {
|
|
1748
|
+
if (s->ensure_level > s->loop->ensure_level) {
|
|
1749
|
+
genop_peep(s, MKOP_A(OP_EPOP, s->ensure_level - s->loop->ensure_level), NOVAL);
|
|
1750
|
+
}
|
|
1751
|
+
genop(s, MKOP_sBx(OP_JMP, s->loop->pc2 - s->pc));
|
|
1752
|
+
}
|
|
1753
|
+
break;
|
|
1754
|
+
|
|
1755
|
+
case NODE_RETRY:
|
|
1756
|
+
{
|
|
1757
|
+
const char *msg = "unexpected retry";
|
|
1758
|
+
|
|
1759
|
+
if (!s->loop) {
|
|
1760
|
+
raise_error(s, msg);
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
struct loopinfo *lp = s->loop;
|
|
1764
|
+
int n = 0;
|
|
1765
|
+
|
|
1766
|
+
while (lp && lp->type != LOOP_RESCUE) {
|
|
1767
|
+
if (lp->type == LOOP_BEGIN) {
|
|
1768
|
+
n++;
|
|
1769
|
+
}
|
|
1770
|
+
lp = lp->prev;
|
|
1771
|
+
}
|
|
1772
|
+
if (!lp) {
|
|
1773
|
+
raise_error(s, msg);
|
|
1774
|
+
}
|
|
1775
|
+
else {
|
|
1776
|
+
if (n > 0) {
|
|
1777
|
+
while (n--) {
|
|
1778
|
+
genop_peep(s, MKOP_A(OP_POPERR, 1), NOVAL);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
if (s->ensure_level > lp->ensure_level) {
|
|
1782
|
+
genop_peep(s, MKOP_A(OP_EPOP, s->ensure_level - lp->ensure_level), NOVAL);
|
|
1783
|
+
}
|
|
1784
|
+
genop(s, MKOP_sBx(OP_JMP, lp->pc1 - s->pc));
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
break;
|
|
1789
|
+
|
|
1790
|
+
case NODE_LVAR:
|
|
1791
|
+
if (val) {
|
|
1792
|
+
int idx = lv_idx(s, sym(tree));
|
|
1793
|
+
|
|
1794
|
+
if (idx > 0) {
|
|
1795
|
+
genop(s, MKOP_AB(OP_MOVE, cursp(), idx));
|
|
1796
|
+
}
|
|
1797
|
+
else {
|
|
1798
|
+
int lv = 0;
|
|
1799
|
+
codegen_scope *up = s->prev;
|
|
1800
|
+
|
|
1801
|
+
while (up) {
|
|
1802
|
+
idx = lv_idx(up, sym(tree));
|
|
1803
|
+
if (idx > 0) {
|
|
1804
|
+
genop(s, MKOP_ABC(OP_GETUPVAR, cursp(), idx, lv));
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
lv++;
|
|
1808
|
+
up = up->prev;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
push();
|
|
1812
|
+
}
|
|
1813
|
+
break;
|
|
1814
|
+
|
|
1815
|
+
case NODE_GVAR:
|
|
1816
|
+
{
|
|
1817
|
+
int sym = new_sym(s, sym(tree));
|
|
1818
|
+
|
|
1819
|
+
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
|
|
1820
|
+
push();
|
|
1821
|
+
}
|
|
1822
|
+
break;
|
|
1823
|
+
|
|
1824
|
+
case NODE_IVAR:
|
|
1825
|
+
{
|
|
1826
|
+
int sym = new_sym(s, sym(tree));
|
|
1827
|
+
|
|
1828
|
+
genop(s, MKOP_ABx(OP_GETIV, cursp(), sym));
|
|
1829
|
+
push();
|
|
1830
|
+
}
|
|
1831
|
+
break;
|
|
1832
|
+
|
|
1833
|
+
case NODE_CVAR:
|
|
1834
|
+
{
|
|
1835
|
+
int sym = new_sym(s, sym(tree));
|
|
1836
|
+
|
|
1837
|
+
genop(s, MKOP_ABx(OP_GETCV, cursp(), sym));
|
|
1838
|
+
push();
|
|
1839
|
+
}
|
|
1840
|
+
break;
|
|
1841
|
+
|
|
1842
|
+
case NODE_CONST:
|
|
1843
|
+
{
|
|
1844
|
+
int sym = new_sym(s, sym(tree));
|
|
1845
|
+
|
|
1846
|
+
genop(s, MKOP_ABx(OP_GETCONST, cursp(), sym));
|
|
1847
|
+
push();
|
|
1848
|
+
}
|
|
1849
|
+
break;
|
|
1850
|
+
|
|
1851
|
+
case NODE_DEFINED:
|
|
1852
|
+
codegen(s, tree, VAL);
|
|
1853
|
+
break;
|
|
1854
|
+
|
|
1855
|
+
case NODE_BACK_REF:
|
|
1856
|
+
{
|
|
1857
|
+
char buf[2] = { '$' };
|
|
1858
|
+
mrb_value str;
|
|
1859
|
+
int sym;
|
|
1860
|
+
|
|
1861
|
+
buf[1] = (char)(intptr_t)tree;
|
|
1862
|
+
str = mrb_str_new(s->mrb, buf, 2);
|
|
1863
|
+
sym = new_sym(s, mrb_intern_str(s->mrb, str));
|
|
1864
|
+
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
|
|
1865
|
+
push();
|
|
1866
|
+
}
|
|
1867
|
+
break;
|
|
1868
|
+
|
|
1869
|
+
case NODE_NTH_REF:
|
|
1870
|
+
{
|
|
1871
|
+
int sym;
|
|
1872
|
+
mrb_state *mrb = s->mrb;
|
|
1873
|
+
mrb_value fix = mrb_fixnum_value((intptr_t)tree);
|
|
1874
|
+
mrb_value str = mrb_str_buf_new(mrb, 4);
|
|
1875
|
+
|
|
1876
|
+
mrb_str_buf_cat(mrb, str, "$", 1);
|
|
1877
|
+
mrb_str_buf_append(mrb, str, mrb_fixnum_to_str(mrb, fix, 10));
|
|
1878
|
+
sym = new_sym(s, mrb_intern_str(mrb, str));
|
|
1879
|
+
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
|
|
1880
|
+
push();
|
|
1881
|
+
}
|
|
1882
|
+
break;
|
|
1883
|
+
|
|
1884
|
+
case NODE_ARG:
|
|
1885
|
+
// should not happen
|
|
1886
|
+
break;
|
|
1887
|
+
|
|
1888
|
+
case NODE_BLOCK_ARG:
|
|
1889
|
+
codegen(s, tree, VAL);
|
|
1890
|
+
break;
|
|
1891
|
+
|
|
1892
|
+
case NODE_INT:
|
|
1893
|
+
if (val) {
|
|
1894
|
+
char *p = (char*)tree->car;
|
|
1895
|
+
int base = (intptr_t)tree->cdr->car;
|
|
1896
|
+
mrb_int i;
|
|
1897
|
+
mrb_code co;
|
|
1898
|
+
int overflow;
|
|
1899
|
+
|
|
1900
|
+
i = readint_mrb_int(s, p, base, FALSE, &overflow);
|
|
1901
|
+
if (overflow) {
|
|
1902
|
+
double f = readint_float(s, p, base);
|
|
1903
|
+
int off = new_lit(s, mrb_float_value(s->mrb, f));
|
|
1904
|
+
|
|
1905
|
+
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
|
|
1906
|
+
}
|
|
1907
|
+
else {
|
|
1908
|
+
if (i < MAXARG_sBx && i > -MAXARG_sBx) {
|
|
1909
|
+
co = MKOP_AsBx(OP_LOADI, cursp(), i);
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1912
|
+
int off = new_lit(s, mrb_fixnum_value(i));
|
|
1913
|
+
co = MKOP_ABx(OP_LOADL, cursp(), off);
|
|
1914
|
+
}
|
|
1915
|
+
genop(s, co);
|
|
1916
|
+
}
|
|
1917
|
+
push();
|
|
1918
|
+
}
|
|
1919
|
+
break;
|
|
1920
|
+
|
|
1921
|
+
case NODE_FLOAT:
|
|
1922
|
+
if (val) {
|
|
1923
|
+
char *p = (char*)tree;
|
|
1924
|
+
mrb_float f = str_to_mrb_float(p);
|
|
1925
|
+
int off = new_lit(s, mrb_float_value(s->mrb, f));
|
|
1926
|
+
|
|
1927
|
+
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
|
|
1928
|
+
push();
|
|
1929
|
+
}
|
|
1930
|
+
break;
|
|
1931
|
+
|
|
1932
|
+
case NODE_NEGATE:
|
|
1933
|
+
{
|
|
1934
|
+
nt = (intptr_t)tree->car;
|
|
1935
|
+
tree = tree->cdr;
|
|
1936
|
+
switch (nt) {
|
|
1937
|
+
case NODE_FLOAT:
|
|
1938
|
+
{
|
|
1939
|
+
char *p = (char*)tree;
|
|
1940
|
+
mrb_float f = str_to_mrb_float(p);
|
|
1941
|
+
int off = new_lit(s, mrb_float_value(s->mrb, -f));
|
|
1942
|
+
|
|
1943
|
+
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
|
|
1944
|
+
push();
|
|
1945
|
+
}
|
|
1946
|
+
break;
|
|
1947
|
+
|
|
1948
|
+
case NODE_INT:
|
|
1949
|
+
{
|
|
1950
|
+
char *p = (char*)tree->car;
|
|
1951
|
+
int base = (intptr_t)tree->cdr->car;
|
|
1952
|
+
mrb_int i;
|
|
1953
|
+
mrb_code co;
|
|
1954
|
+
int overflow;
|
|
1955
|
+
|
|
1956
|
+
i = readint_mrb_int(s, p, base, TRUE, &overflow);
|
|
1957
|
+
if (overflow) {
|
|
1958
|
+
double f = readint_float(s, p, base);
|
|
1959
|
+
int off = new_lit(s, mrb_float_value(s->mrb, -f));
|
|
1960
|
+
|
|
1961
|
+
genop(s, MKOP_ABx(OP_LOADL, cursp(), off));
|
|
1962
|
+
}
|
|
1963
|
+
else {
|
|
1964
|
+
if (i < MAXARG_sBx && i > -MAXARG_sBx) {
|
|
1965
|
+
co = MKOP_AsBx(OP_LOADI, cursp(), i);
|
|
1966
|
+
}
|
|
1967
|
+
else {
|
|
1968
|
+
int off = new_lit(s, mrb_fixnum_value(i));
|
|
1969
|
+
co = MKOP_ABx(OP_LOADL, cursp(), off);
|
|
1970
|
+
}
|
|
1971
|
+
genop(s, co);
|
|
1972
|
+
}
|
|
1973
|
+
push();
|
|
1974
|
+
}
|
|
1975
|
+
break;
|
|
1976
|
+
|
|
1977
|
+
default:
|
|
1978
|
+
{
|
|
1979
|
+
int sym = new_msym(s, mrb_intern2(s->mrb, "-", 1));
|
|
1980
|
+
|
|
1981
|
+
genop(s, MKOP_ABx(OP_LOADI, cursp(), 0));
|
|
1982
|
+
push();
|
|
1983
|
+
codegen(s, tree, VAL);
|
|
1984
|
+
pop(); pop();
|
|
1985
|
+
genop(s, MKOP_ABC(OP_SUB, cursp(), sym, 2));
|
|
1986
|
+
}
|
|
1987
|
+
break;
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
break;
|
|
1991
|
+
|
|
1992
|
+
case NODE_STR:
|
|
1993
|
+
if (val) {
|
|
1994
|
+
char *p = (char*)tree->car;
|
|
1995
|
+
size_t len = (intptr_t)tree->cdr;
|
|
1996
|
+
int ai = mrb_gc_arena_save(s->mrb);
|
|
1997
|
+
int off = new_lit(s, mrb_str_new(s->mrb, p, len));
|
|
1998
|
+
|
|
1999
|
+
mrb_gc_arena_restore(s->mrb, ai);
|
|
2000
|
+
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
|
|
2001
|
+
push();
|
|
2002
|
+
}
|
|
2003
|
+
break;
|
|
2004
|
+
|
|
2005
|
+
case NODE_HEREDOC:
|
|
2006
|
+
tree = ((struct mrb_parser_heredoc_info *)tree)->doc;
|
|
2007
|
+
/* fall through */
|
|
2008
|
+
case NODE_DSTR:
|
|
2009
|
+
if (val) {
|
|
2010
|
+
node *n = tree;
|
|
2011
|
+
|
|
2012
|
+
codegen(s, n->car, VAL);
|
|
2013
|
+
n = n->cdr;
|
|
2014
|
+
while (n) {
|
|
2015
|
+
codegen(s, n->car, VAL);
|
|
2016
|
+
pop(); pop();
|
|
2017
|
+
genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
|
|
2018
|
+
push();
|
|
2019
|
+
n = n->cdr;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
else {
|
|
2023
|
+
node *n = tree;
|
|
2024
|
+
|
|
2025
|
+
while (n) {
|
|
2026
|
+
if ((intptr_t)n->car->car != NODE_STR) {
|
|
2027
|
+
codegen(s, n->car, NOVAL);
|
|
2028
|
+
}
|
|
2029
|
+
n = n->cdr;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
break;
|
|
2033
|
+
|
|
2034
|
+
case NODE_WORDS:
|
|
2035
|
+
gen_literal_array(s, tree, FALSE, val);
|
|
2036
|
+
break;
|
|
2037
|
+
|
|
2038
|
+
case NODE_SYMBOLS:
|
|
2039
|
+
gen_literal_array(s, tree, TRUE, val);
|
|
2040
|
+
break;
|
|
2041
|
+
|
|
2042
|
+
case NODE_XSTR:
|
|
2043
|
+
if (val) {
|
|
2044
|
+
char *p = (char*)tree->car;
|
|
2045
|
+
size_t len = (intptr_t)tree->cdr;
|
|
2046
|
+
int ai = mrb_gc_arena_save(s->mrb);
|
|
2047
|
+
int sym = new_sym(s, mrb_intern2(s->mrb, "Kernel", 6));
|
|
2048
|
+
int off = new_lit(s, mrb_str_new(s->mrb, p, len));
|
|
2049
|
+
|
|
2050
|
+
genop(s, MKOP_A(OP_OCLASS, cursp()));
|
|
2051
|
+
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
|
|
2052
|
+
push();
|
|
2053
|
+
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
|
|
2054
|
+
pop();
|
|
2055
|
+
sym = new_sym(s, mrb_intern2(s->mrb, "`", 1));
|
|
2056
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, 1));
|
|
2057
|
+
mrb_gc_arena_restore(s->mrb, ai);
|
|
2058
|
+
push();
|
|
2059
|
+
}
|
|
2060
|
+
break;
|
|
2061
|
+
|
|
2062
|
+
case NODE_REGX:
|
|
2063
|
+
if (val) {
|
|
2064
|
+
char *p1 = (char*)tree->car;
|
|
2065
|
+
char *p2 = (char*)tree->cdr;
|
|
2066
|
+
int ai = mrb_gc_arena_save(s->mrb);
|
|
2067
|
+
int sym = new_sym(s, mrb_intern2(s->mrb, REGEXP_CLASS, REGEXP_CLASS_CSTR_LEN));
|
|
2068
|
+
int off = new_lit(s, mrb_str_new(s->mrb, p1, strlen(p1)));
|
|
2069
|
+
int argc = 1;
|
|
2070
|
+
|
|
2071
|
+
genop(s, MKOP_A(OP_OCLASS, cursp()));
|
|
2072
|
+
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
|
|
2073
|
+
push();
|
|
2074
|
+
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
|
|
2075
|
+
if (p2) {
|
|
2076
|
+
push();
|
|
2077
|
+
off = new_lit(s, mrb_str_new(s->mrb, p2, strlen(p2)));
|
|
2078
|
+
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
|
|
2079
|
+
argc++;
|
|
2080
|
+
pop();
|
|
2081
|
+
}
|
|
2082
|
+
pop();
|
|
2083
|
+
sym = new_sym(s, mrb_intern2(s->mrb, "compile", 7));
|
|
2084
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, argc));
|
|
2085
|
+
mrb_gc_arena_restore(s->mrb, ai);
|
|
2086
|
+
push();
|
|
2087
|
+
}
|
|
2088
|
+
break;
|
|
2089
|
+
|
|
2090
|
+
case NODE_DREGX:
|
|
2091
|
+
if (val) {
|
|
2092
|
+
node *n = tree->car;
|
|
2093
|
+
int ai = mrb_gc_arena_save(s->mrb);
|
|
2094
|
+
int sym = new_sym(s, mrb_intern2(s->mrb, REGEXP_CLASS, REGEXP_CLASS_CSTR_LEN));
|
|
2095
|
+
int argc = 1;
|
|
2096
|
+
int off;
|
|
2097
|
+
char *p;
|
|
2098
|
+
|
|
2099
|
+
genop(s, MKOP_A(OP_OCLASS, cursp()));
|
|
2100
|
+
genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
|
|
2101
|
+
push();
|
|
2102
|
+
codegen(s, n->car, VAL);
|
|
2103
|
+
n = n->cdr;
|
|
2104
|
+
while (n) {
|
|
2105
|
+
codegen(s, n->car, VAL);
|
|
2106
|
+
pop(); pop();
|
|
2107
|
+
genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
|
|
2108
|
+
push();
|
|
2109
|
+
n = n->cdr;
|
|
2110
|
+
}
|
|
2111
|
+
n = tree->cdr->cdr;
|
|
2112
|
+
if (n->car) {
|
|
2113
|
+
p = (char*)n->car;
|
|
2114
|
+
off = new_lit(s, mrb_str_new(s->mrb, p, strlen(p)));
|
|
2115
|
+
codegen(s, tree->car, VAL);
|
|
2116
|
+
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
|
|
2117
|
+
pop();
|
|
2118
|
+
genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
|
|
2119
|
+
}
|
|
2120
|
+
if (n->cdr) {
|
|
2121
|
+
char *p2 = (char*)n->cdr;
|
|
2122
|
+
int off;
|
|
2123
|
+
|
|
2124
|
+
push();
|
|
2125
|
+
off = new_lit(s, mrb_str_new(s->mrb, p2, strlen(p2)));
|
|
2126
|
+
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
|
|
2127
|
+
argc++;
|
|
2128
|
+
pop();
|
|
2129
|
+
}
|
|
2130
|
+
pop();
|
|
2131
|
+
sym = new_sym(s, mrb_intern2(s->mrb, "compile", 7));
|
|
2132
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, argc));
|
|
2133
|
+
mrb_gc_arena_restore(s->mrb, ai);
|
|
2134
|
+
push();
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
node *n = tree->car;
|
|
2138
|
+
|
|
2139
|
+
while (n) {
|
|
2140
|
+
if ((intptr_t)n->car->car != NODE_STR) {
|
|
2141
|
+
codegen(s, n->car, NOVAL);
|
|
2142
|
+
}
|
|
2143
|
+
n = n->cdr;
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
break;
|
|
2147
|
+
|
|
2148
|
+
case NODE_SYM:
|
|
2149
|
+
if (val) {
|
|
2150
|
+
int sym = new_sym(s, sym(tree));
|
|
2151
|
+
|
|
2152
|
+
genop(s, MKOP_ABx(OP_LOADSYM, cursp(), sym));
|
|
2153
|
+
push();
|
|
2154
|
+
}
|
|
2155
|
+
break;
|
|
2156
|
+
|
|
2157
|
+
case NODE_DSYM:
|
|
2158
|
+
codegen(s, tree, val);
|
|
2159
|
+
if (val) {
|
|
2160
|
+
gen_send_intern(s);
|
|
2161
|
+
}
|
|
2162
|
+
break;
|
|
2163
|
+
|
|
2164
|
+
case NODE_SELF:
|
|
2165
|
+
if (val) {
|
|
2166
|
+
genop(s, MKOP_A(OP_LOADSELF, cursp()));
|
|
2167
|
+
push();
|
|
2168
|
+
}
|
|
2169
|
+
break;
|
|
2170
|
+
|
|
2171
|
+
case NODE_NIL:
|
|
2172
|
+
if (val) {
|
|
2173
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2174
|
+
push();
|
|
2175
|
+
}
|
|
2176
|
+
break;
|
|
2177
|
+
|
|
2178
|
+
case NODE_TRUE:
|
|
2179
|
+
if (val) {
|
|
2180
|
+
genop(s, MKOP_A(OP_LOADT, cursp()));
|
|
2181
|
+
push();
|
|
2182
|
+
}
|
|
2183
|
+
break;
|
|
2184
|
+
|
|
2185
|
+
case NODE_FALSE:
|
|
2186
|
+
if (val) {
|
|
2187
|
+
genop(s, MKOP_A(OP_LOADF, cursp()));
|
|
2188
|
+
push();
|
|
2189
|
+
}
|
|
2190
|
+
break;
|
|
2191
|
+
|
|
2192
|
+
case NODE_ALIAS:
|
|
2193
|
+
{
|
|
2194
|
+
int a = new_msym(s, sym(tree->car));
|
|
2195
|
+
int b = new_msym(s, sym(tree->cdr));
|
|
2196
|
+
int c = new_msym(s, mrb_intern2(s->mrb, "alias_method", 12));
|
|
2197
|
+
|
|
2198
|
+
genop(s, MKOP_A(OP_TCLASS, cursp()));
|
|
2199
|
+
push();
|
|
2200
|
+
genop(s, MKOP_ABx(OP_LOADSYM, cursp(), a));
|
|
2201
|
+
push();
|
|
2202
|
+
genop(s, MKOP_ABx(OP_LOADSYM, cursp(), b));
|
|
2203
|
+
push();
|
|
2204
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2205
|
+
pop_n(3);
|
|
2206
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), c, 2));
|
|
2207
|
+
if (val) {
|
|
2208
|
+
push();
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
break;
|
|
2212
|
+
|
|
2213
|
+
case NODE_UNDEF:
|
|
2214
|
+
{
|
|
2215
|
+
int undef = new_msym(s, mrb_intern2(s->mrb, "undef_method", 12));
|
|
2216
|
+
int num = 0;
|
|
2217
|
+
node *t = tree;
|
|
2218
|
+
|
|
2219
|
+
genop(s, MKOP_A(OP_TCLASS, cursp()));
|
|
2220
|
+
push();
|
|
2221
|
+
while (t) {
|
|
2222
|
+
int symbol = new_msym(s, sym(t->car));
|
|
2223
|
+
genop(s, MKOP_ABx(OP_LOADSYM, cursp(), symbol));
|
|
2224
|
+
push();
|
|
2225
|
+
t = t->cdr;
|
|
2226
|
+
num++;
|
|
2227
|
+
}
|
|
2228
|
+
pop_n(num + 1);
|
|
2229
|
+
genop(s, MKOP_ABC(OP_SEND, cursp(), undef, num));
|
|
2230
|
+
if (val) {
|
|
2231
|
+
push();
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
break;
|
|
2235
|
+
|
|
2236
|
+
case NODE_CLASS:
|
|
2237
|
+
{
|
|
2238
|
+
int idx;
|
|
2239
|
+
|
|
2240
|
+
if (tree->car->car == (node*)0) {
|
|
2241
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2242
|
+
push();
|
|
2243
|
+
}
|
|
2244
|
+
else if (tree->car->car == (node*)1) {
|
|
2245
|
+
genop(s, MKOP_A(OP_OCLASS, cursp()));
|
|
2246
|
+
push();
|
|
2247
|
+
}
|
|
2248
|
+
else {
|
|
2249
|
+
codegen(s, tree->car->car, VAL);
|
|
2250
|
+
}
|
|
2251
|
+
if (tree->cdr->car) {
|
|
2252
|
+
codegen(s, tree->cdr->car, VAL);
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2256
|
+
push();
|
|
2257
|
+
}
|
|
2258
|
+
pop(); pop();
|
|
2259
|
+
idx = new_msym(s, sym(tree->car->cdr));
|
|
2260
|
+
genop(s, MKOP_AB(OP_CLASS, cursp(), idx));
|
|
2261
|
+
idx = scope_body(s, tree->cdr->cdr->car);
|
|
2262
|
+
genop(s, MKOP_ABx(OP_EXEC, cursp(), idx));
|
|
2263
|
+
if (val) {
|
|
2264
|
+
push();
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
break;
|
|
2268
|
+
|
|
2269
|
+
case NODE_MODULE:
|
|
2270
|
+
{
|
|
2271
|
+
int idx;
|
|
2272
|
+
|
|
2273
|
+
if (tree->car->car == (node*)0) {
|
|
2274
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2275
|
+
push();
|
|
2276
|
+
}
|
|
2277
|
+
else if (tree->car->car == (node*)1) {
|
|
2278
|
+
genop(s, MKOP_A(OP_OCLASS, cursp()));
|
|
2279
|
+
push();
|
|
2280
|
+
}
|
|
2281
|
+
else {
|
|
2282
|
+
codegen(s, tree->car->car, VAL);
|
|
2283
|
+
}
|
|
2284
|
+
pop();
|
|
2285
|
+
idx = new_msym(s, sym(tree->car->cdr));
|
|
2286
|
+
genop(s, MKOP_AB(OP_MODULE, cursp(), idx));
|
|
2287
|
+
idx = scope_body(s, tree->cdr->car);
|
|
2288
|
+
genop(s, MKOP_ABx(OP_EXEC, cursp(), idx));
|
|
2289
|
+
if (val) {
|
|
2290
|
+
push();
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
break;
|
|
2294
|
+
|
|
2295
|
+
case NODE_SCLASS:
|
|
2296
|
+
{
|
|
2297
|
+
int idx;
|
|
2298
|
+
|
|
2299
|
+
codegen(s, tree->car, VAL);
|
|
2300
|
+
pop();
|
|
2301
|
+
genop(s, MKOP_AB(OP_SCLASS, cursp(), cursp()));
|
|
2302
|
+
idx = scope_body(s, tree->cdr->car);
|
|
2303
|
+
genop(s, MKOP_ABx(OP_EXEC, cursp(), idx));
|
|
2304
|
+
if (val) {
|
|
2305
|
+
push();
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
break;
|
|
2309
|
+
|
|
2310
|
+
case NODE_DEF:
|
|
2311
|
+
{
|
|
2312
|
+
int sym = new_msym(s, sym(tree->car));
|
|
2313
|
+
int idx = lambda_body(s, tree->cdr, 0);
|
|
2314
|
+
|
|
2315
|
+
genop(s, MKOP_A(OP_TCLASS, cursp()));
|
|
2316
|
+
push();
|
|
2317
|
+
genop(s, MKOP_Abc(OP_LAMBDA, cursp(), idx, OP_L_METHOD));
|
|
2318
|
+
pop();
|
|
2319
|
+
genop(s, MKOP_AB(OP_METHOD, cursp(), sym));
|
|
2320
|
+
if (val) {
|
|
2321
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2322
|
+
push();
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
break;
|
|
2326
|
+
|
|
2327
|
+
case NODE_SDEF:
|
|
2328
|
+
{
|
|
2329
|
+
node *recv = tree->car;
|
|
2330
|
+
int sym = new_msym(s, sym(tree->cdr->car));
|
|
2331
|
+
int idx = lambda_body(s, tree->cdr->cdr, 0);
|
|
2332
|
+
|
|
2333
|
+
codegen(s, recv, VAL);
|
|
2334
|
+
pop();
|
|
2335
|
+
genop(s, MKOP_AB(OP_SCLASS, cursp(), cursp()));
|
|
2336
|
+
push();
|
|
2337
|
+
genop(s, MKOP_Abc(OP_LAMBDA, cursp(), idx, OP_L_METHOD));
|
|
2338
|
+
pop();
|
|
2339
|
+
genop(s, MKOP_AB(OP_METHOD, cursp(), sym));
|
|
2340
|
+
if (val) {
|
|
2341
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2342
|
+
push();
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
break;
|
|
2346
|
+
|
|
2347
|
+
case NODE_POSTEXE:
|
|
2348
|
+
codegen(s, tree, NOVAL);
|
|
2349
|
+
break;
|
|
2350
|
+
|
|
2351
|
+
default:
|
|
2352
|
+
break;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
static codegen_scope*
|
|
2357
|
+
scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
|
|
2358
|
+
{
|
|
2359
|
+
static const codegen_scope codegen_scope_zero = { 0 };
|
|
2360
|
+
mrb_pool *pool = mrb_pool_open(mrb);
|
|
2361
|
+
codegen_scope *p = (codegen_scope *)mrb_pool_alloc(pool, sizeof(codegen_scope));
|
|
2362
|
+
|
|
2363
|
+
if (!p) return 0;
|
|
2364
|
+
*p = codegen_scope_zero;
|
|
2365
|
+
p->mrb = mrb;
|
|
2366
|
+
p->mpool = pool;
|
|
2367
|
+
if (!prev) return p;
|
|
2368
|
+
p->prev = prev;
|
|
2369
|
+
p->ainfo = -1;
|
|
2370
|
+
p->mscope = 0;
|
|
2371
|
+
|
|
2372
|
+
p->irep = mrb_add_irep(mrb);
|
|
2373
|
+
p->idx = p->irep->idx;
|
|
2374
|
+
|
|
2375
|
+
p->icapa = 1024;
|
|
2376
|
+
p->iseq = (mrb_code*)mrb_malloc(mrb, sizeof(mrb_code)*p->icapa);
|
|
2377
|
+
|
|
2378
|
+
p->pcapa = 32;
|
|
2379
|
+
p->irep->pool = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value)*p->pcapa);
|
|
2380
|
+
p->irep->plen = 0;
|
|
2381
|
+
|
|
2382
|
+
p->scapa = 256;
|
|
2383
|
+
p->irep->syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*256);
|
|
2384
|
+
p->irep->slen = 0;
|
|
2385
|
+
|
|
2386
|
+
p->lv = lv;
|
|
2387
|
+
p->sp += node_len(lv)+1; /* add self */
|
|
2388
|
+
p->nlocals = p->sp;
|
|
2389
|
+
p->ai = mrb_gc_arena_save(mrb);
|
|
2390
|
+
|
|
2391
|
+
p->filename = prev->filename;
|
|
2392
|
+
if (p->filename) {
|
|
2393
|
+
p->lines = (short*)mrb_malloc(mrb, sizeof(short)*p->icapa);
|
|
2394
|
+
}
|
|
2395
|
+
p->lineno = prev->lineno;
|
|
2396
|
+
return p;
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
static void
|
|
2400
|
+
scope_finish(codegen_scope *s)
|
|
2401
|
+
{
|
|
2402
|
+
mrb_state *mrb = s->mrb;
|
|
2403
|
+
mrb_irep *irep = s->irep;
|
|
2404
|
+
size_t fname_len;
|
|
2405
|
+
char *fname;
|
|
2406
|
+
|
|
2407
|
+
irep->flags = 0;
|
|
2408
|
+
if (s->iseq) {
|
|
2409
|
+
irep->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->pc);
|
|
2410
|
+
irep->ilen = s->pc;
|
|
2411
|
+
if (s->lines) {
|
|
2412
|
+
irep->lines = (uint16_t *)codegen_realloc(s, s->lines, sizeof(uint16_t)*s->pc);
|
|
2413
|
+
}
|
|
2414
|
+
else {
|
|
2415
|
+
irep->lines = 0;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
irep->pool = (mrb_value *)codegen_realloc(s, irep->pool, sizeof(mrb_value)*irep->plen);
|
|
2419
|
+
irep->syms = (mrb_sym *)codegen_realloc(s, irep->syms, sizeof(mrb_sym)*irep->slen);
|
|
2420
|
+
if (s->filename) {
|
|
2421
|
+
fname_len = strlen(s->filename);
|
|
2422
|
+
fname = codegen_malloc(s, fname_len + 1);
|
|
2423
|
+
memcpy(fname, s->filename, fname_len);
|
|
2424
|
+
fname[fname_len] = '\0';
|
|
2425
|
+
irep->filename = fname;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
irep->nlocals = s->nlocals;
|
|
2429
|
+
irep->nregs = s->nregs;
|
|
2430
|
+
|
|
2431
|
+
mrb_gc_arena_restore(mrb, s->ai);
|
|
2432
|
+
mrb_pool_close(s->mpool);
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
static struct loopinfo*
|
|
2436
|
+
loop_push(codegen_scope *s, enum looptype t)
|
|
2437
|
+
{
|
|
2438
|
+
struct loopinfo *p = (struct loopinfo *)codegen_palloc(s, sizeof(struct loopinfo));
|
|
2439
|
+
|
|
2440
|
+
p->type = t;
|
|
2441
|
+
p->pc1 = p->pc2 = p->pc3 = 0;
|
|
2442
|
+
p->prev = s->loop;
|
|
2443
|
+
p->ensure_level = s->ensure_level;
|
|
2444
|
+
p->acc = cursp();
|
|
2445
|
+
s->loop = p;
|
|
2446
|
+
|
|
2447
|
+
return p;
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
static void
|
|
2451
|
+
loop_break(codegen_scope *s, node *tree)
|
|
2452
|
+
{
|
|
2453
|
+
if (!s->loop) {
|
|
2454
|
+
codegen(s, tree, NOVAL);
|
|
2455
|
+
raise_error(s, "unexpected break");
|
|
2456
|
+
}
|
|
2457
|
+
else {
|
|
2458
|
+
struct loopinfo *loop;
|
|
2459
|
+
|
|
2460
|
+
if (tree) {
|
|
2461
|
+
codegen(s, tree, VAL);
|
|
2462
|
+
pop();
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
loop = s->loop;
|
|
2466
|
+
while (loop->type == LOOP_BEGIN) {
|
|
2467
|
+
genop_peep(s, MKOP_A(OP_POPERR, 1), NOVAL);
|
|
2468
|
+
loop = loop->prev;
|
|
2469
|
+
}
|
|
2470
|
+
while (loop->type == LOOP_RESCUE) {
|
|
2471
|
+
loop = loop->prev;
|
|
2472
|
+
}
|
|
2473
|
+
if (loop->type == LOOP_NORMAL) {
|
|
2474
|
+
int tmp;
|
|
2475
|
+
|
|
2476
|
+
if (s->ensure_level > s->loop->ensure_level) {
|
|
2477
|
+
genop_peep(s, MKOP_A(OP_EPOP, s->ensure_level - s->loop->ensure_level), NOVAL);
|
|
2478
|
+
}
|
|
2479
|
+
if (tree) {
|
|
2480
|
+
genop_peep(s, MKOP_AB(OP_MOVE, loop->acc, cursp()), NOVAL);
|
|
2481
|
+
}
|
|
2482
|
+
tmp = new_label(s);
|
|
2483
|
+
genop(s, MKOP_sBx(OP_JMP, loop->pc3));
|
|
2484
|
+
loop->pc3 = tmp;
|
|
2485
|
+
}
|
|
2486
|
+
else {
|
|
2487
|
+
genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_BREAK));
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
static void
|
|
2493
|
+
loop_pop(codegen_scope *s, int val)
|
|
2494
|
+
{
|
|
2495
|
+
if (val) {
|
|
2496
|
+
genop(s, MKOP_A(OP_LOADNIL, cursp()));
|
|
2497
|
+
}
|
|
2498
|
+
dispatch_linked(s, s->loop->pc3);
|
|
2499
|
+
s->loop = s->loop->prev;
|
|
2500
|
+
if (val) push();
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
static void
|
|
2504
|
+
codedump(mrb_state *mrb, int n)
|
|
2505
|
+
{
|
|
2506
|
+
#ifdef ENABLE_STDIO
|
|
2507
|
+
mrb_irep *irep = mrb->irep[n];
|
|
2508
|
+
uint32_t i;
|
|
2509
|
+
int ai;
|
|
2510
|
+
mrb_code c;
|
|
2511
|
+
|
|
2512
|
+
if (!irep) return;
|
|
2513
|
+
printf("irep %d nregs=%d nlocals=%d pools=%d syms=%d\n", n,
|
|
2514
|
+
irep->nregs, irep->nlocals, (int)irep->plen, (int)irep->slen);
|
|
2515
|
+
for (i=0; i<irep->ilen; i++) {
|
|
2516
|
+
ai = mrb_gc_arena_save(mrb);
|
|
2517
|
+
printf("%03d ", i);
|
|
2518
|
+
c = irep->iseq[i];
|
|
2519
|
+
switch (GET_OPCODE(c)) {
|
|
2520
|
+
case OP_NOP:
|
|
2521
|
+
printf("OP_NOP\n");
|
|
2522
|
+
break;
|
|
2523
|
+
case OP_MOVE:
|
|
2524
|
+
printf("OP_MOVE\tR%d\tR%d\n", GETARG_A(c), GETARG_B(c));
|
|
2525
|
+
break;
|
|
2526
|
+
case OP_LOADL:
|
|
2527
|
+
printf("OP_LOADL\tR%d\tL(%d)\n", GETARG_A(c), GETARG_Bx(c));
|
|
2528
|
+
break;
|
|
2529
|
+
case OP_LOADI:
|
|
2530
|
+
printf("OP_LOADI\tR%d\t%d\n", GETARG_A(c), GETARG_sBx(c));
|
|
2531
|
+
break;
|
|
2532
|
+
case OP_LOADSYM:
|
|
2533
|
+
printf("OP_LOADSYM\tR%d\t:%s\n", GETARG_A(c),
|
|
2534
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
|
2535
|
+
break;
|
|
2536
|
+
case OP_LOADNIL:
|
|
2537
|
+
printf("OP_LOADNIL\tR%d\n", GETARG_A(c));
|
|
2538
|
+
break;
|
|
2539
|
+
case OP_LOADSELF:
|
|
2540
|
+
printf("OP_LOADSELF\tR%d\n", GETARG_A(c));
|
|
2541
|
+
break;
|
|
2542
|
+
case OP_LOADT:
|
|
2543
|
+
printf("OP_LOADT\tR%d\n", GETARG_A(c));
|
|
2544
|
+
break;
|
|
2545
|
+
case OP_LOADF:
|
|
2546
|
+
printf("OP_LOADF\tR%d\n", GETARG_A(c));
|
|
2547
|
+
break;
|
|
2548
|
+
case OP_GETGLOBAL:
|
|
2549
|
+
printf("OP_GETGLOBAL\tR%d\t:%s\n", GETARG_A(c),
|
|
2550
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
|
2551
|
+
break;
|
|
2552
|
+
case OP_SETGLOBAL:
|
|
2553
|
+
printf("OP_SETGLOBAL\t:%s\tR%d\n",
|
|
2554
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
|
2555
|
+
GETARG_A(c));
|
|
2556
|
+
break;
|
|
2557
|
+
case OP_GETCONST:
|
|
2558
|
+
printf("OP_GETCONST\tR%d\t:%s\n", GETARG_A(c),
|
|
2559
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
|
2560
|
+
break;
|
|
2561
|
+
case OP_SETCONST:
|
|
2562
|
+
printf("OP_SETCONST\t:%s\tR%d\n",
|
|
2563
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
|
2564
|
+
GETARG_A(c));
|
|
2565
|
+
break;
|
|
2566
|
+
case OP_GETMCNST:
|
|
2567
|
+
printf("OP_GETMCNST\tR%d\tR%d::%s\n", GETARG_A(c), GETARG_A(c),
|
|
2568
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
|
2569
|
+
break;
|
|
2570
|
+
case OP_SETMCNST:
|
|
2571
|
+
printf("OP_SETMCNST\tR%d::%s\tR%d\n", GETARG_A(c)+1,
|
|
2572
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
|
2573
|
+
GETARG_A(c));
|
|
2574
|
+
break;
|
|
2575
|
+
case OP_GETIV:
|
|
2576
|
+
printf("OP_GETIV\tR%d\t%s\n", GETARG_A(c),
|
|
2577
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
|
2578
|
+
break;
|
|
2579
|
+
case OP_SETIV:
|
|
2580
|
+
printf("OP_SETIV\t%s\tR%d\n",
|
|
2581
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
|
2582
|
+
GETARG_A(c));
|
|
2583
|
+
break;
|
|
2584
|
+
case OP_GETUPVAR:
|
|
2585
|
+
printf("OP_GETUPVAR\tR%d\t%d\t%d\n",
|
|
2586
|
+
GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2587
|
+
break;
|
|
2588
|
+
case OP_SETUPVAR:
|
|
2589
|
+
printf("OP_SETUPVAR\tR%d\t%d\t%d\n",
|
|
2590
|
+
GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2591
|
+
break;
|
|
2592
|
+
case OP_GETCV:
|
|
2593
|
+
printf("OP_GETCV\tR%d\t%s\n", GETARG_A(c),
|
|
2594
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
|
2595
|
+
break;
|
|
2596
|
+
case OP_SETCV:
|
|
2597
|
+
printf("OP_SETCV\t%s\tR%d\n",
|
|
2598
|
+
mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
|
2599
|
+
GETARG_A(c));
|
|
2600
|
+
break;
|
|
2601
|
+
case OP_JMP:
|
|
2602
|
+
printf("OP_JMP\t\t%03d\n", i+GETARG_sBx(c));
|
|
2603
|
+
break;
|
|
2604
|
+
case OP_JMPIF:
|
|
2605
|
+
printf("OP_JMPIF\tR%d\t%03d\n", GETARG_A(c), i+GETARG_sBx(c));
|
|
2606
|
+
break;
|
|
2607
|
+
case OP_JMPNOT:
|
|
2608
|
+
printf("OP_JMPNOT\tR%d\t%03d\n", GETARG_A(c), i+GETARG_sBx(c));
|
|
2609
|
+
break;
|
|
2610
|
+
case OP_SEND:
|
|
2611
|
+
printf("OP_SEND\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2612
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2613
|
+
GETARG_C(c));
|
|
2614
|
+
break;
|
|
2615
|
+
case OP_SENDB:
|
|
2616
|
+
printf("OP_SENDB\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2617
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2618
|
+
GETARG_C(c));
|
|
2619
|
+
break;
|
|
2620
|
+
case OP_TAILCALL:
|
|
2621
|
+
printf("OP_TAILCALL\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2622
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2623
|
+
GETARG_C(c));
|
|
2624
|
+
break;
|
|
2625
|
+
case OP_SUPER:
|
|
2626
|
+
printf("OP_SUPER\tR%d\t%d\n", GETARG_A(c),
|
|
2627
|
+
GETARG_C(c));
|
|
2628
|
+
break;
|
|
2629
|
+
case OP_ARGARY:
|
|
2630
|
+
printf("OP_ARGARY\tR%d\t%d:%d:%d:%d\n", GETARG_A(c),
|
|
2631
|
+
(GETARG_Bx(c)>>10)&0x3f,
|
|
2632
|
+
(GETARG_Bx(c)>>9)&0x1,
|
|
2633
|
+
(GETARG_Bx(c)>>4)&0x1f,
|
|
2634
|
+
(GETARG_Bx(c)>>0)&0xf);
|
|
2635
|
+
break;
|
|
2636
|
+
|
|
2637
|
+
case OP_ENTER:
|
|
2638
|
+
printf("OP_ENTER\t%d:%d:%d:%d:%d:%d:%d\n",
|
|
2639
|
+
(GETARG_Ax(c)>>18)&0x1f,
|
|
2640
|
+
(GETARG_Ax(c)>>13)&0x1f,
|
|
2641
|
+
(GETARG_Ax(c)>>12)&0x1,
|
|
2642
|
+
(GETARG_Ax(c)>>7)&0x1f,
|
|
2643
|
+
(GETARG_Ax(c)>>2)&0x1f,
|
|
2644
|
+
(GETARG_Ax(c)>>1)&0x1,
|
|
2645
|
+
GETARG_Ax(c) & 0x1);
|
|
2646
|
+
break;
|
|
2647
|
+
case OP_RETURN:
|
|
2648
|
+
printf("OP_RETURN\tR%d", GETARG_A(c));
|
|
2649
|
+
switch (GETARG_B(c)) {
|
|
2650
|
+
case OP_R_NORMAL:
|
|
2651
|
+
printf("\n"); break;
|
|
2652
|
+
case OP_R_RETURN:
|
|
2653
|
+
printf("\treturn\n"); break;
|
|
2654
|
+
case OP_R_BREAK:
|
|
2655
|
+
printf("\tbreak\n"); break;
|
|
2656
|
+
default:
|
|
2657
|
+
printf("\tbroken\n"); break;
|
|
2658
|
+
break;
|
|
2659
|
+
}
|
|
2660
|
+
break;
|
|
2661
|
+
case OP_BLKPUSH:
|
|
2662
|
+
printf("OP_BLKPUSH\tR%d\t%d:%d:%d:%d\n", GETARG_A(c),
|
|
2663
|
+
(GETARG_Bx(c)>>10)&0x3f,
|
|
2664
|
+
(GETARG_Bx(c)>>9)&0x1,
|
|
2665
|
+
(GETARG_Bx(c)>>4)&0x1f,
|
|
2666
|
+
(GETARG_Bx(c)>>0)&0xf);
|
|
2667
|
+
break;
|
|
2668
|
+
|
|
2669
|
+
case OP_LAMBDA:
|
|
2670
|
+
printf("OP_LAMBDA\tR%d\tI(%+d)\t%d\n", GETARG_A(c), GETARG_b(c), GETARG_c(c));
|
|
2671
|
+
break;
|
|
2672
|
+
case OP_RANGE:
|
|
2673
|
+
printf("OP_RANGE\tR%d\tR%d\t%d\n", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2674
|
+
break;
|
|
2675
|
+
case OP_METHOD:
|
|
2676
|
+
printf("OP_METHOD\tR%d\t:%s\n", GETARG_A(c),
|
|
2677
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
|
|
2678
|
+
break;
|
|
2679
|
+
|
|
2680
|
+
case OP_ADD:
|
|
2681
|
+
printf("OP_ADD\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2682
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2683
|
+
GETARG_C(c));
|
|
2684
|
+
break;
|
|
2685
|
+
case OP_ADDI:
|
|
2686
|
+
printf("OP_ADDI\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2687
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2688
|
+
GETARG_C(c));
|
|
2689
|
+
break;
|
|
2690
|
+
case OP_SUB:
|
|
2691
|
+
printf("OP_SUB\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2692
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2693
|
+
GETARG_C(c));
|
|
2694
|
+
break;
|
|
2695
|
+
case OP_SUBI:
|
|
2696
|
+
printf("OP_SUBI\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2697
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2698
|
+
GETARG_C(c));
|
|
2699
|
+
break;
|
|
2700
|
+
case OP_MUL:
|
|
2701
|
+
printf("OP_MUL\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2702
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2703
|
+
GETARG_C(c));
|
|
2704
|
+
break;
|
|
2705
|
+
case OP_DIV:
|
|
2706
|
+
printf("OP_DIV\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2707
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2708
|
+
GETARG_C(c));
|
|
2709
|
+
break;
|
|
2710
|
+
case OP_LT:
|
|
2711
|
+
printf("OP_LT\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2712
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2713
|
+
GETARG_C(c));
|
|
2714
|
+
break;
|
|
2715
|
+
case OP_LE:
|
|
2716
|
+
printf("OP_LE\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2717
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2718
|
+
GETARG_C(c));
|
|
2719
|
+
break;
|
|
2720
|
+
case OP_GT:
|
|
2721
|
+
printf("OP_GT\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2722
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2723
|
+
GETARG_C(c));
|
|
2724
|
+
break;
|
|
2725
|
+
case OP_GE:
|
|
2726
|
+
printf("OP_GE\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2727
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2728
|
+
GETARG_C(c));
|
|
2729
|
+
break;
|
|
2730
|
+
case OP_EQ:
|
|
2731
|
+
printf("OP_EQ\tR%d\t:%s\t%d\n", GETARG_A(c),
|
|
2732
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
|
2733
|
+
GETARG_C(c));
|
|
2734
|
+
break;
|
|
2735
|
+
|
|
2736
|
+
case OP_STOP:
|
|
2737
|
+
printf("OP_STOP\n");
|
|
2738
|
+
break;
|
|
2739
|
+
|
|
2740
|
+
case OP_ARRAY:
|
|
2741
|
+
printf("OP_ARRAY\tR%d\tR%d\t%d\n", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2742
|
+
break;
|
|
2743
|
+
case OP_ARYCAT:
|
|
2744
|
+
printf("OP_ARYCAT\tR%d\tR%d\n", GETARG_A(c), GETARG_B(c));
|
|
2745
|
+
break;
|
|
2746
|
+
case OP_ARYPUSH:
|
|
2747
|
+
printf("OP_ARYPUSH\tR%d\tR%d\n", GETARG_A(c), GETARG_B(c));
|
|
2748
|
+
break;
|
|
2749
|
+
case OP_AREF:
|
|
2750
|
+
printf("OP_AREF\tR%d\tR%d\t%d\n", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2751
|
+
break;
|
|
2752
|
+
case OP_APOST:
|
|
2753
|
+
printf("OP_APOST\tR%d\t%d\t%d\n", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2754
|
+
break;
|
|
2755
|
+
case OP_STRING:
|
|
2756
|
+
{
|
|
2757
|
+
mrb_value s = irep->pool[GETARG_Bx(c)];
|
|
2758
|
+
|
|
2759
|
+
s = mrb_str_dump(mrb, s);
|
|
2760
|
+
printf("OP_STRING\tR%d\t%s\n", GETARG_A(c), RSTRING_PTR(s));
|
|
2761
|
+
}
|
|
2762
|
+
break;
|
|
2763
|
+
case OP_STRCAT:
|
|
2764
|
+
printf("OP_STRCAT\tR%d\tR%d\n", GETARG_A(c), GETARG_B(c));
|
|
2765
|
+
break;
|
|
2766
|
+
case OP_HASH:
|
|
2767
|
+
printf("OP_HASH\tR%d\tR%d\t%d\n", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2768
|
+
break;
|
|
2769
|
+
|
|
2770
|
+
case OP_OCLASS:
|
|
2771
|
+
printf("OP_OCLASS\tR%d\n", GETARG_A(c));
|
|
2772
|
+
break;
|
|
2773
|
+
case OP_CLASS:
|
|
2774
|
+
printf("OP_CLASS\tR%d\t:%s\n", GETARG_A(c),
|
|
2775
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
|
|
2776
|
+
break;
|
|
2777
|
+
case OP_MODULE:
|
|
2778
|
+
printf("OP_MODULE\tR%d\t:%s\n", GETARG_A(c),
|
|
2779
|
+
mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
|
|
2780
|
+
break;
|
|
2781
|
+
case OP_EXEC:
|
|
2782
|
+
printf("OP_EXEC\tR%d\tI(%d)\n", GETARG_A(c), n+GETARG_Bx(c));
|
|
2783
|
+
break;
|
|
2784
|
+
case OP_SCLASS:
|
|
2785
|
+
printf("OP_SCLASS\tR%d\tR%d\n", GETARG_A(c), GETARG_B(c));
|
|
2786
|
+
break;
|
|
2787
|
+
case OP_TCLASS:
|
|
2788
|
+
printf("OP_TCLASS\tR%d\n", GETARG_A(c));
|
|
2789
|
+
break;
|
|
2790
|
+
case OP_ERR:
|
|
2791
|
+
printf("OP_ERR\tL(%d)\n", GETARG_Bx(c));
|
|
2792
|
+
break;
|
|
2793
|
+
case OP_EPUSH:
|
|
2794
|
+
printf("OP_EPUSH\t:I(%d)\n", n+GETARG_Bx(c));
|
|
2795
|
+
break;
|
|
2796
|
+
case OP_ONERR:
|
|
2797
|
+
printf("OP_ONERR\t%03d\n", i+GETARG_sBx(c));
|
|
2798
|
+
break;
|
|
2799
|
+
case OP_RESCUE:
|
|
2800
|
+
printf("OP_RESCUE\tR%d\n", GETARG_A(c));
|
|
2801
|
+
break;
|
|
2802
|
+
case OP_RAISE:
|
|
2803
|
+
printf("OP_RAISE\tR%d\n", GETARG_A(c));
|
|
2804
|
+
break;
|
|
2805
|
+
case OP_POPERR:
|
|
2806
|
+
printf("OP_POPERR\t%d\n", GETARG_A(c));
|
|
2807
|
+
break;
|
|
2808
|
+
case OP_EPOP:
|
|
2809
|
+
printf("OP_EPOP\t%d\n", GETARG_A(c));
|
|
2810
|
+
break;
|
|
2811
|
+
|
|
2812
|
+
default:
|
|
2813
|
+
printf("OP_unknown %d\t%d\t%d\t%d\n", GET_OPCODE(c),
|
|
2814
|
+
GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
mrb_gc_arena_restore(mrb, ai);
|
|
2818
|
+
}
|
|
2819
|
+
printf("\n");
|
|
2820
|
+
#endif
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
void
|
|
2824
|
+
codedump_all(mrb_state *mrb, int start)
|
|
2825
|
+
{
|
|
2826
|
+
size_t i;
|
|
2827
|
+
|
|
2828
|
+
for (i=start; i<mrb->irep_len; i++) {
|
|
2829
|
+
codedump(mrb, i);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
static int
|
|
2834
|
+
codegen_start(mrb_state *mrb, parser_state *p)
|
|
2835
|
+
{
|
|
2836
|
+
codegen_scope *scope = scope_new(mrb, 0, 0);
|
|
2837
|
+
|
|
2838
|
+
if (!scope) {
|
|
2839
|
+
return -1;
|
|
2840
|
+
}
|
|
2841
|
+
scope->mrb = mrb;
|
|
2842
|
+
if (p->filename) {
|
|
2843
|
+
scope->filename = p->filename;
|
|
2844
|
+
}
|
|
2845
|
+
if (setjmp(scope->jmp) != 0) {
|
|
2846
|
+
return -1;
|
|
2847
|
+
}
|
|
2848
|
+
// prepare irep
|
|
2849
|
+
codegen(scope, p->tree, NOVAL);
|
|
2850
|
+
mrb_pool_close(scope->mpool);
|
|
2851
|
+
return 0;
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
int
|
|
2855
|
+
mrb_generate_code(mrb_state *mrb, parser_state *p)
|
|
2856
|
+
{
|
|
2857
|
+
int start = mrb->irep_len;
|
|
2858
|
+
int n;
|
|
2859
|
+
|
|
2860
|
+
n = codegen_start(mrb, p);
|
|
2861
|
+
if (n < 0) return n;
|
|
2862
|
+
|
|
2863
|
+
return start;
|
|
2864
|
+
}
|