summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/compile/README.md296
-rw-r--r--doc/mrbgems/README.md11
-rw-r--r--src/array.c2
-rw-r--r--src/codegen.c35
-rw-r--r--src/object.c2
-rw-r--r--src/parse.y24
-rw-r--r--src/state.c2
-rw-r--r--src/vm.c2
8 files changed, 142 insertions, 232 deletions
diff --git a/doc/compile/README.md b/doc/compile/README.md
index ec995bd74..a86ddbe62 100644
--- a/doc/compile/README.md
+++ b/doc/compile/README.md
@@ -23,11 +23,9 @@ Inside of the root directory of the mruby source exist a file
called *build_config.rb*. This file contains the build configuration
of mruby and looks like this for example:
-```
-MRuby::Build.new do |conf|
- toolchain :gcc
-end
-```
+ 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
@@ -51,26 +49,20 @@ configurates the build environment for specific compiler infrastructures.
Toolchain configuration for the GNU C Compiler.
-```
-toolchain :gcc
-```
+ toolchain :gcc
#### clang
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
GCC toolchain.
-```
-toolchain :clang
-```
+ toolchain :clang
#### Visual Studio 2012
Toolchain configuration for Visual Studio 2012 on Windows.
-```
-toolchain :vs2012
-```
+ toolchain :vs2012
### Binaries
@@ -81,108 +73,92 @@ process. The following tools can be selected:
* mirb (mruby interactive shell
To select all define an array in ```conf.bins```:
-```
-conf.bins = %(mrbc mruby mirb)
-```
+
+ conf.bins = %(mrbc mruby mirb)
### File Separator
Some environments require a different file separator character. It is possible to
set the character via ```conf.file_separator```.
-```
-conf.file_separator = '/'
-```
+ conf.file_separator = '/'
### C Compiler
Configuration of the C compiler binary, flags and include paths.
-```
-conf.cc do |cc|
- cc.command = ...
- cc.flags = ...
- cc.include_paths = ...
- cc.defines = ...
- cc.option_include_path = ...
- cc.option_define = ...
- cc.compile_options = ...
-end
-```
+ conf.cc do |cc|
+ cc.command = ...
+ cc.flags = ...
+ cc.include_paths = ...
+ cc.defines = ...
+ cc.option_include_path = ...
+ cc.option_define = ...
+ cc.compile_options = ...
+ end
### Linker
Configuration of the Linker binary, flags and library paths.
-```
-conf.linker do |linker|
- linker.command = ...
- linker.flags = ...
- linker.flags_before_libraries = ...
- linker.libraries = ...
- linker.flags_after_libraries = ...
- linker.library_paths = ....
- linker.option_library = ...
- linker.option_library_path = ...
- linker.link_options = ...
-end
-```
+ conf.linker do |linker|
+ linker.command = ...
+ linker.flags = ...
+ linker.flags_before_libraries = ...
+ linker.libraries = ...
+ linker.flags_after_libraries = ...
+ linker.library_paths = ....
+ linker.option_library = ...
+ linker.option_library_path = ...
+ linker.link_options = ...
+ end
### Archiver
Configuration of the Archiver binary and flags.
-```
-conf.archiver do |archiver|
- archiver.command = ...
- archiver.archive_options = ...
-end
-```
+ conf.archiver do |archiver|
+ archiver.command = ...
+ archiver.archive_options = ...
+ end
### Parser Generator
Configuration of the Parser Generator binary and flags.
-```
-conf.yacc do |yacc|
- yacc.command = ...
- yacc.compile_options = ...
-end
-```
+ conf.yacc do |yacc|
+ yacc.command = ...
+ yacc.compile_options = ...
+ end
### GPerf
Configuration of the GPerf binary and flags.
-```
-conf.gperf do |gperf|
- gperf.command = ...
- gperf.compile_options = ...
-end
-```
+
+ conf.gperf do |gperf|
+ gperf.command = ...
+ gperf.compile_options = ...
+ end
### File Extensions
-```
-conf.exts do |exts
- exts.object = ...
- exts.executable = ...
- exts.library = ...
-end
-```
+ conf.exts do |exts
+ exts.object = ...
+ exts.executable = ...
+ exts.library = ...
+ end
### Mrbgems
Integrate GEMs in the build process.
-```
-# Integrate GEM with additional configuration
-conf.gem 'path/to/gem' do |g|
- g.cc.flags << ...
-end
+ # Integrate GEM with additional configuration
+ conf.gem 'path/to/gem' do |g|
+ g.cc.flags << ...
+ end
-# Integrate GEM without additional configuration
-conf.gem 'path/to/another/gem'
-```
+ # Integrate GEM without additional configuration
+ conf.gem 'path/to/another/gem'
## Cross-Compilation
@@ -192,14 +168,12 @@ achive this the *build_config.rb* needs to contain an instance of
tools and flags for the target platform. An example could look
like this:
-```
-MRuby::CrossBuild.new('32bit') do |conf|
- toolchain :gcc
+ MRuby::CrossBuild.new('32bit') do |conf|
+ toolchain :gcc
- conf.cc.flags << "-m32"
- conf.linker.flags << "-m32
-end
-```
+ conf.cc.flags << "-m32"
+ conf.linker.flags << "-m32
+ end
All configuration options of ```MRuby::Build``` can also be used
in ```MRuby::CrossBuild```.
@@ -209,29 +183,27 @@ in ```MRuby::CrossBuild```.
During the build process the directory *build* will be created in the
root directory. The structure of this directory will look like this:
-```
-+- build
- |
- +- host
- |
- +- bin <- Binaries (mirb, mrbc and mruby)
- |
- +- lib <- Libraries (libmruby.a and libmruby_core.a)
- |
- +- mrblib
- |
- +- src
- |
- +- test <- mrbtest tool
- |
- +- tools
- |
- +- mirb
- |
- +- mrbc
- |
- +- mruby
-```
+ +- build
+ |
+ +- host
+ |
+ +- bin <- Binaries (mirb, mrbc and mruby)
+ |
+ +- lib <- Libraries (libmruby.a and libmruby_core.a)
+ |
+ +- mrblib
+ |
+ +- src
+ |
+ +- test <- mrbtest tool
+ |
+ +- tools
+ |
+ +- mirb
+ |
+ +- mrbc
+ |
+ +- mruby
The compilation workflow will look like this:
* compile all files under *src* (object files will be stored
@@ -263,48 +235,46 @@ link with *build/host/lib/libmruby.a*
In case of a cross-compilation to *i386* the *build* directory structure looks
like this:
-```
-+- build
- |
- +- host
- | |
- | +- bin <- Native Binaries
- | |
- | +- lib <- Native Libraries
- | |
- | +- mrblib
- | |
- | +- src
- | |
- | +- test <- Native mrbtest tool
- | |
- | +- tools
- | |
- | +- mirb
- | |
- | +- mrbc
- | |
- | +- mruby
- +- i386
- |
- +- bin <- Cross-compiled Binaries
- |
- +- lib <- Cross-compiled Libraries
- |
- +- mrblib
- |
- +- src
- |
- +- test <- Cross-compiled mrbtest tool
- |
- +- tools
- |
- +- mirb
- |
- +- mrbc
- |
- +- mruby
-```
+ +- build
+ |
+ +- host
+ | |
+ | +- bin <- Native Binaries
+ | |
+ | +- lib <- Native Libraries
+ | |
+ | +- mrblib
+ | |
+ | +- src
+ | |
+ | +- test <- Native mrbtest tool
+ | |
+ | +- tools
+ | |
+ | +- mirb
+ | |
+ | +- mrbc
+ | |
+ | +- mruby
+ +- i386
+ |
+ +- bin <- Cross-compiled Binaries
+ |
+ +- lib <- Cross-compiled Libraries
+ |
+ +- mrblib
+ |
+ +- src
+ |
+ +- test <- Cross-compiled mrbtest tool
+ |
+ +- tools
+ |
+ +- mirb
+ |
+ +- mrbc
+ |
+ +- mruby
An extra directory is created for the target platform. In case you
compile for *i386* a directory called *i386* is created under the
@@ -331,23 +301,23 @@ link with *build/i386/lib/libmruby.a*
link with *build/i386/lib/libmruby_core.a*
```
- _____________________________________________________________
-| Native Compilation for Host System |
-| _____ ______ _____ ____ ____ _____ |
-|| CC | -> |AR | -> |GEN | -> |CC | -> |CC | -> |AR ||
-|| *.c | |core.a| |y.tab| |mrbc| |*.rb| |lib.a||
-| ----- ------ ----- ---- ---- ----- |
- -------------------------------------------------------------
+ _______________________________________________________________
+| Native Compilation for Host System |
+| _____ ______ _____ ____ ____ _____ |
+| | CC | -> |AR | -> |GEN | -> |CC | -> |CC | -> |AR | |
+| | *.c | |core.a| |y.tab| |mrbc| |*.rb| |lib.a| |
+| ----- ------ ----- ---- ---- ----- |
+ ---------------------------------------------------------------
||
\||/
\/
- ______________________________________________________________
-| Cross Compilation for Target System |
-| _____ _____ _____ ____ ______ _____ |
-|| CC | -> |AR | -> |CC | -> |CC | -> |AR | -> |CC ||
-|| *.c | |lib.a| |mruby| |mirb| |core.a| |mrbc ||
-| ----- ----- ----- ---- ------ ----- |
- --------------------------------------------------------------
+ ________________________________________________________________
+| Cross Compilation for Target System |
+| _____ _____ _____ ____ ______ _____ |
+| | CC | -> |AR | -> |CC | -> |CC | -> |AR | -> |CC | |
+| | *.c | |lib.a| |mruby| |mirb| |core.a| |mrbc | |
+| ----- ----- ----- ---- ------ ----- |
+ ----------------------------------------------------------------
```
## Test Environment
diff --git a/doc/mrbgems/README.md b/doc/mrbgems/README.md
index 49c8f56d1..6c473b57d 100644
--- a/doc/mrbgems/README.md
+++ b/doc/mrbgems/README.md
@@ -99,13 +99,10 @@ mrbgems expects that you have implemented a C method called
by the name of your GEM. If you call your GEM *c_extension_example*, your
finalizer method could look like this:
-```
-void
-mrb_c_extension_example_gem_final(mrb_state* mrb) {
- free(someone);
-}
-```
-
+ void
+ mrb_c_extension_example_gem_final(mrb_state* mrb) {
+ free(someone);
+ }
### Example
diff --git a/src/array.c b/src/array.c
index d4f5d1c5e..a358e1207 100644
--- a/src/array.c
+++ b/src/array.c
@@ -66,7 +66,7 @@ mrb_ary_new(mrb_state *mrb)
static inline void
array_copy(mrb_value *dst, const mrb_value *src, size_t size)
{
- int i;
+ size_t i;
for (i = 0; i < size; i++) {
dst[i] = src[i];
diff --git a/src/codegen.c b/src/codegen.c
index 5c3614814..5803a9c25 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -4,7 +4,6 @@
** See Copyright Notice in mruby.h
*/
-#undef CODEGEN_TEST
#define CODEGEN_DUMP
#include "mruby.h"
@@ -2538,7 +2537,7 @@ codedump(mrb_state *mrb, int n)
void
codedump_all(mrb_state *mrb, int start)
{
- int i;
+ size_t i;
for (i=start; i<mrb->irep_len; i++) {
codedump(mrb, i);
@@ -2577,35 +2576,3 @@ mrb_generate_code(mrb_state *mrb, parser_state *p)
return start;
}
-
-#ifdef CODEGEN_TEST
-int
-main()
-{
- mrb_state *mrb = mrb_open();
- int n;
-
-#if 1
- n = mrb_compile_string(mrb, "p(__FILE__)\np(__LINE__)");
-#else
- n = mrb_compile_string(mrb, "\
-def fib(n)\n\
- if n<2\n\
- n\n\
- else\n\
- fib(n-2)+fib(n-1)\n\
- end\n\
-end\n\
-p(fib(30), \"\\n\")\n\
-");
-#endif
- printf("ret: %d\n", n);
-#ifdef CODEGEN_DUMP
- codedump_all(mrb, n);
-#endif
- mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[0]), mrb_nil_value());
- mrb_close(mrb);
-
- return 0;
-}
-#endif
diff --git a/src/object.c b/src/object.c
index 99034e3be..f8ebd44bc 100644
--- a/src/object.c
+++ b/src/object.c
@@ -395,7 +395,7 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
{
const struct types *type = builtin_types;
struct RString *s;
- int xt;
+ enum mrb_vtype xt;
xt = mrb_type(x);
if ((xt != t) || (xt == MRB_TT_DATA)) {
diff --git a/src/parse.y b/src/parse.y
index 1ca3385f5..9ee9c9bec 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -5,7 +5,6 @@
*/
%{
-#undef PARSER_TEST
#undef PARSER_DEBUG
#define YYDEBUG 1
@@ -5648,26 +5647,3 @@ parser_dump(mrb_state *mrb, node *tree, int offset)
}
#endif
}
-
-#ifdef PARSER_TEST
-int
-main()
-{
- mrb_state *mrb = mrb_open();
- int n;
-
- n = mrb_compile_string(mrb, "\
-def fib(n)\n\
- if n<2\n\
- n\n\
- else\n\
- fib(n-2)+fib(n-1)\n\
- end\n\
-end\n\
-print(fib(20), \"\\n\")\n\
-");
- printf("ret: %d\n", n);
-
- return 0;
-}
-#endif
diff --git a/src/state.c b/src/state.c
index e30b0cea3..53773ac89 100644
--- a/src/state.c
+++ b/src/state.c
@@ -85,7 +85,7 @@ void mrb_free_heap(mrb_state *mrb);
void
mrb_close(mrb_state *mrb)
{
- int i;
+ size_t i;
mrb_final_core(mrb);
diff --git a/src/vm.c b/src/vm.c
index 696b566c8..ca31f6675 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -58,7 +58,7 @@ The value below allows about 60000 recursive calls in the simplest case. */
static inline void
stack_copy(mrb_value *dst, const mrb_value *src, size_t size)
{
- int i;
+ size_t i;
for (i = 0; i < size; i++) {
dst[i] = src[i];