diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-15 18:31:06 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-10-15 18:31:06 +0900 |
| commit | 9cebddf9fe83ae0acde6f64f291fa3c9fc22880f (patch) | |
| tree | 6f9ca4f2941c3da48a504c937719adca36e4cdfe /doc | |
| parent | 8c276f95be2f4e9deed73f08125a23a6746cb517 (diff) | |
| parent | 21e07d61138a87891dc780efaa28e6c76a39378f (diff) | |
| download | mruby-9cebddf9fe83ae0acde6f64f291fa3c9fc22880f.tar.gz mruby-9cebddf9fe83ae0acde6f64f291fa3c9fc22880f.zip | |
Merge pull request #5084 from mruby/mruby3
Mruby3
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/guides/compile.md | 99 | ||||
| -rw-r--r-- | doc/guides/mrbconf.md | 20 | ||||
| -rw-r--r-- | doc/limitations.md | 42 | ||||
| -rw-r--r-- | doc/mruby3.md | 108 | ||||
| -rw-r--r-- | doc/opcode.md | 200 |
5 files changed, 303 insertions, 166 deletions
diff --git a/doc/guides/compile.md b/doc/guides/compile.md index d7937bb2e..233c3e594 100644 --- a/doc/guides/compile.md +++ b/doc/guides/compile.md @@ -14,37 +14,53 @@ To compile mruby out of the source code you need the following tools: Note that `bison` bundled with MacOS is too old to compile `mruby`. Try `brew install bison` and follow the instuction shown to update -the `$PATH` to compile `mruby`. +the `$PATH` to compile `mruby`. We also encourage to upgrade `ruby` +on MacOS in similar manner. Optional: -* GIT (to update mruby source and integrate mrbgems easier) +* git (to update mruby source and integrate mrbgems easier) * C++ compiler (to use GEMs which include \*.cpp, \*.cxx, \*.cc) * Assembler (to use GEMs which include \*.asm) -## Usage +## Build + +To compile `mruby`, just call `rake` inside of the mruby source +root. To generate and execute the test tools call `rake test`. To +clean all build files call `rake clean`. To see full command line on +build, call `rake -v`. + +If you want to compile for the specific configuration, specify +`MRUBY_TARGET` or `TARGET` environment variable, e.g + +```sh +rake TAGRET=host +``` + +The default target is `host`. The compilation target desciption files +(with `.rb` suffix) are contained in the `target` directory. + +A build description file contains the build configuration of mruby and +looks like the following for example: -Inside of the root directory of the mruby source a file exists -called *build_config.rb*. This file contains the build configuration -of mruby and looks like this for example: ```ruby MRuby::Build.new do |conf| toolchain :gcc end ``` -All tools necessary to compile mruby can be set or modified here. In case -you want to maintain an additional *build_config.rb* you can define a -customized path using the *$MRUBY_CONFIG* environment variable. - -To compile just call `rake` inside of the mruby source root. To -generate and execute the test tools call `rake test`. To clean -all build files call `rake clean`. To see full command line on -build, call `rake -v`. +All tools necessary to compile mruby can be set or modified here. In +case you want to try different configuration, you can create a new +configuration file under `target` and specify the configuration using +the `MRUBY_TARGET` environment variable. ## Build Configuration -Inside of the *build_config.rb* the following options can be configured -based on your environment. +To create a new configuration, copy the existing configuration in the +`target` directory, and modify it. We wish you submit a pull-request, +once you created a new configuration for a new platform. + +Inside of the configuration file, the following options can be +configured based on your environment. ### Toolchains @@ -88,15 +104,12 @@ in `ANDROID_STANDALONE_TOOLCHAIN`. ### Binaries It is possible to select which tools should be compiled during the compilation -process. The following tools can be selected: -* mruby (mruby interpreter) -* mirb (mruby interactive shell) +process. For example, -To select them declare conf.gem as follows: -```ruby -conf.gem "#{root}/mrbgems/mruby-bin-mruby" -conf.gem "#{root}/mrbgems/mruby-bin-mirb" -``` +* `mruby` +* `mirb` + +The configuration are done via `mrbgems`. See `Mrbgems` section. ### File Separator @@ -209,17 +222,33 @@ end ### Mrbgems -Integrate GEMs in the build process. +`mruby` comes with the (sort of) packaging system named `mrbgems`. To +specify `gem`, you can use `conf.gem` in the configuration file. + ```ruby -# Integrate GEM with additional configuration -conf.gem 'path/to/gem' do |g| - g.cc.flags << ... -end +# Integrate a bundled Gem you see in `mrbgems` directory +conf.gem :core => 'mruby-something' + +# Integrate a Gem from GitHub +conf.gem :github => 'someone/mruby-another' -# Integrate GEM without additional configuration -conf.gem 'path/to/another/gem' +# Integrate a mruby binary Gem +conf.gem :core => 'mruby-bin-mruby' + +# Integrate a interactive mruby binary Gem +conf.gem :core => 'mruby-bin-mirb' + +# Integrate GemBox (set of Gems) +conf.gembox "default" ``` +A GemBox is a set of Gems defined in `mrbgems/default.gembox` for example. +It's just a set of `mrbgem` configurations. + +There is a `RubyGem` (gem for CRuby) named `mgem` that help you to +manage `mrbgems`. Try `gem install mgem`. `mgem` can show you the list +of registered `mrbgems`. + See doc/mrbgems/README.md for more option about mrbgems. ### Mrbtest @@ -327,6 +356,10 @@ root directory. The structure of this directory will look like this: +- build | + +- presym <- List of preallocated symbolx + | + +- presym.inc <- C source file for preallocated symbols + | +- host | +- bin <- Binaries (mirb, mrbc and mruby) @@ -379,6 +412,10 @@ like this: +- build | + +- presym <- List of preallocated symbolx + | + +- presym.inc <- C source file for preallocated symbols + | +- host | | | +- bin <- Native Binaries diff --git a/doc/guides/mrbconf.md b/doc/guides/mrbconf.md index 1e1a5afcf..c95634604 100644 --- a/doc/guides/mrbconf.md +++ b/doc/guides/mrbconf.md @@ -46,11 +46,11 @@ You can use mrbconfs with following ways: ## Primitive type configuration. -`MRB_USE_FLOAT` +`MRB_USE_FLOAT32` * When defined single precision floating point type(C type `float`) is used as `mrb_float`. -* Else double precision floating point type(C type `double`) is used as `mrb_float`. +* Otherwise double precision floating point type(C type `double`) is used as `mrb_float`. -`MRB_WITHOUT_FLOAT` +`MRB_NO_FLOAT` * When defined removes floating point numbers from mruby. * It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space". @@ -117,7 +117,7 @@ largest value of required alignment. `MRB_NAN_BOXING` * If defined represent `mrb_value` in boxed `double`. -* Conflicts with `MRB_USE_FLOAT` and `MRB_WITHOUT_FLOAT`. +* Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`. `MRB_WORD_BOXING` * If defined represent `mrb_value` as a word. @@ -163,17 +163,17 @@ largest value of required alignment. * Default value is `128`. * Specifies initial capacity of `RString` created by `mrb_str_buf_new` function.. -`MRB_METHOD_CACHE` -* Improve performance for method dispatch. +`MRB_NO_METHOD_CACHE` +* Disable method cache to save memory. `MRB_METHOD_CACHE_SIZE` -* Default value is `128`. -* Ignored if `MRB_METHOD_CACHE` is not defined. +* Default value is `256`. +* Ignored if `MRB_NO_METHOD_CACHE` is defined. * Need to be the power of 2. -`MRB_METHOD_T_STRUCT` +`MRB_USE_METHOD_T_STRUCT` * Use C struct to represent `mrb_method_t` -* No `MRB_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero +* No `MRB_USE_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero * Define this macro on machines that use higher bits of pointers `MRB_ENABLE_ALL_SYMBOLS` diff --git a/doc/limitations.md b/doc/limitations.md index 770daa7a4..8ac959b98 100644 --- a/doc/limitations.md +++ b/doc/limitations.md @@ -17,7 +17,7 @@ Please help to improve it by submitting your findings. ## `1/2` gives `0.5` Since mruby does not have `Bignum`, bigger integers are represented -by `Float` numbers. To enhance interoperability between `Fixnum` +by `Float` numbers. To enhance interoperability between `Integer` and `Float`, mruby provides `Float#upto` and other iterating methods for the `Float` class. As a side effect, `1/2` gives `0.5` not `0`. @@ -63,8 +63,15 @@ end #### mruby [2.1.2 (2020-08-06)] -No exception is raised. +No exception is raised. Instead you have to do: +```ruby +begin + 1 / 0 +rescue => e + raise e +end +``` ## Fiber execution can't cross C function boundary mruby's `Fiber` is implemented in a similar way to Lua's co-routine. This @@ -245,8 +252,7 @@ trace (most recent call last): ## Keyword arguments mruby keyword arguments behave slightly different from CRuby 2.5 -to make the behavior simpler and less confusing. Maybe in the -future, the simpler behavior will be adopted to CRuby as well. +to make the behavior simpler and less confusing. #### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)] @@ -264,6 +270,20 @@ trace (most recent call last): -e:1: keyword argument hash with non symbol keys (ArgumentError) ``` +## `nil?` redefinition in conditional expressions + +Redefinition of `nil?` is ignored in conditional expressions. + +```ruby +a = "a" +def a.nil? + true +end +puts(a.nil? ? "truthy" : "falsy") +``` + +Ruby outputs `falsy`. mruby outputs `truthy`. + ## Argument Destructuring ```ruby @@ -283,17 +303,3 @@ f(1,[2,3]) ``` CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`. - -## `nil?` redefinition in conditional expressions - -Redefinition of `nil?` is ignored in conditional expressions. - -```ruby -a = "a" -def a.nil? - true -end -puts(a.nil? ? "truthy" : "falsy") -``` - -Ruby outputs `falsy`. mruby outputs `truthy`. diff --git a/doc/mruby3.md b/doc/mruby3.md new file mode 100644 index 000000000..4e4f94d07 --- /dev/null +++ b/doc/mruby3.md @@ -0,0 +1,108 @@ +User visible changes in `mruby3` +=== + +# Build System + +You can specify `TARGET` option to `rake` via a command line +option, or via an environment variable, e.g. + +`rake TARGET=host all` + +or + +`TARGET=host rake all` + +It's much easier to switch multiple targets than the +previous `build_config.rb` system. + +## `presym` target + +The first compilation of `mruby` may require generation of a +static symbol table named `build/presym`. You can generate +the table by `rake gensym`. + +## `target` directory + +Build target specification files are loaded from `target` +directory. The default `TARGET` is `host` which is described +in `target/host.rb`. There are many other targets for example: + +* `host-gprof`: compiles with `gprof` for performance tuning +* `host-m32`: compiles in gcc 32bit mode on 64bit platforms +* `boxing`: compiles all three boxing options +* `clang-asan`: compiles with `clang`'s Address Sanitizer + +`target/host.rb` comes with comments to help writing a new +target description. + +If you want to have your target description out of the +source tree, you can specify the path to the description +file in `MRUBY_CONFIG`. + +# Build Target Contribution + +When you write a new target description, please +contribute. We welcome your contribution as a GitHub +pull-request. + +# Languge Changes + +## New Syntax + +We have ported some new syntax from CRuby. + +* R-assignment (`12 => x`) +* Numbered block parameter (`x.map{_1 * 2}`) +* End-less `def` (`def double(x) = x*2`) + +# Configuration Options Changed + +Some configuration macro names are changed for consistency + +## `MRB_NO_FLOAT` + +Changed from `MRB_WITHOUT_FLOAT` to conform `USE_XXX` naming +convention. + +## `MRB_USE_FLOAT32` + +Changed from `MRB_USE_FLOAT` to make sure `float` here means +using single precision float, and not the opposite of +`MRB_NO_FLOAT`. + +## `MRB_USE_METHOD_T_STRUCT` + +Changed from `MRB_METHOD_T_STRUCT`. + +To use `struct` version of `mrb_method_t`. More portable but consumes more memory. +Turned on by default on 32bit platforms. + +## `MRB_NO_BOXING` + +Uses `struct` to represent `mrb_value`. Consumes more memory +but easier to inveticate the internal and to debug. It used +to be default `mrb_value` representation. Now the default is +`MRB_WORD_BOXING`. + +## `MRB_WORD_BOXING` + +Pack `mrb_value` in an `intptr_t` integer. Consumes less +memory compared to `MRB_NO_BOXING` especially on 32 bit +platforms. `Fixnum` size is 31 bits so some integer values +does not fit in `Fixnum` integers. + +## `MRB_NAN_BOXING` + +Pack `mrb_value` in a floating pointer number. Nothing +changed from previous versions. + +## `MRB_USE_MALLOC_TRIM` + +Call `malloc_trim(0)` from mrb_full_gc() if this macro is defined. +If you are using glibc malloc, this macro could reduce memory consumption. + +# Internal Changes + +## `Random` now use `xoshiro128++`. + +For better and faster random number generation. diff --git a/doc/opcode.md b/doc/opcode.md index a79453e8a..513b28302 100644 --- a/doc/opcode.md +++ b/doc/opcode.md @@ -20,121 +20,107 @@ sign) of operands. * sS: signed 16bit * W: 24bit -First two byte operands may be extended to 16bit. When those byte -operands are bigger than 256, the instruction will be prefixed by -`OP_EXT1` (means 1st operand is 16bit) or `OP_EXT2` (means 2nd operand -is 16bit) or `OP_EXT3` (means 1st and 2nd operands are 16bit). - -For instructions marked by `'`, `OP_EXT1` can be prefixed. For those -with `"`, either `OP_EXT1` or `OP_EXT2` or `OP_EXT2` can be prefixed. - ## table.1 Instruction Table | Instruction Name | Operand type | Semantics | |------------------|--------------|--------------------------------------------------------| | OP_NOP | - | no operation | -| OP_MOVE" | BB | R(a) = R(b) | -| OP_LOADL" | BB | R(a) = Pool(b) | -| OP_LOADI" | BB | R(a) = mrb_int(b) | -| OP_LOADINEG" | BB | R(a) = mrb_int(-b) | -| OP_LOADI__1' | B | R(a) = mrb_int(-1) | -| OP_LOADI_0' | B | R(a) = mrb_int(0) | -| OP_LOADI_1' | B | R(a) = mrb_int(1) | -| OP_LOADI_2' | B | R(a) = mrb_int(2) | -| OP_LOADI_3' | B | R(a) = mrb_int(3) | -| OP_LOADI_4' | B | R(a) = mrb_int(4) | -| OP_LOADI_5' | B | R(a) = mrb_int(5) | -| OP_LOADI_6' | B | R(a) = mrb_int(6) | -| OP_LOADI_7' | B | R(a) = mrb_int(7) | -| OP_LOADI16' | BsS | R(a) = mrb_int(b) | -| OP_LOADSYM" | BB | R(a) = Syms(b) | -| OP_LOADNIL' | B | R(a) = nil | -| OP_LOADSELF' | B | R(a) = self | -| OP_LOADT' | B | R(a) = true | -| OP_LOADF' | B | R(a) = false | -| OP_GETGV" | BB | R(a) = getglobal(Syms(b)) | -| OP_SETGV" | BB | setglobal(Syms(b), R(a)) | -| OP_GETSV" | BB | R(a) = Special[Syms(b)] | -| OP_SETSV" | BB | Special[Syms(b)] = R(a) | -| OP_GETIV" | BB | R(a) = ivget(Syms(b)) | -| OP_SETIV" | BB | ivset(Syms(b),R(a)) | -| OP_GETCV" | BB | R(a) = cvget(Syms(b)) | -| OP_SETCV" | BB | cvset(Syms(b),R(a)) | -| OP_GETCONST" | BB | R(a) = constget(Syms(b)) | -| OP_SETCONST" | BB | constset(Syms(b),R(a)) | -| OP_GETMCNST" | BB | R(a) = R(a)::Syms(b) | -| OP_SETMCNST" | BB | R(a+1)::Syms(b) = R(a) | -| OP_GETUPVAR" | BBB | R(a) = uvget(b,c) | -| OP_SETUPVAR" | BBB | uvset(b,c,R(a)) | +| OP_MOVE | BB | R(a) = R(b) | +| OP_LOADL | BB | R(a) = Pool(b) | +| OP_LOADI | BB | R(a) = mrb_int(b) | +| OP_LOADINEG | BB | R(a) = mrb_int(-b) | +| OP_LOADI__1 | B | R(a) = mrb_int(-1) | +| OP_LOADI_0 | B | R(a) = mrb_int(0) | +| OP_LOADI_1 | B | R(a) = mrb_int(1) | +| OP_LOADI_2 | B | R(a) = mrb_int(2) | +| OP_LOADI_3 | B | R(a) = mrb_int(3) | +| OP_LOADI_4 | B | R(a) = mrb_int(4) | +| OP_LOADI_5 | B | R(a) = mrb_int(5) | +| OP_LOADI_6 | B | R(a) = mrb_int(6) | +| OP_LOADI_7 | B | R(a) = mrb_int(7) | +| OP_LOADI16 | BsS | R(a) = mrb_int(b) | +| OP_LOADSYM | BB | R(a) = Syms(b) | +| OP_LOADNIL | B | R(a) = nil | +| OP_LOADSELF | B | R(a) = self | +| OP_LOADT | B | R(a) = true | +| OP_LOADF | B | R(a) = false | +| OP_GETGV | BB | R(a) = getglobal(Syms(b)) | +| OP_SETGV | BB | setglobal(Syms(b), R(a)) | +| OP_GETSV | BB | R(a) = Special[Syms(b)] | +| OP_SETSV | BB | Special[Syms(b)] = R(a) | +| OP_GETIV | BB | R(a) = ivget(Syms(b)) | +| OP_SETIV | BB | ivset(Syms(b),R(a)) | +| OP_GETCV | BB | R(a) = cvget(Syms(b)) | +| OP_SETCV | BB | cvset(Syms(b),R(a)) | +| OP_GETCONST | BB | R(a) = constget(Syms(b)) | +| OP_SETCONST | BB | constset(Syms(b),R(a)) | +| OP_GETMCNST | BB | R(a) = R(a)::Syms(b) | +| OP_SETMCNST | BB | R(a+1)::Syms(b) = R(a) | +| OP_GETUPVAR | BBB | R(a) = uvget(b,c) | +| OP_SETUPVAR | BBB | uvset(b,c,R(a)) | | OP_JMP | S | pc=a | -| OP_JMPIF' | BS | if R(a) pc=b | -| OP_JMPNOT' | BS | if !R(a) pc=b | -| OP_JMPNIL' | BS | if R(a)==nil pc=b | -| OP_ONERR | S | rescue_push(a) | -| OP_EXCEPT' | B | R(a) = exc | -| OP_RESCUE" | BB | R(b) = R(a).isa?(R(b)) | -| OP_POPERR' | B | a.times{rescue_pop()} | -| OP_RAISE' | B | raise(R(a)) | -| OP_EPUSH' | B | ensure_push(SEQ[a]) | -| OP_EPOP' | B | A.times{ensure_pop().call} | -| OP_SENDV" | BB | R(a) = call(R(a),Syms(b),*R(a+1)) | -| OP_SENDVB" | BB | R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) | -| OP_SEND" | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) | -| OP_SENDB" | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) | +| OP_JMPIF | BS | if R(a) pc=b | +| OP_JMPNOT | BS | if !R(a) pc=b | +| OP_JMPNIL | BS | if R(a)==nil pc=b | +| OP_JMPUW | S | unwind_and_jump_to(a) | +| OP_EXCEPT | B | R(a) = exc | +| OP_RESCUE | BB | R(b) = R(a).isa?(R(b)) | +| OP_RAISEIF | B | raise(R(a)) if R(a) | +| OP_SENDV | BB | R(a) = call(R(a),Syms(b),*R(a+1)) | +| OP_SENDVB | BB | R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) | +| OP_SEND | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) | +| OP_SENDB | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) | | OP_CALL | - | R(0) = self.call(frame.argc, frame.argv) | -| OP_SUPER" | BB | R(a) = super(R(a+1),... ,R(a+b+1)) | -| OP_ARGARY' | BS | R(a) = argument array (16=5:1:5:1:4) | +| OP_SUPER | BB | R(a) = super(R(a+1),... ,R(a+b+1)) | +| OP_ARGARY | BS | R(a) = argument array (16=5:1:5:1:4) | | OP_ENTER | W | arg setup according to flags (23=5:5:1:5:5:1:1) | -| OP_KEY_P" | BB | R(a) = kdict.key?(Syms(b)) | +| OP_KEY_P | BB | R(a) = kdict.key?(Syms(b)) | | OP_KEYEND | - | raise unless kdict.empty? | -| OP_KARG" | BB | R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) | -| OP_RETURN' | B | return R(a) (normal) | -| OP_RETURN_BLK' | B | return R(a) (in-block return) | -| OP_BREAK' | B | break R(a) | -| OP_BLKPUSH' | BS | R(a) = block (16=5:1:5:1:4) | -| OP_ADD' | B | R(a) = R(a)+R(a+1) | -| OP_ADDI" | BB | R(a) = R(a)+mrb_int(b) | -| OP_SUB' | B | R(a) = R(a)-R(a+1) | -| OP_SUBI" | BB | R(a) = R(a)-mrb_int(b) | -| OP_MUL' | B | R(a) = R(a)*R(a+1) | -| OP_DIV' | B | R(a) = R(a)/R(a+1) | -| OP_EQ' | B | R(a) = R(a)==R(a+1) | -| OP_LT' | B | R(a) = R(a)<R(a+1) | -| OP_LE' | B | R(a) = R(a)<=R(a+1) | -| OP_GT' | B | R(a) = R(a)>R(a+1) | -| OP_GE' | B | R(a) = R(a)>=R(a+1) | -| OP_ARRAY" | BB | R(a) = ary_new(R(a),R(a+1)..R(a+b)) | -| OP_ARRAY2" | BBB | R(a) = ary_new(R(b),R(b+1)..R(b+c)) | -| OP_ARYCAT' | B | ary_cat(R(a),R(a+1)) | -| OP_ARYPUSH' | B | ary_push(R(a),R(a+1)) | -| OP_ARYDUP' | B | R(a) = ary_dup(R(a)) | -| OP_AREF" | BBB | R(a) = R(b)[c] | -| OP_ASET" | BBB | R(a)[c] = R(b) | -| OP_APOST" | BBB | *R(a),R(a+1)..R(a+c) = R(a)[b..] | -| OP_INTERN' | B | R(a) = intern(R(a)) | -| OP_STRING" | BB | R(a) = str_dup(Lit(b)) | -| OP_STRCAT' | B | str_cat(R(a),R(a+1)) | -| OP_HASH" | BB | R(a) = hash_new(R(a),R(a+1)..R(a+b)) | -| OP_HASHADD" | BB | R(a) = hash_push(R(a),R(a+1)..R(a+b)) | -| OP_HASHCAT' | B | R(a) = hash_cat(R(a),R(a+1)) | -| OP_LAMBDA" | BB | R(a) = lambda(SEQ[b],OP_L_LAMBDA) | -| OP_BLOCK" | BB | R(a) = lambda(SEQ[b],OP_L_BLOCK) | -| OP_METHOD" | BB | R(a) = lambda(SEQ[b],OP_L_METHOD) | -| OP_RANGE_INC' | B | R(a) = range_new(R(a),R(a+1),FALSE) | -| OP_RANGE_EXC' | B | R(a) = range_new(R(a),R(a+1),TRUE) | -| OP_OCLASS' | B | R(a) = ::Object | -| OP_CLASS" | BB | R(a) = newclass(R(a),Syms(b),R(a+1)) | -| OP_MODULE" | BB | R(a) = newmodule(R(a),Syms(b)) | -| OP_EXEC" | BB | R(a) = blockexec(R(a),SEQ[b]) | -| OP_DEF" | BB | R(a).newmethod(Syms(b),R(a+1)) | -| OP_ALIAS" | BB | alias_method(target_class,Syms(a),Syms(b)) | -| OP_UNDEF' | B | undef_method(target_class,Syms(a)) | -| OP_SCLASS' | B | R(a) = R(a).singleton_class | -| OP_TCLASS' | B | R(a) = target_class | -| OP_DEBUG" | BBB | print a,b,c | -| OP_ERR' | B | raise(LocalJumpError, Lit(a)) | -| OP_EXT1 | - | make 1st operand 16bit | -| OP_EXT2 | - | make 2nd operand 16bit | -| OP_EXT3 | - | make 1st and 2nd operands 16bit | +| OP_KARG | BB | R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) | +| OP_RETURN | B | return R(a) (normal) | +| OP_RETURN_BLK | B | return R(a) (in-block return) | +| OP_BREAK | B | break R(a) | +| OP_BLKPUSH | BS | R(a) = block (16=5:1:5:1:4) | +| OP_ADD | B | R(a) = R(a)+R(a+1) | +| OP_ADDI | BB | R(a) = R(a)+mrb_int(b) | +| OP_SUB | B | R(a) = R(a)-R(a+1) | +| OP_SUBI | BB | R(a) = R(a)-mrb_int(b) | +| OP_MUL | B | R(a) = R(a)*R(a+1) | +| OP_DIV | B | R(a) = R(a)/R(a+1) | +| OP_EQ | B | R(a) = R(a)==R(a+1) | +| OP_LT | B | R(a) = R(a)<R(a+1) | +| OP_LE | B | R(a) = R(a)<=R(a+1) | +| OP_GT | B | R(a) = R(a)>R(a+1) | +| OP_GE | B | R(a) = R(a)>=R(a+1) | +| OP_ARRAY | BB | R(a) = ary_new(R(a),R(a+1)..R(a+b)) | +| OP_ARRAY2 | BBB | R(a) = ary_new(R(b),R(b+1)..R(b+c)) | +| OP_ARYCAT | B | ary_cat(R(a),R(a+1)) | +| OP_ARYPUSH | B | ary_push(R(a),R(a+1)) | +| OP_ARYDUP | B | R(a) = ary_dup(R(a)) | +| OP_AREF | BBB | R(a) = R(b)[c] | +| OP_ASET | BBB | R(a)[c] = R(b) | +| OP_APOST | BBB | *R(a),R(a+1)..R(a+c) = R(a)[b..] | +| OP_INTERN | B | R(a) = intern(R(a)) | +| OP_STRING | BB | R(a) = str_dup(Lit(b)) | +| OP_STRCAT | B | str_cat(R(a),R(a+1)) | +| OP_HASH | BB | R(a) = hash_new(R(a),R(a+1)..R(a+b)) | +| OP_HASHADD | BB | R(a) = hash_push(R(a),R(a+1)..R(a+b)) | +| OP_HASHCAT | B | R(a) = hash_cat(R(a),R(a+1)) | +| OP_LAMBDA | BB | R(a) = lambda(SEQ[b],OP_L_LAMBDA) | +| OP_BLOCK | BB | R(a) = lambda(SEQ[b],OP_L_BLOCK) | +| OP_METHOD | BB | R(a) = lambda(SEQ[b],OP_L_METHOD) | +| OP_RANGE_INC | B | R(a) = range_new(R(a),R(a+1),FALSE) | +| OP_RANGE_EXC | B | R(a) = range_new(R(a),R(a+1),TRUE) | +| OP_OCLASS | B | R(a) = ::Object | +| OP_CLASS | BB | R(a) = newclass(R(a),Syms(b),R(a+1)) | +| OP_MODULE | BB | R(a) = newmodule(R(a),Syms(b)) | +| OP_EXEC | BB | R(a) = blockexec(R(a),SEQ[b]) | +| OP_DEF | BB | R(a).newmethod(Syms(b),R(a+1)) | +| OP_ALIAS | BB | alias_method(target_class,Syms(a),Syms(b)) | +| OP_UNDEF | B | undef_method(target_class,Syms(a)) | +| OP_SCLASS | B | R(a) = R(a).singleton_class | +| OP_TCLASS | B | R(a) = target_class | +| OP_DEBUG | BBB | print a,b,c | +| OP_ERR | B | raise(LocalJumpError, Lit(a)) | | OP_STOP | - | stop VM | |------------------|--------------|--------------------------------------------------------| |
