mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
@@ -6,7 +6,7 @@ mruby is the lightweight implementation of the Ruby language complying to (part
|
||||
of) the [ISO standard][ISO-standard]. Its syntax is Ruby 2.x compatible.
|
||||
|
||||
mruby can be linked and embedded within your application. We provide the
|
||||
interpreter program "mruby" and the interactive mruby shell "mirb" as examples.
|
||||
interpreter program "mruby", and the interactive mruby shell "mirb" as examples.
|
||||
You can also compile Ruby programs into compiled byte code using the mruby
|
||||
compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is
|
||||
also able to generate compiled byte code in a C source file, see the "mrbtest"
|
||||
|
||||
@@ -19,10 +19,10 @@ Optional:
|
||||
* Bison (to compile `mrbgems/mruby-compiler/core/parse.y`)
|
||||
* gperf (to compile `mrbgems/mruby-compiler/core/keywords`)
|
||||
|
||||
Note that `bison` bundled with MacOS is too old to compile `mruby`.
|
||||
Note that `bison` bundled with macOS is too old to compile `mruby`.
|
||||
Try `brew install bison` and follow the instruction shown to update
|
||||
the `$PATH` to compile `mruby`. We also encourage to upgrade `ruby`
|
||||
on MacOS in similar manner.
|
||||
the `$PATH` to compile `mruby`. We also encourage you to upgrade `ruby`
|
||||
on macOS in similar manner.
|
||||
|
||||
## Build
|
||||
|
||||
@@ -52,7 +52,7 @@ All tools necessary to compile mruby can be set or modified here.
|
||||
We wish you submit a pull-request to `build_config/PLATFORM.rb`, once you
|
||||
created a new configuration for a new platform.
|
||||
|
||||
Inside of the configuration file, the following options can be
|
||||
Inside the configuration file, the following options can be
|
||||
configured based on your environment.
|
||||
|
||||
### Toolchains
|
||||
@@ -135,7 +135,7 @@ end
|
||||
|
||||
C Compiler has header searcher to detect installed library.
|
||||
|
||||
If you need a include path of header file use `search_header_path`:
|
||||
If you need an include path of header file use `search_header_path`:
|
||||
|
||||
```ruby
|
||||
# Searches ```iconv.h```.
|
||||
@@ -311,7 +311,7 @@ conf.enable_cxx_exception
|
||||
|
||||
#### C++ exception disabling.
|
||||
|
||||
If your compiler does not support C++ and you want to ensure
|
||||
If your compiler does not support C++, and you want to ensure
|
||||
you don't use mrbgem written in C++, you can explicitly disable
|
||||
C++ exception, add following:
|
||||
|
||||
@@ -360,7 +360,7 @@ directory.
|
||||
|
||||
### Mrbtest in Cross-Compilation
|
||||
|
||||
In cross compilation, you can run `mrbtest` on emulator if
|
||||
In cross compilation, you can run `mrbtest` on an emulator if
|
||||
you have it by changing configuration of test runner.
|
||||
|
||||
```ruby
|
||||
|
||||
@@ -114,7 +114,7 @@ b [class:]method
|
||||
The breakpoint will be ordered in serial from 1.
|
||||
The number, which was given to the deleted breakpoint, will never be given to another breakpoint again.
|
||||
|
||||
You can give multiple breakpoints to specified the line number and method.
|
||||
You can give multiple breakpoints to the specified the line number and method.
|
||||
Be ware that breakpoint command will not check the validity of the class name and method name.
|
||||
|
||||
You can get the current breakpoint information by the following options.
|
||||
@@ -165,7 +165,7 @@ Example:
|
||||
(foo.rb:1) delete
|
||||
```
|
||||
|
||||
This will delete all of the breakpoints.
|
||||
This will delete all the breakpoints.
|
||||
|
||||
```
|
||||
(foo.rb:1) delete 1 3
|
||||
@@ -192,7 +192,7 @@ Example:
|
||||
(foo.rb:1) disable
|
||||
```
|
||||
|
||||
Use `disable` if you would like to disable all of the breakpoints.
|
||||
Use `disable` if you would like to disable all the breakpoints.
|
||||
|
||||
```
|
||||
(foo.rb:1) disable 1 3
|
||||
@@ -324,7 +324,7 @@ expr: expression
|
||||
|
||||
The expression is mandatory.
|
||||
The displayed expressions will be serially ordered from 1.
|
||||
If an exception occurs, the exception information will be displayed and the debugging will be continued.
|
||||
If an exception occurs, the exception information will be displayed, and the debugging will be continued.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ execution speed. This is an error indicating overflow of "GC arena"
|
||||
implementing "conservative GC".
|
||||
|
||||
GC (garbage collector) must ensure that object is "alive", in other
|
||||
words, that it is referenced by somewhere from program. This can be
|
||||
words, that it is referenced by somewhere from the program. This can be
|
||||
determined by checking if the object can be directly or indirectly
|
||||
referenced by root. The local variables, global variables and
|
||||
constants etc are root.
|
||||
|
||||
If program execution is performed inside mruby VM, there is nothing to
|
||||
worry about because GC can access all roots owned by VM.
|
||||
worry about because GC can access all roots owned by the VM.
|
||||
|
||||
The problem arises when executing C functions. The object referenced
|
||||
by C variable is also "alive", but mruby GC cannot aware of this, so
|
||||
@@ -38,7 +38,7 @@ The biggest problem is we have no way to access to the stack area in
|
||||
portable way. Therefore, we cannot use this method if we'd like to
|
||||
implement highly portable runtime, like mruby.
|
||||
|
||||
So we came up with an another plan to implement "conservative GC" in mruby.
|
||||
So we came up with another plan to implement "conservative GC" in mruby.
|
||||
|
||||
Again, the problem is when an object which was created in C function, becomes
|
||||
no longer referenced in the Ruby world, and cannot be treated as garbage.
|
||||
@@ -161,7 +161,7 @@ Please note that the final `inspect` representation of entire array
|
||||
was created before the call of `mrb_gc_arena_restore()`. Otherwise,
|
||||
required temporal object may be deleted by GC.
|
||||
|
||||
We may have a usecase where after creating many temporal objects, we'd
|
||||
We may have an usecase where after creating many temporal objects, we'd
|
||||
like to keep some of them. In this case, we cannot use the same idea
|
||||
in `ary_inspect()` like appending objects to existing one.
|
||||
Instead, after `mrb_gc_arena_restore()`, we must re-register the objects we
|
||||
|
||||
@@ -165,7 +165,7 @@ largest value of required alignment.
|
||||
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
|
||||
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
|
||||
* The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`.
|
||||
* Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`.
|
||||
* Return `TRUE` if `ptr` is in the read-only section, otherwise return `FALSE`.
|
||||
|
||||
## Other configuration.
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ For specifying commit hash to checkout use `:checksum_hash` option:
|
||||
conf.gem mgem: 'mruby-redis', checksum_hash: '3446d19fc4a3f9697b5ddbf2a904f301c42f2f4e'
|
||||
```
|
||||
|
||||
If there is missing dependencies, mrbgem dependencies solver will reference
|
||||
mrbgem from core or mgem-list.
|
||||
If there are missing dependencies, mrbgem dependencies solver will reference
|
||||
mrbgem from the core or mgem-list.
|
||||
|
||||
To pull all gems from remote GIT repository on build, call ```rake -p```,
|
||||
or ```rake --pull-gems```.
|
||||
@@ -80,7 +80,7 @@ end
|
||||
```
|
||||
|
||||
As mentioned, the GemBox uses the same conventions as `MRuby::Build`. The GemBox
|
||||
must be saved with a `.gembox` extension inside the `mrbgems` directory to to be
|
||||
must be saved with a `.gembox` extension inside the `mrbgems` directory to be
|
||||
picked up by mruby.
|
||||
|
||||
To use this example GemBox, we save it as `custom.gembox` inside the `mrbgems`
|
||||
@@ -149,7 +149,7 @@ The mrbgems build process will use this specification to compile Object and Ruby
|
||||
files. The compilation results will be added to `lib/libmruby.a`. This file exposes
|
||||
the GEM functionality to tools like `mruby` and `mirb`.
|
||||
|
||||
The following properties can be set inside of your `MRuby::Gem::Specification` for
|
||||
The following properties can be set inside your `MRuby::Gem::Specification` for
|
||||
information purpose:
|
||||
|
||||
* `spec.license` or `spec.licenses` (A single license or a list of them under which this GEM is licensed)
|
||||
@@ -230,7 +230,7 @@ end
|
||||
```
|
||||
|
||||
In case your GEM has more complex build requirements you can use
|
||||
the following options additionally inside of your GEM specification:
|
||||
the following options additionally inside your GEM specification:
|
||||
|
||||
* `spec.cc.flags` (C compiler flags)
|
||||
* `spec.cc.defines` (C compiler defines)
|
||||
@@ -245,7 +245,7 @@ the following options additionally inside of your GEM specification:
|
||||
* `spec.test_objs` (Object test files for integration into mrbtest)
|
||||
* `spec.test_preload` (Initialization files for mrbtest)
|
||||
|
||||
You also can use `spec.mruby.cc` and `spec.mruby.linker` to add extra global parameters for compiler and linker.
|
||||
You also can use `spec.mruby.cc` and `spec.mruby.linker` to add extra global parameters for the compiler and linker.
|
||||
|
||||
### include_paths and dependency
|
||||
|
||||
|
||||
+3
-3
@@ -54,7 +54,7 @@ end
|
||||
|
||||
#### mruby [3.0.0 (2021-03-05)]
|
||||
|
||||
No exception is raised. Instead you have to do:
|
||||
No exception is raised. Instead, you have to do:
|
||||
|
||||
```ruby
|
||||
begin
|
||||
@@ -66,7 +66,7 @@ end
|
||||
|
||||
## Fiber execution can't cross C function boundary
|
||||
|
||||
mruby's `Fiber` is implemented in a similar way to Lua's co-routine. This
|
||||
mruby's `Fiber` is implemented similarly to Lua's co-routine. This
|
||||
results in the consequence that you can't switch context within C functions.
|
||||
Only exception is `mrb_fiber_yield` at return.
|
||||
|
||||
@@ -95,7 +95,7 @@ p Liste.new "foobar"
|
||||
## Method visibility
|
||||
|
||||
For simplicity reasons no method visibility (public/private/protected) is
|
||||
supported. Those methods are defined but they are dummy methods.
|
||||
supported. Those methods are defined, but they are dummy methods.
|
||||
|
||||
```ruby
|
||||
class VisibleTest
|
||||
|
||||
+3
-3
@@ -76,8 +76,8 @@ to be default `mrb_value` representation. Now the default is
|
||||
## `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
|
||||
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`
|
||||
@@ -117,7 +117,7 @@ Instructions that access pool[i]/syms[i] where i>255.
|
||||
* `OP_STRING16`
|
||||
* `OP_LOADSYM16`
|
||||
|
||||
Instructions that load a 32 bit integer.
|
||||
Instructions that load a 32-bit integer.
|
||||
|
||||
* `OP_LOADI32`
|
||||
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
# The new bytecode
|
||||
|
||||
We will reimplement VM to use 8bit instruction code. By
|
||||
We will reimplement the VM to use 8bit instruction code. By
|
||||
bytecode, we mean real byte code. The whole purpose is
|
||||
reducing the memory consumption of mruby VM.
|
||||
|
||||
# Instructions
|
||||
|
||||
Instructions are bytes. There can be 256 instructions. Currently we
|
||||
Instructions are bytes. There can be 256 instructions. Currently, we
|
||||
have 94 instructions. Instructions can take 0 to 3 operands.
|
||||
|
||||
## operands
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mruby-method
|
||||
===
|
||||
|
||||
A implementation of class **Method** and **UnboundMethod** for mruby
|
||||
An implementation of class **Method** and **UnboundMethod** for mruby
|
||||
|
||||
```ruby
|
||||
p Enumerable.instance_method(:find_all).source_location
|
||||
|
||||
@@ -4,7 +4,7 @@ mruby sleep module
|
||||
|
||||
## install by mrbgems
|
||||
|
||||
- add conf.gem line to your build configuration.
|
||||
- add `conf.gem` line to your build configuration.
|
||||
|
||||
```ruby
|
||||
MRuby::Build.new do |conf|
|
||||
|
||||
Reference in New Issue
Block a user