Index: EcnlProtoTool/trunk/mruby-1.3.0/.cproject
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/.cproject	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/.cproject	(revision 331)
@@ -19,5 +19,5 @@
 						<toolChain id="com.renesas.cdt.rz.debug.win32.toolchain.Id.87786683" name="KPIT GNUARM-NONE-EABI Toolchain" superClass="com.renesas.cdt.rz.debug.win32.toolchain.Id">
 							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.PE" id="com.renesas.cdt.rz.debug.win32.targetplatform.Id.1600182357" name="Target Platform" osList="all" superClass="com.renesas.cdt.rz.debug.win32.targetplatform.Id"/>
-							<builder buildPath="${workspace_loc:/mruby-1.2.0}" id="com.renesas.cdt.rz.debug.win32.builder.Id.1846611762" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Builder" superClass="com.renesas.cdt.rz.debug.win32.builder.Id"/>
+							<builder buildPath="${workspace_loc:/mruby-1.3.0}" id="com.renesas.cdt.rz.debug.win32.builder.Id.1846611762" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Builder" superClass="com.renesas.cdt.rz.debug.win32.builder.Id"/>
 							<tool id="com.renesas.cdt.rz.debug.win32.tool.libgen.Id.1116635171" name="Library Generator" superClass="com.renesas.cdt.rz.debug.win32.tool.libgen.Id">
 								<option id="com.renesas.cdt.core.LibraryGenerator.option.ctype.458951408" name="ctype.h : æå­ãæ±ããã§ãã¯ãã¾ã" superClass="com.renesas.cdt.core.LibraryGenerator.option.ctype" value="true" valueType="boolean"/>
Index: EcnlProtoTool/trunk/mruby-1.3.0/.gitignore
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/.gitignore	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/.gitignore	(revision 331)
@@ -18,4 +18,5 @@
 /.git
 cscope.out
+tags
 /src/y.tab.c
 /bin
Index: EcnlProtoTool/trunk/mruby-1.3.0/.gitlab-ci.yml
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/.gitlab-ci.yml	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/.gitlab-ci.yml	(revision 331)
@@ -0,0 +1,3214 @@
+---
+stages:
+- pretest
+- test
+pretest:
+  stage: pretest
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.1
+  tags:
+  - linux
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+  script: "./minirake all test"
+Test gcc-4.7 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.7 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc47_0.7
+  variables:
+    CC: gcc-4.7
+    CXX: g++-4.7
+    LD: gcc-4.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.8 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc48_0.7
+  variables:
+    CC: gcc-4.8
+    CXX: g++-4.8
+    LD: gcc-4.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-4.9 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc49_0.7
+  variables:
+    CC: gcc-4.9
+    CXX: g++-4.9
+    LD: gcc-4.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-5 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc5_0.7
+  variables:
+    CC: gcc-5
+    CXX: g++-5
+    LD: gcc-5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test gcc-6 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:gcc6_0.7
+  variables:
+    CC: gcc-6
+    CXX: g++-6
+    LD: gcc-6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.5 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang35_0.7
+  variables:
+    CC: clang-3.5
+    CXX: clang++-3.5
+    LD: clang-3.5
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.6 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang36_0.7
+  variables:
+    CC: clang-3.6
+    CXX: clang++-3.6
+    LD: clang-3.6
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.7 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang37_0.7
+  variables:
+    CC: clang-3.7
+    CXX: clang++-3.7
+    LD: clang-3.7
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.8 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang38_0.7
+  variables:
+    CC: clang-3.8
+    CXX: clang++-3.8
+    LD: clang-3.8
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 32bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-m32 -DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: "-m32"
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_int16_nan:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_int16_nan_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_INT16=1 -DMRB_NAN_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_float:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_float_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_float_int16:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_float_int16_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT16=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_float_int64:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
+Test clang-3.9 64bit_float_int64_utf8:
+  stage: test
+  image: registry.gitlab.com/dabroz/mruby:clang39_0.7
+  variables:
+    CC: clang-3.9
+    CXX: clang++-3.9
+    LD: clang-3.9
+    CFLAGS: "-DMRB_USE_FLOAT=1 -DMRB_INT64=1 -DMRB_WORD_BOXING=1 -DMRB_UTF8_STRING=1"
+    LDFLAGS: ''
+  script: env; ./minirake --verbose all test
Index: EcnlProtoTool/trunk/mruby-1.3.0/.info
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/.info	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/.info	(revision 331)
@@ -4,4 +4,4 @@
 GCC_STRING=5.2-GNUARM-NONE_v16.01
 VERSION_IDE=
-E2STUDIO_VERSION=5.3.1.002
+E2STUDIO_VERSION=5.4.0.018
 ACTIVE_CONFIGURATION=Debug
Index: EcnlProtoTool/trunk/mruby-1.3.0/.project
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/.project	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/.project	(revision 331)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>mruby-1.2.0</name>
+	<name>mruby-1.3.0</name>
 	<comment></comment>
 	<projects>
Index: EcnlProtoTool/trunk/mruby-1.3.0/.travis.yml
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/.travis.yml	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/.travis.yml	(revision 331)
@@ -8,5 +8,5 @@
       sudo: 9000
     - os: osx
-      osx_image: xcod6.4
+      osx_image: xcode7.1
 
 addons:
@@ -17,10 +17,2 @@
 env: MRUBY_CONFIG=travis_config.rb
 script: "./minirake all test"
-
-notifications:
-  # Update mruby-head installed on Travis CI so other projects can test against it.
-  webhooks:
-    urls:
-      - "https://rubies.travis-ci.org/rebuild/mruby-head"
-    on_success: always
-    on_failure: never
Index: EcnlProtoTool/trunk/mruby-1.3.0/AUTHORS
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/AUTHORS	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/AUTHORS	(revision 331)
@@ -35,2 +35,4 @@
    Terence Lee
    Zachary Scott
+   Tomasz DÄ
+browski
Index: EcnlProtoTool/trunk/mruby-1.3.0/MITL
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/MITL	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/MITL	(revision 331)
@@ -1,3 +1,3 @@
-Copyright (c) 2015 mruby developers
+Copyright (c) 2017 mruby developers
 
 Permission is hereby granted, free of charge, to any person obtaining a
Index: EcnlProtoTool/trunk/mruby-1.3.0/README.md
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/README.md	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/README.md	(revision 331)
@@ -18,5 +18,5 @@
 ## How to get mruby
 
-The stable version 1.2.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/1.2.0.zip](https://github.com/mruby/mruby/archive/1.2.0.zip)
+The stable version 1.3.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/1.3.0.zip](https://github.com/mruby/mruby/archive/1.3.0.zip)
 
 The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
@@ -27,4 +27,6 @@
     $ git clone https://github.com/mruby/mruby.git
 
+You can also install and compile mruby using [ruby-install](https://github.com/postmodern/ruby-install), [ruby-build](https://github.com/rbenv/ruby-build) or [rvm](https://github.com/rvm/rvm).
+
 ## mruby home-page
 
@@ -33,5 +35,5 @@
 ## Mailing list
 
-We don't have mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby).
+We don't have a mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby).
 
 ## How to compile and install (mruby and gems)
@@ -53,5 +55,5 @@
 mruby contains a package manager called *mrbgems*. To create extensions
 in C and/or Ruby you should create a *GEM*. For a documentation of how to
-use mrbgems consult the file [doc/mrbgems/README.md](doc/mrbgems/README.md). For example code of
+use mrbgems consult the file [doc/guides/mrbgems.md](doc/guides/mrbgems.md). For example code of
 how to use mrbgems look into the folder *examples/mrbgems/*.
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/Rakefile
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/Rakefile	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/Rakefile	(revision 331)
@@ -28,4 +28,6 @@
 
 load "#{MRUBY_ROOT}/tasks/benchmark.rake"
+
+load "#{MRUBY_ROOT}/tasks/gitlab.rake"
 
 ##############################
Index: EcnlProtoTool/trunk/mruby-1.3.0/appveyor.yml
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/appveyor.yml	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/appveyor.yml	(revision 331)
@@ -0,0 +1,27 @@
+version: "{build}"
+
+os: Visual Studio 2015
+
+clone_depth: 50
+
+
+environment:
+  matrix:
+    # Visual Studio 2015 64bit
+    - visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
+      machine: amd64
+
+    # Visual Studio 2013 64bit
+    - visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
+      machine: amd64
+
+
+init:
+  - call "%visualcpp%" %machine%
+  # For using bison.exe
+  - set PATH=%PATH%;C:\cygwin\bin;
+
+
+build_script:
+  - set MRUBY_CONFIG=appveyor_config.rb
+  - ruby .\minirake test
Index: EcnlProtoTool/trunk/mruby-1.3.0/appveyor_config.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/appveyor_config.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/appveyor_config.rb	(revision 331)
@@ -0,0 +1,50 @@
+MRuby::Build.new('debug') do |conf|
+  toolchain :visualcpp
+  enable_debug
+
+  # include all core GEMs
+  conf.gembox 'full-core'
+  conf.compilers.each do |c|
+    c.defines += %w(MRB_GC_STRESS MRB_GC_FIXED_ARENA)
+  end
+
+  build_mrbc_exec
+end
+
+MRuby::Build.new('full-debug') do |conf|
+  toolchain :visualcpp
+  enable_debug
+
+  # include all core GEMs
+  conf.gembox 'full-core'
+  conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
+
+  conf.enable_test
+end
+
+MRuby::Build.new do |conf|
+  toolchain :visualcpp
+
+  # include all core GEMs
+  conf.gembox 'full-core'
+  conf.compilers.each do |c|
+    c.defines += %w(MRB_GC_FIXED_ARENA)
+  end
+  conf.enable_bintest
+  conf.enable_test
+end
+
+MRuby::Build.new('cxx_abi') do |conf|
+  toolchain :visualcpp
+
+  conf.gembox 'full-core'
+  conf.compilers.each do |c|
+    c.defines += %w(MRB_GC_FIXED_ARENA)
+  end
+  conf.enable_bintest
+  conf.enable_test
+
+  enable_cxx_abi
+
+  build_mrbc_exec
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/build.bat
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/build.bat	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/build.bat	(revision 331)
@@ -1,4 +1,9 @@
+set DIR=%~dp0
+set PATH=%PATH%;%DIR%\..\tools\bin
 
-call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86
+rem call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86
+call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
+
+cd /d %DIR%
 
 ruby -Eutf-8 ./minirake %1
Index: EcnlProtoTool/trunk/mruby-1.3.0/build_config.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/build_config.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/build_config.rb	(revision 331)
@@ -17,6 +17,8 @@
   # end
   # conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
-  # conf.gem :github => 'masuidrive/mrbgems-example', :checksum_hash => '76518e8aecd131d047378448ac8055fa29d974a9'
-  # conf.gem :git => 'git@github.com:masuidrive/mrbgems-example.git', :branch => 'master', :options => '-v'
+  # conf.gem :core => 'mruby-eval'
+  # conf.gem :mgem => 'mruby-io'
+  # conf.gem :github => 'iij/mruby-io'
+  # conf.gem :git => 'git@github.com:iij/mruby-io.git', :branch => 'master', :options => '-v'
 
   # include the default GEMs
@@ -147,5 +149,10 @@
   conf.archiver.command = "arm-none-eabi-ar"
 
-  conf.cc.flags << %w(-MD -MP -mlittle-endian -mcpu=cortex-a9 -mthumb -mthumb-interwork -marm -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -mno-unaligned-access -fno-strict-aliasing)
+  conf.cc.flags << %w(-MD -MP -mlittle-endian -mcpu=cortex-a9 -mthumb -mthumb-interwork -marm -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -mno-unaligned-access -fno-strict-aliasing -nostdinc)
+  conf.cc.include_paths  << "../musl-1.1.18/include"
+
+  conf.linker.flags << %w(-nostdlib)
+  conf.linker.library_paths << "../musl-1.1.18/lib"
+  conf.linker.libraries << %w(c gcc)
 
   #configuration for low memory environment
@@ -160,27 +167,26 @@
   conf.gem "#{root}/mrbgems/mruby-string-ext"
   conf.gem '../mrbgems/mruby-onig-regexp'  do |g|
-    g.cc.include_paths  << "../onigmo-5.15.0/src"
+    g.cc.include_paths  << "../onigmo-6.1.3/src"
   end
   conf.gem "#{root}/../mrbgems/mruby-blockly"
+  conf.gem "#{root}/../mrbgems/mruby-digest" do |g|
+    g.cc.include_paths << "#{g.dir}/../../openssl-1.1.0e/include"
+  end
+  conf.gem "#{root}/../mrbgems/mruby-dir"
+  conf.gem "#{root}/../mrbgems/mruby-env"
+  conf.gem "#{root}/../mrbgems/mruby-errno"
+  conf.gem "#{root}/../mrbgems/mruby-iijson"
   conf.gem "#{root}/../mrbgems/mruby-io"
-  conf.gem "#{root}/../mrbgems/mruby-dir" do |g|
-    g.cc.defines = %w(__NEWLIB__=2)
-    g.cc.include_paths << "#{g.dir}/../../musl-1.1.12/include"
-  end
+  conf.gem "#{root}/../mrbgems/mruby-ipaddr"
+  conf.gem "#{root}/../mrbgems/mruby-mock"
   conf.gem "#{root}/../mrbgems/mruby-pack"
-  conf.gem "#{root}/../mrbgems/mruby-socket" do |g|
-    g.cc.include_paths << "#{g.dir}/../../musl-1.1.12/include"
+  conf.gem "#{root}/../mrbgems/mruby-require"
+  conf.gem "#{root}/../mrbgems/mruby-socket"
+  conf.gem "#{root}/../mrbgems/mruby-tls-openssl" do |g|
+    g.cc.include_paths << "#{g.dir}/../../openssl-1.1.0e/include"
   end
   conf.gem "#{root}/../mrbgems/mruby-arduino" do |g|
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/api"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/hal"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc/iodefines"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H"
-    g.cc.include_paths << "#{g.dir}/../../asp3_dcre/mbed/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H"
-    g.cc.include_paths << "#{g.dir}/../../sample/gr_peach"
     g.cc.include_paths << "#{g.dir}/../../prototool/src"
+    g.cc.include_paths << "#{g.dir}/../../mbed_api/src"
   end
   conf.gem "#{root}/../mrbgems/mruby-ecnl"
Index: EcnlProtoTool/trunk/mruby-1.3.0/examples/mrbgems/ruby_extension_example/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/examples/mrbgems/ruby_extension_example/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/examples/mrbgems/ruby_extension_example/mrbgem.rake	(revision 331)
@@ -12,4 +12,6 @@
   # spec.linker.libraries << 'external_lib'
 
+  spec.add_dependency('mruby-print', :core => 'mruby-print')
+
   # Default build files
   # spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
Index: EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_IntelEdison.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_IntelEdison.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_IntelEdison.rb	(revision 331)
@@ -0,0 +1,69 @@
+# Cross-compiling setup for Intel Edison (poky linux) platform
+# Get SDK from here: https://software.intel.com/en-us/iot/hardware/edison/downloads
+# REMEMBER to check and update the SDK root in the constant POKY_EDISON_PATH
+
+MRuby::Build.new do |conf|
+  toolchain :gcc
+  conf.gembox 'default'
+  conf.cc.defines = %w(ENABLE_READLINE)
+  conf.gembox 'default'
+
+  #lightweight regular expression
+  conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master"
+
+end
+
+# Define cross build settings
+MRuby::CrossBuild.new('core2-32-poky-linux') do |conf|
+  toolchain :gcc
+
+  # Mac OS X
+  #
+  POKY_EDISON_PATH = '/opt/poky-edison/1.7.2'
+
+  POKY_EDISON_SYSROOT =  "#{POKY_EDISON_PATH}/sysroots/core2-32-poky-linux"
+  POKY_EDISON_X86_PATH = "#{POKY_EDISON_PATH}/sysroots/i386-pokysdk-darwin"
+  POKY_EDISON_BIN_PATH = "#{POKY_EDISON_X86_PATH}/usr/bin/i586-poky-linux"
+
+
+  conf.cc do |cc|
+    cc.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-gcc"
+    cc.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include", "#{POKY_EDISON_X86_PATH}/usr/include"]
+    cc.flags = %w(-m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer)
+    cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types)
+    cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
+    cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
+    cc.defines = %w(ENABLE_READLINE)
+  end
+
+  conf.cxx do |cxx|
+    cxx.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++"
+    cxx.include_paths = conf.cc.include_paths.dup
+    cxx.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include/c++/4.9.1"]
+    cxx.flags = conf.cc.flags.dup
+    cxx.defines = conf.cc.defines.dup
+    cxx.compile_options = conf.cc.compile_options.dup
+  end
+
+  conf.archiver do |archiver|
+    archiver.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-ar"
+    archiver.archive_options = 'rcs %{outfile} %{objs}'
+  end
+
+  conf.linker do |linker|
+    linker.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++"
+    linker.flags = %w(-m32 -march=i586)
+    linker.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
+    linker.flags << %w(-O1)
+    linker.libraries = %w(m pthread)
+  end
+
+  #do not build executable test
+  conf.build_mrbtest_lib_only
+
+  conf.gembox 'default'
+
+  #lightweight regular expression
+  conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master"
+
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_RX630.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_RX630.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_RX630.rb	(revision 331)
@@ -0,0 +1,82 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+
+end
+
+# Cross Compiling configuration for RX630
+# http://gadget.renesas.com/
+#
+# Requires gnurx_v14.03
+MRuby::CrossBuild.new("RX630") do |conf|
+  toolchain :gcc
+
+  # Linux
+  BIN_PATH = "/usr/share/gnurx_v14.03_elf-1/bin"
+
+  conf.cc do |cc|
+    cc.command = "#{BIN_PATH}/rx-elf-gcc"
+    cc.flags = "-Wall -g -O2 -flto -mcpu=rx600 -m64bit-doubles"
+    cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
+
+    #configuration for low memory environment
+    cc.defines << %w(MRB_USE_FLOAT)
+    cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
+    cc.defines << %w(MRB_USE_IV_SEGLIST)
+    cc.defines << %w(KHASH_DEFAULT_SIZE=8)
+    cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
+    cc.defines << %w(MRB_GC_STRESS)
+    cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
+    #cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
+  end
+
+  conf.cxx do |cxx|
+    cxx.command = conf.cc.command.dup
+    cxx.include_paths = conf.cc.include_paths.dup
+    cxx.flags = conf.cc.flags.dup
+    cxx.defines = conf.cc.defines.dup
+    cxx.compile_options = conf.cc.compile_options.dup
+  end
+
+  conf.linker do |linker|
+    linker.command="#{BIN_PATH}/rx-elf-ld"
+  end
+
+  conf.archiver do |archiver|
+    archiver.command = "#{BIN_PATH}/rx-elf-ar"
+    archiver.archive_options = 'rcs %{outfile} %{objs}'
+  end
+
+  #no executables
+  conf.bins = []
+
+  #do not build executable test
+  conf.build_mrbtest_lib_only
+
+  #disable C++ exception
+  conf.disable_cxx_exception
+
+  #gems from core
+  conf.gem :core => "mruby-sprintf"
+  conf.gem :core => "mruby-print"
+  conf.gem :core => "mruby-math"
+  conf.gem :core => "mruby-enum-ext"
+  conf.gem :core => "mruby-numeric-ext"
+
+  #light-weight regular expression
+  #conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
+
+  #Arduino API
+  #conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
+
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_arm64-v8a.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_arm64-v8a.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_arm64-v8a.rb	(revision 331)
@@ -0,0 +1,26 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+end
+
+# Requires Android NDK r13 or later.
+MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
+  params = { 
+    :arch => 'arm64-v8a', 
+    :platform => 'android-24',
+    :toolchain => :clang,
+  }
+  toolchain :android, params
+
+  conf.gembox 'default'
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_armeabi.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_armeabi.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_armeabi.rb	(revision 331)
@@ -0,0 +1,26 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+end
+
+# Requires Android NDK r13 or later.
+MRuby::CrossBuild.new('android-armeabi') do |conf|
+  params = { 
+    :arch => 'armeabi', 
+    :platform => 'android-24',
+    :toolchain => :clang,
+  }
+  toolchain :android, params
+
+  conf.gembox 'default'
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_armeabi_v7a_neon_hard.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_armeabi_v7a_neon_hard.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/examples/targets/build_config_android_armeabi_v7a_neon_hard.rb	(revision 331)
@@ -0,0 +1,28 @@
+MRuby::Build.new do |conf|
+
+  # Gets set by the VS command prompts.
+  if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
+    toolchain :visualcpp
+  else
+    toolchain :gcc
+  end
+
+  enable_debug
+
+  # include the default GEMs
+  conf.gembox 'default'
+end
+
+# Requires Android NDK r13 or later.
+MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
+  params = {
+    :arch => 'armeabi-v7a',
+    :mfpu => 'neon',
+    :mfloat_abi => 'hard',
+    :platform => 'android-24',
+    :toolchain => :clang,
+  }
+  toolchain :android, params
+
+  conf.gembox 'default'
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mrbconf.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mrbconf.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mrbconf.h	(revision 331)
@@ -8,8 +8,24 @@
 #define MRUBYCONF_H
 
+#include <limits.h>
+#include <stdint.h>
+
+/* architecture selection: */
+/* specify -DMRB_32BIT or -DMRB_64BIT to override */
+#if !defined(MRB_32BIT) && !defined(MRB_64BIT)
+#if UINT64_MAX == SIZE_MAX
+#define MRB_64BIT
+#else
+#define MRB_32BIT
+#endif
+#endif
+
+#if defined(MRB_32BIT) && defined(MRB_64BIT)
+#error Cannot build for 32 and 64 bit architecture at the same time
+#endif
+
 /* configuration options: */
 /* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
 //#define MRB_USE_FLOAT
-#define MRB_USE_FLOAT
 
 /* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT64 */
@@ -33,13 +49,10 @@
 /* argv max size in mrb_funcall */
 //#define MRB_FUNCALL_ARGC_MAX 16
-#define MRB_FUNCALL_ARGC_MAX 8
 
 /* number of object per heap page */
 //#define MRB_HEAP_PAGE_SIZE 1024
-#define MRB_HEAP_PAGE_SIZE 64
 
 /* use segmented list for IV table */
 //#define MRB_USE_IV_SEGLIST
-#define MRB_USE_IV_SEGLIST
 
 /* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
@@ -58,5 +71,4 @@
 /* default size of khash table bucket */
 //#define KHASH_DEFAULT_SIZE 32
-#define KHASH_DEFAULT_SIZE 8
 
 /* allocated memory address alignment */
@@ -65,9 +77,7 @@
 /* page size of memory pool */
 //#define POOL_PAGE_SIZE 16000
-#define POOL_PAGE_SIZE 4096
 
 /* initial minimum size for string buffer */
 //#define MRB_STR_BUF_MIN_SIZE 128
-#define MRB_STR_BUF_MIN_SIZE 20
 
 /* arena size */
@@ -76,5 +86,4 @@
 /* fixed size GC arena */
 //#define MRB_GC_FIXED_ARENA
-#define MRB_GC_FIXED_ARENA
 
 /* state atexit stack size */
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby.h	(revision 331)
@@ -2,5 +2,5 @@
 ** mruby - An embeddable Ruby implementation
 **
-** Copyright (c) mruby developers 2010-2015
+** Copyright (c) mruby developers 2010-2017
 **
 ** Permission is hereby granted, free of charge, to any person obtaining
@@ -29,13 +29,51 @@
 #define MRUBY_H
 
+#ifdef __cplusplus
+#define __STDC_LIMIT_MACROS
+#define __STDC_CONSTANT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
 #include <stdint.h>
 #include <stddef.h>
 #include <limits.h>
 
+#ifdef __cplusplus
+#ifndef SIZE_MAX
+#ifdef __SIZE_MAX__
+#define SIZE_MAX __SIZE_MAX__
+#else
+#define SIZE_MAX std::numeric_limits<size_t>::max()
+#endif
+#endif
+#endif
+
+#ifdef MRB_DEBUG
+#include <assert.h>
+#define mrb_assert(p) assert(p)
+#define mrb_assert_int_fit(t1,n,t2,max) assert((n)>=0 && ((sizeof(n)<=sizeof(t2))||(n<=(t1)(max))))
+#else
+#define mrb_assert(p) ((void)0)
+#define mrb_assert_int_fit(t1,n,t2,max) ((void)0)
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#define mrb_static_assert(exp, str) _Static_assert(exp, str)
+#else
+#define mrb_static_assert(exp, str) mrb_assert(exp)
+#endif
+
 #include "mrbconf.h"
+
+#ifdef MRB_USE_FLOAT
+#define MRB_FLOAT_EPSILON FLT_EPSILON
+#else
+#define MRB_FLOAT_EPSILON DBL_EPSILON
+#endif
+
 #include "mruby/common.h"
-#include "mruby/value.h"
-#include "mruby/gc.h"
-#include "mruby/version.h"
+#include <mruby/value.h>
+#include <mruby/gc.h>
+#include <mruby/version.h>
 
 /**
@@ -76,5 +114,5 @@
   int nregs;
   int ridx;
-  int eidx;
+  int epos;
   struct REnv *env;
   mrb_code *pc;                 /* return address */
@@ -88,5 +126,5 @@
   MRB_FIBER_CREATED = 0,
   MRB_FIBER_RUNNING,
-  MRB_FIBER_RESUMING,
+  MRB_FIBER_RESUMED,
   MRB_FIBER_SUSPENDED,
   MRB_FIBER_TRANSFERRED,
@@ -106,7 +144,8 @@
   int rsize;
   struct RProc **ensure;                  /* ensure handler stack */
-  int esize;
+  int esize, eidx;
 
   enum mrb_fiber_state status;
+  mrb_bool vmexec;
   struct RFiber *fib;
 };
@@ -116,7 +155,11 @@
 typedef void (*mrb_atexit_func)(struct mrb_state*);
 
+#define MRB_STATE_NO_REGEXP 1
+#define MRB_STATE_REGEXP    2
+
 typedef struct mrb_state {
   struct mrb_jmpbuf *jmp;
 
+  uint32_t flags;
   mrb_allocf allocf;                      /* memory allocation function */
   void *allocf_ud;                        /* auxiliary data of allocf */
@@ -124,7 +167,7 @@
   struct mrb_context *c;
   struct mrb_context *root_c;
+  struct iv_tbl *globals;                 /* global variable table */
 
   struct RObject *exc;                    /* exception */
-  struct iv_tbl *globals;                 /* global variable table */
 
   struct RObject *top_self;
@@ -158,7 +201,15 @@
 #endif
 
+#ifdef MRB_BYTECODE_DECODE_OPTION
+  mrb_code (*bytecode_decoder)(struct mrb_state* mrb, mrb_code code);
+#endif
+
   struct RClass *eException_class;
   struct RClass *eStandardError_class;
   struct RObject *nomem_err;              /* pre-allocated NoMemoryError */
+  struct RObject *stack_err;              /* pre-allocated SysStackError */
+#ifdef MRB_GC_FIXED_ARENA
+  struct RObject *arena_err;              /* pre-allocated arena overfow error */
+#endif
 
   void *ud; /* auxiliary data */
@@ -182,10 +233,10 @@
  *      !!!c
  *      void mrb_example_gem_init(mrb_state* mrb) {
- *              struct RClass *example_class;
- *              example_class = mrb_define_class(mrb, "Example_Class", mrb->object_class);
+ *          struct RClass *example_class;
+ *          example_class = mrb_define_class(mrb, "Example_Class", mrb->object_class);
  *      }
  *
  *      void mrb_example_gem_final(mrb_state* mrb) {
- *              //free(TheAnimals);
+ *          //free(TheAnimals);
  *      }
  *
@@ -200,4 +251,5 @@
 /**
  * Defines a new module.
+ *
  * @param [mrb_state *] mrb_state* The current mruby state.
  * @param [const char *] char* The name of the module.
@@ -209,9 +261,9 @@
 /**
  * Include a module in another class or module.
- * Equivalent to: 
- *
- *   module B                                                                                                         
- *     include A                                                                                                      
- *   end 
+ * Equivalent to:
+ *
+ *   module B
+ *     include A
+ *   end
  * @param [mrb_state *] mrb_state* The current mruby state.
  * @param [struct RClass *] RClass* A reference to module or a class.
@@ -230,5 +282,5 @@
  * @param [struct RClass *] RClass* A reference to module or a class.
  * @param [struct RClass *] RClass* A reference to the module to be prepended.
- */ 
+ */
 MRB_API void mrb_prepend_module(mrb_state*, struct RClass*, struct RClass*);
 
@@ -264,27 +316,20 @@
  *
  * Example:
- *   # Ruby style
- *   class Foo
- *
- *     def Foo.bar
+ *
+ *     # Ruby style
+ *     class Foo
+ *       def Foo.bar
+ *       end
  *     end
- *
- *   end
- *   // C style
- *   mrb_value bar_method(mrb_state* mrb, mrb_value self){
- *
- *     return mrb_nil_value();
- *
- *   }
- *   void mrb_example_gem_init(mrb_state* mrb){
- *
- *     struct RClass *foo;
- *
- *     foo = mrb_define_class(mrb, "Foo", mrb->object_class);
- *
- *     mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
- * 
- *   }
- * @param [mrb_state *] mrb_state* The MRuby state reference. 
+ *     // C style
+ *     mrb_value bar_method(mrb_state* mrb, mrb_value self){
+ *       return mrb_nil_value();
+ *     }
+ *     void mrb_example_gem_init(mrb_state* mrb){
+ *       struct RClass *foo;
+ *       foo = mrb_define_class(mrb, "Foo", mrb->object_class);
+ *       mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
+ *     }
+ * @param [mrb_state *] mrb_state* The MRuby state reference.
  * @param [struct RClass *] RClass* The class where the class method will be defined.
  * @param [const char *] char* The name of the class method being defined.
@@ -299,28 +344,23 @@
  *
  * Example:
- *   # Ruby style
- *   module Foo
- *                                                                                                     
- *     def Foo.bar                                                                                                    *     end
- *
- *   end                                                                                                             
- *   // C style                                                                                                      
- *   mrb_value bar_method(mrb_state* mrb, mrb_value self){ 
- *                                                          
- *     return mrb_nil_value();                                                                                        *               
- *   }                                                                                                               
- *   void mrb_example_gem_init(mrb_state* mrb){
- *                                                                      
- *     struct RClass *foo;
- *                                                                                           
- *     foo = mrb_define_module(mrb, "Foo");
- *                                                        
- *     mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
- *
- *   }    
+ *
+ *        # Ruby style
+ *        module Foo
+ *          def Foo.bar
+ *          end
+ *        end
+ *        // C style
+ *        mrb_value bar_method(mrb_state* mrb, mrb_value self){
+ *          return mrb_nil_value();
+ *        }
+ *        void mrb_example_gem_init(mrb_state* mrb){
+ *          struct RClass *foo;
+ *          foo = mrb_define_module(mrb, "Foo");
+ *          mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
+ *        }
  *  @param [mrb_state *] mrb_state* The MRuby state reference.
  *  @param [struct RClass *] RClass* The module where the module function will be defined.
  *  @param [const char *] char* The name of the module function being defined.
- *  @param [mrb_func_t] mrb_func_t The function pointer to the module function definition. 
+ *  @param [mrb_func_t] mrb_func_t The function pointer to the module function definition.
  *  @param [mrb_aspec] mrb_aspec The method parameters declaration.
  */
@@ -331,27 +371,21 @@
  *
  * Example:
- *    # Ruby style
- *
- *    class ExampleClass
- *    
- *    AGE = 22
- *
- *    end
- *
- *    // C style
- *    #include <stdio.h> 
- *    #include <mruby.h>
- *
- *    void
- *    mrb_example_gem_init(mrb_state* mrb){
- * 
- *      mrb_define_const(mrb, mrb->kernel_module, "AGE", mrb_fixnum_value(22));
- *
- *    }
- *
- *    mrb_value
- *    mrb_example_gem_final(mrb_state* mrb){
- *
- *    }
+ *
+ *          # Ruby style
+ *          class ExampleClass
+ *            AGE = 22
+ *          end
+ *          // C style
+ *          #include <stdio.h>
+ *          #include <mruby.h>
+ *
+ *          void
+ *          mrb_example_gem_init(mrb_state* mrb){
+ *            mrb_define_const(mrb, mrb->kernel_module, "AGE", mrb_fixnum_value(22));
+ *          }
+ *
+ *          mrb_value
+ *          mrb_example_gem_final(mrb_state* mrb){
+ *          }
  *  @param [mrb_state *] mrb_state* The MRuby state reference.
  *  @param [struct RClass *] RClass* A class or module the constant is defined in.
@@ -365,57 +399,44 @@
  *
  * Example:
- *   # Ruby style
- *
- *   class ExampleClassA
- *
- *     def example_method
- *       "example"
+ *
+ *     # Ruby style
+ *
+ *     class ExampleClassA
+ *       def example_method
+ *         "example"
+ *       end
  *     end
- *
- *   end
- *
- *   ExampleClassA.new.example_method # => example
- *
- *   class ExampleClassB < ExampleClassA
- *
- *     undef_method :example_method
- *
- *   end
- *
- *   ExampleClassB.new.example_method # => undefined method 'example_method' for ExampleClassB (NoMethodError)
- *
- *   // C style
- *   #include <stdio.h>
- *   #include <mruby.h>
- *  
- *   mrb_value
- *   mrb_example_method(mrb_state *mrb){
- *
- *     return mrb_str_new_cstr(mrb, "example");
- *
- *   }
- *
- *   void
- *   mrb_example_gem_init(mrb_state* mrb){
- *     struct RClass *example_class_a;
- *     struct RClass *example_class_b;
- *     struct RClass *example_class_c;
- *
- *     example_class_a = mrb_define_class(mrb, "ExampleClassA", mrb->object_class);
- *
- *     mrb_define_method(mrb, example_class_a, "example_method", mrb_example_method, MRB_ARGS_NONE());
- *
- *     example_class_b = mrb_define_class(mrb, "ExampleClassB", example_class_a);
- *
- *     example_class_c = mrb_define_class(mrb, "ExampleClassC", example_class_b);
- *
- *     mrb_undef_method(mrb, example_class_c, "example_method");
- *
- *   }
- *
- *   mrb_example_gem_final(mrb_state* mrb){
- *
- *   }
- *
+ *     ExampleClassA.new.example_method # => example
+ *
+ *     class ExampleClassB < ExampleClassA
+ *       undef_method :example_method
+ *     end
+ *
+ *     ExampleClassB.new.example_method # => undefined method 'example_method' for ExampleClassB (NoMethodError)
+ *
+ *     // C style
+ *     #include <stdio.h>
+ *     #include <mruby.h>
+ *
+ *     mrb_value
+ *     mrb_example_method(mrb_state *mrb){
+ *       return mrb_str_new_lit(mrb, "example");
+ *     }
+ *
+ *     void
+ *     mrb_example_gem_init(mrb_state* mrb){
+ *       struct RClass *example_class_a;
+ *       struct RClass *example_class_b;
+ *       struct RClass *example_class_c;
+ *
+ *       example_class_a = mrb_define_class(mrb, "ExampleClassA", mrb->object_class);
+ *       mrb_define_method(mrb, example_class_a, "example_method", mrb_example_method, MRB_ARGS_NONE());
+ *       example_class_b = mrb_define_class(mrb, "ExampleClassB", example_class_a);
+ *       example_class_c = mrb_define_class(mrb, "ExampleClassC", example_class_b);
+ *       mrb_undef_method(mrb, example_class_c, "example_method");
+ *     }
+ *
+ *     mrb_example_gem_final(mrb_state* mrb){
+ *     }
  * @param [mrb_state*] mrb_state* The mruby state reference.
  * @param [struct RClass*] RClass* A class the method will be undefined from.
@@ -426,45 +447,35 @@
 /**
  * Undefine a class method.
- *
  * Example:
- *   # Ruby style
- *
- *   class ExampleClass
- *     def self.example_method
- *       "example"
- *     end
- *
- *   end
- *
- *   ExampleClass.example_method
- *   
- *   // C style
- *   #include <stdio.h>
- *   #include <mruby.h> 
- *
- *   mrb_value
- *   mrb_example_method(mrb_state *mrb){
- *
- *     return mrb_str_new_cstr(mrb, "example");
- *     
- *   }
- *
- *   void
- *   mrb_example_gem_init(mrb_state* mrb){
- *
- *     struct RClass *example_class;
- *     
- *     example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
- *
- *     mrb_define_class_method(mrb, example_class, "example_method", mrb_example_method, MRB_ARGS_NONE());
- *
- *     mrb_undef_class_method(mrb, example_class, "example_method");
- *
- *   }
- *
- *   void
- *   mrb_example_gem_final(mrb_state* mrb){
- *
- *   }
+ *
+ *      # Ruby style
+ *      class ExampleClass
+ *        def self.example_method
+ *          "example"
+ *        end
+ *      end
+ *
+ *     ExampleClass.example_method
+ *
+ *     // C style
+ *     #include <stdio.h>
+ *     #include <mruby.h>
+ *
+ *     mrb_value
+ *     mrb_example_method(mrb_state *mrb){
+ *       return mrb_str_new_lit(mrb, "example");
+ *     }
+ *
+ *     void
+ *     mrb_example_gem_init(mrb_state* mrb){
+ *       struct RClass *example_class;
+ *       example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
+ *       mrb_define_class_method(mrb, example_class, "example_method", mrb_example_method, MRB_ARGS_NONE());
+ *       mrb_undef_class_method(mrb, example_class, "example_method");
+ *      }
+ *
+ *      void
+ *      mrb_example_gem_final(mrb_state* mrb){
+ *      }
  * @param [mrb_state*] mrb_state* The mruby state reference.
  * @param [RClass*] RClass* A class the class method will be undefined from.
@@ -478,22 +489,21 @@
  * Example:
  *
- *   # Ruby style
- *   class ExampleClass
- *   end
- *
- *   p ExampleClass # => #<ExampleClass:0x9958588>
- *   // C style
- *   #include <stdio.h>
- *   #include <mruby.h>
- *
- *   void
- *   mrb_example_gem_init(mrb_state* mrb) {
- *     struct RClass *example_class;
- *     mrb_value obj;
- *
- *     example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class); # => class ExampleClass; end
- *     obj = mrb_obj_new(mrb, example_class, 0, NULL); # => ExampleClass.new
- *     mrb_p(mrb, obj); // => Kernel#p
- *   }  
+ *     # Ruby style
+ *     class ExampleClass
+ *     end
+ *
+ *     p ExampleClass # => #<ExampleClass:0x9958588>
+ *     // C style
+ *     #include <stdio.h>
+ *     #include <mruby.h>
+ *
+ *     void
+ *     mrb_example_gem_init(mrb_state* mrb) {
+ *       struct RClass *example_class;
+ *       mrb_value obj;
+ *       example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class); # => class ExampleClass; end
+ *       obj = mrb_obj_new(mrb, example_class, 0, NULL); # => ExampleClass.new
+ *       mrb_p(mrb, obj); // => Kernel#p
+ *      }
  * @param [mrb_state*] mrb The current mruby state.
  * @param [RClass*] c Reference to the class of the new object.
@@ -517,13 +527,13 @@
  * Example:
  *
- *   void
- *   mrb_example_gem_init(mrb_state* mrb) {
- *      struct RClass *example_class;
- *      mrb_value obj;
- *
- *      example_class = mrb_class_new(mrb, mrb->object_class);
- *      obj = mrb_obj_new(mrb, example_class, 0, NULL); // => #<#<Class:0x9a945b8>:0x9a94588>
- *      mrb_p(mrb, obj); // => Kernel#p
- *   }
+ *      void
+ *      mrb_example_gem_init(mrb_state* mrb) {
+ *        struct RClass *example_class;
+ *
+ *        mrb_value obj;
+ *        example_class = mrb_class_new(mrb, mrb->object_class);
+ *        obj = mrb_obj_new(mrb, example_class, 0, NULL); // => #<#<Class:0x9a945b8>:0x9a94588>
+ *        mrb_p(mrb, obj); // => Kernel#p
+ *       }
  *
  * @param [mrb_state*] mrb The current mruby state.
@@ -537,10 +547,10 @@
  *
  * Example:
- *   void
- *   mrb_example_gem_init(mrb_state* mrb) {
- *      struct RClass *example_module;
- *
- *      example_module = mrb_module_new(mrb);
- *   }
+ *      void
+ *      mrb_example_gem_init(mrb_state* mrb) {
+ *        struct RClass *example_module;
+ *
+ *        example_module = mrb_module_new(mrb);
+ *      }
  *
  * @param [mrb_state*] mrb The current mruby state.
@@ -553,21 +563,21 @@
  *
  * Example:
- *   void
- *   mrb_example_gem_init(mrb_state* mrb) {
- *      struct RClass *example_class;
- *      mrb_bool cd;
- *
- *      example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
- *      cd = mrb_class_defined(mrb, "ExampleClass");
- *      
- *      // If mrb_class_defined returns 1 then puts "True"
- *      // If mrb_class_defined returns 0 then puts "False"
- *      if (cd == 1){
- *        puts("True");
+ *     void
+ *     mrb_example_gem_init(mrb_state* mrb) {
+ *       struct RClass *example_class;
+ *       mrb_bool cd;
+ *
+ *       example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
+ *       cd = mrb_class_defined(mrb, "ExampleClass");
+ *
+ *       // If mrb_class_defined returns 1 then puts "True"
+ *       // If mrb_class_defined returns 0 then puts "False"
+ *       if (cd == 1){
+ *         puts("True");
+ *       }
+ *       else {
+ *         puts("False");
+ *       }
  *      }
- *      else {
- *        puts("False");
- *      }
- *   }
  *
  * @param [mrb_state*] mrb The current mruby state.
@@ -584,4 +594,43 @@
 */
 MRB_API struct RClass * mrb_class_get(mrb_state *mrb, const char *name);
+
+/**
+ * Gets a exception class.
+ * @param [mrb_state*] mrb The current mruby state.
+ * @param [const char *] name The name of the class.
+ * @return [struct RClass *] A reference to the class.
+*/
+MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name);
+
+/**
+ * Returns an mrb_bool. True if inner class was defined, and false if the inner class was not defined.
+ *
+ * Example:
+ *     void
+ *     mrb_example_gem_init(mrb_state* mrb) {
+ *       struct RClass *example_outer, *example_inner;
+ *       mrb_bool cd;
+ *
+ *       example_outer = mrb_define_module(mrb, "ExampleOuter");
+ *
+ *       example_inner = mrb_define_class_under(mrb, example_outer, "ExampleInner", mrb->object_class);
+ *       cd = mrb_class_defined_under(mrb, example_outer, "ExampleInner");
+ *
+ *       // If mrb_class_defined_under returns 1 then puts "True"
+ *       // If mrb_class_defined_under returns 0 then puts "False"
+ *       if (cd == 1){
+ *         puts("True");
+ *       }
+ *       else {
+ *         puts("False");
+ *       }
+ *      }
+ *
+ * @param [mrb_state*] mrb The current mruby state.
+ * @param [struct RClass *] outer The name of the outer class.
+ * @param [const char *] name A string representing the name of the inner class.
+ * @return [mrb_bool] A boolean value.
+ */
+MRB_API mrb_bool mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name);
 
 /**
@@ -616,5 +665,5 @@
  *
  * Equivalent to:
- *   Object#dup    
+ *   Object#dup
  * @param [mrb_state*] mrb The current mruby state.
  * @param [mrb_value] obj Object to be duplicate.
@@ -628,34 +677,34 @@
  * class it returns true, it returns false otherwise.
  *
- * Example:
- *   # Ruby style
- *   class ExampleClass
- *      def example_method
+ *      Example:
+ *      # Ruby style
+ *      class ExampleClass
+ *        def example_method
+ *        end
  *      end
- *   end
- *
- *   ExampleClass.new.respond_to?(:example_method) # => true
- *
- *   // C style
- *   void
- *   mrb_example_gem_init(mrb_state* mrb) {
- *      struct RClass *example_class;
- *      mrb_sym mid;
- *      mrb_bool obj_resp;
- *
- *      example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
- *      mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE());
- *      mid = mrb_intern_str(mrb, mrb_str_new_cstr(mrb, "example_method" ));
- *      obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world)
- *      
- *      // If mrb_obj_respond_to returns 1 then puts "True"
- *      // If mrb_obj_respond_to returns 0 then puts "False"
- *      if (obj_resp == 1) {
- *        puts("True");
+ *
+ *      ExampleClass.new.respond_to?(:example_method) # => true
+ *
+ *      // C style
+ *      void
+ *      mrb_example_gem_init(mrb_state* mrb) {
+ *        struct RClass *example_class;
+ *        mrb_sym mid;
+ *        mrb_bool obj_resp;
+ *
+ *        example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
+ *        mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE());
+ *        mid = mrb_intern_str(mrb, mrb_str_new_lit(mrb, "example_method" ));
+ *        obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world)
+ *
+ *        // If mrb_obj_respond_to returns 1 then puts "True"
+ *        // If mrb_obj_respond_to returns 0 then puts "False"
+ *        if (obj_resp == 1) {
+ *          puts("True");
+ *        }
+ *        else if (obj_resp == 0) {
+ *          puts("False");
+ *        }
  *      }
- *      else if (obj_resp == 0) {
- *        puts("False");
- *      }
- *   }
  *
  * @param [mrb_state*] mrb The current mruby state.
@@ -795,8 +844,76 @@
 /**
  * Call existing ruby functions.
+ *
+ *      #include <stdio.h>
+ *      #include <mruby.h>
+ *      #include "mruby/compile.h"
+ *
+ *      int
+ *      main()
+ *      {
+ *        mrb_int i = 99;
+ *        mrb_state *mrb = mrb_open();
+ *
+ *        if (!mrb) { }
+ *        FILE *fp = fopen("test.rb","r");
+ *        mrb_value obj = mrb_load_file(mrb,fp);
+ *        mrb_funcall(mrb, obj, "method_name", 1, mrb_fixnum_value(i));
+ *        fclose(fp);
+ *        mrb_close(mrb);
+ *       }
+ * @param [mrb_state*] mrb_state* The current mruby state.
+ * @param [mrb_value] mrb_value A reference to an mruby value.
+ * @param [const char*] const char* The name of the method.
+ * @param [mrb_int] mrb_int The number of arguments the method has.
+ * @param [...] ... Variadic values(not type safe!).
+ * @return [mrb_value] mrb_value mruby function value.
  */
 MRB_API mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, mrb_int,...);
+/**
+ * Call existing ruby functions. This is basically the type safe version of mrb_funcall.
+ *
+ *      #include <stdio.h>
+ *      #include <mruby.h>
+ *      #include "mruby/compile.h"
+ *      int
+ *      main()
+ *      {
+ *        mrb_int i = 99;
+ *        mrb_state *mrb = mrb_open();
+ *
+ *        if (!mrb) { }
+ *        mrb_sym m_sym = mrb_intern_lit(mrb, "method_name"); // Symbol for method.
+ *
+ *        FILE *fp = fopen("test.rb","r");
+ *        mrb_value obj = mrb_load_file(mrb,fp);
+ *        mrb_funcall_argv(mrb, obj, m_sym, 1, &obj); // Calling ruby function from test.rb.
+ *        fclose(fp);
+ *        mrb_close(mrb);
+ *       }
+ * @param [mrb_state*] mrb_state* The current mruby state.
+ * @param [mrb_value] mrb_value A reference to an mruby value.
+ * @param [mrb_sym] mrb_sym The symbol representing the method.
+ * @param [mrb_int] mrb_int The number of arguments the method has.
+ * @param [const mrb_value*] mrb_value* Pointer to the object.
+ * @return [mrb_value] mrb_value mruby function value.
+ * @see mrb_funcall
+ */
 MRB_API mrb_value mrb_funcall_argv(mrb_state*, mrb_value, mrb_sym, mrb_int, const mrb_value*);
+/**
+ * Call existing ruby functions with a block.
+ */
 MRB_API mrb_value mrb_funcall_with_block(mrb_state*, mrb_value, mrb_sym, mrb_int, const mrb_value*, mrb_value);
+/**
+ * Create a symbol
+ *
+ *     # Ruby style:
+ *     :pizza # => :pizza
+ *
+ *     // C style:
+ *     mrb_sym m_sym = mrb_intern_lit(mrb, "pizza"); //  => :pizza
+ * @param [mrb_state*] mrb_state* The current mruby state.
+ * @param [const char*] const char* The name of the method.
+ * @return [mrb_sym] mrb_sym A symbol.
+ */
 MRB_API mrb_sym mrb_intern_cstr(mrb_state*,const char*);
 MRB_API mrb_sym mrb_intern(mrb_state*,const char*,size_t);
@@ -892,6 +1009,11 @@
 MRB_API mrb_value mrb_top_self(mrb_state *);
 MRB_API mrb_value mrb_run(mrb_state*, struct RProc*, mrb_value);
-MRB_API mrb_value mrb_toplevel_run(mrb_state*, struct RProc*);
-MRB_API mrb_value mrb_context_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
+MRB_API mrb_value mrb_top_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
+MRB_API mrb_value mrb_vm_run(mrb_state*, struct RProc*, mrb_value, unsigned int);
+MRB_API mrb_value mrb_vm_exec(mrb_state*, struct RProc*, mrb_code*);
+/* compatibility macros */
+#define mrb_toplevel_run_keep(m,p,k) mrb_top_run((m),(p),mrb_top_self(m),(k))
+#define mrb_toplevel_run(m,p) mrb_toplevel_run_keep((m),(p),0)
+#define mrb_context_run(m,p,s,k) mrb_vm_run((m),(p),(s),(k))
 
 MRB_API void mrb_p(mrb_state*, mrb_value);
@@ -965,25 +1087,29 @@
    + exception objects obtained from those macros are local to mrb
 */
-#define E_RUNTIME_ERROR             (mrb_class_get(mrb, "RuntimeError"))
-#define E_TYPE_ERROR                (mrb_class_get(mrb, "TypeError"))
-#define E_ARGUMENT_ERROR            (mrb_class_get(mrb, "ArgumentError"))
-#define E_INDEX_ERROR               (mrb_class_get(mrb, "IndexError"))
-#define E_RANGE_ERROR               (mrb_class_get(mrb, "RangeError"))
-#define E_NAME_ERROR                (mrb_class_get(mrb, "NameError"))
-#define E_NOMETHOD_ERROR            (mrb_class_get(mrb, "NoMethodError"))
-#define E_SCRIPT_ERROR              (mrb_class_get(mrb, "ScriptError"))
-#define E_SYNTAX_ERROR              (mrb_class_get(mrb, "SyntaxError"))
-#define E_LOCALJUMP_ERROR           (mrb_class_get(mrb, "LocalJumpError"))
-#define E_REGEXP_ERROR              (mrb_class_get(mrb, "RegexpError"))
-#define E_SYSSTACK_ERROR            (mrb_class_get(mrb, "SystemStackError"))
-
-#define E_NOTIMP_ERROR              (mrb_class_get(mrb, "NotImplementedError"))
-#define E_FLOATDOMAIN_ERROR         (mrb_class_get(mrb, "FloatDomainError"))
-
-#define E_KEY_ERROR                 (mrb_class_get(mrb, "KeyError"))
+#define E_RUNTIME_ERROR             (mrb_exc_get(mrb, "RuntimeError"))
+#define E_TYPE_ERROR                (mrb_exc_get(mrb, "TypeError"))
+#define E_ARGUMENT_ERROR            (mrb_exc_get(mrb, "ArgumentError"))
+#define E_INDEX_ERROR               (mrb_exc_get(mrb, "IndexError"))
+#define E_RANGE_ERROR               (mrb_exc_get(mrb, "RangeError"))
+#define E_NAME_ERROR                (mrb_exc_get(mrb, "NameError"))
+#define E_NOMETHOD_ERROR            (mrb_exc_get(mrb, "NoMethodError"))
+#define E_SCRIPT_ERROR              (mrb_exc_get(mrb, "ScriptError"))
+#define E_SYNTAX_ERROR              (mrb_exc_get(mrb, "SyntaxError"))
+#define E_LOCALJUMP_ERROR           (mrb_exc_get(mrb, "LocalJumpError"))
+#define E_REGEXP_ERROR              (mrb_exc_get(mrb, "RegexpError"))
+
+#define E_NOTIMP_ERROR              (mrb_exc_get(mrb, "NotImplementedError"))
+#define E_FLOATDOMAIN_ERROR         (mrb_exc_get(mrb, "FloatDomainError"))
+
+#define E_KEY_ERROR                 (mrb_exc_get(mrb, "KeyError"))
 
 MRB_API mrb_value mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg);
 MRB_API mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv);
 MRB_API mrb_value mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c);
+
+/* continue execution to the proc */
+/* this function should always be called as the last function of a method */
+/* e.g. return mrb_yield_cont(mrb, proc, self, argc, argv); */
+mrb_value mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const mrb_value *argv);
 
 /* mrb_gc_protect() leaves the object in the arena */
@@ -1013,4 +1139,5 @@
 MRB_API mrb_bool mrb_respond_to(mrb_state *mrb, mrb_value obj, mrb_sym mid);
 MRB_API mrb_bool mrb_obj_is_instance_of(mrb_state *mrb, mrb_value obj, struct RClass* c);
+MRB_API mrb_bool mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mrb_func_t func);
 
 
@@ -1034,5 +1161,5 @@
  * @mrbgem mruby-fiber
  */
-#define E_FIBER_ERROR (mrb_class_get(mrb, "FiberError"))
+#define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
 
 /* memory pool implementation */
@@ -1050,21 +1177,33 @@
 MRB_API void mrb_show_copyright(mrb_state *mrb);
 
-#ifdef MRB_DEBUG
-#include <assert.h>
-#define mrb_assert(p) assert(p)
-#define mrb_assert_int_fit(t1,n,t2,max) assert((n)>=0 && ((sizeof(n)<=sizeof(t2))||(n<=(t1)(max))))
-#else
-#define mrb_assert(p) ((void)0)
-#define mrb_assert_int_fit(t1,n,t2,max) ((void)0)
-#endif
-
-#if __STDC_VERSION__ >= 201112L
-#define mrb_static_assert(exp, str) _Static_assert(exp, str)
-#else
-#define mrb_static_assert(exp, str) mrb_assert(exp)
-#endif
-
 MRB_API mrb_value mrb_format(mrb_state *mrb, const char *format, ...);
 
+#if 0
+/* memcpy and memset does not work with gdb reverse-next on my box */
+/* use naive memcpy and memset instead */
+#undef memcpy
+#undef memset
+static inline void*
+mrbmemcpy(void *dst, const void *src, size_t n)
+{
+  char *d = dst;
+  const char *s = src;
+  while (n--)
+    *d++ = *s++;
+  return d;
+}
+#define memcpy(a,b,c) mrbmemcpy(a,b,c)
+
+static inline void*
+mrbmemset(void *s, int c, size_t n)
+{
+  char *t = s;
+  while (n--)
+    *t++ = c;
+  return s;
+}
+#define memset(a,b,c) mrbmemset(a,b,c)
+#endif
+
 MRB_END_DECL
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/array.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/array.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/array.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_ARRAY_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /*
@@ -55,12 +55,58 @@
  *
  * @param mrb The mruby state reference.
- * @return The initialized array
+ * @return The initialized array.
  */
 MRB_API mrb_value mrb_ary_new(mrb_state *mrb);
 
+/*
+ * Initializes a new array with initial values
+ *
+ * Equivalent to:
+ *
+ *      Array[value1, value2, ...]
+ *
+ * @param mrb The mruby state reference.
+ * @param size The numer of values.
+ * @param vals The actual values.
+ * @return The initialized array.
+ */
 MRB_API mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals);
+
+/*
+ * Initializes a new array with two initial values
+ *
+ * Equivalent to:
+ *
+ *      Array[car, cdr]
+ *
+ * @param mrb The mruby state reference.
+ * @param car The first value.
+ * @param cdr The second value.
+ * @return The initialized array.
+ */
 MRB_API mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr);
-MRB_API void mrb_ary_concat(mrb_state*, mrb_value, mrb_value);
-MRB_API mrb_value mrb_ary_splat(mrb_state*, mrb_value);
+
+/*
+ * Concatenate two arrays. The target array will be modified
+ *
+ * Equivalent to:
+ *      ary.concat(other)
+ *
+ * @param mrb The mruby state reference.
+ * @param self The target array.
+ * @param other The array that will be concatenated to self.
+ */
+MRB_API void mrb_ary_concat(mrb_state *mrb, mrb_value self, mrb_value other);
+
+/*
+ * Create an array from the input. It tries calling to_a on the
+ * value. If value does not respond to that, it creates a new
+ * array with just this value.
+ *
+ * @param mrb The mruby state reference.
+ * @param value The value to change into an array.
+ * @return An array representation of value.
+ */
+MRB_API mrb_value mrb_ary_splat(mrb_state *mrb, mrb_value value);
 
 /*
@@ -85,6 +131,6 @@
  *
  * @param mrb The mruby state reference.
- * @param ary The array from which the value will be poped.
- * @return The poped value.
+ * @param ary The array from which the value will be popped.
+ * @return The popped value.
  */
 MRB_API mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
@@ -118,12 +164,79 @@
 MRB_API void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val);
 
-MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value a, mrb_value b);
+/*
+ * Replace the array with another array
+ *
+ * Equivalent to:
+ *
+ *      ary.replace(other)
+ *
+ * @param mrb The mruby state reference
+ * @param self The target array.
+ * @param other The array to replace it with.
+ */
+MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other);
 MRB_API mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self);
+
+/*
+ * Unshift an element into an array
+ *
+ * Equivalent to:
+ *
+ *     ary.unshift(item)
+ *
+ * @param mrb The mruby state reference.
+ * @param self The target array.
+ * @param item The item to unshift.
+ */
 MRB_API mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
 MRB_API mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
+
+/*
+ * Shifts the first element from the array.
+ *
+ * Equivalent to:
+ *
+ *      ary.shift
+ *
+ * @param mrb The mruby state reference.
+ * @param self The array from which the value will be shifted.
+ * @return The shifted value.
+ */
 MRB_API mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self);
+
+/*
+ * Removes all elements from this array
+ *
+ * Equivalent to:
+ *
+ *      ary.clear
+ *
+ * @param mrb The mruby state reference.
+ * @param self The target array.
+ * @return self
+ */
 MRB_API mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self);
+
+/*
+ * Join the array elements together in a string
+ *
+ * Equivalent to:
+ *
+ *      ary.join(sep="")
+ *
+ * @param mrb The mruby state reference.
+ * @param ary The target array
+ * @param sep The separater, can be NULL
+ */
 MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
-MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int len);
+
+/*
+ * Update the capacity of the array
+ *
+ * @param mrb The mruby state reference.
+ * @param ary The target array.
+ * @param new_len The new capacity of the array
+ */
+MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len);
 
 static inline mrb_int
@@ -135,4 +248,13 @@
 }
 
+static inline mrb_value
+ary_elt(mrb_value ary, mrb_int offset)
+{
+  if (offset < 0 || RARRAY_LEN(ary) <= offset) {
+    return mrb_nil_value();
+  }
+  return RARRAY_PTR(ary)[offset];
+}
+
 MRB_END_DECL
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_nan.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/boxing_nan.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_nan.h	(revision 331)
@@ -54,5 +54,5 @@
 
 #define mrb_tt(o)       ((enum mrb_vtype)(((o).value.ttt & 0xfc000)>>14)-1)
-#define mrb_type(o)     ((uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT)
+#define mrb_type(o)     (enum mrb_vtype)((uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT)
 #define mrb_ptr(o)      ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)((o).value.p)))<<2))
 #define mrb_float(o)    (o).f
@@ -61,14 +61,18 @@
 #define mrb_symbol(o)   (o).value.sym
 
+#ifdef MRB_64BIT
+#define BOXNAN_SHIFT_LONG_POINTER(v) (((uintptr_t)(v)>>34)&0x3fff)
+#else
+#define BOXNAN_SHIFT_LONG_POINTER(v) 0
+#endif
+
 #define BOXNAN_SET_VALUE(o, tt, attr, v) do {\
-  switch (tt) {\
-  case MRB_TT_FALSE:\
-  case MRB_TT_TRUE:\
-  case MRB_TT_UNDEF:\
-  case MRB_TT_FIXNUM:\
-  case MRB_TT_SYMBOL: (o).attr = (v); break;\
-  default: (o).value.i = 0; (o).value.p = (void*)((uintptr_t)(o).value.p | (((uintptr_t)(v))>>2)); break;\
-  }\
-  (o).value.ttt = (0xfff00000|(((tt)+1)<<14));\
+  (o).attr = (v);\
+  (o).value.ttt = 0xfff00000 | (((tt)+1)<<14);\
+} while (0)
+
+#define BOXNAN_SET_OBJ_VALUE(o, tt, v) do {\
+  (o).value.p = (void*)((uintptr_t)(v)>>2);\
+  (o).value.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\
 } while (0)
 
@@ -77,5 +81,6 @@
     (r).value.ttt = 0x7ff80000; \
     (r).value.i = 0; \
-  } else { \
+  } \
+  else { \
     (r).f = v; \
   }} while(0)
@@ -87,6 +92,6 @@
 #define SET_INT_VALUE(r,n) BOXNAN_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
 #define SET_SYM_VALUE(r,v) BOXNAN_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
-#define SET_OBJ_VALUE(r,v) BOXNAN_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))
-#define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_VALUE(r, MRB_TT_CPTR, value.p, v)
+#define SET_OBJ_VALUE(r,v) BOXNAN_SET_OBJ_VALUE(r, (((struct RObject*)(v))->tt), (v))
+#define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_OBJ_VALUE(r, MRB_TT_CPTR, v)
 #define SET_UNDEF_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_word.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/boxing_word.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/boxing_word.h	(revision 331)
@@ -10,4 +10,8 @@
 #if defined(MRB_INT16)
 # error MRB_INT16 is too small for MRB_WORD_BOXING.
+#endif
+
+#if defined(MRB_INT64) && !defined(MRB_64BIT)
+#error MRB_INT64 cannot be used with MRB_WORD_BOXING in 32-bit mode.
 #endif
 
@@ -63,5 +67,5 @@
 #define mrb_cptr(o)    (o).value.vp->p
 #define mrb_float(o)   (o).value.fp->f
-#define mrb_fixnum(o)  (o).value.i
+#define mrb_fixnum(o)  ((mrb_int)(o).value.i)
 #define mrb_symbol(o)  (o).value.sym
 
@@ -92,11 +96,11 @@
 #define mrb_nil_p(o)  ((o).w == MRB_Qnil)
 
-#define BOXWORD_SET_VALUE(o, ttt, attr, v) do {\
+#define BOXWORD_SET_VALUE(o, ttt, attr, v) do { \
   switch (ttt) {\
   case MRB_TT_FALSE:  (o).w = (v) ? MRB_Qfalse : MRB_Qnil; break;\
   case MRB_TT_TRUE:   (o).w = MRB_Qtrue; break;\
   case MRB_TT_UNDEF:  (o).w = MRB_Qundef; break;\
-  case MRB_TT_FIXNUM: (o).value.i_flag = MRB_FIXNUM_FLAG; (o).attr = (v); break;\
-  case MRB_TT_SYMBOL: (o).value.sym_flag = MRB_SYMBOL_FLAG; (o).attr = (v); break;\
+  case MRB_TT_FIXNUM: (o).w = 0;(o).value.i_flag = MRB_FIXNUM_FLAG; (o).attr = (v); break;\
+  case MRB_TT_SYMBOL: (o).w = 0;(o).value.sym_flag = MRB_SYMBOL_FLAG; (o).attr = (v); break;\
   default:            (o).w = 0; (o).attr = (v); if ((o).value.bp) (o).value.bp->tt = ttt; break;\
   }\
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/class.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/class.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/class.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_CLASS_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -52,5 +52,6 @@
 }
 
-// TODO: figure out where to put user flags
+/* TODO: figure out where to put user flags */
+#define MRB_FLAG_IS_FROZEN (1 << 18)
 #define MRB_FLAG_IS_PREPENDED (1 << 19)
 #define MRB_FLAG_IS_ORIGIN (1 << 20)
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/common.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/common.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/common.h	(revision 331)
@@ -1,4 +1,4 @@
 /*
-** mruby/common.h - mruby common platform definitions
+**"common.h - mruby common platform definition"
 **
 ** See Copyright Notice in mruby.h
@@ -10,6 +10,11 @@
 
 #ifdef __cplusplus
+#ifdef MRB_ENABLE_CXX_ABI
+#define MRB_BEGIN_DECL
+#define MRB_END_DECL
+#else
 # define MRB_BEGIN_DECL extern "C" {
 # define MRB_END_DECL	}
+#endif
 #else
 /** Start declarations in C mode */
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/compile.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/compile.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/compile.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_COMPILE_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -15,5 +15,5 @@
 MRB_BEGIN_DECL
 
-#include "mruby.h"
+#include <mruby.h>
 
 struct mrb_jmpbuf;
@@ -40,6 +40,4 @@
 MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
 MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
-
-MRB_API mrb_value mrb_toplevel_run_keep(mrb_state*, struct RProc*, unsigned int);
 
 /* AST node structure */
@@ -105,5 +103,6 @@
 };
 
-#define MRB_PARSER_BUF_SIZE 1024
+#define MRB_PARSER_TOKBUF_MAX 65536
+#define MRB_PARSER_TOKBUF_SIZE 256
 
 /* parser structure */
@@ -133,6 +132,8 @@
 
   mrb_ast_node *pb;
-  char buf[MRB_PARSER_BUF_SIZE];
-  int bidx;
+  char *tokbuf;
+  char buf[MRB_PARSER_TOKBUF_SIZE];
+  int tidx;
+  int tsiz;
 
   mrb_ast_node *all_heredocs;	/* list of mrb_parser_heredoc_info* */
@@ -163,4 +164,5 @@
 MRB_API void mrb_parser_free(struct mrb_parser_state*);
 MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
+MRB_API double mrb_float_read(const char*, char**);
 
 MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
@@ -174,4 +176,5 @@
 MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,int,mrbc_context*);
 MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
+MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
 
 /* program load functions */
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/data.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/data.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/data.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_DATA_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/debug.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/debug.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/debug.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_DEBUG_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/dump.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/dump.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/dump.h	(revision 331)
@@ -8,7 +8,7 @@
 #define MRUBY_DUMP_H
 
-#include "mruby.h"
-#include "mruby/irep.h"
-#include "mruby/common.h"
+#include <mruby.h>
+#include <mruby/irep.h>
+#include "common.h"
 
 /**
@@ -53,5 +53,5 @@
 #define RITE_BINARY_IDENT              "RITE"
 #define RITE_BINARY_IDENT_LIL          "ETIR"
-#define RITE_BINARY_FORMAT_VER         "0003"
+#define RITE_BINARY_FORMAT_VER         "0004"
 #define RITE_COMPILER_NAME             "MATZ"
 #define RITE_COMPILER_VERSION          "0000"
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/error.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/error.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/error.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_ERROR_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -32,4 +32,11 @@
 /* declaration for fail method */
 MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
+
+struct RBreak {
+  MRB_OBJECT_HEADER;
+  struct iv_tbl *iv;
+  struct RProc *proc;
+  mrb_value val;
+};
 
 /**
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/gc.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/gc.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/gc.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_GC_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -18,5 +18,7 @@
 struct mrb_state;
 
-typedef void (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
+#define MRB_EACH_OBJ_OK 0
+#define MRB_EACH_OBJ_BREAK 1
+typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
 void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
 MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
@@ -63,4 +65,5 @@
   int interval_ratio;
   int step_ratio;
+  mrb_bool iterating     :1;
   mrb_bool disabled      :1;
   mrb_bool full          :1;
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/hash.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/hash.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/hash.h	(revision 331)
@@ -8,5 +8,6 @@
 #define MRUBY_HASH_H
 
-#include "mruby/common.h"
+#include "common.h"
+#include <mruby/khash.h>
 
 /**
@@ -24,8 +25,15 @@
 #define mrb_hash_value(p)  mrb_obj_value((void*)(p))
 
-MRB_API mrb_value mrb_hash_new_capa(mrb_state*, int);
+MRB_API mrb_value mrb_hash_new_capa(mrb_state*, mrb_int);
 
 /*
  * Initializes a new hash.
+ *
+ * Equivalent to:
+ *
+ *      Hash.new
+ *
+ * @param mrb The mruby state reference.
+ * @return The initialized hash.
  */
 MRB_API mrb_value mrb_hash_new(mrb_state *mrb);
@@ -33,16 +41,59 @@
 /*
  * Sets a keys and values to hashes.
+ *
+ * Equivalent to:
+ *
+ *      hash[key] = val
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @param key The key to set.
+ * @param val The value to set.
+ * @return The value.
  */
 MRB_API void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val);
 
 /*
- * Gets a value from a key.
+ * Gets a value from a key. If the key is not found, the default of the
+ * hash is used.
+ *
+ * Equivalent to:
+ *
+ *     hash[key]
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @param key The key to get.
+ * @return The found value.
  */
 MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
 
+/*
+ * Gets a value from a key. If the key is not found, the default parameter is
+ * used.
+ *
+ * Equivalent to:
+ *
+ *     hash.hash_key?(key) ? hash[key] : def
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @param key The key to get.
+ * @param def The default value.
+ * @return The found value.
+ */
 MRB_API mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def);
 
 /*
  * Deletes hash key and value pair.
+ *
+ * Equivalent to:
+ *
+ *     hash.delete(key)
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @param key The key to delete.
+ * @return The deleted value.
  */
 MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
@@ -50,13 +101,63 @@
 /*
  * Gets an array of keys.
+ *
+ * Equivalent to:
+ *
+ *     hash.keys
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @return An array with the keys of the hash.
  */
 MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
 MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
+
+/*
+ * Check if the hash is empty
+ *
+ * Equivalent to:
+ *
+ *     hash.empty?
+ *
+ * @param mrb The mruby state reference.
+ * @param self The target hash.
+ * @return True if the hash is empty, false otherwise.
+ */
 MRB_API mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
 
 /*
+ * Gets an array of values.
+ *
+ * Equivalent to:
+ *
+ *     hash.values
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @return An array with the values of the hash.
+ */
+MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash);
+
+/*
  * Clears the hash.
+ *
+ * Equivalent to:
+ *
+ *     hash.clear
+ *
+ * @param mrb The mruby state reference.
+ * @param hash The target hash.
+ * @return The hash
  */
 MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
+
+/* declaration of struct kh_ht */
+/* be careful when you touch the internal */
+typedef struct {
+  mrb_value v;
+  mrb_int n;
+} mrb_hash_value;
+
+KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
 
 /* RHASH_TBL allocates st_table if not available. */
@@ -67,5 +168,7 @@
 MRB_API struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash);
 
-#define MRB_HASH_PROC_DEFAULT 256
+#define MRB_HASH_DEFAULT      1
+#define MRB_HASH_PROC_DEFAULT 2
+#define MRB_RHASH_DEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_DEFAULT)
 #define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/irep.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/irep.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/irep.h	(revision 331)
@@ -8,6 +8,6 @@
 #define MRUBY_IREP_H
 
-#include "mruby/common.h"
-#include "mruby/compile.h"
+#include "common.h"
+#include <mruby/compile.h>
 
 /**
@@ -40,4 +40,5 @@
   struct mrb_locals *lv;
   /* debug info */
+  mrb_bool own_filename;
   const char *filename;
   uint16_t *lines;
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/istruct.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/istruct.h	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/istruct.h	(revision 331)
@@ -0,0 +1,47 @@
+/*
+** mruby/istruct.h - Inline structures
+**
+** See Copyright Notice in mruby.h
+*/
+
+#ifndef MRUBY_ISTRUCT_H
+#define MRUBY_ISTRUCT_H
+
+#include "common.h"
+#include <string.h>
+
+/**
+ * Inline structures that fit in RVALUE
+ *
+ * They cannot have finalizer, and cannot have instance variables.
+ */
+MRB_BEGIN_DECL
+
+#define ISTRUCT_DATA_SIZE (sizeof(void*) * 3)
+
+struct RIstruct {
+  MRB_OBJECT_HEADER;
+  char inline_data[ISTRUCT_DATA_SIZE];
+};
+
+#define RISTRUCT(obj)         ((struct RIstruct*)(mrb_ptr(obj)))
+#define ISTRUCT_PTR(obj)      (RISTRUCT(obj)->inline_data)
+
+MRB_INLINE mrb_int mrb_istruct_size()
+{
+  return ISTRUCT_DATA_SIZE;
+}
+
+MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
+{
+  return ISTRUCT_PTR(object);
+}
+
+MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
+{
+  memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
+}
+
+MRB_END_DECL
+
+#endif /* MRUBY_ISTRUCT_H */
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/khash.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/khash.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/khash.h	(revision 331)
@@ -10,6 +10,6 @@
 #include <string.h>
 
-#include "mruby.h"
-#include "mruby/common.h"
+#include <mruby.h>
+#include "common.h"
 
 /**
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/numeric.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/numeric.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/numeric.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_NUMERIC_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -21,4 +21,10 @@
 #define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
 
+#ifdef MRB_INT64
+#define FIXABLE_FLOAT(f) FIXABLE((mrb_int)(f))
+#else
+#define FIXABLE_FLOAT(f) FIXABLE(f)
+#endif
+
 MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
 MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, int base);
@@ -32,4 +38,57 @@
 mrb_value mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y);
 
+#ifndef __has_builtin
+  #define __has_builtin(x) 0
+#endif
+
+#if (defined(__GNUC__) && __GNUC__ >= 5) ||   \
+    (__has_builtin(__builtin_add_overflow) && \
+     __has_builtin(__builtin_sub_overflow) && \
+     __has_builtin(__builtin_mul_overflow))
+# define MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
+#endif
+
+/*
+// Clang 3.8 and 3.9 have problem compiling mruby in 32-bit mode, when MRB_INT64 is set
+// because of missing __mulodi4 and similar functions in its runtime. We need to use custom
+// implementation for them.
+*/
+#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
+#if defined(__clang__) && (__clang_major__ == 3) && (__clang_minor__ >= 8) && \
+    defined(MRB_32BIT) && defined(MRB_INT64)
+#undef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
+#endif
+#endif
+
+#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
+
+#ifndef MRB_WORD_BOXING
+# define WBCHK(x) 0
+#else
+# define WBCHK(x) !FIXABLE(x)
+#endif
+
+static inline mrb_bool
+mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
+{
+  return __builtin_add_overflow(augend, addend, sum) || WBCHK(*sum);
+}
+
+static inline mrb_bool
+mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
+{
+  return __builtin_sub_overflow(minuend, subtrahend, difference) || WBCHK(*difference);
+}
+
+static inline mrb_bool
+mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
+{
+  return __builtin_mul_overflow(multiplier, multiplicand, product) || WBCHK(*product);
+}
+
+#undef WBCHK
+
+#else
+
 #define MRB_UINT_MAKE2(n) uint ## n ## _t
 #define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
@@ -37,45 +96,4 @@
 
 #define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1 - MRB_FIXNUM_SHIFT))
-
-/* Idea from Potion: https://github.com/perl11/potion (MIT) */
-#if (defined(__clang__) && ((__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ >= 4))) \
-    || (defined(__GNUC__) && __GNUC__ >= 5)
-
-static inline mrb_bool
-mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
-{
-  mrb_bool of;
-
-#ifdef MRB_INT64
-  long long val;
-  of = __builtin_saddll_overflow(augend, addend, &val) ||
-#else
-  int val;
-  of = __builtin_sadd_overflow(augend, addend, &val) ||
-#endif
-  (val > MRB_INT_MAX) || (val < MRB_INT_MIN);
-
-  *sum = (mrb_int) val;
-  return of;
-}
-
-static inline mrb_bool
-mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
-{
-  mrb_bool of;
-
-#ifdef MRB_INT64
-  long long val;
-  of = __builtin_ssubll_overflow(minuend, subtrahend, &val) ||
-#else
-  int val;
-  of = __builtin_ssub_overflow(minuend, subtrahend, &val) ||
-#endif
-  (val > MRB_INT_MAX) || (val < MRB_INT_MIN);
-
-  *difference = (mrb_int) val;
-  return of;
-}
-#else
 
 static inline mrb_bool
@@ -99,5 +117,32 @@
 }
 
+static inline mrb_bool
+mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
+{
+#if MRB_INT_BIT == 32
+  int64_t n = (int64_t)multiplier * multiplicand;
+  *product = (mrb_int)n;
+  return !FIXABLE(n);
+#else
+  if (multiplier > 0) {
+    if (multiplicand > 0) {
+      if (multiplier > MRB_INT_MAX / multiplicand) return TRUE;
+    }
+    else {
+      if (multiplicand < MRB_INT_MAX / multiplier) return TRUE;
+    }
+  }
+  else {
+    if (multiplicand > 0) {
+      if (multiplier < MRB_INT_MAX / multiplicand) return TRUE;
+    }
+    else {
+      if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE;
+    }
+  }
+  *product = multiplier * multiplicand;
+  return FALSE;
 #endif
+}
 
 #undef MRB_INT_OVERFLOW_MASK
@@ -106,4 +151,6 @@
 #undef MRB_UINT_MAKE2
 
+#endif
+
 MRB_END_DECL
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/object.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/object.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/object.h	(revision 331)
@@ -23,4 +23,8 @@
 #define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
 
+#define MRB_FROZEN_P(o) ((o)->flags & MRB_FLAG_IS_FROZEN)
+#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FLAG_IS_FROZEN)
+#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FLAG_IS_FROZEN)
+
 struct RObject {
   MRB_OBJECT_HEADER;
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/opcode.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/opcode.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/opcode.h	(revision 331)
@@ -83,5 +83,6 @@
   OP_JMPNOT,/*    A sBx   if !R(A) pc+=sBx                                */
   OP_ONERR,/*     sBx     rescue_push(pc+sBx)                             */
-  OP_RESCUE,/*    A       clear(exc); R(A) := exception (ignore when A=0) */
+  OP_RESCUE,/*    A B C   if A (if C exc=R(A) else R(A) := exc);
+                          if B R(B) := exc.isa?(R(B)); clear(exc)         */
   OP_POPERR,/*    A       A.times{rescue_pop()}                           */
   OP_RAISE,/*     A       raise(R(A))                                     */
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/proc.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/proc.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/proc.h	(revision 331)
@@ -8,6 +8,6 @@
 #define MRUBY_PROC_H
 
-#include "mruby/common.h"
-#include "mruby/irep.h"
+#include "common.h"
+#include <mruby/irep.h>
 
 /**
@@ -19,6 +19,9 @@
   MRB_OBJECT_HEADER;
   mrb_value *stack;
-  mrb_sym mid;
   ptrdiff_t cioff;
+  union {
+    mrb_sym mid;
+    struct mrb_context *c;
+  } cxt;
 };
 
@@ -27,4 +30,6 @@
 #define MRB_ENV_UNSHARE_STACK(e) ((e)->cioff = -1)
 #define MRB_ENV_STACK_SHARED_P(e) ((e)->cioff >= 0)
+
+MRB_API void mrb_env_unshare(mrb_state*, struct REnv*);
 
 struct RProc {
@@ -51,4 +56,6 @@
 #define MRB_PROC_STRICT 256
 #define MRB_PROC_STRICT_P(p) (((p)->flags & MRB_PROC_STRICT) != 0)
+#define MRB_PROC_ORPHAN 512
+#define MRB_PROC_ORPHAN_P(p) (((p)->flags & MRB_PROC_ORPHAN) != 0)
 
 #define mrb_proc_ptr(v)    ((struct RProc*)(mrb_ptr(v)))
@@ -69,5 +76,5 @@
 #define mrb_cfunc_env_get(mrb, idx) mrb_proc_cfunc_env_get(mrb, idx)
 
-#include "mruby/khash.h"
+#include <mruby/khash.h>
 KHASH_DECLARE(mt, mrb_sym, struct RProc*, TRUE)
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/range.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/range.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/range.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_RANGE_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -26,5 +26,6 @@
 };
 
-#define mrb_range_ptr(v)    ((struct RRange*)(mrb_ptr(v)))
+MRB_API struct RRange* mrb_range_ptr(mrb_state *mrb, mrb_value v);
+#define mrb_range_raw_ptr(v) ((struct RRange*)mrb_ptr(v))
 #define mrb_range_value(p)  mrb_obj_value((void*)(p))
 
@@ -41,5 +42,5 @@
 MRB_API mrb_value mrb_range_new(mrb_state *mrb, mrb_value start, mrb_value end, mrb_bool exclude);
 
-MRB_API mrb_bool mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len);
+MRB_API mrb_int mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc);
 mrb_value mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, const mrb_value *argv, mrb_value (*func)(mrb_state*, mrb_value, mrb_int));
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/re.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/re.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/re.h	(revision 331)
@@ -8,13 +8,9 @@
 #define MRUBY_RE_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+MRB_BEGIN_DECL
 
 #define REGEXP_CLASS          "Regexp"
 
-#ifdef __cplusplus
-}
-#endif
+MRB_END_DECL
 
 #endif  /* RE_H */
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/string.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/string.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/string.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_STRING_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -45,5 +45,6 @@
   if (RSTR_EMBED_P(s)) {\
     RSTR_SET_EMBED_LEN((s),(n));\
-  } else {\
+  }\
+  else {\
     s->as.heap.len = (mrb_int)(n);\
   }\
@@ -63,8 +64,4 @@
 #define RSTR_UNSET_NOFREE_FLAG(s) ((s)->flags &= ~MRB_STR_NOFREE)
 
-#define RSTR_FROZEN_P(s) ((s)->flags & MRB_STR_FROZEN)
-#define RSTR_SET_FROZEN_FLAG(s) ((s)->flags |= MRB_STR_FROZEN)
-#define RSTR_UNSET_FROZEN_FLAG(s) ((s)->flags &= ~MRB_STR_FROZEN)
-
 /*
  * Returns a pointer from a Ruby string
@@ -73,23 +70,117 @@
 #define RSTRING(s)           mrb_str_ptr(s)
 #define RSTRING_PTR(s)       RSTR_PTR(RSTRING(s))
-#define RSTRING_EMBED_LEN(s) RSTR_ENBED_LEN(RSTRING(s))
+#define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s))
 #define RSTRING_LEN(s)       RSTR_LEN(RSTRING(s))
 #define RSTRING_CAPA(s)      RSTR_CAPA(RSTRING(s))
 #define RSTRING_END(s)       (RSTRING_PTR(s) + RSTRING_LEN(s))
-mrb_int mrb_str_strlen(mrb_state*, struct RString*);
+MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
 
 #define MRB_STR_SHARED    1
 #define MRB_STR_NOFREE    2
-#define MRB_STR_FROZEN    4
-#define MRB_STR_EMBED     8
-#define MRB_STR_EMBED_LEN_MASK 0x1f0
-#define MRB_STR_EMBED_LEN_SHIFT 4
+#define MRB_STR_NO_UTF    8
+#define MRB_STR_EMBED    16
+#define MRB_STR_EMBED_LEN_MASK 0x3e0
+#define MRB_STR_EMBED_LEN_SHIFT 5
 
 void mrb_gc_free_str(mrb_state*, struct RString*);
 MRB_API void mrb_str_modify(mrb_state*, struct RString*);
+/*
+ * Appends self to other. Returns self as a concatnated string.
+ *
+ *
+ *  Example:
+ *
+ *     !!!c
+ *     int
+ *     main(int argc,
+ *          char **argv)
+ *     {
+ *       // Variable declarations.
+ *       mrb_value str1;
+ *       mrb_value str2;
+ *
+ *       mrb_state *mrb = mrb_open();
+ *       if (!mrb)
+ *       {
+ *          // handle error
+ *       }
+ *
+ *       // Creates new Ruby strings.
+ *       str1 = mrb_str_new_lit(mrb, "abc");
+ *       str2 = mrb_str_new_lit(mrb, "def");
+ *
+ *       // Concatnates str2 to str1.
+ *       mrb_str_concat(mrb, str1, str2);
+ *
+ *      // Prints new Concatnated Ruby string.
+ *      mrb_p(mrb, str1);
+ *
+ *      mrb_close(mrb);
+ *      return 0;
+ *    }
+ *
+ *
+ *  Result:
+ *
+ *     => "abcdef"
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] self String to concatenate.
+ * @param [mrb_value] other String to append to self.
+ * @return [mrb_value] Returns a new String appending other to self.
+ */
 MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
 
 /*
  * Adds two strings together.
+ *
+ *
+ *  Example:
+ *
+ *     !!!c
+ *     int
+ *     main(int argc,
+ *          char **argv)
+ *     {
+ *       // Variable declarations.
+ *       mrb_value a;
+ *       mrb_value b;
+ *       mrb_value c;
+ *
+ *       mrb_state *mrb = mrb_open();
+ *       if (!mrb)
+ *       {
+ *          // handle error
+ *       }
+ *
+ *       // Creates two Ruby strings from the passed in C strings.
+ *       a = mrb_str_new_lit(mrb, "abc");
+ *       b = mrb_str_new_lit(mrb, "def");
+ *
+ *       // Prints both C strings.
+ *       mrb_p(mrb, a);
+ *       mrb_p(mrb, b);
+ *
+ *       // Concatnates both Ruby strings.
+ *       c = mrb_str_plus(mrb, a, b);
+ *
+ *      // Prints new Concatnated Ruby string.
+ *      mrb_p(mrb, c);
+ *
+ *      mrb_close(mrb);
+ *      return 0;
+ *    }
+ *
+ *
+ *  Result:
+ *
+ *     => "abc"  # First string
+ *     => "def"  # Second string
+ *     => "abcdef" # First & Second concatnated.
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] a First string to concatenate.
+ * @param [mrb_value] b Second string to concatenate.
+ * @return [mrb_value] Returns a new String containing a concatenated to b.
  */
 MRB_API mrb_value mrb_str_plus(mrb_state*, mrb_value, mrb_value);
@@ -97,4 +188,8 @@
 /*
  * Converts pointer into a Ruby string.
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [void*] p The pointer to convert to Ruby string.
+ * @return [mrb_value] Returns a new Ruby String.
  */
 MRB_API mrb_value mrb_ptr_to_str(mrb_state *, void*);
@@ -102,9 +197,48 @@
 /*
  * Returns an object as a Ruby string.
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] obj An object to return as a Ruby string.
+ * @return [mrb_value] An object as a Ruby string.
  */
 MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
 
 /*
- * Resizes the string's length.
+ * Resizes the string's length. Returns the amount of characters
+ * in the specified by len.
+ *
+ * Example:
+ *
+ *     !!!c
+ *     int
+ *     main(int argc,
+ *          char **argv)
+ *     {
+ *         // Variable declaration.
+ *         mrb_value str;
+ *
+ *         mrb_state *mrb = mrb_open();
+ *         if (!mrb)
+ *         {
+ *            // handle error
+ *         }
+ *         // Creates a new string.
+ *         str = mrb_str_new_lit(mrb, "Hello, world!");
+ *         // Returns 5 characters of
+ *         mrb_str_resize(mrb, str, 5);
+ *         mrb_p(mrb, str);
+ *
+ *         mrb_close(mrb);
+ *         return 0;
+ *      }
+ *
+ * Result:
+ *
+ *     => "Hello"
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str The Ruby string to resize.
+ * @param [mrb_value] len The length.
+ * @return [mrb_value] An object as a Ruby string.
  */
 MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
@@ -112,4 +246,42 @@
 /*
  * Returns a sub string.
+ *
+ *  Example:
+ *
+ *     !!!c
+ *     int
+ *     main(int argc,
+ *     char const **argv)
+ *     {
+ *       // Variable declarations.
+ *       mrb_value str1;
+ *       mrb_value str2;
+ *
+ *       mrb_state *mrb = mrb_open();
+ *       if (!mrb)
+ *       {
+ *         // handle error
+ *       }
+ *       // Creates new string.
+ *       str1 = mrb_str_new_lit(mrb, "Hello, world!");
+ *       // Returns a sub-string within the range of 0..2
+ *       str2 = mrb_str_substr(mrb, str1, 0, 2);
+ *
+ *       // Prints sub-string.
+ *       mrb_p(mrb, str2);
+ *
+ *       mrb_close(mrb);
+ *       return 0;
+ *     }
+ *
+ *  Result:
+ *
+ *     => "He"
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string.
+ * @param [mrb_int] beg The beginning point of the sub-string.
+ * @param [mrb_int] len The end point of the sub-string.
+ * @return [mrb_value] An object as a Ruby sub-string.
  */
 MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
@@ -117,4 +289,9 @@
 /*
  * Returns a Ruby string type.
+ *
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string.
+ * @return [mrb_value] A Ruby string.
  */
 MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
@@ -124,13 +301,31 @@
 
 MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr);
-MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr);
+MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
+/*
+ * Returns the length of the Ruby string.
+ *
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string.
+ * @return [mrb_int] The length of the passed in Ruby string.
+ */
+MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
 
 /*
  * Duplicates a string object.
+ *
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string.
+ * @return [mrb_value] Duplicated Ruby string.
  */
 MRB_API mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str);
 
 /*
- * Returns a symbol from a passed in string.
+ * Returns a symbol from a passed in Ruby string.
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] self Ruby string.
+ * @return [mrb_value] A symbol.
  */
 MRB_API mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
@@ -146,4 +341,9 @@
 /*
  * Returns true if the strings match and false if the strings don't match.
+ *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str1 Ruby string to compare.
+ * @param [mrb_value] str2 Ruby string to compare.
+ * @return [mrb_value] boolean value.
  */
 MRB_API mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2);
@@ -152,4 +352,9 @@
  * Returns a concated string comprised of a Ruby string and a C string.
  *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string.
+ * @param [const char *] ptr A C string.
+ * @param [size_t] len length of C string.
+ * @return [mrb_value] A Ruby string.
  * @see mrb_str_cat_cstr
  */
@@ -159,4 +364,8 @@
  * Returns a concated string comprised of a Ruby string and a C string.
  *
+ * @param [mrb_state] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string.
+ * @param [const char *] ptr A C string.
+ * @return [mrb_value] A Ruby string.
  * @see mrb_str_cat
  */
@@ -176,5 +385,17 @@
 
 /*
- * Returns a C string from a Ruby string.
+ * Returns a newly allocated C string from a Ruby string.
+ * This is an utility function to pass a Ruby string to C library functions.
+ *
+ * - Returned string does not contain any NUL characters (but terminator).
+ * - It raises an ArgumentError exception if Ruby string contains
+ *   NUL characters.
+ * - Retured string will be freed automatically on next GC.
+ * - Caller can modify returned string without affecting Ruby string
+ *   (e.g. it can be used for mkstemp(3)).
+ *
+ * @param [mrb_state *] mrb The current mruby state.
+ * @param [mrb_value] str Ruby string. Must be an instance of String.
+ * @return [char *] A newly allocated C string.
  */
 MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/throw.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/throw.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/throw.h	(revision 331)
@@ -8,5 +8,11 @@
 #define MRB_THROW_H
 
-#ifdef MRB_ENABLE_CXX_EXCEPTION
+#if defined(MRB_ENABLE_CXX_ABI)
+# if !defined(__cplusplus)
+#  error Trying to use C++ exception handling in C code
+# endif
+#endif
+
+#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
 
 #define MRB_TRY(buf) do { try {
@@ -21,9 +27,17 @@
 #include <setjmp.h>
 
-#define MRB_TRY(buf) do { if (setjmp((buf)->impl) == 0) {
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#define MRB_SETJMP _setjmp
+#define MRB_LONGJMP _longjmp
+#else
+#define MRB_SETJMP setjmp
+#define MRB_LONGJMP longjmp
+#endif
+
+#define MRB_TRY(buf) do { if (MRB_SETJMP((buf)->impl) == 0) {
 #define MRB_CATCH(buf) } else {
 #define MRB_END_EXC(buf) } } while(0)
 
-#define MRB_THROW(buf) longjmp((buf)->impl, 1);
+#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
 #define mrb_jmpbuf_impl jmp_buf
 
@@ -33,5 +47,5 @@
   mrb_jmpbuf_impl impl;
 
-#ifdef MRB_ENABLE_CXX_EXCEPTION
+#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
   static mrb_int jmpbuf_id;
   mrb_jmpbuf() : impl(jmpbuf_id++) {}
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/value.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/value.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/value.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_VALUE_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -21,4 +21,18 @@
 #if defined(MRB_INT16) && defined(MRB_INT64)
 # error "You can't define MRB_INT16 and MRB_INT64 at the same time."
+#endif
+
+#if defined _MSC_VER && _MSC_VER < 1800
+# define PRIo64 "llo"
+# define PRId64 "lld"
+# define PRIx64 "llx"
+# define PRIo16 "ho"
+# define PRId16 "hd"
+# define PRIx16 "hx"
+# define PRIo32 "o"
+# define PRId32 "d"
+# define PRIx32 "x"
+#else
+# include <inttypes.h>
 #endif
 
@@ -28,4 +42,7 @@
 # define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
 # define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
+# define MRB_PRIo PRIo64
+# define MRB_PRId PRId64
+# define MRB_PRIx PRIx64
 #elif defined(MRB_INT16)
   typedef int16_t mrb_int;
@@ -33,4 +50,7 @@
 # define MRB_INT_MIN (INT16_MIN>>MRB_FIXNUM_SHIFT)
 # define MRB_INT_MAX (INT16_MAX>>MRB_FIXNUM_SHIFT)
+# define MRB_PRIo PRIo16
+# define MRB_PRId PRId16
+# define MRB_PRIx PRIx16
 #else
   typedef int32_t mrb_int;
@@ -38,12 +58,15 @@
 # define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
 # define MRB_INT_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
-#endif
-
+# define MRB_PRIo PRIo32
+# define MRB_PRId PRId32
+# define MRB_PRIx PRIx32
+#endif
+
+
+MRB_API double mrb_float_read(const char*, char**);
 #ifdef MRB_USE_FLOAT
   typedef float mrb_float;
-# define str_to_mrb_float(buf) strtof(buf, NULL)
 #else
   typedef double mrb_float;
-# define str_to_mrb_float(buf) strtod(buf, NULL)
 #endif
 
@@ -63,5 +86,4 @@
 #  define isinf(n) (!_finite(n) && !_isnan(n))
 #  define signbit(n) (_copysign(1.0, (n)) < 0.0)
-#  define strtof (float)strtod
 static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
 #  define INFINITY (*(float *)&IEEE754_INFINITY_BITS_SINGLE)
@@ -94,8 +116,10 @@
   MRB_TT_DATA,        /*  21 */
   MRB_TT_FIBER,       /*  22 */
-  MRB_TT_MAXDEFINE    /*  23 */
+  MRB_TT_ISTRUCT,     /*  23 */
+  MRB_TT_BREAK,       /*  24 */
+  MRB_TT_MAXDEFINE    /*  25 */
 };
 
-#include "mruby/object.h"
+#include <mruby/object.h>
 
 #ifdef MRB_DOCUMENTATION_BLOCK
@@ -188,4 +212,6 @@
   mrb_value v;
   SET_OBJ_VALUE(v, (struct RBasic*)p);
+  mrb_assert(p == mrb_ptr(v));
+  mrb_assert(((struct RBasic*)p)->tt == mrb_type(v));
   return v;
 }
@@ -242,4 +268,12 @@
 
 #ifdef MRB_USE_ETEXT_EDATA
+#if (defined(__APPLE__) && defined(__MACH__))
+#include <mach-o/getsect.h>
+static inline mrb_bool
+mrb_ro_data_p(const char *p)
+{
+  return (const char*)get_etext() < p && p < (const char*)get_edata();
+}
+#else
 extern char _etext[];
 #ifdef MRB_NO_INIT_ARRAY_START
@@ -260,4 +294,5 @@
 }
 #endif
+#endif
 #else
 # define mrb_ro_data_p(p) FALSE
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/variable.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/variable.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/variable.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_VARIABLE_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -55,7 +55,65 @@
 MRB_API void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src);
 MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id);
+
+/**
+ * Get a global variable. Will return nil if the var does not exist
+ *
+ * Example:
+ *
+ *     !!!ruby
+ *     # Ruby style
+ *     var = $value
+ *
+ *     !!!c
+ *     // C style
+ *     mrb_sym sym = mrb_intern_lit(mrb, "$value");
+ *     mrb_value var = mrb_gv_get(mrb, sym);
+ *
+ * @param mrb The mruby state reference
+ * @param sym The name of the global variable
+ * @return The value of that global variable. May be nil
+ */
 MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
+
+/**
+ * Set a global variable
+ *
+ * Example:
+ *
+ *     !!!ruby
+ *     # Ruby style
+ *     $value = "foo"
+ *
+ *     !!!c
+ *     // C style
+ *     mrb_sym sym = mrb_intern_lit(mrb, "$value");
+ *     mrb_gv_set(mrb, sym, mrb_str_new_lit("foo"));
+ *
+ * @param mrb The mruby state reference
+ * @param sym The name of the global variable
+ * @param val The value of the global variable
+ */
 MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
+
+/**
+ * Remove a global variable.
+ *
+ * Example:
+ *
+ *     !!!ruby
+ *     # Ruby style
+ *     $value = nil
+ *
+ *     !!!c
+ *     // C style
+ *     mrb_sym sym = mrb_intern_lit(mrb, "$value");
+ *     mrb_gv_remove(mrb, sym);
+ *
+ * @param mrb The mruby state reference
+ * @param sym The name of the global variable
+ * @param val The value of the global variable
+ */
 MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym);
+
 MRB_API mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym);
 MRB_API void mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v);
Index: EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/version.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/include/mruby/version.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/include/mruby/version.h	(revision 331)
@@ -8,5 +8,5 @@
 #define MRUBY_VERSION_H
 
-#include "mruby/common.h"
+#include "common.h"
 
 /**
@@ -43,5 +43,5 @@
  * Minor release version number.
  */
-#define MRUBY_RELEASE_MINOR 2
+#define MRUBY_RELEASE_MINOR 3
 
 /*
@@ -63,15 +63,15 @@
  * Release year.
  */
-#define MRUBY_RELEASE_YEAR 2015
+#define MRUBY_RELEASE_YEAR 2017
 
 /*
  * Release month.
  */
-#define MRUBY_RELEASE_MONTH 11
+#define MRUBY_RELEASE_MONTH 7
 
 /*
  * Release day.
  */
-#define MRUBY_RELEASE_DAY 17
+#define MRUBY_RELEASE_DAY 4
 
 /*
Index: EcnlProtoTool/trunk/mruby-1.3.0/minirake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/minirake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/minirake	(revision 331)
@@ -114,6 +114,5 @@
     # their time stamp.  Other tasks can be more sophisticated.
     def timestamp
-      prerequisites = @prerequisites.collect{ |n| n.is_a?(Proc) ? n.call(name) : n }.flatten
-      prerequisites.collect { |n| Task[n].timestamp }.max || Time.now
+      Time.now
     end
 
@@ -241,4 +240,5 @@
     # Time stamp for file task.
     def timestamp
+      return Time.at(0) unless File.exist?(name)
       stat = File::stat(name.to_s)
       stat.directory? ? Time.at(0) : stat.mtime
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/default.gembox
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/default.gembox	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/default.gembox	(revision 331)
@@ -54,5 +54,5 @@
   conf.gem :core => "mruby-enumerator"
 
-  # Use Enumerable::Lazy class (require mruby-enumerator)
+  # Use Enumerator::Lazy class (require mruby-enumerator)
   conf.gem :core => "mruby-enum-lazy"
 
@@ -72,4 +72,7 @@
   conf.gem :core => "mruby-kernel-ext"
 
+  # Use class/module extension
+  conf.gem :core => "mruby-class-ext"
+
   # Use mruby-compiler to build other mrbgems
   conf.gem :core => "mruby-compiler"
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-array-ext/mrblib/array.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-array-ext/mrblib/array.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-array-ext/mrblib/array.rb	(revision 331)
@@ -1,3 +1,28 @@
 class Array
+  ##
+  # call-seq:
+  #    Array.try_convert(obj) -> array or nil
+  #
+  # Tries to convert +obj+ into an array, using +to_ary+ method.
+  # converted array or +nil+ if +obj+ cannot be converted for any reason.
+  # This method can be used to check if an argument is an array.
+  #
+  #    Array.try_convert([1])   #=> [1]
+  #    Array.try_convert("1")   #=> nil
+  #
+  #    if tmp = Array.try_convert(arg)
+  #      # the argument is an array
+  #    elsif tmp = String.try_convert(arg)
+  #      # the argument is a string
+  #    end
+  #
+  def self.try_convert(obj)
+    if obj.respond_to?(:to_ary)
+      obj.to_ary
+    else
+      nil
+    end
+  end
+
   ##
   # call-seq:
@@ -251,6 +276,7 @@
   #
   #  Alternatively, if a block is given it will only be executed when an
-  #  invalid +index+ is referenced.  Negative values of +index+ count from the
-  #  end of the array.
+  #  invalid +index+ is referenced.
+  #
+  #  Negative values of +index+ count from the end of the array.
   #
   #     a = [ 11, 22, 33, 44 ]
@@ -710,3 +736,30 @@
     nil
   end
+
+  ##
+  #  call-seq:
+  #     ary.to_ary -> ary
+  #
+  #  Returns +self+.
+  #
+  def to_ary
+    self
+  end
+
+  ##
+  # call-seq:
+  #   ary.dig(idx, ...)                 -> object
+  #
+  # Extracts the nested value specified by the sequence of <i>idx</i>
+  # objects by calling +dig+ at each step, returning +nil+ if any
+  # intermediate step is +nil+.
+  #
+  def dig(idx,*args)
+    n = self[idx]
+    if args.size > 0
+      n&.dig(*args)
+    else
+      n
+    end
+  end
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-array-ext/src/array.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-array-ext/src/array.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-array-ext/src/array.c	(revision 331)
@@ -1,7 +1,7 @@
-#include "mruby.h"
-#include "mruby/value.h"
-#include "mruby/array.h"
-#include "mruby/range.h"
-#include "mruby/hash.h"
+#include <mruby.h>
+#include <mruby/value.h>
+#include <mruby/array.h>
+#include <mruby/range.h>
+#include <mruby/hash.h>
 
 /*
@@ -132,5 +132,5 @@
     if (mrb_nil_p(v)) {
       mrb_raisef(mrb, E_TYPE_ERROR, "wrong element type %S at %S (expected array)",
-        mrb_str_new_cstr(mrb,  mrb_obj_classname(mrb, RARRAY_PTR(ary)[i])),
+        mrb_str_new_cstr(mrb,  mrb_obj_classname(mrb, ary_elt(ary, i))),
         mrb_fixnum_value(i)
       );
@@ -150,4 +150,79 @@
 }
 
+/*
+ *  call-seq:
+ *     ary.slice!(index)         -> obj or nil
+ *     ary.slice!(start, length) -> new_ary or nil
+ *     ary.slice!(range)         -> new_ary or nil
+ *
+ *  Deletes the element(s) given by an +index+ (optionally up to +length+
+ *  elements) or by a +range+.
+ *
+ *  Returns the deleted object (or objects), or +nil+ if the +index+ is out of
+ *  range.
+ *
+ *     a = [ "a", "b", "c" ]
+ *     a.slice!(1)     #=> "b"
+ *     a               #=> ["a", "c"]
+ *     a.slice!(-1)    #=> "c"
+ *     a               #=> ["a"]
+ *     a.slice!(100)   #=> nil
+ *     a               #=> ["a"]
+ */
+
+static mrb_value
+mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
+{
+  struct RArray *a = mrb_ary_ptr(self);
+  mrb_int i, j, k, len;
+  mrb_value index;
+  mrb_value val;
+  mrb_value *ptr;
+  mrb_value ary;
+
+  mrb_ary_modify(mrb, a);
+
+  if (mrb_get_args(mrb, "o|i", &index, &len) == 1) {
+    switch (mrb_type(index)) {
+    case MRB_TT_RANGE:
+      if (mrb_range_beg_len(mrb, index, &i, &len, a->len, TRUE) == 1) {
+        goto delete_pos_len;
+      }
+      else {
+        return mrb_nil_value();
+      }
+    case MRB_TT_FIXNUM:
+      val = mrb_funcall(mrb, self, "delete_at", 1, index);
+      return val;
+    default:
+      val = mrb_funcall(mrb, self, "delete_at", 1, index);
+      return val;
+    }
+  }
+
+  i = mrb_fixnum(index);
+ delete_pos_len:
+  if (i < 0) i += a->len;
+  if (i < 0 || a->len < i) return mrb_nil_value();
+  if (len < 0) return mrb_nil_value();
+  if (a->len == i) return mrb_ary_new(mrb);
+  if (len > a->len - i) len = a->len - i;
+
+  ary = mrb_ary_new_capa(mrb, len);
+
+  for (j = i, k = 0; k < len; ++j, ++k) {
+    mrb_ary_push(mrb, ary, a->ptr[j]);
+  }
+
+  ptr = a->ptr + i;
+  for (j = i; j < a->len - len; ++j) {
+    *ptr = *(ptr+len);
+    ++ptr;
+  }
+
+  mrb_ary_resize(mrb, self, a->len - len);
+  return ary;
+}
+
 void
 mrb_mruby_array_ext_gem_init(mrb_state* mrb)
@@ -160,4 +235,5 @@
   mrb_define_method(mrb, a, "values_at", mrb_ary_values_at, MRB_ARGS_ANY());
   mrb_define_method(mrb, a, "to_h",   mrb_ary_to_h, MRB_ARGS_REQ(0));
+  mrb_define_method(mrb, a, "slice!", mrb_ary_slice_bang,   MRB_ARGS_ANY());
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-array-ext/test/array.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-array-ext/test/array.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-array-ext/test/array.rb	(revision 331)
@@ -1,4 +1,11 @@
 ##
 # Array(Ext) Test
+
+assert("Array.try_convert") do
+  assert_nil Array.try_convert(0)
+  assert_nil Array.try_convert(nil)
+  assert_equal [], Array.try_convert([])
+  assert_equal [1,2,3], Array.try_convert([1,2,3])
+end
 
 assert("Array#assoc") do
@@ -295,6 +302,53 @@
 end
 
+assert('Array#to_h (Modified)') do
+  class A
+    def to_ary
+      $a.clear
+      nil
+    end
+  end
+  $a = [A.new]
+  assert_raise(TypeError) { $a.to_h }
+end
+
 assert("Array#index (block)") do
   assert_nil (1..10).to_a.index { |i| i % 5 == 0 and i % 7 == 0 }
   assert_equal 34, (1..100).to_a.index { |i| i % 5 == 0 and i % 7 == 0 }
 end
+
+assert("Array#to_ary") do
+  assert_equal [], [].to_ary
+  assert_equal [1,2,3], [1,2,3].to_ary
+end
+
+assert("Array#dig") do
+  h = [[[1]], 0]
+  assert_equal(1, h.dig(0, 0, 0))
+  assert_nil(h.dig(2, 0))
+  assert_raise(TypeError) {h.dig(:a)}
+end
+
+assert("Array#slice!") do
+  a = [1, 2, 3]
+  b = a.slice!(0)
+  c = [1, 2, 3, 4, 5]
+  d = c.slice!(0, 2)
+  e = [1, 2, 3, 4, 5]
+  f = e.slice!(1..3)
+  g = [1, 2, 3]
+  h = g.slice!(-1)
+  i = [1, 2, 3]
+  j = i.slice!(0, -1)
+
+  assert_equal(a, [2, 3])
+  assert_equal(b, 1)
+  assert_equal(c, [3, 4, 5])
+  assert_equal(d, [1, 2])
+  assert_equal(e, [1, 5])
+  assert_equal(f, [2, 3, 4])
+  assert_equal(g, [1, 2])
+  assert_equal(h, 3)
+  assert_equal(i, [1, 2, 3])
+  assert_equal(j, nil)
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/bintest/mrdb.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/bintest/mrdb.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/bintest/mrdb.rb	(revision 331)
@@ -15,5 +15,5 @@
     # compile
     `./bin/mrbc -g -o "#{bin.path}" "#{script.path}"`
-    
+
     # add mrdb quit
     testcase << {:cmd=>"quit"}
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/bintest/print.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/bintest/print.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/bintest/print.rb	(revision 331)
@@ -14,5 +14,5 @@
     # compile
     `./bin/mrbc -g -o "#{bin.path}" "#{script.path}"`
-    
+
     # add mrdb quit
     testcase << {:cmd=>"quit"}
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c	(revision 331)
@@ -5,12 +5,12 @@
 
 #include <string.h>
-#include "mruby.h"
-#include "mruby/irep.h"
+#include <mruby.h>
+#include <mruby/irep.h>
 #include "mrdb.h"
-#include "mruby/debug.h"
-#include "mruby/opcode.h"
-#include "mruby/class.h"
-#include "mruby/proc.h"
-#include "mruby/variable.h"
+#include <mruby/debug.h>
+#include <mruby/opcode.h>
+#include <mruby/class.h>
+#include <mruby/proc.h>
+#include <mruby/variable.h>
 #include "mrdberror.h"
 #include "apibreak.h"
@@ -21,18 +21,19 @@
 
 static uint16_t
-check_lineno( mrb_irep_debug_info_file *info_file, uint16_t lineno )
+check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
 {
   uint32_t count = info_file->line_entry_count;
   uint16_t l_idx;
 
-  if( info_file->line_type == mrb_debug_line_ary ) {
+  if (info_file->line_type == mrb_debug_line_ary) {
     for (l_idx = 0; l_idx < count; ++l_idx) {
-      if(lineno == info_file->lines.ary[l_idx]) {
+      if (lineno == info_file->lines.ary[l_idx]) {
         return lineno;
       }
     }
-  } else {
+  }
+  else {
     for (l_idx = 0; l_idx < count; ++l_idx) {
-      if(lineno == info_file->lines.flat_map[l_idx].line) {
+      if (lineno == info_file->lines.flat_map[l_idx].line) {
         return lineno;
       }
@@ -44,5 +45,5 @@
 
 static int32_t
-get_break_index( mrb_debug_context *dbg, int32_t bpno )
+get_break_index(mrb_debug_context *dbg, uint32_t bpno)
 {
   uint32_t i;
@@ -51,5 +52,5 @@
 
   for(i = 0 ; i < dbg->bpnum; i++) {
-    if(dbg->bp[i].bpno == bpno) {
+    if (dbg->bp[i].bpno == bpno) {
       hit = TRUE;
       index = i;
@@ -58,5 +59,5 @@
   }
 
-  if(hit == FALSE) {
+  if (hit == FALSE) {
     return MRB_DEBUG_BREAK_INVALID_NO;
   }
@@ -66,5 +67,5 @@
 
 static void
-free_breakpoint( mrb_state *mrb, mrb_debug_breakpoint *bp )
+free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp)
 {
   switch(bp->type) {
@@ -74,5 +75,5 @@
     case MRB_DEBUG_BPTYPE_METHOD:
       mrb_free(mrb, (void*)bp->point.methodpoint.method_name);
-      if(bp->point.methodpoint.class_name != NULL) {
+      if (bp->point.methodpoint.class_name != NULL) {
         mrb_free(mrb, (void*)bp->point.methodpoint.class_name);
       }
@@ -84,5 +85,5 @@
 
 static uint16_t
-check_file_lineno( struct mrb_irep *irep, const char *file, uint16_t lineno )
+check_file_lineno(struct mrb_irep *irep, const char *file, uint16_t lineno)
 {
   mrb_irep_debug_info_file *info_file;
@@ -94,15 +95,15 @@
   for (f_idx = 0; f_idx < irep->debug_info->flen; ++f_idx) {
     info_file = irep->debug_info->files[f_idx];
-    if(!strcmp(info_file->filename, file)) {
+    if (!strcmp(info_file->filename, file)) {
       result = MRB_DEBUG_BP_FILE_OK;
 
-      fix_lineno = check_lineno( info_file, lineno );
-      if(fix_lineno != 0) { 
+      fix_lineno = check_lineno(info_file, lineno);
+      if (fix_lineno != 0) {
         return result | MRB_DEBUG_BP_LINENO_OK;
       }
     }
-    for ( i=0; i < irep->rlen; ++i ) {
+    for (i=0; i < irep->rlen; ++i) {
       result  |= check_file_lineno(irep->reps[i], file, lineno);
-      if(result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
+      if (result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
         return result;
       }
@@ -113,5 +114,5 @@
 
 static const char*
-get_class_name( mrb_state *mrb, struct RClass *class_obj )
+get_class_name(mrb_state *mrb, struct RClass *class_obj)
 {
   struct RClass *outer;
@@ -124,5 +125,5 @@
 
 static int32_t
-compare_break_method( mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc )
+compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
 {
   const char* class_name;
@@ -138,22 +139,22 @@
 
   method_p = &bp->point.methodpoint;
-  if(strcmp(method_p->method_name, method_name) == 0) {
+  if (strcmp(method_p->method_name, method_name) == 0) {
     class_name = get_class_name(mrb, class_obj);
-    if(class_name == NULL) {
-      if(method_p->class_name == NULL) {
+    if (class_name == NULL) {
+      if (method_p->class_name == NULL) {
         return bp->bpno;
       }
     }
-    else if(method_p->class_name != NULL) {
+    else if (method_p->class_name != NULL) {
       m = mrb_method_search_vm(mrb, &class_obj, method_sym);
-      if(m == NULL) {
+      if (m == NULL) {
         return MRB_DEBUG_OK;
       }
-      if(MRB_PROC_CFUNC_P(m)) {
+      if (MRB_PROC_CFUNC_P(m)) {
         *isCfunc = TRUE;
       }
 
       is_defined = mrb_class_defined(mrb, method_p->class_name);
-      if(is_defined == FALSE) {
+      if (is_defined == FALSE) {
         return MRB_DEBUG_OK;
       }
@@ -162,5 +163,5 @@
       ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name));
       m = mrb_method_search_vm(mrb, &sc, ssym);
-      if(m == NULL) {
+      if (m == NULL) {
         return MRB_DEBUG_OK;
       }
@@ -168,5 +169,5 @@
       class_name = get_class_name(mrb, class_obj);
       sn = get_class_name(mrb, sc);
-      if(strcmp(sn, class_name) == 0) {
+      if (strcmp(sn, class_name) == 0) {
         return bp->bpno;
       }
@@ -177,5 +178,5 @@
 
 int32_t
-mrb_debug_set_break_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
+mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
 {
   int32_t index;
@@ -183,23 +184,24 @@
   uint16_t result;
 
-  if((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
-    return MRB_DEBUG_INVALID_ARGUMENT;
-  }
-
-  if(dbg->bpnum >= MAX_BREAKPOINT) {
+  if ((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
+    return MRB_DEBUG_INVALID_ARGUMENT;
+  }
+
+  if (dbg->bpnum >= MAX_BREAKPOINT) {
     return MRB_DEBUG_BREAK_NUM_OVER;
   }
 
-  if(dbg->next_bpno > MAX_BREAKPOINTNO) {
+  if (dbg->next_bpno > MAX_BREAKPOINTNO) {
     return MRB_DEBUG_BREAK_NO_OVER;
   }
 
   /* file and lineno check (line type mrb_debug_line_ary only.) */
-  result = check_file_lineno( dbg->root_irep, file, lineno );
-  if(result == 0) {
+  result = check_file_lineno(dbg->root_irep, file, lineno);
+  if (result == 0) {
     return MRB_DEBUG_BREAK_INVALID_FILE;
-  }else if(result == MRB_DEBUG_BP_FILE_OK) {
+  }
+  else if (result == MRB_DEBUG_BP_FILE_OK) {
     return MRB_DEBUG_BREAK_INVALID_LINENO;
-  } 
+  }
 
   set_file = mrb_malloc(mrb, strlen(file) + 1);
@@ -221,5 +223,5 @@
 
 int32_t
-mrb_debug_set_break_method( mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name )
+mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name)
 {
   int32_t index;
@@ -227,17 +229,17 @@
   char* set_method;
 
-  if((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
-    return MRB_DEBUG_INVALID_ARGUMENT;
-  }
-
-  if(dbg->bpnum >= MAX_BREAKPOINT) {
+  if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
+    return MRB_DEBUG_INVALID_ARGUMENT;
+  }
+
+  if (dbg->bpnum >= MAX_BREAKPOINT) {
     return MRB_DEBUG_BREAK_NUM_OVER;
   }
 
-  if(dbg->next_bpno > MAX_BREAKPOINTNO) {
+  if (dbg->next_bpno > MAX_BREAKPOINTNO) {
     return MRB_DEBUG_BREAK_NO_OVER;
   }
 
-  if(class_name != NULL) {
+  if (class_name != NULL) {
     set_class = mrb_malloc(mrb, strlen(class_name) + 1);
     strncpy(set_class, class_name, strlen(class_name) + 1);
@@ -264,7 +266,7 @@
 
 int32_t
-mrb_debug_get_breaknum( mrb_state *mrb, mrb_debug_context *dbg )
-{
-  if((mrb == NULL) || (dbg == NULL)) {
+mrb_debug_get_breaknum(mrb_state *mrb, mrb_debug_context *dbg)
+{
+  if ((mrb == NULL) || (dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
@@ -273,14 +275,14 @@
 }
 
-int32_t 
-mrb_debug_get_break_all( mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp )
+int32_t
+mrb_debug_get_break_all(mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp)
 {
   uint32_t get_size = 0;
 
-  if((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
-    return MRB_DEBUG_INVALID_ARGUMENT;
-  }
-
-  if(dbg->bpnum >= size) {
+  if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
+    return MRB_DEBUG_INVALID_ARGUMENT;
+  }
+
+  if (dbg->bpnum >= size) {
     get_size = size;
   }
@@ -295,14 +297,14 @@
 
 int32_t
-mrb_debug_get_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp )
-{
-  uint32_t index;
-
-  if((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
+mrb_debug_get_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp)
+{
+  int32_t index;
+
+  if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
 
   index = get_break_index(dbg, bpno);
-  if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
     return MRB_DEBUG_BREAK_INVALID_NO;
   }
@@ -316,16 +318,16 @@
 }
 
-int32_t 
-mrb_debug_delete_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
+int32_t
+mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
 {
   uint32_t i;
   int32_t index;
 
-  if((mrb == NULL) ||(dbg == NULL)) {
+  if ((mrb == NULL) ||(dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
 
   index = get_break_index(dbg, bpno);
-  if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
     return MRB_DEBUG_BREAK_INVALID_NO;
   }
@@ -334,5 +336,5 @@
 
   for(i = index ; i < dbg->bpnum; i++) {
-    if((i + 1) == dbg->bpnum) {
+    if ((i + 1) == dbg->bpnum) {
       memset(&dbg->bp[i], 0, sizeof(mrb_debug_breakpoint));
     }
@@ -347,10 +349,10 @@
 }
 
-int32_t 
-mrb_debug_delete_break_all( mrb_state *mrb, mrb_debug_context *dbg )
-{
-  uint32_t i;
-
-  if((mrb == NULL) || (dbg == NULL)) {
+int32_t
+mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg)
+{
+  uint32_t i;
+
+  if ((mrb == NULL) || (dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
@@ -365,15 +367,15 @@
 }
 
-int32_t 
-mrb_debug_enable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
+int32_t
+mrb_debug_enable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
 {
   int32_t index = 0;
 
-  if((mrb == NULL) || (dbg == NULL)) {
+  if ((mrb == NULL) || (dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
 
   index = get_break_index(dbg, bpno);
-  if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
     return MRB_DEBUG_BREAK_INVALID_NO;
   }
@@ -385,9 +387,9 @@
 
 int32_t
-mrb_debug_enable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
-{
-  uint32_t i;
-
-  if((mrb == NULL) || (dbg == NULL)) {
+mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
+{
+  uint32_t i;
+
+  if ((mrb == NULL) || (dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
@@ -400,15 +402,15 @@
 }
 
-int32_t 
-mrb_debug_disable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
+int32_t
+mrb_debug_disable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
 {
   int32_t index = 0;
 
-  if((mrb == NULL) || (dbg == NULL)) {
+  if ((mrb == NULL) || (dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
 
   index = get_break_index(dbg, bpno);
-  if(index == MRB_DEBUG_BREAK_INVALID_NO) {
+  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
     return MRB_DEBUG_BREAK_INVALID_NO;
   }
@@ -419,10 +421,10 @@
 }
 
-int32_t 
-mrb_debug_disable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
-{
-  uint32_t i;
-
-  if((mrb == NULL) || (dbg == NULL)) {
+int32_t
+mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
+{
+  uint32_t i;
+
+  if ((mrb == NULL) || (dbg == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
@@ -436,8 +438,8 @@
 
 static mrb_bool
-check_start_pc_for_line( mrb_irep *irep, mrb_code *pc, uint16_t line )
-{
-  if( pc > irep->iseq ) {
-    if( line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
+check_start_pc_for_line(mrb_irep *irep, mrb_code *pc, uint16_t line)
+{
+  if (pc > irep->iseq) {
+    if (line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
       return FALSE;
     }
@@ -447,15 +449,15 @@
 
 int32_t
-mrb_debug_check_breakpoint_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line )
+mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line)
 {
   mrb_debug_breakpoint *bp;
   mrb_debug_linepoint *line_p;
-  int i;
-
-  if((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
-    return MRB_DEBUG_INVALID_ARGUMENT;
-  }
-
-  if(!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
+  uint32_t i;
+
+  if ((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
+    return MRB_DEBUG_INVALID_ARGUMENT;
+  }
+
+  if (!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
     return MRB_DEBUG_OK;
   }
@@ -465,7 +467,7 @@
     switch (bp->type) {
       case MRB_DEBUG_BPTYPE_LINE:
-        if(bp->enable == TRUE) {
+        if (bp->enable == TRUE) {
           line_p = &bp->point.linepoint;
-          if((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
+          if ((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
             return bp->bpno;
           }
@@ -484,12 +486,12 @@
 
 
-int32_t 
-mrb_debug_check_breakpoint_method( mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc )
+int32_t
+mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
 {
   mrb_debug_breakpoint *bp;
   int32_t bpno;
-  int i;
-
-  if((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
+  uint32_t i;
+
+  if ((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
     return MRB_DEBUG_INVALID_ARGUMENT;
   }
@@ -497,13 +499,13 @@
   bp = dbg->bp;
   for(i=0; i<dbg->bpnum; i++) {
-    if(bp->type == MRB_DEBUG_BPTYPE_METHOD) {
-      if(bp->enable == TRUE) {
+    if (bp->type == MRB_DEBUG_BPTYPE_METHOD) {
+      if (bp->enable == TRUE) {
         bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc);
-        if(bpno > 0) {
+        if (bpno > 0) {
           return bpno;
         }
       }
     }
-    else if(bp->type == MRB_DEBUG_BPTYPE_NONE) {
+    else if (bp->type == MRB_DEBUG_BPTYPE_NONE) {
       break;
     }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h	(revision 331)
@@ -7,20 +7,20 @@
 #define APIBREAK_H_
 
-#include "mruby.h"
+#include <mruby.h>
 #include "mrdb.h"
 
-int32_t mrb_debug_set_break_line( mrb_state *, mrb_debug_context *, const char *, uint16_t );
-int32_t mrb_debug_set_break_method( mrb_state *, mrb_debug_context *, const char *, const char * );
-int32_t mrb_debug_get_breaknum( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_get_break_all( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
-int32_t mrb_debug_get_break( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint * );
-int32_t mrb_debug_delete_break( mrb_state *, mrb_debug_context *, uint32_t );
-int32_t mrb_debug_delete_break_all( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_enable_break( mrb_state *, mrb_debug_context *, uint32_t );
-int32_t mrb_debug_enable_break_all( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_disable_break( mrb_state *, mrb_debug_context *, uint32_t );
-int32_t mrb_debug_disable_break_all( mrb_state *, mrb_debug_context * );
-int32_t mrb_debug_check_breakpoint_line( mrb_state *, mrb_debug_context *, const char *, uint16_t );
-int32_t mrb_debug_check_breakpoint_method( mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool* );
+int32_t mrb_debug_set_break_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
+int32_t mrb_debug_set_break_method(mrb_state *, mrb_debug_context *, const char *, const char *);
+int32_t mrb_debug_get_breaknum(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_get_break_all(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
+int32_t mrb_debug_get_break(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint *);
+int32_t mrb_debug_delete_break(mrb_state *, mrb_debug_context *, uint32_t);
+int32_t mrb_debug_delete_break_all(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_enable_break(mrb_state *, mrb_debug_context *, uint32_t);
+int32_t mrb_debug_enable_break_all(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_disable_break(mrb_state *, mrb_debug_context *, uint32_t);
+int32_t mrb_debug_disable_break_all(mrb_state *, mrb_debug_context *);
+int32_t mrb_debug_check_breakpoint_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
+int32_t mrb_debug_check_breakpoint_method(mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool*);
 
 #endif /* APIBREAK_H_ */
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c	(revision 331)
@@ -10,7 +10,7 @@
 #include "mrdberror.h"
 #include "apilist.h"
-#include "mruby/compile.h"
-#include "mruby/irep.h"
-#include "mruby/debug.h"
+#include <mruby/compile.h>
+#include <mruby/irep.h>
+#include <mruby/debug.h>
 
 #define LINE_BUF_SIZE MAX_COMMAND_LINE
@@ -72,5 +72,5 @@
 
   p = strrchr(path, '/');
-  len = p != NULL ? p - path : strlen(path);
+  len = p != NULL ? (size_t)(p - path) : strlen(path);
 
   dir = mrb_malloc(mrb, len + 1);
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.h	(revision 331)
@@ -6,5 +6,5 @@
 #define APILIST_H_
 
-#include "mruby.h"
+#include <mruby.h>
 #include "mrdb.h"
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c	(revision 331)
@@ -6,10 +6,10 @@
 #include <string.h>
 #include "mrdb.h"
-#include "mruby/value.h"
-#include "mruby/class.h"
-#include "mruby/compile.h"
-#include "mruby/error.h"
-#include "mruby/numeric.h"
-#include "mruby/string.h"
+#include <mruby/value.h>
+#include <mruby/class.h>
+#include <mruby/compile.h>
+#include <mruby/error.h>
+#include <mruby/numeric.h>
+#include <mruby/string.h>
 #include "apiprint.h"
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.h	(revision 331)
@@ -6,5 +6,5 @@
 #define APIPRINT_H_
 
-#include "mruby.h"
+#include <mruby.h>
 #include "mrdb.h"
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c	(revision 331)
@@ -6,8 +6,8 @@
 #include <ctype.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/dump.h"
-#include "mruby/debug.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/dump.h>
+#include <mruby/debug.h>
+#include <mruby/string.h>
 #include "mrdb.h"
 #include "mrdberror.h"
@@ -71,10 +71,10 @@
   uint32_t l;
 
-  if((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) {
+  if ((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) {
     return 0;
   }
 
-  while( !(ISBLANK(*ps)||ISCNTRL(*ps)) ) {
-    if(!ISDIGIT(*ps)) {
+  while (!(ISBLANK(*ps)||ISCNTRL(*ps))) {
+    if (!ISDIGIT(*ps)) {
       return 0;
     }
@@ -91,5 +91,5 @@
   int32_t ret = MRB_DEBUG_OK;
 
-  if(mrdb->wcnt == 1) {
+  if (mrdb->wcnt == 1) {
     ret = func(mrb, mrdb->dbg);
     print_api_common_error(ret);
@@ -110,13 +110,13 @@
     ps = mrdb->words[i];
     bpno = parse_breakpoint_no(ps);
-    if(bpno == 0) {
+    if (bpno == 0) {
       printf(BREAK_ERR_MSG_INVALIDBPNO, ps);
       break;
     }
     ret = func(mrb, mrdb->dbg, (uint32_t)bpno);
-    if(ret == MRB_DEBUG_BREAK_INVALID_NO) {
+    if (ret == MRB_DEBUG_BREAK_INVALID_NO) {
       printf(BREAK_ERR_MSG_NOBPNO, bpno);
     }
-    else if(ret != MRB_DEBUG_OK) {
+    else if (ret != MRB_DEBUG_OK) {
       print_api_common_error(ret);
     }
@@ -129,15 +129,15 @@
   char* ps = args;
 
-  if(ISBLANK(*ps)||ISCNTRL(*ps)) {
+  if (ISBLANK(*ps)||ISCNTRL(*ps)) {
     puts(BREAK_ERR_MSG_BLANK);
     return MRB_DEBUG_BPTYPE_NONE;
   }
 
-  if(!ISDIGIT(*ps)) {
+  if (!ISDIGIT(*ps)) {
     return MRB_DEBUG_BPTYPE_METHOD;
   }
 
-  while( !(ISBLANK(*ps)||ISCNTRL(*ps)) ) {
-    if(!ISDIGIT(*ps)) {
+  while (!(ISBLANK(*ps)||ISCNTRL(*ps))) {
+    if (!ISDIGIT(*ps)) {
       printf(BREAK_ERR_MSG_INVALIDSTR, args);
       return MRB_DEBUG_BPTYPE_NONE;
@@ -146,5 +146,5 @@
   }
 
-  if((*args == '0')||(strlen(args) >= LINENO_MAX_DIGIT)) {
+  if ((*args == '0')||(strlen(args) >= LINENO_MAX_DIGIT)) {
     puts(BREAK_ERR_MSG_RANGEOVER);
     return MRB_DEBUG_BPTYPE_NONE;
@@ -159,10 +159,10 @@
   const char* enable_letter[] = {BREAK_INFO_MSG_DISABLE, BREAK_INFO_MSG_ENABLE};
 
-  if(bp->type == MRB_DEBUG_BPTYPE_LINE) {
+  if (bp->type == MRB_DEBUG_BPTYPE_LINE) {
     printf(BREAK_INFO_MSG_LINEBREAK,
       bp->bpno, enable_letter[bp->enable], bp->point.linepoint.file, bp->point.linepoint.lineno);
   }
   else {
-    if(bp->point.methodpoint.class_name == NULL) {
+    if (bp->point.methodpoint.class_name == NULL) {
       printf(BREAK_INFO_MSG_METHODBREAK_NOCLASS,
         bp->bpno, enable_letter[bp->enable], bp->point.methodpoint.method_name);
@@ -184,9 +184,9 @@
 
   bpnum = mrb_debug_get_breaknum(mrb, mrdb->dbg);
-  if(bpnum < 0) {
+  if (bpnum < 0) {
     print_api_common_error(bpnum);
     return;
   }
-  else if(bpnum == 0) {
+  else if (bpnum == 0) {
     puts(BREAK_ERR_MSG_NOBPNO_INFOALL);
     return;
@@ -195,5 +195,5 @@
 
   ret = mrb_debug_get_break_all(mrb, mrdb->dbg, (uint32_t)bpnum, bp_list);
-  if(ret < 0) {
+  if (ret < 0) {
     print_api_common_error(ret);
     return;
@@ -220,5 +220,5 @@
     ps = mrdb->words[i];
     bpno = parse_breakpoint_no(ps);
-    if(bpno == 0) {
+    if (bpno == 0) {
       puts(BREAK_ERR_MSG_INVALIDBPNO_INFO);
       break;
@@ -226,13 +226,13 @@
 
     ret = mrb_debug_get_break(mrb, mrdb->dbg, bpno, &bp);
-    if(ret == MRB_DEBUG_BREAK_INVALID_NO) {
+    if (ret == MRB_DEBUG_BREAK_INVALID_NO) {
       printf(BREAK_ERR_MSG_NOBPNO_INFO, bpno);
       break;
     }
-    else if(ret != MRB_DEBUG_OK) {
+    else if (ret != MRB_DEBUG_OK) {
       print_api_common_error(ret);
       break;
     }
-    else if(isFirst == TRUE) {
+    else if (isFirst == TRUE) {
       isFirst = FALSE;
       puts(BREAK_INFO_MSG_HEADER);
@@ -251,5 +251,5 @@
   uint32_t l;
 
-  if(mrdb->wcnt <= 1) {
+  if (mrdb->wcnt <= 1) {
     puts(BREAK_ERR_MSG_BLANK);
     return MRB_DEBUG_BPTYPE_NONE;
@@ -257,9 +257,10 @@
 
   args = mrdb->words[1];
-  if((body = strrchr(args, ':')) == NULL) {
+  if ((body = strrchr(args, ':')) == NULL) {
     body = args;
     type = check_bptype(body);
-  } else {
-    if(body == args) {
+  }
+  else {
+    if (body == args) {
       printf(BREAK_ERR_MSG_INVALIDSTR, args);
       return MRB_DEBUG_BPTYPE_NONE;
@@ -272,8 +273,9 @@
     case MRB_DEBUG_BPTYPE_LINE:
       STRTOUL(l, body);
-      if( l <= 65535 ) {
+      if (l <= 65535) {
         *line = l;
         *file = (body == args)? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)): args;
-      } else {
+      }
+      else {
         puts(BREAK_ERR_MSG_RANGEOVER);
         type = MRB_DEBUG_BPTYPE_NONE;
@@ -281,15 +283,17 @@
       break;
     case MRB_DEBUG_BPTYPE_METHOD:
-      if(body == args) {
+      if (body == args) {
         /* method only */
-        if( ISUPPER(*body)||ISLOWER(*body)||(*body == '_') ) {
+        if (ISUPPER(*body)||ISLOWER(*body)||(*body == '_')) {
           *method = body;
           *cname = NULL;
-        } else {
+        }
+        else {
           printf(BREAK_ERR_MSG_INVALIDMETHOD, args);
           type = MRB_DEBUG_BPTYPE_NONE;
         }
-      } else {
-        if( ISUPPER(*args) ) {
+      }
+      else {
+        if (ISUPPER(*args)) {
           switch(*body) {
             case '@': case '$': case '?': case '.': case ',': case ':':
@@ -303,5 +307,6 @@
             break;
           }
-        } else {
+        }
+        else {
           printf(BREAK_ERR_MSG_INVALIDCLASS, args);
           type = MRB_DEBUG_BPTYPE_NONE;
@@ -344,10 +349,13 @@
     if (type == MRB_DEBUG_BPTYPE_LINE) {
       printf(BREAK_SET_MSG_LINE, ret, file, line);
-    } else if ((type == MRB_DEBUG_BPTYPE_METHOD)&&(cname == NULL)) {
+    }
+    else if ((type == MRB_DEBUG_BPTYPE_METHOD)&&(cname == NULL)) {
       printf(BREAK_SET_MSG_METHOD, ret, method);
-    } else {
+    }
+    else {
       printf(BREAK_SET_MSG_CLASS_METHOD, ret, cname, method);
     }
-  } else {
+  }
+  else {
     switch (ret) {
       case MRB_DEBUG_BREAK_INVALID_LINENO:
@@ -380,5 +388,5 @@
 dbgcmd_info_break(mrb_state *mrb, mrdb_state *mrdb)
 {
-  if(mrdb->wcnt == 2) {
+  if (mrdb->wcnt == 2) {
     info_break_all(mrb, mrdb);
   }
@@ -396,5 +404,5 @@
 
   ret = exe_set_command_all(mrb, mrdb, mrb_debug_delete_break_all);
-  if(ret != TRUE) {
+  if (ret != TRUE) {
     exe_set_command_select(mrb, mrdb, mrb_debug_delete_break);
   }
@@ -409,5 +417,5 @@
 
   ret = exe_set_command_all(mrb, mrdb, mrb_debug_enable_break_all);
-  if(ret != TRUE) {
+  if (ret != TRUE) {
     exe_set_command_select(mrb, mrdb, mrb_debug_enable_break);
   }
@@ -422,5 +430,5 @@
 
   ret = exe_set_command_all(mrb, mrdb, mrb_debug_disable_break_all);
-  if(ret != TRUE) {
+  if (ret != TRUE) {
     exe_set_command_select(mrb, mrdb, mrb_debug_disable_break);
   }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c	(revision 331)
@@ -9,5 +9,5 @@
 
 #include "apilist.h"
-#include "mruby/compile.h"
+#include <mruby/compile.h>
 
 typedef struct help_msg {
@@ -334,5 +334,5 @@
     return FALSE;
   }
-  if((lbracket = strchr(pattern, '[')) == NULL) {
+  if ((lbracket = strchr(pattern, '[')) == NULL) {
     return !strcmp(pattern, cmd);
   }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c	(revision 331)
@@ -6,10 +6,10 @@
 #include <string.h>
 #include "mrdb.h"
-#include "mruby/value.h"
-#include "mruby/class.h"
-#include "mruby/compile.h"
-#include "mruby/error.h"
-#include "mruby/numeric.h"
-#include "mruby/string.h"
+#include <mruby/value.h>
+#include <mruby/class.h>
+#include <mruby/compile.h>
+#include <mruby/error.h>
+#include <mruby/numeric.h>
+#include <mruby/string.h>
 #include "apiprint.h"
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c	(revision 331)
@@ -4,5 +4,5 @@
 */
 
-#include "mruby/opcode.h"
+#include <mruby/opcode.h>
 #include "mrdb.h"
 
@@ -12,9 +12,10 @@
   mrb_debug_context *dbg = mrdb->dbg;
 
-  if( dbg->xm == DBG_INIT ){
+  if (dbg->xm == DBG_INIT){
     dbg->xm = DBG_RUN;
-  } else {
+  }
+  else {
     dbg->xm = DBG_QUIT;
-    if( dbg->xphase == DBG_PHASE_RUNNING ){
+    if (dbg->xphase == DBG_PHASE_RUNNING){
       struct RClass *exc;
       puts("Start it from the beginning.");
@@ -23,5 +24,5 @@
     }
   }
-  
+
   return DBGST_RESTART;
 }
@@ -33,13 +34,14 @@
   int ccnt = 1;
 
-  if( mrdb->wcnt > 1 ){
+  if (mrdb->wcnt > 1){
     sscanf(mrdb->words[1], "%d", &ccnt);
   }
   dbg->ccnt = (uint16_t)(ccnt > 0 ? ccnt : 1);  /* count of continue */
 
-  if( dbg->xphase == DBG_PHASE_AFTER_RUN ){
+  if (dbg->xphase == DBG_PHASE_AFTER_RUN){
     puts("The program is not running.");
     dbg->xm = DBG_QUIT;
-  } else {
+  }
+  else {
     dbg->xm = DBG_RUN;
   }
@@ -53,2 +55,10 @@
   return DBGST_CONTINUE;
 }
+
+dbgcmd_state
+dbgcmd_next(mrb_state *mrb, mrdb_state *mrdb)
+{
+  mrdb->dbg->xm = DBG_NEXT;
+  mrdb->dbg->prvci = mrb->c->ci;
+  return DBGST_CONTINUE;
+}
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c	(revision 331)
@@ -9,10 +9,10 @@
 #include <ctype.h>
 
-#include "mruby.h"
-#include "mruby/dump.h"
-#include "mruby/debug.h"
-#include "mruby/class.h"
-#include "mruby/opcode.h"
-#include "mruby/variable.h"
+#include <mruby.h>
+#include <mruby/dump.h>
+#include <mruby/debug.h>
+#include <mruby/class.h>
+#include <mruby/opcode.h>
+#include <mruby/variable.h>
 
 #include "mrdb.h"
@@ -58,4 +58,5 @@
   {"run",       NULL,           1, 0, 0, DBGCMD_RUN,            dbgcmd_run},             /* r[un] */
   {"step",      NULL,           1, 0, 1, DBGCMD_STEP,           dbgcmd_step},            /* s[tep] */
+  {"next",      NULL,           1, 0, 1, DBGCMD_NEXT,           dbgcmd_next},            /* n[ext] */
   {NULL}
 };
@@ -406,5 +407,5 @@
 
   ret = mrb_debug_get_break(mrb, mrdb->dbg, mrdb->dbg->stopped_bpno, &bp);
-  if(ret == 0) {
+  if (ret == 0) {
     switch(bp.type) {
       case MRB_DEBUG_BPTYPE_LINE:
@@ -416,5 +417,5 @@
         method_name = bp.point.methodpoint.method_name;
         class_name = bp.point.methodpoint.class_name;
-        if(class_name == NULL) {
+        if (class_name == NULL) {
           printf("Breakpoint %d, %s\n", bp.bpno, method_name);
         }
@@ -422,5 +423,5 @@
           printf("Breakpoint %d, %s:%s\n", bp.bpno, class_name, method_name);
         }
-        if(mrdb->dbg->isCfunc) {
+        if (mrdb->dbg->isCfunc) {
           printf("Stopped before calling the C function.\n");
         }
@@ -445,5 +446,5 @@
   char* file = mrb_debug_get_source(mrb, mrdb, mrdb->srcpath, mrdb->dbg->prvfile);
   uint16_t lineno = mrdb->dbg->prvline;
-  if(file != NULL) {
+  if (file != NULL) {
     mrb_debug_list(mrb, mrdb->dbg, file, lineno, lineno);
     mrb_free(mrb, file);
@@ -531,7 +532,7 @@
       break;
   }
-  if(sym != 0) {
+  if (sym != 0) {
     dbg->method_bpno = mrb_debug_check_breakpoint_method(mrb, dbg, c, sym, &isCfunc);
-    if(isCfunc) {
+    if (isCfunc) {
       bpno = dbg->method_bpno;
       dbg->method_bpno = 0;
@@ -557,8 +558,9 @@
   dbg->regs = regs;
 
-  if(dbg->xphase == DBG_PHASE_RESTART) {
+  if (dbg->xphase == DBG_PHASE_RESTART) {
     dbg->root_irep = irep;
     dbg->prvfile = NULL;
     dbg->prvline = 0;
+    dbg->prvci = NULL;
     dbg->xm = DBG_RUN;
     dbg->xphase = DBG_PHASE_RUNNING;
@@ -570,5 +572,4 @@
   switch (dbg->xm) {
   case DBG_STEP:
-  case DBG_NEXT:  // temporary
     if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
       return;
@@ -576,4 +577,16 @@
     dbg->method_bpno = 0;
     dbg->bm = BRK_STEP;
+    break;
+
+  case DBG_NEXT:
+    if (!file || (dbg->prvfile == file && dbg->prvline == line)) {
+      return;
+    }
+    if ((intptr_t)(dbg->prvci) < (intptr_t)(mrb->c->ci)) {
+      return;
+    }
+    dbg->prvci = NULL;
+    dbg->method_bpno = 0;
+    dbg->bm = BRK_NEXT;
     break;
 
@@ -611,5 +624,5 @@
   dbg->prvline = line;
 
-  if(dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
+  if (dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {
     return;
   }
@@ -634,5 +647,5 @@
     st = cmd->func(mrb, mrdb);
 
-    if( (st == DBGST_CONTINUE) || (st == DBGST_RESTART) ) break;
+    if ((st == DBGST_CONTINUE) || (st == DBGST_RESTART)) break;
   }
   return dbg->xm;
@@ -671,5 +684,5 @@
   mrdb->srcpath = args.srcpath;
 
-  if(mrdb->dbg->xm == DBG_QUIT) {
+  if (mrdb->dbg->xm == DBG_QUIT) {
     mrdb->dbg->xphase = DBG_PHASE_RESTART;
   }
@@ -679,5 +692,5 @@
   mrdb->dbg->xm = DBG_INIT;
   mrdb->dbg->ccnt = 1;
-  
+
   /* setup hook functions */
   mrb->code_fetch_hook = mrb_code_fetch_hook;
@@ -726,19 +739,19 @@
     }
   }
-  
+
   mrdb->dbg->prvfile = "-";
   mrdb->dbg->prvline = 0;
-  
+
   while (1) {
     cmd = get_and_parse_command(mrb, mrdb);
     mrb_assert(cmd);
-    
+
     if (cmd->id == DBGCMD_QUIT) {
       break;
     }
-    
-    if( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart;
-  }
-  
+
+    if ( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart;
+  }
+
   cleanup(mrb, &args);
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h	(revision 331)
@@ -7,5 +7,5 @@
 #define MRDB_H
 
-#include "mruby.h"
+#include <mruby.h>
 
 #include "mrdbconf.h"
@@ -110,4 +110,5 @@
   const char *prvfile;
   int32_t prvline;
+  mrb_callinfo *prvci;
 
   mrdb_exemode xm;
@@ -147,4 +148,5 @@
 dbgcmd_state dbgcmd_continue(mrb_state*, mrdb_state*);
 dbgcmd_state dbgcmd_step(mrb_state*, mrdb_state*);
+dbgcmd_state dbgcmd_next(mrb_state*, mrdb_state*);
 /* cmdbreak.c */
 dbgcmd_state dbgcmd_break(mrb_state*, mrdb_state*);
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c	(revision 331)
@@ -11,4 +11,7 @@
 #include <stdio.h>
 #include <ctype.h>
+
+#include <signal.h>
+#include <setjmp.h>
 
 #ifdef ENABLE_READLINE
@@ -30,9 +33,19 @@
 #endif
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/proc.h"
-#include "mruby/compile.h"
-#include "mruby/string.h"
+#ifndef _WIN32
+#define MIRB_SIGSETJMP(env) sigsetjmp(env, 1)
+#define MIRB_SIGLONGJMP(env, val) siglongjmp(env, val)
+#define SIGJMP_BUF sigjmp_buf
+#else
+#define MIRB_SIGSETJMP(env) setjmp(env)
+#define MIRB_SIGLONGJMP(env, val) longjmp(env, val)
+#define SIGJMP_BUF jmp_buf
+#endif
+
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/proc.h>
+#include <mruby/compile.h>
+#include <mruby/string.h>
 
 #ifdef ENABLE_READLINE
@@ -195,4 +208,5 @@
 
 struct _args {
+  FILE *rfp;
   mrb_bool verbose      : 1;
   int argc;
@@ -252,4 +266,19 @@
     }
   }
+
+  if (args->rfp == NULL) {
+    if (*argv != NULL) {
+      args->rfp = fopen(argv[0], "r");
+      if (args->rfp == NULL) {
+        printf("Cannot open program file. (%s)\n", *argv);
+        return EXIT_FAILURE;
+      }
+      argc--; argv++;
+    }
+  }
+  args->argv = (char **)mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
+  memcpy(args->argv, argv, (argc+1) * sizeof(char*));
+  args->argc = argc;
+
   return EXIT_SUCCESS;
 }
@@ -258,4 +287,7 @@
 cleanup(mrb_state *mrb, struct _args *args)
 {
+  if (args->rfp)
+    fclose(args->rfp);
+  mrb_free(mrb, args->argv);
   mrb_close(mrb);
 }
@@ -308,14 +340,32 @@
 }
 
+
+#ifndef ENABLE_READLINE
+volatile sig_atomic_t input_canceled = 0;
+void
+ctrl_c_handler(int signo)
+{
+  input_canceled = 1;
+}
+#else
+SIGJMP_BUF ctrl_c_buf;
+void
+ctrl_c_handler(int signo)
+{
+  MIRB_SIGLONGJMP(ctrl_c_buf, 1);
+}
+#endif
+
 int
 main(int argc, char **argv)
 {
-  char ruby_code[1024] = { 0 };
+  char ruby_code[4096] = { 0 };
   char last_code_line[1024] = { 0 };
 #ifndef ENABLE_READLINE
   int last_char;
-  int char_index;
+  size_t char_index;
 #else
   char *history_path;
+  char* line;
 #endif
   mrbc_context *cxt;
@@ -324,5 +374,7 @@
   mrb_value result;
   struct _args args;
+  mrb_value ARGV;
   int n;
+  int i;
   mrb_bool code_block_open = FALSE;
   int ai;
@@ -335,5 +387,4 @@
     return EXIT_FAILURE;
   }
-  mrb_define_global_const(mrb, "ARGV", mrb_ary_new_capa(mrb, 0));
 
   n = parse_args(mrb, argc, argv, &args);
@@ -343,4 +394,14 @@
     return n;
   }
+
+  ARGV = mrb_ary_new_capa(mrb, args.argc);
+  for (i = 0; i < args.argc; i++) {
+    char* utf8 = mrb_utf8_from_locale(args.argv[i], -1);
+    if (utf8) {
+      mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, utf8));
+      mrb_utf8_free(utf8);
+    }
+  }
+  mrb_define_global_const(mrb, "ARGV", ARGV);
 
 #ifdef ENABLE_READLINE
@@ -369,15 +430,31 @@
     char *utf8;
 
+    if (args.rfp) {
+      if (fgets(last_code_line, sizeof(last_code_line)-1, args.rfp) != NULL)
+        goto done;
+      break;
+    }
+
 #ifndef ENABLE_READLINE
     print_cmdline(code_block_open);
 
+    signal(SIGINT, ctrl_c_handler);
     char_index = 0;
     while ((last_char = getchar()) != '\n') {
       if (last_char == EOF) break;
-      if (char_index > sizeof(last_code_line)-2) {
+      if (char_index >= sizeof(last_code_line)-2) {
         fputs("input string too long\n", stderr);
         continue;
       }
       last_code_line[char_index++] = last_char;
+    }
+    signal(SIGINT, SIG_DFL);
+    if (input_canceled) {
+      ruby_code[0] = '\0';
+      last_code_line[0] = '\0';
+      code_block_open = FALSE;
+      puts("^C");
+      input_canceled = 0;
+      continue;
     }
     if (last_char == EOF) {
@@ -389,5 +466,17 @@
     last_code_line[char_index] = '\0';
 #else
-    char* line = MIRB_READLINE(code_block_open ? "* " : "> ");
+    if (MIRB_SIGSETJMP(ctrl_c_buf) == 0) {
+      ;
+    }
+    else {
+      ruby_code[0] = '\0';
+      last_code_line[0] = '\0';
+      code_block_open = FALSE;
+      puts("^C");
+    }
+    signal(SIGINT, ctrl_c_handler);
+    line = MIRB_READLINE(code_block_open ? "* " : "> ");
+    signal(SIGINT, SIG_DFL);
+
     if (line == NULL) {
       printf("\n");
@@ -403,4 +492,6 @@
     free(line);
 #endif
+
+done:
 
     if (code_block_open) {
@@ -454,7 +545,7 @@
           mrb_codedump_all(mrb, proc);
         }
-        /* pass a proc for evaulation */
+        /* pass a proc for evaluation */
         /* evaluate the bytecode */
-        result = mrb_context_run(mrb,
+        result = mrb_vm_run(mrb,
             proc,
             mrb_top_self(mrb),
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c	(revision 331)
@@ -2,8 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/compile.h"
-#include "mruby/dump.h"
-#include "mruby/proc.h"
+#include <mruby.h>
+#include <mruby/compile.h>
+#include <mruby/dump.h>
+#include <mruby/proc.h>
 
 #define RITEBIN_EXT ".mrb"
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby-config/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby-config/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby-config/mrbgem.rake	(revision 331)
@@ -24,5 +24,5 @@
     config = Hash[open("#{build_dir}/lib/libmruby.flags.mak").read.split("\n").map {|x| a = x.split(/\s*=\s*/, 2); [a[0], a[1].gsub('\\"', '"') ]}]
     IO.write(t.name, File.open(t.name) {|f|
-      f.read.gsub (/echo (MRUBY_CFLAGS|MRUBY_LIBS|MRUBY_LDFLAGS_BEFORE_LIBS|MRUBY_LDFLAGS)/) {|x| config[$1].empty? ? '' : "echo #{config[$1]}"}
+      f.read.gsub (/echo (MRUBY_CFLAGS|MRUBY_LIBS|MRUBY_LDFLAGS_BEFORE_LIBS|MRUBY_LDFLAGS|MRUBY_LIBMRUBY_PATH)/) {|x| config[$1].empty? ? '' : "echo #{config[$1]}"}
     })
     FileUtils.chmod(0755, t.name)
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby-config/mruby-config
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby-config/mruby-config	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby-config/mruby-config	(revision 331)
@@ -7,10 +7,12 @@
     --ldflags-before-libs) echo MRUBY_LDFLAGS_BEFORE_LIBS;;
     --libs) echo MRUBY_LIBS;;
+    --libmruby-path) echo MRUBY_LIBMRUBY_PATH;;
     --help) echo "Usage: mruby-config [switches]"
             echo "  switches:"
             echo "  --cflags                    print flags passed to compiler"
             echo "  --ldflags                   print flags passed to linker"
-            echo "  --ldflags-before-libs       print flags passwd to linker before linked libraries"
+            echo "  --ldflags-before-libs       print flags passed to linker before linked libraries"
             echo "  --libs                      print linked libraries"
+            echo "  --libmruby-path             print libmruby path"
             exit 0;;
   esac
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby-config/mruby-config.bat
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby-config/mruby-config.bat	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby-config/mruby-config.bat	(revision 331)
@@ -8,4 +8,5 @@
 if "%0" equ "--ldflags-before-libs" goto ldflagsbeforelibs
 if "%0" equ "--libs" goto libs
+if "%0" equ "--libmruby-path" goto libmrubypath
 if "%0" equ "--help" goto showhelp
 echo Invalid Option
@@ -28,4 +29,8 @@
 goto top
 
+:libmrubypath
+echo MRUBY_LIBMRUBY_PATH
+goto top
+
 :showhelp
 echo Usage: mruby-config [switches]
@@ -33,4 +38,5 @@
 echo   --cflags                   print flags passed to compiler
 echo   --ldflags                  print flags passed to linker
-echo   --ldflags-before-libs      print flags passwd to linker before linked libraries
+echo   --ldflags-before-libs      print flags passed to linker before linked libraries
 echo   --libs                     print linked libraries
+echo   --libmruby-path            print libmruby path
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/bintest/mruby.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby/bintest/mruby.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/bintest/mruby.rb	(revision 331)
@@ -3,7 +3,7 @@
 assert('regression for #1564') do
   o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1`
-  assert_equal o, "-e:1:2: syntax error, unexpected tLSHFT\n"
+  assert_include o, "-e:1:2: syntax error"
   o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1`
-  assert_equal o, "-e:1:3: syntax error, unexpected tLSHFT\n"
+  assert_include o, "-e:1:3: syntax error"
 end
 
@@ -45,2 +45,16 @@
   assert_equal "\"test\"\n\"fin\"\n", `#{cmd('mruby')} #{script.path}`
 end
+
+assert('garbage collecting built-in classes') do
+  script = Tempfile.new('test.rb')
+
+  script.write <<RUBY
+NilClass = nil
+GC.start
+Array.dup
+print nil.class.to_s
+RUBY
+  script.flush
+  assert_equal "NilClass", `#{cmd('mruby')} #{script.path}`
+  assert_equal 0, $?.exitstatus
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/mrbgem.rake	(revision 331)
@@ -5,3 +5,9 @@
   spec.bins = %w(mruby)
   spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
+  spec.add_dependency('mruby-error', :core => 'mruby-error')
+
+  if build.cxx_exception_enabled?
+    @objs << build.compile_as_cxx("#{spec.dir}/tools/mruby/mruby.c", "#{spec.build_dir}/tools/mruby/mruby.cxx")
+    @objs.delete_if { |v| v == objfile("#{spec.build_dir}/tools/mruby/mruby") }
+  end
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c	(revision 331)
@@ -2,9 +2,9 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/compile.h"
-#include "mruby/dump.h"
-#include "mruby/variable.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/compile.h>
+#include <mruby/dump.h>
+#include <mruby/variable.h>
 
 #ifdef MRB_DISABLE_STDIO
@@ -189,57 +189,63 @@
     return n;
   }
-
-  ARGV = mrb_ary_new_capa(mrb, args.argc);
-  for (i = 0; i < args.argc; i++) {
-    char* utf8 = mrb_utf8_from_locale(args.argv[i], -1);
-    if (utf8) {
-      mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, utf8));
+  else {
+    int ai = mrb_gc_arena_save(mrb);
+    ARGV = mrb_ary_new_capa(mrb, args.argc);
+    for (i = 0; i < args.argc; i++) {
+      char* utf8 = mrb_utf8_from_locale(args.argv[i], -1);
+      if (utf8) {
+        mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, utf8));
+        mrb_utf8_free(utf8);
+      }
+    }
+    mrb_define_global_const(mrb, "ARGV", ARGV);
+
+    c = mrbc_context_new(mrb);
+    if (args.verbose)
+      c->dump_result = TRUE;
+    if (args.check_syntax)
+      c->no_exec = TRUE;
+
+    /* Set $0 */
+    zero_sym = mrb_intern_lit(mrb, "$0");
+    if (args.rfp) {
+      const char *cmdline;
+      cmdline = args.cmdline ? args.cmdline : "-";
+      mrbc_filename(mrb, c, cmdline);
+      mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
+    }
+    else {
+      mrbc_filename(mrb, c, "-e");
+      mrb_gv_set(mrb, zero_sym, mrb_str_new_lit(mrb, "-e"));
+    }
+
+    /* Load program */
+    if (args.mrbfile) {
+      v = mrb_load_irep_file_cxt(mrb, args.rfp, c);
+    }
+    else if (args.rfp) {
+      v = mrb_load_file_cxt(mrb, args.rfp, c);
+    }
+    else {
+      char* utf8 = mrb_utf8_from_locale(args.cmdline, -1);
+      if (!utf8) abort();
+      v = mrb_load_string_cxt(mrb, utf8, c);
       mrb_utf8_free(utf8);
     }
-  }
-  mrb_define_global_const(mrb, "ARGV", ARGV);
-
-  c = mrbc_context_new(mrb);
-  if (args.verbose)
-    c->dump_result = TRUE;
-  if (args.check_syntax)
-    c->no_exec = TRUE;
-
-  /* Set $0 */
-  zero_sym = mrb_intern_lit(mrb, "$0");
-  if (args.rfp) {
-    const char *cmdline;
-    cmdline = args.cmdline ? args.cmdline : "-";
-    mrbc_filename(mrb, c, cmdline);
-    mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
-  }
-  else {
-    mrbc_filename(mrb, c, "-e");
-    mrb_gv_set(mrb, zero_sym, mrb_str_new_lit(mrb, "-e"));
-  }
-
-  /* Load program */
-  if (args.mrbfile) {
-    v = mrb_load_irep_file_cxt(mrb, args.rfp, c);
-  }
-  else if (args.rfp) {
-    v = mrb_load_file_cxt(mrb, args.rfp, c);
-  }
-  else {
-    char* utf8 = mrb_utf8_from_locale(args.cmdline, -1);
-    if (!utf8) abort();
-    v = mrb_load_string_cxt(mrb, utf8, c);
-    mrb_utf8_free(utf8);
-  }
-
-  mrbc_context_free(mrb, c);
-  if (mrb->exc) {
-    if (!mrb_undef_p(v)) {
-      mrb_print_error(mrb);
-    }
-    n = -1;
-  }
-  else if (args.check_syntax) {
-    printf("Syntax OK\n");
+
+    mrb_gc_arena_restore(mrb, ai);
+    mrbc_context_free(mrb, c);
+    if (mrb->exc) {
+      if (mrb_undef_p(v)) {
+        mrb_p(mrb, mrb_obj_value(mrb->exc));
+      }
+      else {
+        mrb_print_error(mrb);
+      }
+      n = -1;
+    }
+    else if (args.check_syntax) {
+      printf("Syntax OK\n");
+    }
   }
   cleanup(mrb, &args);
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c	(revision 331)
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/irep.h"
-#include "mruby/dump.h"
+#include <mruby.h>
+#include <mruby/irep.h>
+#include <mruby/dump.h>
 
 struct strip_args {
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/mrbgem.rake	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/mrbgem.rake	(revision 331)
@@ -0,0 +1,5 @@
+MRuby::Gem::Specification.new('mruby-class-ext') do |spec|
+  spec.license = 'MIT'
+  spec.author  = 'mruby developers'
+  spec.summary = 'class/module extension'
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/src/class.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/src/class.c	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/src/class.c	(revision 331)
@@ -0,0 +1,23 @@
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/string.h"
+
+static mrb_value
+mrb_mod_name(mrb_state *mrb, mrb_value self)
+{
+  mrb_value name = mrb_class_path(mrb, mrb_class_ptr(self));
+  return mrb_nil_p(name)? name : mrb_str_dup(mrb, name);
+}
+
+void
+mrb_mruby_class_ext_gem_init(mrb_state *mrb)
+{
+  struct RClass *mod = mrb->module_class;
+
+  mrb_define_method(mrb, mod, "name", mrb_mod_name, MRB_ARGS_NONE());
+}
+
+void
+mrb_mruby_class_ext_gem_final(mrb_state *mrb)
+{
+}
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/test/module.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/test/module.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-class-ext/test/module.rb	(revision 331)
@@ -0,0 +1,10 @@
+assert 'Module#name' do
+  module A
+    class B
+    end
+  end
+
+  assert_nil A::B.singleton_class.name
+  assert_equal 'Fixnum', Fixnum.name
+  assert_equal 'A::B', A::B.name
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/bintest/mrbc.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-compiler/bintest/mrbc.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/bintest/mrbc.rb	(revision 331)
@@ -11,2 +11,20 @@
   assert_equal 0, $?.exitstatus
 end
+
+assert('parsing function with void argument') do
+  a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb')
+  a.write('f ()')
+  a.flush
+  result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1`
+  assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
+  assert_equal 0, $?.exitstatus
+end
+
+assert('embedded document with invalid terminator') do
+  a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb')
+  a.write("=begin\n=endx\n")
+  a.flush
+  result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1`
+  assert_equal "#{a.path}:3:0: embedded document meets end of file", result.chomp
+  assert_equal 1, $?.exitstatus
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/core/codegen.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-compiler/core/codegen.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/core/codegen.c	(revision 331)
@@ -9,14 +9,18 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/compile.h"
-#include "mruby/proc.h"
-#include "mruby/numeric.h"
-#include "mruby/string.h"
-#include "mruby/debug.h"
+#include <mruby.h>
+#include <mruby/compile.h>
+#include <mruby/proc.h>
+#include <mruby/numeric.h>
+#include <mruby/string.h>
+#include <mruby/debug.h>
 #include "node.h"
-#include "mruby/opcode.h"
-#include "mruby/re.h"
-#include "mruby/throw.h"
+#include <mruby/opcode.h>
+#include <mruby/re.h>
+#include <mruby/throw.h>
+
+#ifndef MRB_CODEGEN_LEVEL_MAX
+#define MRB_CODEGEN_LEVEL_MAX 1024
+#endif
 
 typedef mrb_ast_node node;
@@ -74,4 +78,6 @@
   uint16_t filename_index;
   parser_state* parser;
+
+  int rlev;                     /* recursion levels */
 } codegen_scope;
 
@@ -94,8 +100,9 @@
   while (s->prev) {
     codegen_scope *tmp = s->prev;
+    mrb_free(s->mrb, s->iseq);
     mrb_pool_close(s->mpool);
     s = tmp;
   }
-#ifndef MBB_DISABLE_STDIO
+#ifndef MRB_DISABLE_STDIO
   if (s->filename && s->lineno) {
     fprintf(stderr, "codegen error:%s:%d: %s\n", s->filename, s->lineno, message);
@@ -340,4 +347,10 @@
         }
       }
+      if (c0 == OP_LOADNIL) {
+        if (GETARG_B(i) == GETARG_A(i0)) {
+          s->pc--;
+          return 0;
+        }
+      }
       break;
     case OP_JMPIF:
@@ -381,4 +394,7 @@
     scope_error(s);
     break;
+  }
+  if (diff > MAXARG_sBx) {
+    codegen_error(s, "too distant jump address");
   }
   s->iseq[pc] = MKOP_AsBx(c, GETARG_A(i), diff);
@@ -495,5 +511,10 @@
 }
 
-static inline int
+/* method symbols should be fit in 9 bits */
+#define MAXMSYMLEN 512
+/* maximum symbol numbers */
+#define MAXSYMLEN 65536
+
+static int
 new_msym(codegen_scope *s, mrb_sym sym)
 {
@@ -503,11 +524,11 @@
 
   len = s->irep->slen;
-  if (len > 256) len = 256;
+  if (len > MAXMSYMLEN) len = MAXMSYMLEN;
   for (i=0; i<len; i++) {
     if (s->irep->syms[i] == sym) return i;
     if (s->irep->syms[i] == 0) break;
   }
-  if (i == 256) {
-    codegen_error(s, "too many symbols (max 256)");
+  if (i == MAXMSYMLEN) {
+    codegen_error(s, "too many symbols (max " MRB_STRINGIZE(MAXMSYMLEN) ")");
   }
   s->irep->syms[i] = sym;
@@ -516,5 +537,5 @@
 }
 
-static inline int
+static int
 new_sym(codegen_scope *s, mrb_sym sym)
 {
@@ -524,11 +545,16 @@
     if (s->irep->syms[i] == sym) return i;
   }
-  if (s->irep->slen > 125 && s->irep->slen < 256) {
-    s->irep->syms = (mrb_sym *)codegen_realloc(s, s->irep->syms, sizeof(mrb_sym)*65536);
-    for (i = 0; i < 256 - s->irep->slen; i++) {
+  if (s->irep->slen == MAXSYMLEN) {
+    codegen_error(s, "too many symbols (max " MRB_STRINGIZE(MAXSYMLEN) ")");
+  }
+
+  if (s->irep->slen > MAXMSYMLEN/2 && s->scapa == MAXMSYMLEN) {
+    s->scapa = MAXSYMLEN;
+    s->irep->syms = (mrb_sym *)codegen_realloc(s, s->irep->syms, sizeof(mrb_sym)*MAXSYMLEN);
+    for (i = s->irep->slen; i < MAXMSYMLEN; i++) {
       static const mrb_sym mrb_sym_zero = { 0 };
-      s->irep->syms[i + s->irep->slen] = mrb_sym_zero;
-    }
-    s->irep->slen = 256;
+      s->irep->syms[i] = mrb_sym_zero;
+    }
+    s->irep->slen = MAXMSYMLEN;
   }
   s->irep->syms[s->irep->slen] = sym;
@@ -583,7 +609,4 @@
   push();                       /* push for a block parameter */
 
-  lp = loop_push(s, LOOP_FOR);
-  lp->pc1 = new_label(s);
-
   /* generate loop variable */
   n2 = tree->car;
@@ -595,4 +618,9 @@
     gen_vmassignment(s, n2, 1, VAL);
   }
+  /* construct loop */
+  lp = loop_push(s, LOOP_FOR);
+  lp->pc2 = new_label(s);
+
+  /* loop body */
   codegen(s, tree->cdr->cdr->car, VAL);
   pop();
@@ -645,4 +673,7 @@
     ba = tree->car->cdr->cdr->cdr->cdr ? 1 : 0;
 
+    if (ma > 0x1f || oa > 0x1f || pa > 0x1f || ka > 0x1f) {
+      codegen_error(s, "too many formal arguments");
+    }
     a = ((mrb_aspec)(ma & 0x1f) << 18)
       | ((mrb_aspec)(oa & 0x1f) << 13)
@@ -765,6 +796,8 @@
 }
 
+#define CALL_MAXARGS 127
+
 static int
-gen_values(codegen_scope *s, node *t, int val)
+gen_values(codegen_scope *s, node *t, int val, int extra)
 {
   int n = 0;
@@ -773,16 +806,24 @@
   while (t) {
     is_splat = (intptr_t)t->car->car == NODE_SPLAT; /* splat mode */
-    if (n >= 127 || is_splat) {
+    if (
+      n+extra >= CALL_MAXARGS - 1 /* need to subtract one because vm.c expects an array if n == CALL_MAXARGS */
+      || is_splat) {
       if (val) {
-        pop_n(n);
-        genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), n));
-        push();
-        codegen(s, t->car, VAL);
-        pop(); pop();
-        if (is_splat) {
-          genop(s, MKOP_AB(OP_ARYCAT, cursp(), cursp()+1));
+        if (is_splat && n == 0 && (intptr_t)t->car->cdr->car == NODE_ARRAY) {
+          codegen(s, t->car->cdr, VAL);
+          pop();
         }
         else {
-          genop(s, MKOP_AB(OP_ARYPUSH, cursp(), cursp()+1));
+          pop_n(n);
+          genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), n));
+          push();
+          codegen(s, t->car, VAL);
+          pop(); pop();
+          if (is_splat) {
+            genop(s, MKOP_AB(OP_ARYCAT, cursp(), cursp()+1));
+          }
+          else {
+            genop(s, MKOP_AB(OP_ARYPUSH, cursp(), cursp()+1));
+          }
         }
         t = t->cdr;
@@ -801,6 +842,4 @@
       }
       else {
-        codegen(s, t->car->cdr, NOVAL);
-        t = t->cdr;
         while (t) {
           codegen(s, t->car, NOVAL);
@@ -818,18 +857,27 @@
 }
 
-#define CALL_MAXARGS 127
-
 static void
-gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val)
+gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe)
 {
   mrb_sym sym = name ? name : sym(tree->cdr->car);
-  int idx;
+  int idx, skip = 0;
   int n = 0, noop = 0, sendv = 0, blk = 0;
 
   codegen(s, tree->car, VAL); /* receiver */
+  if (safe) {
+    int recv = cursp()-1;
+    genop(s, MKOP_A(OP_LOADNIL, cursp()));
+    push();
+    genop(s, MKOP_AB(OP_MOVE, cursp(), recv));
+    push(); pop();              /* space for a block */
+    pop();
+    idx = new_msym(s, mrb_intern_lit(s->mrb, "=="));
+    genop(s, MKOP_ABC(OP_EQ, cursp(), idx, 1));
+    skip = genop(s, MKOP_AsBx(OP_JMPIF, cursp(), 0));
+  }
   idx = new_msym(s, sym);
   tree = tree->cdr->cdr->car;
   if (tree) {
-    n = gen_values(s, tree->car, VAL);
+    n = gen_values(s, tree->car, VAL, sp?1:0);
     if (n < 0) {
       n = noop = sendv = 1;
@@ -863,29 +911,29 @@
     const char *symname = mrb_sym2name_len(s->mrb, sym, &symlen);
 
-    if (!noop && symlen == 1 && symname[0] == '+')  {
+    if (!noop && symlen == 1 && symname[0] == '+' && n == 1)  {
       genop_peep(s, MKOP_ABC(OP_ADD, cursp(), idx, n), val);
     }
-    else if (!noop && symlen == 1 && symname[0] == '-')  {
+    else if (!noop && symlen == 1 && symname[0] == '-' && n == 1)  {
       genop_peep(s, MKOP_ABC(OP_SUB, cursp(), idx, n), val);
     }
-    else if (!noop && symlen == 1 && symname[0] == '*')  {
+    else if (!noop && symlen == 1 && symname[0] == '*' && n == 1)  {
       genop(s, MKOP_ABC(OP_MUL, cursp(), idx, n));
     }
-    else if (!noop && symlen == 1 && symname[0] == '/')  {
+    else if (!noop && symlen == 1 && symname[0] == '/' && n == 1)  {
       genop(s, MKOP_ABC(OP_DIV, cursp(), idx, n));
     }
-    else if (!noop && symlen == 1 && symname[0] == '<')  {
+    else if (!noop && symlen == 1 && symname[0] == '<' && n == 1)  {
       genop(s, MKOP_ABC(OP_LT, cursp(), idx, n));
     }
-    else if (!noop && symlen == 2 && symname[0] == '<' && symname[1] == '=')  {
+    else if (!noop && symlen == 2 && symname[0] == '<' && symname[1] == '=' && n == 1)  {
       genop(s, MKOP_ABC(OP_LE, cursp(), idx, n));
     }
-    else if (!noop && symlen == 1 && symname[0] == '>')  {
+    else if (!noop && symlen == 1 && symname[0] == '>' && n == 1)  {
       genop(s, MKOP_ABC(OP_GT, cursp(), idx, n));
     }
-    else if (!noop && symlen == 2 && symname[0] == '>' && symname[1] == '=')  {
+    else if (!noop && symlen == 2 && symname[0] == '>' && symname[1] == '=' && n == 1)  {
       genop(s, MKOP_ABC(OP_GE, cursp(), idx, n));
     }
-    else if (!noop && symlen == 2 && symname[0] == '=' && symname[1] == '=')  {
+    else if (!noop && symlen == 2 && symname[0] == '=' && symname[1] == '=' && n == 1)  {
       genop(s, MKOP_ABC(OP_EQ, cursp(), idx, n));
     }
@@ -900,4 +948,7 @@
     }
   }
+  if (safe) {
+    dispatch(s, skip);
+  }
   if (val) {
     push();
@@ -912,5 +963,5 @@
 
   tree = tree->cdr;
-  switch ((intptr_t)type) {
+  switch (type) {
   case NODE_GVAR:
     idx = new_sym(s, sym(tree));
@@ -962,6 +1013,8 @@
 
   case NODE_CALL:
+  case NODE_SCALL:
     push();
-    gen_call(s, tree, attrsym(s, sym(tree->cdr->car)), sp, NOVAL);
+    gen_call(s, tree, attrsym(s, sym(tree->cdr->car)), sp, NOVAL,
+             type == NODE_SCALL);
     pop();
     if (val) {
@@ -980,5 +1033,5 @@
   default:
 #ifndef MRB_DISABLE_STDIO
-    printf("unknown lhs %d\n", type);
+    fprintf(stderr, "unknown lhs %d\n", type);
 #endif
     break;
@@ -1033,5 +1086,7 @@
       }
     }
-    push();
+    if (!val) {
+      push();
+    }
   }
 }
@@ -1176,10 +1231,37 @@
 
 static void
+gen_retval(codegen_scope *s, node *tree)
+{
+  if ((intptr_t)tree->car == NODE_SPLAT) {
+    genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), 0));
+    push();
+    codegen(s, tree, VAL);
+    pop(); pop();
+    genop(s, MKOP_AB(OP_ARYCAT, cursp(), cursp()+1));
+  }
+  else {
+    codegen(s, tree, VAL);
+    pop();
+  }
+}
+
+static void
 codegen(codegen_scope *s, node *tree, int val)
 {
   int nt;
-
-  if (!tree) return;
-
+  int rlev = s->rlev;
+
+  if (!tree) {
+    if (val) {
+      genop(s, MKOP_A(OP_LOADNIL, cursp()));
+      push();
+    }
+    return;
+  }
+
+  s->rlev++;
+  if (s->rlev > MRB_CODEGEN_LEVEL_MAX) {
+    codegen_error(s, "too complex expression");
+  }
   if (s->irep && s->filename_index != tree->filename_index) {
     s->irep->filename = mrb_parser_get_filename(s->parser, s->filename_index);
@@ -1210,11 +1292,10 @@
       struct loopinfo *lp;
 
+      if (tree->car == NULL) goto exit;
       onerr = genop(s, MKOP_Bx(OP_ONERR, 0));
       lp = loop_push(s, LOOP_BEGIN);
       lp->pc1 = onerr;
-      if (tree->car) {
-        codegen(s, tree->car, val);
-        if (val) pop();
-      }
+      codegen(s, tree->car, VAL);
+      pop();
       lp->type = LOOP_RESCUE;
       noexc = genop(s, MKOP_Bx(OP_JMP, 0));
@@ -1227,5 +1308,5 @@
         int exc = cursp();
 
-        genop(s, MKOP_A(OP_RESCUE, exc));
+        genop(s, MKOP_ABC(OP_RESCUE, exc, 0, 0));
         push();
         while (n2) {
@@ -1236,18 +1317,20 @@
           pos2 = 0;
           do {
-            if (n4) {
+            if (n4 && n4->car && (intptr_t)n4->car->car == NODE_SPLAT) {
               codegen(s, n4->car, VAL);
-            }
-            else {
-              genop(s, MKOP_ABx(OP_GETCONST, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "StandardError"))));
-              push();
-            }
-            genop(s, MKOP_AB(OP_MOVE, cursp(), exc));
-            pop();
-            if (n4 && n4->car && (intptr_t)n4->car->car == NODE_SPLAT) {
+              genop(s, MKOP_AB(OP_MOVE, cursp(), exc));
+              pop();
               genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "__case_eqq")), 1));
             }
             else {
-              genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "===")), 1));
+              if (n4) {
+                codegen(s, n4->car, VAL);
+              }
+              else {
+                genop(s, MKOP_ABx(OP_GETCONST, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "StandardError"))));
+                push();
+              }
+              pop();
+              genop(s, MKOP_ABC(OP_RESCUE, exc, cursp(), 1));
             }
             tmp = genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2));
@@ -1294,5 +1377,7 @@
 
   case NODE_ENSURE:
-    {
+    if (!tree->cdr || !tree->cdr->cdr ||
+        ((intptr_t)tree->cdr->cdr->car == NODE_BEGIN &&
+         tree->cdr->cdr->cdr)) {
       int idx;
       int epush = s->pc;
@@ -1306,8 +1391,11 @@
       genop_peep(s, MKOP_A(OP_EPOP, 1), NOVAL);
     }
+    else {                      /* empty ensure ignored */
+      codegen(s, tree->car, val);
+    }
     break;
 
   case NODE_LAMBDA:
-    {
+    if (val) {
       int idx = lambda_body(s, tree, 1);
 
@@ -1318,5 +1406,5 @@
 
   case NODE_BLOCK:
-    {
+    if (val) {
       int idx = lambda_body(s, tree, 1);
 
@@ -1331,4 +1419,8 @@
       node *e = tree->cdr->cdr->car;
 
+      if (!tree->car) {
+        codegen(s, e, val);
+        goto exit;
+      }
       switch ((intptr_t)tree->car->car) {
       case NODE_TRUE:
@@ -1336,9 +1428,9 @@
       case NODE_STR:
         codegen(s, tree->cdr->car, val);
-        return;
+        goto exit;
       case NODE_FALSE:
       case NODE_NIL:
         codegen(s, e, val);
-        return;
+        goto exit;
       }
       codegen(s, tree->car, VAL);
@@ -1347,8 +1439,4 @@
 
       codegen(s, tree->cdr->car, val);
-      if (val && !(tree->cdr->car)) {
-        genop(s, MKOP_A(OP_LOADNIL, cursp()));
-        push();
-      }
       if (e) {
         if (val) pop();
@@ -1485,5 +1573,7 @@
         if (pos3) dispatch_linked(s, pos3);
         if (head) pop();
-        genop(s, MKOP_AB(OP_MOVE, cursp(), pos));
+        if (cursp() != pos) {
+          genop(s, MKOP_AB(OP_MOVE, cursp(), pos));
+        }
         push();
       }
@@ -1505,5 +1595,8 @@
   case NODE_FCALL:
   case NODE_CALL:
-    gen_call(s, tree, 0, 0, val);
+    gen_call(s, tree, 0, 0, val, 0);
+    break;
+  case NODE_SCALL:
+    gen_call(s, tree, 0, 0, val, 1);
     break;
 
@@ -1553,5 +1646,5 @@
       int n;
 
-      n = gen_values(s, tree, val);
+      n = gen_values(s, tree, val, 0);
       if (n >= 0) {
         if (val) {
@@ -1602,5 +1695,5 @@
 
   case NODE_SPLAT:
-    codegen(s, tree, VAL);
+    codegen(s, tree, val);
     break;
 
@@ -1617,5 +1710,5 @@
       int rhs = cursp();
 
-      if ((intptr_t)t->car == NODE_ARRAY && nosplat(t->cdr)) {
+      if ((intptr_t)t->car == NODE_ARRAY && t->cdr && nosplat(t->cdr)) {
         /* fixed rhs */
         t = t->cdr;
@@ -1630,6 +1723,12 @@
           n = 0;
           while (t) {
-            gen_assignment(s, t->car, rhs+n, NOVAL);
-            n++;
+            if (n < len) {
+              gen_assignment(s, t->car, rhs+n, NOVAL);
+              n++;
+            }
+            else {
+              genop(s, MKOP_A(OP_LOADNIL, rhs+n));
+              gen_assignment(s, t->car, rhs+n, NOVAL);
+            }
             t = t->cdr;
           }
@@ -1688,7 +1787,70 @@
       mrb_int len;
       const char *name = mrb_sym2name_len(s->mrb, sym, &len);
-      int idx;
-
-      codegen(s, tree->car, VAL);
+      int idx, callargs = -1, vsp = -1;
+
+      if ((len == 2 && name[0] == '|' && name[1] == '|') &&
+          ((intptr_t)tree->car->car == NODE_CONST ||
+           (intptr_t)tree->car->car == NODE_CVAR)) {
+        int onerr, noexc, exc;
+        struct loopinfo *lp;
+
+        onerr = genop(s, MKOP_Bx(OP_ONERR, 0));
+        lp = loop_push(s, LOOP_BEGIN);
+        lp->pc1 = onerr;
+        exc = cursp();
+        codegen(s, tree->car, VAL);
+        lp->type = LOOP_RESCUE;
+        genop(s, MKOP_A(OP_POPERR, 1));
+        noexc = genop(s, MKOP_Bx(OP_JMP, 0));
+        dispatch(s, onerr);
+        genop(s, MKOP_ABC(OP_RESCUE, exc, 0, 0));
+        genop(s, MKOP_A(OP_LOADF, exc));
+        dispatch(s, noexc);
+        loop_pop(s, NOVAL);
+      }
+      else if ((intptr_t)tree->car->car == NODE_CALL) {
+        node *n = tree->car->cdr;
+
+        if (val) {
+          vsp = cursp();
+          push();
+        }
+        codegen(s, n->car, VAL);   /* receiver */
+        idx = new_msym(s, sym(n->cdr->car));
+        if (n->cdr->cdr->car) {
+          int base = cursp()-1;
+          int nargs = gen_values(s, n->cdr->cdr->car->car, VAL, 1);
+
+          /* copy receiver and arguments */
+          if (nargs >= 0) {
+            int i;
+
+            genop(s, MKOP_AB(OP_MOVE, cursp(), base));
+            for (i=0; i<nargs; i++) {
+              genop(s, MKOP_AB(OP_MOVE, cursp()+i+1, base+i+1));
+            }
+            push_n(nargs+1);
+            pop_n(nargs+1);
+            callargs = nargs;
+          }
+          else {
+            /* varargs */
+            push();
+            genop(s, MKOP_AB(OP_MOVE, cursp(), base));
+            genop(s, MKOP_AB(OP_MOVE, cursp()+1, base+1));
+            callargs = CALL_MAXARGS;
+          }
+          genop(s, MKOP_ABC(OP_SEND, cursp(), idx, callargs));
+        }
+        else {
+          genop(s, MKOP_AB(OP_MOVE, cursp(), cursp()-1));
+          genop(s, MKOP_ABC(OP_SEND, cursp(), idx, 0));
+          callargs = 0;
+        }
+        push();
+      }
+      else {
+        codegen(s, tree->car, VAL);
+      }
       if (len == 2 &&
           ((name[0] == '|' && name[1] == '|') ||
@@ -1697,10 +1859,39 @@
 
         pop();
-        pos = genop_peep(s, MKOP_AsBx(name[0] == '|' ? OP_JMPIF : OP_JMPNOT, cursp(), 0), NOVAL);
+        if (val) {
+          if (vsp >= 0) {
+            genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
+          }
+          pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0));
+        }
+        else {
+          pos = genop_peep(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0), NOVAL);
+        }
         codegen(s, tree->cdr->cdr->car, VAL);
         pop();
-        gen_assignment(s, tree->car, cursp(), val);
+        if (val && vsp >= 0) {
+          genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
+        }
+        if ((intptr_t)tree->car->car == NODE_CALL) {
+          mrb_sym m = sym(tree->car->cdr->cdr->car);
+          mrb_sym m2 = attrsym(s, m);
+
+          idx = new_msym(s, m2);
+          pop();
+          if (callargs == CALL_MAXARGS) {
+            genop(s, MKOP_AB(OP_ARYPUSH, cursp(), cursp()+1));
+            pop();
+            genop(s, MKOP_ABC(OP_SEND, cursp(), idx, callargs));
+          }
+          else {
+            pop_n(callargs);
+            genop(s, MKOP_ABC(OP_SEND, cursp(), idx, callargs+1));
+          }
+        }
+        else {
+          gen_assignment(s, tree->car, cursp(), val);
+        }
         dispatch(s, pos);
-        break;
+        goto exit;
       }
       codegen(s, tree->cdr->cdr->car, VAL);
@@ -1736,17 +1927,45 @@
         genop(s, MKOP_ABC(OP_SEND, cursp(), idx, 1));
       }
-    }
-    gen_assignment(s, tree->car, cursp(), val);
+      if (callargs < 0) {
+        gen_assignment(s, tree->car, cursp(), val);
+      }
+      else {
+        if (val && vsp >= 0) {
+          genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
+        }
+        if (callargs == CALL_MAXARGS) {
+          pop();
+          genop(s, MKOP_AB(OP_ARYPUSH, cursp(), cursp()+1));
+        }
+        else {
+          pop_n(callargs);
+          callargs++;
+        }
+        pop();
+        idx = new_msym(s, attrsym(s,sym(tree->car->cdr->cdr->car)));
+        genop(s, MKOP_ABC(OP_SEND, cursp(), idx, callargs));
+      }
+    }
     break;
 
   case NODE_SUPER:
     {
+      codegen_scope *s2 = s;
+      int lv = 0;
       int n = 0, noop = 0, sendv = 0;
 
       push();        /* room for receiver */
+      while (!s2->mscope) {
+        lv++;
+        s2 = s2->prev;
+        if (!s2) break;
+      }
+      genop(s, MKOP_ABx(OP_ARGARY, cursp(), (lv & 0xf)));
+      push(); push();         /* ARGARY pushes two values */
+      pop(); pop();
       if (tree) {
         node *args = tree->car;
         if (args) {
-          n = gen_values(s, args, VAL);
+          n = gen_values(s, args, VAL, 0);
           if (n < 0) {
             n = noop = sendv = 1;
@@ -1796,6 +2015,5 @@
   case NODE_RETURN:
     if (tree) {
-      codegen(s, tree, VAL);
-      pop();
+      gen_retval(s, tree);
     }
     else {
@@ -1823,8 +2041,7 @@
       }
       if (s2) ainfo = s2->ainfo;
-      genop(s, MKOP_ABx(OP_BLKPUSH, cursp(), (ainfo<<4)|(lv & 0xf)));
       push();
       if (tree) {
-        n = gen_values(s, tree, VAL);
+        n = gen_values(s, tree, VAL, 0);
         if (n < 0) {
           n = sendv = 1;
@@ -1833,4 +2050,5 @@
       }
       pop_n(n+1);
+      genop(s, MKOP_ABx(OP_BLKPUSH, cursp(), (ainfo<<4)|(lv & 0xf)));
       if (sendv) n = CALL_MAXARGS;
       genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "call")), n));
@@ -1869,5 +2087,5 @@
 
   case NODE_REDO:
-    if (!s->loop) {
+    if (!s->loop || s->loop->type == LOOP_BEGIN || s->loop->type == LOOP_RESCUE) {
       raise_error(s, "unexpected redo");
     }
@@ -1878,4 +2096,5 @@
       genop(s, MKOP_sBx(OP_JMP, s->loop->pc2 - s->pc));
     }
+    if (val) push();
     break;
 
@@ -1912,4 +2131,5 @@
         }
       }
+      if (val) push();
     }
     break;
@@ -1984,25 +2204,23 @@
   case NODE_BACK_REF:
     if (val) {
-      char buf[2] = { '$' };
+      char buf[3];
+      int sym;
+
+      buf[0] = '$';
+      buf[1] = (char)(intptr_t)tree;
+      buf[2] = 0;
+      sym = new_sym(s, mrb_intern_cstr(s->mrb, buf));
+      genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
+      push();
+    }
+    break;
+
+  case NODE_NTH_REF:
+    if (val) {
+      mrb_state *mrb = s->mrb;
       mrb_value str;
       int sym;
 
-      buf[1] = (char)(intptr_t)tree;
-      str = mrb_str_new(s->mrb, buf, 2);
-      sym = new_sym(s, mrb_intern_str(s->mrb, str));
-      genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
-      push();
-    }
-    break;
-
-  case NODE_NTH_REF:
-    if (val) {
-      int sym;
-      mrb_state *mrb = s->mrb;
-      mrb_value fix = mrb_fixnum_value((intptr_t)tree);
-      mrb_value str = mrb_str_buf_new(mrb, 4);
-
-      mrb_str_cat_lit(mrb, str, "$");
-      mrb_str_cat_str(mrb, str, mrb_fixnum_to_str(mrb, fix, 10));
+      str = mrb_format(mrb, "$%S", mrb_fixnum_value((mrb_int)(intptr_t)tree));
       sym = new_sym(s, mrb_intern_str(mrb, str));
       genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
@@ -2051,5 +2269,5 @@
     if (val) {
       char *p = (char*)tree;
-      mrb_float f = str_to_mrb_float(p);
+      mrb_float f = mrb_float_read(p, NULL);
       int off = new_lit(s, mrb_float_value(s->mrb, f));
 
@@ -2065,7 +2283,7 @@
       switch (nt) {
       case NODE_FLOAT:
-        {
+        if (val) {
           char *p = (char*)tree;
-          mrb_float f = str_to_mrb_float(p);
+          mrb_float f = mrb_float_read(p, NULL);
           int off = new_lit(s, mrb_float_value(s->mrb, -f));
 
@@ -2076,5 +2294,5 @@
 
       case NODE_INT:
-        {
+        if (val) {
           char *p = (char*)tree->car;
           int base = (intptr_t)tree->cdr->car;
@@ -2105,5 +2323,5 @@
 
       default:
-        {
+        if (val) {
           int sym = new_msym(s, mrb_intern_lit(s->mrb, "-"));
 
@@ -2113,4 +2331,7 @@
           pop(); pop();
           genop(s, MKOP_ABC(OP_SUB, cursp(), sym, 2));
+        }
+        else {
+          codegen(s, tree, NOVAL);
         }
         break;
@@ -2139,5 +2360,9 @@
       node *n = tree;
 
-      if (!n) break;
+      if (!n) {
+        genop(s, MKOP_A(OP_LOADNIL, cursp()));
+        push();
+        break;
+      }
       codegen(s, n->car, VAL);
       n = n->cdr;
@@ -2176,7 +2401,5 @@
       int sym = new_sym(s, mrb_intern_lit(s->mrb, "Kernel"));
 
-      if (val == NOVAL) { push(); }
-      genop(s, MKOP_A(OP_OCLASS, cursp()));
-      genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
+      genop(s, MKOP_A(OP_LOADSELF, cursp()));
       push();
       codegen(s, tree->car, VAL);
@@ -2193,10 +2416,9 @@
         n = n->cdr;
       }
-      pop();
-      pop();
+      push();                   /* for block */
+      pop_n(3);
       sym = new_sym(s, mrb_intern_lit(s->mrb, "`"));
       genop(s, MKOP_ABC(OP_SEND, cursp(), sym, 1));
-      if (val == NOVAL) { pop(); }
-      else { push(); }
+      if (val) push();
       mrb_gc_arena_restore(s->mrb, ai);
     }
@@ -2208,17 +2430,15 @@
       size_t len = (intptr_t)tree->cdr;
       int ai = mrb_gc_arena_save(s->mrb);
-      int sym = new_sym(s, mrb_intern_lit(s->mrb, "Kernel"));
       int off = new_lit(s, mrb_str_new(s->mrb, p, len));
-
-      if (val == NOVAL) { push(); }
-      genop(s, MKOP_A(OP_OCLASS, cursp()));
-      genop(s, MKOP_ABx(OP_GETMCNST, cursp(), sym));
+      int sym;
+
+      genop(s, MKOP_A(OP_LOADSELF, cursp()));
       push();
       genop(s, MKOP_ABx(OP_STRING, cursp(), off));
-      pop();
+      push(); push();
+      pop_n(3);
       sym = new_sym(s, mrb_intern_lit(s->mrb, "`"));
       genop(s, MKOP_ABC(OP_SEND, cursp(), sym, 1));
-      if (val == NOVAL) { pop(); }
-      else { push(); }
+      if (val) push();
       mrb_gc_arena_restore(s->mrb, ai);
     }
@@ -2244,5 +2464,6 @@
           off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
           genop(s, MKOP_ABx(OP_STRING, cursp(), off));
-        } else {
+        }
+        else {
           genop(s, MKOP_A(OP_LOADNIL, cursp()));
         }
@@ -2295,6 +2516,6 @@
         genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
       }
-      if (n->cdr) {
-        char *p2 = (char*)n->cdr;
+      if (n->cdr->car) {
+        char *p2 = (char*)n->cdr->car;
 
         push();
@@ -2302,7 +2523,14 @@
         genop(s, MKOP_ABx(OP_STRING, cursp(), off));
         argc++;
-        pop();
-      }
-      pop();
+      }
+      if (n->cdr->cdr) {
+        char *p2 = (char*)n->cdr->cdr;
+
+        push();
+        off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
+        genop(s, MKOP_ABx(OP_STRING, cursp(), off));
+        argc++;
+      }
+      pop_n(argc);
       sym = new_sym(s, mrb_intern_lit(s->mrb, "compile"));
       genop(s, MKOP_ABC(OP_SEND, cursp(), sym, argc));
@@ -2379,5 +2607,6 @@
       push();
       genop(s, MKOP_A(OP_LOADNIL, cursp()));
-      pop_n(3);
+      push();
+      pop_n(4);
       genop(s, MKOP_ABC(OP_SEND, cursp(), c, 2));
       if (val) {
@@ -2396,5 +2625,20 @@
       push();
       while (t) {
-        int symbol = new_msym(s, sym(t->car));
+        int symbol;
+        if (num >= CALL_MAXARGS - 1) {
+          pop_n(num);
+          genop(s, MKOP_ABC(OP_ARRAY, cursp(), cursp(), num));
+          while (t) {
+            symbol = new_msym(s, sym(t->car));
+            push();
+            genop(s, MKOP_ABx(OP_LOADSYM, cursp(), symbol));
+            pop();
+            genop(s, MKOP_AB(OP_ARYPUSH, cursp(), cursp()+1));
+            t = t->cdr;
+          }
+          num = CALL_MAXARGS;
+          break;
+        }
+        symbol = new_msym(s, sym(t->car));
         genop(s, MKOP_ABx(OP_LOADSYM, cursp(), symbol));
         push();
@@ -2402,5 +2646,8 @@
         num++;
       }
-      pop_n(num + 1);
+      pop();
+      if (num < CALL_MAXARGS) {
+        pop_n(num);
+      }
       genop(s, MKOP_ABC(OP_SEND, cursp(), undef, num));
       if (val) {
@@ -2529,4 +2776,6 @@
     break;
   }
+ exit:
+  s->rlev = rlev;
 }
 
@@ -2570,5 +2819,5 @@
   p->icapa = 1024;
   p->iseq = (mrb_code*)mrb_malloc(mrb, sizeof(mrb_code)*p->icapa);
-  p->irep->iseq = p->iseq;
+  p->irep->iseq = NULL;
 
   p->pcapa = 32;
@@ -2576,5 +2825,5 @@
   p->irep->plen = 0;
 
-  p->scapa = 256;
+  p->scapa = MAXMSYMLEN;
   p->irep->syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*p->scapa);
   p->irep->slen = 0;
@@ -2620,4 +2869,6 @@
   p->filename_index = prev->filename_index;
 
+  p->rlev = prev->rlev+1;
+
   return p;
 }
@@ -2646,6 +2897,6 @@
   irep->reps = (mrb_irep**)codegen_realloc(s, irep->reps, sizeof(mrb_irep*)*irep->rlen);
   if (s->filename) {
-    s->irep->filename = mrb_parser_get_filename(s->parser, s->filename_index);
-    mrb_debug_info_append_file(mrb, s->irep, s->debug_start_pos, s->pc);
+    irep->filename = mrb_parser_get_filename(s->parser, s->filename_index);
+    mrb_debug_info_append_file(mrb, irep, s->debug_start_pos, s->pc);
 
     fname_len = strlen(s->filename);
@@ -2654,4 +2905,5 @@
     fname[fname_len] = '\0';
     irep->filename = fname;
+    irep->own_filename = TRUE;
   }
 
@@ -2689,6 +2941,5 @@
 
     if (tree) {
-      codegen(s, tree, VAL);
-      pop();
+      gen_retval(s, tree);
     }
 
@@ -2702,5 +2953,6 @@
     }
     if (!loop) {
-      codegen_error(s, "unexpected break");
+      raise_error(s, "unexpected break");
+      return;
     }
 
@@ -2718,4 +2970,7 @@
     }
     else {
+      if (!tree) {
+        genop(s, MKOP_A(OP_LOADNIL, cursp()));
+      }
       genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_BREAK));
     }
@@ -2726,8 +2981,8 @@
 loop_pop(codegen_scope *s, int val)
 {
+  dispatch_linked(s, s->loop->pc3);
   if (val) {
     genop(s, MKOP_A(OP_LOADNIL, cursp()));
   }
-  dispatch_linked(s, s->loop->pc3);
   s->loop = s->loop->prev;
   if (val) push();
@@ -2739,4 +2994,5 @@
   codegen_scope *scope = scope_new(mrb, 0, 0);
   struct RProc *proc;
+  struct mrb_jmpbuf *prev_jmp = mrb->jmp;
 
   if (!scope) {
@@ -2749,4 +3005,5 @@
 
   MRB_TRY(&scope->jmp) {
+    mrb->jmp = &scope->jmp; 
     /* prepare irep */
     codegen(scope, p->tree, NOVAL);
@@ -2754,12 +3011,12 @@
     mrb_irep_decref(mrb, scope->irep);
     mrb_pool_close(scope->mpool);
+    proc->c = NULL;
+    mrb->jmp = prev_jmp;
     return proc;
   }
   MRB_CATCH(&scope->jmp) {
-    if (scope->filename == scope->irep->filename) {
-      scope->irep->filename = NULL;
-    }
     mrb_irep_decref(mrb, scope->irep);
     mrb_pool_close(scope->mpool);
+    mrb->jmp = prev_jmp;
     return NULL;
   }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/core/node.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-compiler/core/node.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/core/node.h	(revision 331)
@@ -5,6 +5,6 @@
 */
 
-#ifndef NODE_H
-#define NODE_H
+#ifndef MRUBY_COMPILER_NODE_H
+#define MRUBY_COMPILER_NODE_H
 
 enum node_type {
@@ -39,4 +39,5 @@
   NODE_OP_ASGN,
   NODE_CALL,
+  NODE_SCALL,
   NODE_FCALL,
   NODE_VCALL,
@@ -115,3 +116,3 @@
 };
 
-#endif  /* NODE_H */
+#endif  /* MRUBY_COMPILER_NODE_H */
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/core/parse.y
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-compiler/core/parse.y	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/core/parse.y	(revision 331)
@@ -23,10 +23,10 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/compile.h"
-#include "mruby/proc.h"
-#include "mruby/error.h"
+#include <mruby.h>
+#include <mruby/compile.h>
+#include <mruby/proc.h>
+#include <mruby/error.h>
+#include <mruby/throw.h>
 #include "node.h"
-#include "mruby/throw.h"
 
 #define YYLEX_PARAM p
@@ -42,4 +42,5 @@
 static void yywarning(parser_state *p, const char *s);
 static void backref_error(parser_state *p, node *n);
+static void void_expr_error(parser_state *p, node *n);
 static void tokadd(parser_state *p, int32_t c);
 
@@ -73,4 +74,6 @@
 #define sym(x) ((mrb_sym)(intptr_t)(x))
 #define nsym(x) ((node*)(intptr_t)(x))
+#define nint(x) ((node*)(intptr_t)(x))
+#define intn(x) ((int)(intptr_t)(x))
 
 static inline mrb_sym
@@ -309,4 +312,10 @@
 }
 
+static node*
+new_mod_rescue(parser_state *p, node *body, node *resq)
+{
+  return new_rescue(p, body, list1(list3(0, 0, resq)), 0);
+}
+
 /* (:ensure body ensure) */
 static node*
@@ -348,4 +357,5 @@
 new_if(parser_state *p, node *a, node *b, node *c)
 {
+  void_expr_error(p, a);
   return list4((node*)NODE_IF, a, b, c);
 }
@@ -355,4 +365,5 @@
 new_unless(parser_state *p, node *a, node *b, node *c)
 {
+  void_expr_error(p, a);
   return list4((node*)NODE_IF, a, c, b);
 }
@@ -362,4 +373,5 @@
 new_while(parser_state *p, node *a, node *b)
 {
+  void_expr_error(p, a);
   return cons((node*)NODE_WHILE, cons(a, b));
 }
@@ -369,4 +381,5 @@
 new_until(parser_state *p, node *a, node *b)
 {
+  void_expr_error(p, a);
   return cons((node*)NODE_UNTIL, cons(a, b));
 }
@@ -376,4 +389,5 @@
 new_for(parser_state *p, node *v, node *o, node *b)
 {
+  void_expr_error(p, o);
   return list4((node*)NODE_FOR, v, o, b);
 }
@@ -386,4 +400,5 @@
   node *n2 = n;
 
+  void_expr_error(p, a);
   while (n2->cdr) {
     n2 = n2->cdr;
@@ -409,7 +424,8 @@
 /* (:call a b c) */
 static node*
-new_call(parser_state *p, node *a, mrb_sym b, node *c)
-{
-  node *n = list4((node*)NODE_CALL, a, nsym(b), c);
+new_call(parser_state *p, node *a, mrb_sym b, node *c, int pass)
+{
+  node *n = list4(nint(pass?NODE_CALL:NODE_SCALL), a, nsym(b), c);
+  void_expr_error(p, a);
   NODE_LINENO(n, a);
   return n;
@@ -507,4 +523,5 @@
 new_colon2(parser_state *p, node *b, mrb_sym c)
 {
+  void_expr_error(p, b);
   return cons((node*)NODE_COLON2, cons(b, nsym(c)));
 }
@@ -614,4 +631,5 @@
 new_class(parser_state *p, node *c, node *s, node *b)
 {
+  void_expr_error(p, s);
   return list4((node*)NODE_CLASS, c, s, cons(locals_node(p), b));
 }
@@ -621,4 +639,5 @@
 new_sclass(parser_state *p, node *o, node *b)
 {
+  void_expr_error(p, o);
   return list3((node*)NODE_SCLASS, o, cons(locals_node(p), b));
 }
@@ -642,4 +661,5 @@
 new_sdef(parser_state *p, node *o, mrb_sym m, node *a, node *b)
 {
+  void_expr_error(p, o);
   return list6((node*)NODE_SDEF, o, nsym(m), locals_node(p), a, b);
 }
@@ -694,4 +714,5 @@
 new_asgn(parser_state *p, node *a, node *b)
 {
+  void_expr_error(p, b);
   return cons((node*)NODE_ASGN, cons(a, b));
 }
@@ -701,4 +722,5 @@
 new_masgn(parser_state *p, node *a, node *b)
 {
+  void_expr_error(p, b);
   return cons((node*)NODE_MASGN, cons(a, b));
 }
@@ -708,4 +730,5 @@
 new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b)
 {
+  void_expr_error(p, b);
   return list4((node*)NODE_OP_ASGN, a, nsym(op), b);
 }
@@ -715,5 +738,5 @@
 new_int(parser_state *p, const char *s, int base)
 {
-  return list3((node*)NODE_INT, (node*)strdup(s), (node*)(intptr_t)base);
+  return list3((node*)NODE_INT, (node*)strdup(s), nint(base));
 }
 
@@ -729,5 +752,5 @@
 new_str(parser_state *p, const char *s, int len)
 {
-  return cons((node*)NODE_STR, cons((node*)strndup(s, len), (node*)(intptr_t)len));
+  return cons((node*)NODE_STR, cons((node*)strndup(s, len), nint(len)));
 }
 
@@ -743,5 +766,5 @@
 new_xstr(parser_state *p, const char *s, int len)
 {
-  return cons((node*)NODE_XSTR, cons((node*)strndup(s, len), (node*)(intptr_t)len));
+  return cons((node*)NODE_XSTR, cons((node*)strndup(s, len), nint(len)));
 }
 
@@ -760,5 +783,5 @@
 }
 
-/* (:str . (a . a)) */
+/* (:regx . (s . (opt . enc))) */
 static node*
 new_regx(parser_state *p, const char *p1, const char* p2, const char* p3)
@@ -767,5 +790,5 @@
 }
 
-/* (:dregx . a) */
+/* (:dregx . (a . b)) */
 static node*
 new_dregx(parser_state *p, node *a, node *b)
@@ -778,5 +801,5 @@
 new_back_ref(parser_state *p, int n)
 {
-  return cons((node*)NODE_BACK_REF, (node*)(intptr_t)n);
+  return cons((node*)NODE_BACK_REF, nint(n));
 }
 
@@ -785,5 +808,5 @@
 new_nth_ref(parser_state *p, int n)
 {
-  return cons((node*)NODE_NTH_REF, (node*)(intptr_t)n);
+  return cons((node*)NODE_NTH_REF, nint(n));
 }
 
@@ -827,5 +850,6 @@
 call_uni_op(parser_state *p, node *recv, const char *m)
 {
-  return new_call(p, recv, intern_cstr(m), 0);
+  void_expr_error(p, recv);
+  return new_call(p, recv, intern_cstr(m), 0, 1);
 }
 
@@ -834,5 +858,5 @@
 call_bin_op(parser_state *p, node *recv, const char *m, node *arg1)
 {
-  return new_call(p, recv, intern_cstr(m), list1(list1(arg1)));
+  return new_call(p, recv, intern_cstr(m), list1(list1(arg1)), 1);
 }
 
@@ -853,12 +877,15 @@
   node *n;
 
-  if (a->car == (node*)NODE_SUPER ||
-      a->car == (node*)NODE_ZSUPER) {
+  switch ((enum node_type)intn(a->car)) {
+  case NODE_SUPER:
+  case NODE_ZSUPER:
     if (!a->cdr) a->cdr = cons(0, b);
     else {
       args_with_block(p, a->cdr, b);
     }
-  }
-  else {
+    break;
+  case NODE_CALL:
+  case NODE_FCALL:
+  case NODE_SCALL:
     n = a->cdr->cdr->cdr;
     if (!n->car) n->car = cons(0, b);
@@ -866,4 +893,7 @@
       args_with_block(p, n->car, b);
     }
+    break;
+  default:
+    break;
   }
 }
@@ -895,5 +925,5 @@
 assignable(parser_state *p, node *lhs)
 {
-  if ((int)(intptr_t)lhs->car == NODE_LVAR) {
+  if (intn(lhs->car) == NODE_LVAR) {
     local_add(p, sym(lhs->cdr));
   }
@@ -905,5 +935,5 @@
   node *n;
 
-  if ((int)(intptr_t)lhs->car == NODE_LVAR) {
+  if (intn(lhs->car) == NODE_LVAR) {
     if (!local_var_p(p, sym(lhs->cdr))) {
       n = new_fcall(p, sym(lhs->cdr), 0);
@@ -921,5 +951,5 @@
 new_strterm(parser_state *p, string_type type, int term, int paren)
 {
-  return cons((node*)(intptr_t)type, cons((node*)0, cons((node*)(intptr_t)paren, (node*)(intptr_t)term)));
+  return cons(nint(type), cons((node*)0, cons(nint(paren), nint(term))));
 }
 
@@ -1002,8 +1032,8 @@
   else {
     /* next heredoc */
-    p->lex_strterm->car = (node*)(intptr_t)parsing_heredoc_inf(p)->type;
-  }
-}
-#define is_strterm_type(p,str_func) ((int)(intptr_t)((p)->lex_strterm->car) & (str_func))
+    p->lex_strterm->car = nint(parsing_heredoc_inf(p)->type);
+  }
+}
+#define is_strterm_type(p,str_func) (intn((p)->lex_strterm->car) & (str_func))
 
 /* xxx ----------------------------- */
@@ -1077,5 +1107,5 @@
 %token <id>  tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
 %token <nd>  tINTEGER tFLOAT tCHAR tXSTRING tREGEXP
-%token <nd>  tSTRING tSTRING_PART tSTRING_MID
+%token <nd>  tSTRING tSTRING_PART tSTRING_MID tLABEL_END
 %token <nd>  tNTH_REF tBACK_REF
 %token <num> tREGEXP_END
@@ -1085,10 +1115,10 @@
 %type <nd> top_compstmt top_stmts top_stmt
 %type <nd> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
-%type <nd> expr_value arg_value primary_value
+%type <nd> expr_value arg_rhs primary_value
 %type <nd> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
 %type <nd> args call_args opt_call_args
 %type <nd> paren_args opt_paren_args variable
 %type <nd> command_args aref_args opt_block_arg block_arg var_ref var_lhs
-%type <nd> command_asgn mrhs superclass block_call block_command
+%type <nd> command_asgn command_rhs mrhs superclass block_call block_command
 %type <nd> f_block_optarg f_block_opt
 %type <nd> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
@@ -1101,4 +1131,5 @@
 %type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_opt_asgn
 %type <nd> heredoc words symbols
+%type <num> call_op call_op2     /* 0:'&.', 1:'.', 2:'::' */
 
 %token tUPLUS             /* unary+ */
@@ -1129,4 +1160,5 @@
 %token tAMPER             /* & */
 %token tLAMBDA            /* -> */
+%token tANDDOT            /* &. */
 %token tSYMBEG tREGEXP_BEG tWORDS_BEG tSYMBOLS_BEG
 %token tSTRING_BEG tXSTRING_BEG tSTRING_DVAR tLAMBEG
@@ -1292,9 +1324,9 @@
                 | stmt modifier_rescue stmt
                     {
-                      $$ = new_rescue(p, $1, list1(list3(0, 0, $3)), 0);
+                      $$ = new_mod_rescue(p, $1, $3);
                     }
                 | keyword_END '{' compstmt '}'
                     {
-                      yyerror(p, "END not suported");
+                      yyerror(p, "END not supported");
                       $$ = new_postexe(p, $3);
                     }
@@ -1304,19 +1336,38 @@
                       $$ = new_masgn(p, $1, $3);
                     }
-                | var_lhs tOP_ASGN command_call
+                | lhs '=' mrhs
+                    {
+                      $$ = new_asgn(p, $1, new_array(p, $3));
+                    }
+                | mlhs '=' arg
+                    {
+                      $$ = new_masgn(p, $1, $3);
+                    }
+                | mlhs '=' mrhs
+                    {
+                      $$ = new_masgn(p, $1, new_array(p, $3));
+                    }
+                | expr
+                ;
+
+command_asgn    : lhs '=' command_rhs
+                    {
+                      $$ = new_asgn(p, $1, $3);
+                    }
+                | var_lhs tOP_ASGN command_rhs
                     {
                       $$ = new_op_asgn(p, $1, $2, $3);
                     }
-                | primary_value '[' opt_call_args rbracket tOP_ASGN command_call
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, intern("[]",2), $3), $5, $6);
-                    }
-                | primary_value '.' tIDENTIFIER tOP_ASGN command_call
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0), $4, $5);
-                    }
-                | primary_value '.' tCONSTANT tOP_ASGN command_call
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0), $4, $5);
+                | primary_value '[' opt_call_args rbracket tOP_ASGN command_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, intern("[]",2), $3, '.'), $5, $6);
+                    }
+                | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0, $2), $4, $5);
+                    }
+                | primary_value call_op tCONSTANT tOP_ASGN command_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0, $2), $4, $5);
                     }
                 | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
@@ -1325,36 +1376,21 @@
                       $$ = 0;
                     }
-                | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0), $4, $5);
-                    }
-                | backref tOP_ASGN command_call
+                | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0, tCOLON2), $4, $5);
+                    }
+                | backref tOP_ASGN command_rhs
                     {
                       backref_error(p, $1);
                       $$ = new_begin(p, 0);
                     }
-                | lhs '=' mrhs
-                    {
-                      $$ = new_asgn(p, $1, new_array(p, $3));
-                    }
-                | mlhs '=' arg_value
-                    {
-                      $$ = new_masgn(p, $1, $3);
-                    }
-                | mlhs '=' mrhs
-                    {
-                      $$ = new_masgn(p, $1, new_array(p, $3));
-                    }
-                | expr
-                ;
-
-command_asgn    : lhs '=' command_call
-                    {
-                      $$ = new_asgn(p, $1, $3);
-                    }
-                | lhs '=' command_asgn
-                    {
-                      $$ = new_asgn(p, $1, $3);
-                    }
+		;
+
+command_rhs     : command_call   %prec tOP_ASGN
+                | command_call modifier_rescue stmt
+                    {
+                      $$ = new_mod_rescue(p, $1, $3);
+                    }
+                | command_asgn
                 ;
 
@@ -1383,5 +1419,7 @@
                     {
                       if (!$1) $$ = new_nil(p);
-                      else $$ = $1;
+                      else {
+                        $$ = $1;
+                      }
                     }
                 ;
@@ -1392,5 +1430,8 @@
 
 block_command   : block_call
-                | block_call dot_or_colon operation2 command_args
+                | block_call call_op2 operation2 command_args
+                    {
+                      $$ = new_call(p, $1, $3, $4, $2);
+                    }
                 ;
 
@@ -1417,21 +1458,21 @@
                       $$ = new_fcall(p, $1, $2);
                     }
-                | primary_value '.' operation2 command_args     %prec tLOWEST
-                    {
-                      $$ = new_call(p, $1, $3, $4);
-                    }
-                | primary_value '.' operation2 command_args cmd_brace_block
+                | primary_value call_op operation2 command_args     %prec tLOWEST
+                    {
+                      $$ = new_call(p, $1, $3, $4, $2);
+                    }
+                | primary_value call_op operation2 command_args cmd_brace_block
                     {
                       args_with_block(p, $4, $5);
-                      $$ = new_call(p, $1, $3, $4);
+                      $$ = new_call(p, $1, $3, $4, $2);
                    }
                 | primary_value tCOLON2 operation2 command_args %prec tLOWEST
                     {
-                      $$ = new_call(p, $1, $3, $4);
+                      $$ = new_call(p, $1, $3, $4, tCOLON2);
                     }
                 | primary_value tCOLON2 operation2 command_args cmd_brace_block
                     {
                       args_with_block(p, $4, $5);
-                      $$ = new_call(p, $1, $3, $4);
+                      $$ = new_call(p, $1, $3, $4, tCOLON2);
                     }
                 | keyword_super command_args
@@ -1549,17 +1590,17 @@
                 | primary_value '[' opt_call_args rbracket
                     {
-                      $$ = new_call(p, $1, intern("[]",2), $3);
-                    }
-                | primary_value '.' tIDENTIFIER
-                    {
-                      $$ = new_call(p, $1, $3, 0);
+                      $$ = new_call(p, $1, intern("[]",2), $3, '.');
+                    }
+                | primary_value call_op tIDENTIFIER
+                    {
+                      $$ = new_call(p, $1, $3, 0, $2);
                     }
                 | primary_value tCOLON2 tIDENTIFIER
                     {
-                      $$ = new_call(p, $1, $3, 0);
-                    }
-                | primary_value '.' tCONSTANT
-                    {
-                      $$ = new_call(p, $1, $3, 0);
+                      $$ = new_call(p, $1, $3, 0, tCOLON2);
+                    }
+                | primary_value call_op tCONSTANT
+                    {
+                      $$ = new_call(p, $1, $3, 0, $2);
                     }
                 | primary_value tCOLON2 tCONSTANT
@@ -1588,17 +1629,17 @@
                 | primary_value '[' opt_call_args rbracket
                     {
-                      $$ = new_call(p, $1, intern("[]",2), $3);
-                    }
-                | primary_value '.' tIDENTIFIER
-                    {
-                      $$ = new_call(p, $1, $3, 0);
+                      $$ = new_call(p, $1, intern("[]",2), $3, '.');
+                    }
+                | primary_value call_op tIDENTIFIER
+                    {
+                      $$ = new_call(p, $1, $3, 0, $2);
                     }
                 | primary_value tCOLON2 tIDENTIFIER
                     {
-                      $$ = new_call(p, $1, $3, 0);
-                    }
-                | primary_value '.' tCONSTANT
-                    {
-                      $$ = new_call(p, $1, $3, 0);
+                      $$ = new_call(p, $1, $3, 0, tCOLON2);
+                    }
+                | primary_value call_op tCONSTANT
+                    {
+                      $$ = new_call(p, $1, $3, 0, $2);
                     }
                 | primary_value tCOLON2 tCONSTANT
@@ -1638,4 +1679,5 @@
                 | primary_value tCOLON2 cname
                     {
+                      void_expr_error(p, $1);
                       $$ = cons($1, nsym($3));
                     }
@@ -1716,47 +1758,39 @@
                 ;
 
-arg             : lhs '=' arg
+arg             : lhs '=' arg_rhs
                     {
                       $$ = new_asgn(p, $1, $3);
                     }
-                | lhs '=' arg modifier_rescue arg
-                    {
-                      $$ = new_asgn(p, $1, new_rescue(p, $3, list1(list3(0, 0, $5)), 0));
-                    }
-                | var_lhs tOP_ASGN arg
+                | var_lhs tOP_ASGN arg_rhs
                     {
                       $$ = new_op_asgn(p, $1, $2, $3);
                     }
-                | var_lhs tOP_ASGN arg modifier_rescue arg
-                    {
-                      $$ = new_op_asgn(p, $1, $2, new_rescue(p, $3, list1(list3(0, 0, $5)), 0));
-                    }
-                | primary_value '[' opt_call_args rbracket tOP_ASGN arg
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, intern("[]",2), $3), $5, $6);
-                    }
-                | primary_value '.' tIDENTIFIER tOP_ASGN arg
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0), $4, $5);
-                    }
-                | primary_value '.' tCONSTANT tOP_ASGN arg
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0), $4, $5);
-                    }
-                | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
-                    {
-                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0), $4, $5);
-                    }
-                | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
+                | primary_value '[' opt_call_args rbracket tOP_ASGN arg_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, intern("[]",2), $3, '.'), $5, $6);
+                    }
+                | primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0, $2), $4, $5);
+                    }
+                | primary_value call_op tCONSTANT tOP_ASGN arg_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0, $2), $4, $5);
+                    }
+                | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
+                    {
+                      $$ = new_op_asgn(p, new_call(p, $1, $3, 0, tCOLON2), $4, $5);
+                    }
+                | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
                     {
                       yyerror(p, "constant re-assignment");
                       $$ = new_begin(p, 0);
                     }
-                | tCOLON3 tCONSTANT tOP_ASGN arg
+                | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
                     {
                       yyerror(p, "constant re-assignment");
                       $$ = new_begin(p, 0);
                     }
-                | backref tOP_ASGN arg
+                | backref tOP_ASGN arg_rhs
                     {
                       backref_error(p, $1);
@@ -1897,11 +1931,4 @@
                 ;
 
-arg_value       : arg
-                    {
-                      $$ = $1;
-                      if (!$$) $$ = new_nil(p);
-                    }
-                ;
-
 aref_args       : none
                 | args trailer
@@ -1910,5 +1937,5 @@
                       NODE_LINENO($$, $1);
                     }
-                | args ',' assocs trailer
+                | args comma assocs trailer
                     {
                       $$ = push($1, new_hash(p, $3));
@@ -1918,4 +1945,16 @@
                       $$ = cons(new_hash(p, $1), 0);
                       NODE_LINENO($$, $1);
+                    }
+                ;
+
+arg_rhs         : arg %prec tOP_ASGN
+                    {
+                      $$ = $1;
+                    }
+                | arg modifier_rescue arg
+                    {
+                      void_expr_error(p, $1);
+                      void_expr_error(p, $3);
+                      $$ = new_mod_rescue(p, $1, $3);
                     }
                 ;
@@ -1938,5 +1977,5 @@
                       NODE_LINENO($$, $1);
                     }
-                | args ',' assocs ','
+                | args comma assocs ','
                     {
                       $$ = cons(push($1, new_hash(p, $3)), 0);
@@ -1952,4 +1991,5 @@
 call_args       : command
                     {
+                      void_expr_error(p, $1);
                       $$ = cons(list1($1), 0);
                       NODE_LINENO($$, $1);
@@ -1965,5 +2005,5 @@
                       NODE_LINENO($$, $1);
                     }
-                | args ',' assocs opt_block_arg
+                | args comma assocs opt_block_arg
                     {
                       $$ = cons(push($1, new_hash(p, $3)), $4);
@@ -1988,5 +2028,5 @@
                 ;
 
-block_arg       : tAMPER arg_value
+block_arg       : tAMPER arg
                     {
                       $$ = new_block_arg(p, $2);
@@ -1994,5 +2034,5 @@
                 ;
 
-opt_block_arg   : ',' block_arg
+opt_block_arg   : comma block_arg
                     {
                       $$ = $2;
@@ -2004,42 +2044,45 @@
                 ;
 
-args            : arg_value
-                    {
+comma           : ','
+                | ','  heredoc_bodies
+                ;
+
+args            : arg
+                    {
+                      void_expr_error(p, $1);
                       $$ = cons($1, 0);
                       NODE_LINENO($$, $1);
                     }
-                | tSTAR arg_value
-                    {
+                | tSTAR arg
+                    {
+                      void_expr_error(p, $2);
                       $$ = cons(new_splat(p, $2), 0);
                       NODE_LINENO($$, $2);
                     }
-                | args ',' arg_value
-                    {
+                | args comma arg
+                    {
+                      void_expr_error(p, $3);
                       $$ = push($1, $3);
                     }
-                | args ',' tSTAR arg_value
-                    {
+                | args comma tSTAR arg
+                    {
+                      void_expr_error(p, $4);
                       $$ = push($1, new_splat(p, $4));
                     }
-                | args ',' heredoc_bodies arg_value
-                    {
-                      $$ = push($1, $4);
-                    }
-                | args ',' heredoc_bodies tSTAR arg_value
-                    {
-                      $$ = push($1, new_splat(p, $5));
-                    }
-                ;
-
-mrhs            : args ',' arg_value
-                    {
+                ;
+
+mrhs            : args comma arg
+                    {
+                      void_expr_error(p, $3);
                       $$ = push($1, $3);
                     }
-                | args ',' tSTAR arg_value
-                    {
+                | args comma tSTAR arg
+                    {
+                      void_expr_error(p, $4);
                       $$ = push($1, new_splat(p, $4));
                     }
-                | tSTAR arg_value
-                    {
+                | tSTAR arg
+                    {
+                      void_expr_error(p, $2);
                       $$ = list1(new_splat(p, $2));
                     }
@@ -2073,5 +2116,5 @@
                       p->cmdarg_stack = 0;
                     }
-                  expr {p->lstate = EXPR_ENDARG;} rparen
+                  stmt {p->lstate = EXPR_ENDARG;} rparen
                     {
                       p->cmdarg_stack = $<stack>2;
@@ -2080,5 +2123,5 @@
                 | tLPAREN_ARG {p->lstate = EXPR_ENDARG;} rparen
                     {
-                      $$ = 0;
+                      $$ = new_nil(p);
                     }
                 | tLPAREN compstmt ')'
@@ -2108,15 +2151,7 @@
                       $$ = new_return(p, 0);
                     }
-                | keyword_yield '(' call_args rparen
-                    {
-                      $$ = new_yield(p, $3);
-                    }
-                | keyword_yield '(' rparen
-                    {
-                      $$ = new_yield(p, 0);
-                    }
-                | keyword_yield
-                    {
-                      $$ = new_yield(p, 0);
+                | keyword_yield opt_paren_args
+                    {
+                      $$ = new_yield(p, $2);
                     }
                 | keyword_not '(' expr rparen
@@ -2229,5 +2264,5 @@
                   term
                     {
-                      $<nd>$ = cons(local_switch(p), (node*)(intptr_t)p->in_single);
+                      $<nd>$ = cons(local_switch(p), nint(p->in_single));
                       p->in_single = 0;
                     }
@@ -2239,5 +2274,5 @@
                       local_resume(p, $<nd>6->car);
                       p->in_def = $<num>4;
-                      p->in_single = (int)(intptr_t)$<nd>6->cdr;
+                      p->in_single = intn($<nd>6->cdr);
                     }
                 | keyword_module
@@ -2433,5 +2468,5 @@
                 | f_arg ','
                     {
-                      $$ = new_args(p, $1, 0, 1, 0, 0);
+                      $$ = new_args(p, $1, 0, 0, 0, 0);
                     }
                 | f_arg ',' f_rest_arg ',' f_arg opt_f_block_arg
@@ -2561,16 +2596,16 @@
                       $$ = $1;
                     }
-                | block_call dot_or_colon operation2 opt_paren_args
-                    {
-                      $$ = new_call(p, $1, $3, $4);
-                    }
-                | block_call dot_or_colon operation2 opt_paren_args brace_block
-                    {
-                      $$ = new_call(p, $1, $3, $4);
+                | block_call call_op2 operation2 opt_paren_args
+                    {
+                      $$ = new_call(p, $1, $3, $4, $2);
+                    }
+                | block_call call_op2 operation2 opt_paren_args brace_block
+                    {
+                      $$ = new_call(p, $1, $3, $4, $2);
                       call_with_block(p, $$, $5);
                     }
-                | block_call dot_or_colon operation2 command_args do_block
-                    {
-                      $$ = new_call(p, $1, $3, $4);
+                | block_call call_op2 operation2 command_args do_block
+                    {
+                      $$ = new_call(p, $1, $3, $4, $2);
                       call_with_block(p, $$, $5);
                     }
@@ -2581,23 +2616,23 @@
                       $$ = new_fcall(p, $1, $2);
                     }
-                | primary_value '.' operation2 opt_paren_args
-                    {
-                      $$ = new_call(p, $1, $3, $4);
+                | primary_value call_op operation2 opt_paren_args
+                    {
+                      $$ = new_call(p, $1, $3, $4, $2);
                     }
                 | primary_value tCOLON2 operation2 paren_args
                     {
-                      $$ = new_call(p, $1, $3, $4);
+                      $$ = new_call(p, $1, $3, $4, tCOLON2);
                     }
                 | primary_value tCOLON2 operation3
                     {
-                      $$ = new_call(p, $1, $3, 0);
-                    }
-                | primary_value '.' paren_args
-                    {
-                      $$ = new_call(p, $1, intern("call",4), $3);
+                      $$ = new_call(p, $1, $3, 0, tCOLON2);
+                    }
+                | primary_value call_op paren_args
+                    {
+                      $$ = new_call(p, $1, intern("call",4), $3, $2);
                     }
                 | primary_value tCOLON2 paren_args
                     {
-                      $$ = new_call(p, $1, intern("call",4), $3);
+                      $$ = new_call(p, $1, intern("call",4), $3, tCOLON2);
                     }
                 | keyword_super paren_args
@@ -2611,5 +2646,5 @@
                 | primary_value '[' opt_call_args rbracket
                     {
-                      $$ = new_call(p, $1, intern("[]",2), $3);
+                      $$ = new_call(p, $1, intern("[]",2), $3, '.');
                     }
                 ;
@@ -2671,5 +2706,5 @@
                 ;
 
-exc_list        : arg_value
+exc_list        : arg
                     {
                         $$ = list1($1);
@@ -2766,8 +2801,4 @@
                 ;
 
-opt_heredoc_bodies : /* none */
-                   | heredoc_bodies
-                   ;
-
 heredoc_bodies  : heredoc_body
                 | heredoc_bodies heredoc_body
@@ -2825,5 +2856,5 @@
                       $$ = new_sym(p, $1);
                     }
-                | tSYMBEG tSTRING_BEG string_interp tSTRING
+                | tSYMBEG tSTRING_BEG string_rep tSTRING
                     {
                       p->lstate = EXPR_END;
@@ -2925,8 +2956,9 @@
                 | keyword__FILE__
                     {
-                      if (!p->filename) {
-                        p->filename = "(null)";
+                      const char *fn = p->filename;
+                      if (!fn) {
+                        fn = "(null)";
                       }
-                      $$ = new_str(p, p->filename, strlen(p->filename));
+                      $$ = new_str(p, fn, strlen(fn));
                     }
                 | keyword__LINE__
@@ -2955,5 +2987,5 @@
                     {
                       $$ = $3;
-                    } /* 
+                    } /*
                 | error term
                     {
@@ -3098,6 +3130,7 @@
                 ;
 
-f_opt           : f_opt_asgn arg_value
-                    {
+f_opt           : f_opt_asgn arg
+                    {
+                      void_expr_error(p, $2);
                       $$ = cons(nsym($1), $2);
                     }
@@ -3106,4 +3139,5 @@
 f_block_opt     : f_opt_asgn primary_value
                     {
+                      void_expr_error(p, $2);
                       $$ = cons(nsym($1), $2);
                     }
@@ -3179,5 +3213,5 @@
                       }
                       else {
-                        switch ((enum node_type)(int)(intptr_t)$3->car) {
+                        switch ((enum node_type)intn($3->car)) {
                         case NODE_STR:
                         case NODE_DSTR:
@@ -3216,11 +3250,29 @@
                 ;
 
-assoc           : arg_value tASSOC arg_value
-                    {
+assoc           : arg tASSOC arg
+                    {
+                      void_expr_error(p, $1);
+                      void_expr_error(p, $3);
                       $$ = cons($1, $3);
                     }
-                | tLABEL arg_value
-                    {
+                | tLABEL arg
+                    {
+                      void_expr_error(p, $2);
                       $$ = cons(new_sym(p, $1), $2);
+                    }
+                | tLABEL_END arg
+                    {
+                      void_expr_error(p, $2);
+                      $$ = cons(new_sym(p, new_strsym(p, $1)), $2);
+                    }
+                | tSTRING_BEG tLABEL_END arg
+                    {
+                      void_expr_error(p, $3);
+                      $$ = cons(new_sym(p, new_strsym(p, $2)), $3);
+                    }
+                | tSTRING_BEG string_rep tLABEL_END arg
+                    {
+                      void_expr_error(p, $4);
+                      $$ = cons(new_dsym(p, push($2, $3)), $4);
                     }
                 ;
@@ -3246,4 +3298,21 @@
                 ;
 
+call_op         : '.'
+                    {
+                      $$ = '.';
+                    }
+                | tANDDOT
+                    {
+                      $$ = 0;
+                    }
+                ;
+
+call_op2        : call_op
+                | tCOLON2
+                    {
+                      $$ = tCOLON2;
+                    }
+                ;
+
 opt_terms       : /* none */
                 | terms
@@ -3262,9 +3331,10 @@
 trailer         : /* none */
                 | nl
-                | ','
+                | comma
                 ;
 
 term            : ';' {yyerrok;}
                 | nl
+                | heredoc_body
                 ;
 
@@ -3274,8 +3344,8 @@
                       p->column = 0;
                     }
-                  opt_heredoc_bodies
+                ;
 
 terms           : term
-                | terms ';' {yyerrok;}
+                | terms term
                 ;
 
@@ -3286,5 +3356,5 @@
                 ;
 %%
-#define yylval  (*((YYSTYPE*)(p->ylval)))
+#define pylval  (*((YYSTYPE*)(p->ylval)))
 
 static void
@@ -3374,5 +3444,5 @@
 
   if (c == NODE_NTH_REF) {
-    yyerror_i(p, "can't set variable $%d", (int)(intptr_t)n->cdr);
+    yyerror_i(p, "can't set variable $%" MRB_PRId, (mrb_int)(intptr_t)n->cdr);
   }
   else if (c == NODE_BACK_REF) {
@@ -3381,4 +3451,37 @@
   else {
     mrb_bug(p->mrb, "Internal error in backref_error() : n=>car == %S", mrb_fixnum_value(c));
+  }
+}
+
+static void
+void_expr_error(parser_state *p, node *n)
+{
+  int c;
+
+  if (n == NULL) return;
+  c = (int)(intptr_t)n->car;
+  switch (c) {
+  case NODE_BREAK:
+  case NODE_RETURN:
+  case NODE_NEXT:
+  case NODE_REDO:
+  case NODE_RETRY:
+    yyerror(p, "void value expression");
+    break;
+  case NODE_AND:
+  case NODE_OR:
+    void_expr_error(p, n->cdr->car);
+    void_expr_error(p, n->cdr->cdr);
+    break;
+  case NODE_BEGIN:
+    if (n->cdr) {
+      while (n->cdr) {
+        n = n->cdr;
+      }
+      void_expr_error(p, n->car);
+    }
+    break;
+  default:
+    break;
   }
 }
@@ -3469,4 +3572,5 @@
     c0 = nextc(p);
     if (c0 == -1) return c0;    /* do not skip partial EOF */
+    if (c0 >= 0) --p->column;
     list = push(list, (node*)(intptr_t)c0);
   } while(n--);
@@ -3517,5 +3621,5 @@
     for (;;) {
       c = nextc(p);
-      if (c < 0) return c;
+      if (c < 0) return FALSE;
       if (c == '\n') {
         p->lineno++;
@@ -3547,5 +3651,10 @@
 newtok(parser_state *p)
 {
-  p->bidx = 0;
+  if (p->tokbuf != p->buf) {
+    mrb_free(p->mrb, p->tokbuf);
+    p->tokbuf = p->buf;
+    p->tsiz = MRB_PARSER_TOKBUF_SIZE;
+  }
+  p->tidx = 0;
   return p->column - 1;
 }
@@ -3555,5 +3664,5 @@
 {
   char utf8[4];
-  unsigned len;
+  int i, len;
 
   /* mrb_assert(-0x10FFFF <= c && c <= 0xFF); */
@@ -3589,9 +3698,20 @@
     }
   }
-  if (p->bidx+len <= MRB_PARSER_BUF_SIZE) {
-    unsigned i;
-    for (i = 0; i < len; i++) {
-      p->buf[p->bidx++] = utf8[i];
-    }
+  if (p->tidx+len >= p->tsiz) {
+    if (p->tsiz >= MRB_PARSER_TOKBUF_MAX) {
+      p->tidx += len;
+      return;
+    }
+    p->tsiz *= 2;
+    if (p->tokbuf == p->buf) {
+      p->tokbuf = (char*)mrb_malloc(p->mrb, p->tsiz);
+      memcpy(p->tokbuf, p->buf, MRB_PARSER_TOKBUF_SIZE);
+    }
+    else {
+      p->tokbuf = (char*)mrb_realloc(p->mrb, p->tokbuf, p->tsiz);
+    }
+  }
+  for (i = 0; i < len; i++) {
+    p->tokbuf[p->tidx++] = utf8[i];
   }
 }
@@ -3600,5 +3720,5 @@
 toklast(parser_state *p)
 {
-  return p->buf[p->bidx-1];
+  return p->tokbuf[p->tidx-1];
 }
 
@@ -3606,11 +3726,9 @@
 tokfix(parser_state *p)
 {
-  int i = p->bidx, imax = MRB_PARSER_BUF_SIZE - 1;
-
-  if (i > imax) {
-    i = imax;
+  if (p->tidx >= MRB_PARSER_TOKBUF_MAX) {
+    p->tidx = MRB_PARSER_TOKBUF_MAX-1;
     yyerror(p, "string too long (truncated)");
   }
-  p->buf[i] = '\0';
+  p->tokbuf[p->tidx] = '\0';
 }
 
@@ -3618,5 +3736,5 @@
 tok(parser_state *p)
 {
-  return p->buf;
+  return p->tokbuf;
 }
 
@@ -3624,5 +3742,5 @@
 toklen(parser_state *p)
 {
-  return p->bidx;
+  return p->tidx;
 }
 
@@ -3667,4 +3785,42 @@
 
   return retval;
+}
+
+static int32_t
+read_escape_unicode(parser_state *p, int limit)
+{
+  int32_t c;
+  int buf[9];
+  int i;
+
+  /* Look for opening brace */
+  i = 0;
+  buf[0] = nextc(p);
+  if (buf[0] < 0) goto eof;
+  if (ISXDIGIT(buf[0])) {
+    /* \uxxxx form */
+    for (i=1; i<limit; i++) {
+      buf[i] = nextc(p);
+      if (buf[i] < 0) goto eof;
+      if (!ISXDIGIT(buf[i])) {
+        pushback(p, buf[i]);
+        break;
+      }
+    }
+  }
+  else {
+    pushback(p, buf[0]);
+  }
+  c = scan_hex(buf, i, &i);
+  if (i == 0) {
+  eof:
+    yyerror(p, "Invalid escape character syntax");
+    return -1;
+  }
+  if (c < 0 || c > 0x10FFFF || (c & 0xFFFFF800) == 0xD800) {
+    yyerror(p, "Invalid Unicode code point");
+    return -1;
+  }
+  return c;
 }
 
@@ -3741,51 +3897,15 @@
 
   case 'u':     /* Unicode */
-  {
-    int buf[9];
-    int i;
-
-    /* Look for opening brace */
-    i = 0;
-    buf[0] = nextc(p);
-    if (buf[0] < 0) goto eof;
-    if (buf[0] == '{') {
+    if (peek(p, '{')) {
       /* \u{xxxxxxxx} form */
-      for (i=0; i<9; i++) {
-        buf[i] = nextc(p);
-        if (buf[i] < 0) goto eof;
-        if (buf[i] == '}') {
-          break;
-        }
-        else if (!ISXDIGIT(buf[i])) {
-          yyerror(p, "Invalid escape character syntax");
-          pushback(p, buf[i]);
-          return 0;
-        }
-      }
-    }
-    else if (ISXDIGIT(buf[0])) {
-      /* \uxxxx form */
-      for (i=1; i<4; i++) {
-        buf[i] = nextc(p);
-        if (buf[i] < 0) goto eof;
-        if (!ISXDIGIT(buf[i])) {
-          pushback(p, buf[i]);
-          break;
-        }
-      }
+      nextc(p);
+      c = read_escape_unicode(p, 8);
+      if (c < 0) return 0;
+      if (nextc(p) != '}') goto eof;
     }
     else {
-      pushback(p, buf[0]);
-    }
-    c = scan_hex(buf, i, &i);
-    if (i == 0) {
-      yyerror(p, "Invalid escape character syntax");
-      return 0;
-    }
-    if (c < 0 || c > 0x10FFFF || (c & 0xFFFFF800) == 0xD800) {
-      yyerror(p, "Invalid Unicode code point");
-      return 0;
-    }
-  }
+      c = read_escape_unicode(p, 4);
+      if (c < 0) return 0;
+    }
   return -c;
 
@@ -3845,5 +3965,8 @@
   int end = (intptr_t)p->lex_strterm->cdr->cdr->cdr;
   parser_heredoc_info *hinf = (type & STR_FUNC_HEREDOC) ? parsing_heredoc_inf(p) : NULL;
-
+  int cmd_state = p->cmd_start;
+
+  if (beg == 0) beg = -3;       /* should never happen */
+  if (end == 0) end = -3;
   newtok(p);
   while ((c = nextc(p)) != end || nest_level != 0) {
@@ -3867,5 +3990,10 @@
         }
         if ((len-1 == hinf->term_len) && (strncmp(s, hinf->term, len-1) == 0)) {
-          return tHEREDOC_END;
+          if (c < 0) {
+            p->parsing_heredoc = NULL;
+          }
+          else {
+            return tHEREDOC_END;
+          }
         }
       }
@@ -3876,5 +4004,5 @@
         return 0;
       }
-      yylval.nd = new_str(p, tok(p), toklen(p));
+      pylval.nd = new_str(p, tok(p), toklen(p));
       return tHD_STRING_MID;
     }
@@ -3908,4 +4036,18 @@
           tokadd(p, c);
         }
+        else if (c == 'u' && peek(p, '{')) {
+          /* \u{xxxx xxxx xxxx} form */
+          nextc(p);
+          while (1) {
+            do c = nextc(p); while (ISSPACE(c));
+            if (c == '}') break;
+            pushback(p, c);
+            c = read_escape_unicode(p, 8);
+            if (c < 0) break;
+            tokadd(p, -c);
+          }
+          if (hinf)
+            hinf->line_head = FALSE;
+        }
         else {
           pushback(p, c);
@@ -3935,5 +4077,5 @@
         p->lstate = EXPR_BEG;
         p->cmd_start = TRUE;
-        yylval.nd = new_str(p, tok(p), toklen(p));
+        pylval.nd = new_str(p, tok(p), toklen(p));
         if (hinf) {
           hinf->line_head = FALSE;
@@ -3965,7 +4107,11 @@
         pushback(p, c);
         tokfix(p);
-        yylval.nd = new_str(p, tok(p), toklen(p));
+        pylval.nd = new_str(p, tok(p), toklen(p));
         return tSTRING_MID;
       }
+    }
+    if (c == '\n') {
+      p->lineno++;
+      p->column = 0;
     }
     tokadd(p, c);
@@ -3977,5 +4123,5 @@
 
   if (type & STR_FUNC_XQUOTE) {
-    yylval.nd = new_xstr(p, tok(p), toklen(p));
+    pylval.nd = new_xstr(p, tok(p), toklen(p));
     return tXSTRING;
   }
@@ -4019,18 +4165,27 @@
     if (flag > flags) {
       dup = strndup(flags, (size_t)(flag - flags));
-    } else {
+    }
+    else {
       dup = NULL;
     }
     if (enc) {
       encp = strndup(&enc, 1);
-    } else {
+    }
+    else {
       encp = NULL;
     }
-    yylval.nd = new_regx(p, s, dup, encp);
+    pylval.nd = new_regx(p, s, dup, encp);
 
     return tREGEXP;
   }
-
-  yylval.nd = new_str(p, tok(p), toklen(p));
+  pylval.nd = new_str(p, tok(p), toklen(p));
+  if (IS_LABEL_POSSIBLE()) {
+    if (IS_LABEL_SUFFIX(0)) {
+      p->lstate = EXPR_BEG;
+      nextc(p);
+      return tLABEL_END;
+    }
+  }
+
   return tSTRING;
 }
@@ -4102,5 +4257,5 @@
   p->lstate = EXPR_END;
 
-  yylval.nd = newnode;
+  pylval.nd = newnode;
   return tHEREDOC_BEG;
 }
@@ -4206,5 +4361,5 @@
     if ((c = nextc(p)) == '*') {
       if ((c = nextc(p)) == '=') {
-        yylval.id = intern("**",2);
+        pylval.id = intern("**",2);
         p->lstate = EXPR_BEG;
         return tOP_ASGN;
@@ -4215,5 +4370,5 @@
     else {
       if (c == '=') {
-        yylval.id = intern_c('*');
+        pylval.id = intern_c('*');
         p->lstate = EXPR_BEG;
         return tOP_ASGN;
@@ -4331,5 +4486,5 @@
     if (c == '<') {
       if ((c = nextc(p)) == '=') {
-        yylval.id = intern("<<",2);
+        pylval.id = intern("<<",2);
         p->lstate = EXPR_BEG;
         return tOP_ASGN;
@@ -4353,5 +4508,5 @@
     if (c == '>') {
       if ((c = nextc(p)) == '=') {
-        yylval.id = intern(">>",2);
+        pylval.id = intern(">>",2);
         p->lstate = EXPR_BEG;
         return tOP_ASGN;
@@ -4450,5 +4605,5 @@
     }
     tokfix(p);
-    yylval.nd = new_str(p, tok(p), toklen(p));
+    pylval.nd = new_str(p, tok(p), toklen(p));
     p->lstate = EXPR_END;
     return tCHAR;
@@ -4458,5 +4613,5 @@
       p->lstate = EXPR_BEG;
       if ((c = nextc(p)) == '=') {
-        yylval.id = intern("&&",2);
+        pylval.id = intern("&&",2);
         p->lstate = EXPR_BEG;
         return tOP_ASGN;
@@ -4465,6 +4620,10 @@
       return tANDOP;
     }
+    else if (c == '.') {
+      p->lstate = EXPR_DOT;
+      return tANDDOT;
+    }
     else if (c == '=') {
-      yylval.id = intern_c('&');
+      pylval.id = intern_c('&');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -4493,5 +4652,5 @@
       p->lstate = EXPR_BEG;
       if ((c = nextc(p)) == '=') {
-        yylval.id = intern("||",2);
+        pylval.id = intern("||",2);
         p->lstate = EXPR_BEG;
         return tOP_ASGN;
@@ -4501,5 +4660,5 @@
     }
     if (c == '=') {
-      yylval.id = intern_c('|');
+      pylval.id = intern_c('|');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -4525,5 +4684,5 @@
     }
     if (c == '=') {
-      yylval.id = intern_c('+');
+      pylval.id = intern_c('+');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -4553,5 +4712,5 @@
     }
     if (c == '=') {
-      yylval.id = intern_c('-');
+      pylval.id = intern_c('-');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -4627,5 +4786,5 @@
         }
         else if (nondigit) goto trailing_uc;
-        yylval.nd = new_int(p, tok(p), 16);
+        pylval.nd = new_int(p, tok(p), 16);
         return tINTEGER;
       }
@@ -4651,5 +4810,5 @@
         }
         else if (nondigit) goto trailing_uc;
-        yylval.nd = new_int(p, tok(p), 2);
+        pylval.nd = new_int(p, tok(p), 2);
         return tINTEGER;
       }
@@ -4675,5 +4834,5 @@
         }
         else if (nondigit) goto trailing_uc;
-        yylval.nd = new_int(p, tok(p), 10);
+        pylval.nd = new_int(p, tok(p), 10);
         return tINTEGER;
       }
@@ -4708,5 +4867,5 @@
           tokfix(p);
           if (nondigit) goto trailing_uc;
-          yylval.nd = new_int(p, tok(p), 8);
+          pylval.nd = new_int(p, tok(p), 8);
           return tINTEGER;
         }
@@ -4725,5 +4884,5 @@
       else {
         pushback(p, c);
-        yylval.nd = new_int(p, "0", 10);
+        pylval.nd = new_int(p, "0", 10);
         return tINTEGER;
       }
@@ -4801,5 +4960,5 @@
 
       errno = 0;
-      d = strtod(tok(p), &endp);
+      d = mrb_float_read(tok(p), &endp);
       if (d == 0 && endp == tok(p)) {
         yywarning_s(p, "corrupted float value %s", tok(p));
@@ -4809,8 +4968,8 @@
         errno = 0;
       }
-      yylval.nd = new_float(p, tok(p));
+      pylval.nd = new_float(p, tok(p));
       return tFLOAT;
     }
-    yylval.nd = new_int(p, tok(p), 10);
+    pylval.nd = new_int(p, tok(p), 10);
     return tINTEGER;
   }
@@ -4854,5 +5013,5 @@
     }
     if ((c = nextc(p)) == '=') {
-      yylval.id = intern_c('/');
+      pylval.id = intern_c('/');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -4873,5 +5032,5 @@
   case '^':
     if ((c = nextc(p)) == '=') {
-      yylval.id = intern_c('^');
+      pylval.id = intern_c('^');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -5047,5 +5206,5 @@
     }
     if ((c = nextc(p)) == '=') {
-      yylval.id = intern_c('%');
+      pylval.id = intern_c('%');
       p->lstate = EXPR_BEG;
       return tOP_ASGN;
@@ -5101,5 +5260,5 @@
       tokadd(p, c);
       tokfix(p);
-      yylval.id = intern_cstr(tok(p));
+      pylval.id = intern_cstr(tok(p));
       return tGVAR;
 
@@ -5111,5 +5270,5 @@
       gvar:
       tokfix(p);
-      yylval.id = intern_cstr(tok(p));
+      pylval.id = intern_cstr(tok(p));
       return tGVAR;
 
@@ -5123,5 +5282,5 @@
         goto gvar;
       }
-      yylval.nd = new_back_ref(p, c);
+      pylval.nd = new_back_ref(p, c);
       return tBACK_REF;
 
@@ -5142,5 +5301,5 @@
           return 0;
         }
-        yylval.nd = new_nth_ref(p, (int)n);
+        pylval.nd = new_nth_ref(p, (int)n);
       }
       return tNTH_REF;
@@ -5166,5 +5325,5 @@
       }
       if (c < 0) {
-        if (p->bidx == 1) {
+        if (p->tidx == 1) {
           yyerror(p, "incomplete instance variable syntax");
         }
@@ -5175,5 +5334,5 @@
       }
       else if (isdigit(c)) {
-        if (p->bidx == 1) {
+        if (p->tidx == 1) {
           yyerror_i(p, "'@%c' is not allowed as an instance variable name", c);
         }
@@ -5270,5 +5429,5 @@
           nextc(p);
           tokfix(p);
-          yylval.id = intern_cstr(tok(p));
+          pylval.id = intern_cstr(tok(p));
           return tLABEL;
         }
@@ -5281,8 +5440,8 @@
         if (kw) {
           enum mrb_lex_state_enum state = p->lstate;
-          yylval.num = p->lineno;
+          pylval.num = p->lineno;
           p->lstate = kw->state;
           if (state == EXPR_FNAME) {
-            yylval.id = intern_cstr(kw->name);
+            pylval.id = intern_cstr(kw->name);
             return kw->id[0];
           }
@@ -5331,5 +5490,5 @@
       mrb_sym ident = intern_cstr(tok(p));
 
-      yylval.id = ident;
+      pylval.id = ident;
 #if 0
       if (last_state != EXPR_DOT && islower(tok(p)[0]) && lvar_defined(ident)) {
@@ -5396,8 +5555,9 @@
 mrb_parser_parse(parser_state *p, mrbc_context *c)
 {
-  struct mrb_jmpbuf buf;
-  p->jmp = &buf;
+  struct mrb_jmpbuf buf1;
+  p->jmp = &buf1;
 
   MRB_TRY(p->jmp) {
+    int n;
 
     p->cmd_start = TRUE;
@@ -5407,5 +5567,25 @@
 
     parser_init_cxt(p, c);
-    yyparse(p);
+
+    if (p->mrb->jmp) {
+      n = yyparse(p);
+    }
+    else {
+      struct mrb_jmpbuf buf2;
+
+      p->mrb->jmp = &buf2;
+      MRB_TRY(p->mrb->jmp) {
+        n = yyparse(p);
+      }
+      MRB_CATCH(p->mrb->jmp) {
+        p->nerr++;
+      }
+      MRB_END_EXC(p->mrb->jmp);
+      p->mrb->jmp = 0;
+    }
+    if (n != 0 || p->nerr > 0) {
+      p->tree = 0;
+      return;
+    }
     if (!p->tree) {
       p->tree = new_nil(p);
@@ -5415,5 +5595,4 @@
       mrb_parser_dump(p->mrb, p->tree, 0);
     }
-
   }
   MRB_CATCH(p->jmp) {
@@ -5443,5 +5622,5 @@
 
   p->s = p->send = NULL;
-#ifndef MRB_DISBLE_STDIO
+#ifndef MRB_DISABLE_STDIO
   p->f = NULL;
 #endif
@@ -5456,4 +5635,6 @@
   yydebug = 1;
 #endif
+  p->tsiz = MRB_PARSER_TOKBUF_SIZE;
+  p->tokbuf = p->buf;
 
   p->lex_strterm = NULL;
@@ -5470,4 +5651,7 @@
 MRB_API void
 mrb_parser_free(parser_state *p) {
+  if (p->tokbuf != p->buf) {
+    mrb_free(p->mrb, p->tokbuf);
+  }
   mrb_pool_close(p->pool);
 }
@@ -5482,4 +5666,5 @@
 mrbc_context_free(mrb_state *mrb, mrbc_context *cxt)
 {
+  mrb_free(mrb, cxt->filename);
   mrb_free(mrb, cxt->syms);
   mrb_free(mrb, cxt);
@@ -5491,7 +5676,10 @@
   if (s) {
     int len = strlen(s);
-    char *p = (char *)mrb_alloca(mrb, len + 1);
+    char *p = (char *)mrb_malloc(mrb, len + 1);
 
     memcpy(p, s, len + 1);
+    if (c->filename) {
+      mrb_free(mrb, c->filename);
+    }
     c->filename = p;
   }
@@ -5578,6 +5766,6 @@
 }
 
-static mrb_value
-load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
+MRB_API mrb_value
+mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
 {
   struct RClass *target = mrb->object_class;
@@ -5601,5 +5789,7 @@
     }
     else {
-      mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
+      if (mrb->exc == NULL) {
+        mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
+      }
       mrb_parser_free(p);
       return mrb_undef_value();
@@ -5609,5 +5799,7 @@
   mrb_parser_free(p);
   if (proc == NULL) {
-    mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
+    if (mrb->exc == NULL) {
+      mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
+    }
     return mrb_undef_value();
   }
@@ -5629,5 +5821,5 @@
     mrb->c->ci->target_class = target;
   }
-  v = mrb_toplevel_run_keep(mrb, proc, keep);
+  v = mrb_top_run(mrb, proc, mrb_top_self(mrb), keep);
   if (mrb->exc) return mrb_nil_value();
   return v;
@@ -5638,5 +5830,5 @@
 mrb_load_file_cxt(mrb_state *mrb, FILE *f, mrbc_context *c)
 {
-  return load_exec(mrb, mrb_parse_file(mrb, f, c), c);
+  return mrb_load_exec(mrb, mrb_parse_file(mrb, f, c), c);
 }
 
@@ -5651,5 +5843,5 @@
 mrb_load_nstring_cxt(mrb_state *mrb, const char *s, int len, mrbc_context *c)
 {
-  return load_exec(mrb, mrb_parse_nstring(mrb, s, len, c), c);
+  return mrb_load_exec(mrb, mrb_parse_nstring(mrb, s, len, c), c);
 }
 
@@ -5805,8 +5997,7 @@
         dump_recur(mrb, n->car, offset+2);
       }
-      n = n->cdr;
-      if (n) {
+      if (n->cdr) {
         dump_prefix(n, offset+1);
-        printf("blk=&%s\n", mrb_sym2name(mrb, sym(n)));
+        printf("blk=&%s\n", mrb_sym2name(mrb, sym(n->cdr)));
       }
     }
@@ -5946,5 +6137,15 @@
   case NODE_FCALL:
   case NODE_CALL:
-    printf("NODE_CALL:\n");
+  case NODE_SCALL:
+    switch (nodetype) {
+    case NODE_FCALL:
+      printf("NODE_FCALL:\n"); break;
+    case NODE_CALL:
+      printf("NODE_CALL(.):\n"); break;
+    case NODE_SCALL:
+      printf("NODE_SCALL(&.):\n"); break;
+    default:
+      break;
+    }
     mrb_parser_dump(mrb, tree->car, offset+1);
     dump_prefix(tree, offset+1);
@@ -6154,5 +6355,5 @@
 
   case NODE_NTH_REF:
-    printf("NODE_NTH_REF: $%d\n", (int)(intptr_t)tree);
+    printf("NODE_NTH_REF: $%" MRB_PRId "\n", (mrb_int)(intptr_t)tree);
     break;
 
@@ -6206,10 +6407,17 @@
     dump_prefix(tree, offset);
     printf("tail: %s\n", (char*)tree->cdr->cdr->car);
-    dump_prefix(tree, offset);
-    printf("opt: %s\n", (char*)tree->cdr->cdr->cdr);
+    if (tree->cdr->cdr->cdr->car) {
+      dump_prefix(tree, offset);
+      printf("opt: %s\n", (char*)tree->cdr->cdr->cdr->car);
+    }
+    if (tree->cdr->cdr->cdr->cdr) {
+      dump_prefix(tree, offset);
+      printf("enc: %s\n", (char*)tree->cdr->cdr->cdr->cdr);
+    }
     break;
 
   case NODE_SYM:
-    printf("NODE_SYM :%s\n", mrb_sym2name(mrb, sym(tree)));
+    printf("NODE_SYM :%s (%d)\n", mrb_sym2name(mrb, sym(tree)),
+           (int)(intptr_t)tree);
     break;
 
@@ -6425,6 +6633,6 @@
 
   case NODE_HEREDOC:
-    printf("NODE_HEREDOC:\n");
-    mrb_parser_dump(mrb, ((parser_heredoc_info*)tree)->doc, offset+1);
+    printf("NODE_HEREDOC (<<%s):\n", ((parser_heredoc_info*)tree)->term);
+    dump_recur(mrb, ((parser_heredoc_info*)tree)->doc, offset+1);
     break;
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-compiler/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-compiler/mrbgem.rake	(revision 331)
@@ -9,9 +9,9 @@
   lex_def = "#{current_dir}/core/lex.def"
   core_objs = Dir.glob("#{current_dir}/core/*.c").map { |f|
-    next nil if build.cxx_abi_enabled? and f =~ /(codegen).c$/
+    next nil if build.cxx_exception_enabled? and f =~ /(codegen).c$/
     objfile(f.pathmap("#{current_build_dir}/core/%n"))
   }.compact
 
-  if build.cxx_abi_enabled?
+  if build.cxx_exception_enabled?
     core_objs <<
       build.compile_as_cxx("#{current_build_dir}/core/y.tab.c", "#{current_build_dir}/core/y.tab.cxx",
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-ext/mrblib/enum.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enum-ext/mrblib/enum.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-ext/mrblib/enum.rb	(revision 331)
@@ -59,11 +59,12 @@
   def take(n)
     raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
-    raise ArgumentError, "attempt to take negative size" if n < 0
-
-    n = n.to_int
-    ary = []
-    self.each do |*val|
-      break if ary.size >= n
+    i = n.to_int
+    raise ArgumentError, "attempt to take negative size" if i < 0
+    ary = []
+    return ary if i == 0
+    self.each do |*val|
       ary << val.__svalue
+      i -= 1
+      break if i == 0
     end
     ary
@@ -124,4 +125,5 @@
       block.call(ary.dup) if ary.size == n
     end
+    nil
   end
 
@@ -154,4 +156,5 @@
     end
     block.call(ary) unless ary.empty?
+    nil
   end
 
@@ -215,19 +218,26 @@
   # If the enumerable is empty, the first form returns <code>nil</code>, and the
   # second form returns an empty array.
-  def first(n=NONE)
-    if n == NONE
+  def first(*args)
+    case args.length
+    when 0
       self.each do |*val|
         return val.__svalue
       end
       return nil
+    when 1
+      n = args[0]
+      raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
+      i = n.to_int
+      raise ArgumentError, "attempt to take negative size" if i < 0
+      ary = []
+      return ary if i == 0
+      self.each do |*val|
+        ary << val.__svalue
+        i -= 1
+        break if i == 0
+      end
+      ary
     else
-      a = []
-      i = 0
-      self.each do |*val|
-        break if n<=i
-        a.push val.__svalue
-        i += 1
-      end
-      a
+      raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0..1)"
     end
   end
@@ -385,9 +395,9 @@
         first = false
       else
+        val = val.__svalue
         if block
-          max = val.__svalue if block.call(*val, max) > 0
-          min = val.__svalue if block.call(*val, min) < 0
+          max = val if block.call(val, max) > 0
+          min = val if block.call(val, min) < 0
         else
-          val = val.__svalue
           max = val if (val <=> max) > 0
           min = val if (val <=> min) < 0
@@ -574,33 +584,36 @@
   #
 
-  def cycle(n=nil, &block)
-    return to_enum(:cycle, n) if !block && n.nil?
-
-    ary = []
-    if n.nil?
-      self.each do|*val|
-        ary.push val
-        block.call(*val)
-      end
-      loop do
-        ary.each do|e|
-          block.call(*e)
-        end
-      end
+  def cycle(nv = nil, &block)
+    return to_enum(:cycle, nv) unless block
+
+    n = nil
+
+    if nv.nil?
+      n = -1
     else
-      raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
-
-      n = n.to_int
-      self.each do|*val|
-        ary.push val
-      end
-      count = 0
-      while count < n
-        ary.each do|e|
-          block.call(*e)
-        end
-        count += 1
-      end
-    end
+      unless nv.respond_to?(:to_int)
+        raise TypeError, "no implicit conversion of #{nv.class} into Integer"
+      end
+      n = nv.to_int
+      unless n.kind_of?(Integer)
+        raise TypeError, "no implicit conversion of #{nv.class} into Integer"
+      end
+      return nil if n <= 0
+    end
+
+    ary = []
+    each do |*i|
+      ary.push(i)
+      yield(*i)
+    end
+    return nil if ary.empty?
+
+    while n < 0 || 0 < (n -= 1)
+      ary.each do |i|
+        yield(*i)
+      end
+    end
+
+    nil
   end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-ext/test/enum.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enum-ext/test/enum.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-ext/test/enum.rb	(revision 331)
@@ -26,12 +26,14 @@
 assert("Enumerable#each_cons") do
   a = []
-  (1..5).each_cons(3){|e| a << e}
+  b = (1..5).each_cons(3){|e| a << e}
   assert_equal [[1, 2, 3], [2, 3, 4], [3, 4, 5]], a
+  assert_equal nil, b
 end
 
 assert("Enumerable#each_slice") do
   a = []
-  (1..10).each_slice(3){|e| a << e}
+  b = (1..10).each_slice(3){|e| a << e}
   assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], a
+  assert_equal nil, b
 end
 
@@ -129,4 +131,11 @@
   assert_equal ["a", "b", "c", "a", "b", "c"], a
   assert_raise(TypeError) { ["a", "b", "c"].cycle("a") { |v| a << v } }
+
+  empty = Class.new do
+    include Enumerable
+    def each
+    end
+  end
+  assert_nil empty.new.cycle { break :nope }
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-lazy/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enum-lazy/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-lazy/mrbgem.rake	(revision 331)
@@ -2,5 +2,5 @@
   spec.license = 'MIT'
   spec.author  = 'mruby developers'
-  spec.summary = 'Enumerable::Lazy class'
+  spec.summary = 'Enumerator::Lazy class'
   spec.add_dependency('mruby-enumerator', :core => 'mruby-enumerator')
   spec.add_dependency('mruby-enum-ext', :core => 'mruby-enum-ext')
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-lazy/mrblib/lazy.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enum-lazy/mrblib/lazy.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-lazy/mrblib/lazy.rb	(revision 331)
@@ -3,5 +3,5 @@
   # = Enumerable#lazy implementation
   #
-  # Enumerable#lazy returns an instance of Enumerable::Lazy.
+  # Enumerable#lazy returns an instance of Enumerator::Lazy.
   # You can use it just like as normal Enumerable object,
   # except these methods act as 'lazy':
@@ -17,7 +17,9 @@
   #   - zip
   def lazy
-    Lazy.new(self)
+    Enumerator::Lazy.new(self)
   end
+end
 
+class Enumerator
   # == Acknowledgements
   #
@@ -40,4 +42,13 @@
       }
     end
+
+    def to_enum(meth=:each, *args, &block)
+      lz = Lazy.new(self, &block)
+      lz.obj = self
+      lz.meth = meth
+      lz.args = args
+      lz
+    end
+    alias enum_for to_enum
 
     def map(&block)
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-lazy/test/lazy.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enum-lazy/test/lazy.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enum-lazy/test/lazy.rb	(revision 331)
@@ -1,8 +1,8 @@
-assert("Enumerable::Lazy") do
+assert("Enumerator::Lazy") do
   a = [1, 2]
-  assert_equal Enumerable::Lazy, a.lazy.class
+  assert_equal Enumerator::Lazy, a.lazy.class
 end
 
-assert("Enumerable::Lazy laziness") do
+assert("Enumerator::Lazy laziness") do
   a = Object.new
   def a.each
@@ -41,5 +41,11 @@
 end
 
-assert("Enumerable::Lazy#zip with cycle") do
+assert("Enumrator::Lazy#to_enum") do
+  lazy_enum = (0..Float::INFINITY).lazy.to_enum(:each_slice, 2)
+  assert_kind_of Enumerator::Lazy, lazy_enum
+  assert_equal [0*1, 2*3, 4*5, 6*7], lazy_enum.map { |a| a.first * a.last }.first(4)
+end
+
+assert("Enumerator::Lazy#zip with cycle") do
   e1 = [1, 2, 3].cycle
   e2 = [:a, :b].cycle
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/mrblib/enumerator.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enumerator/mrblib/enumerator.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/mrblib/enumerator.rb	(revision 331)
@@ -154,10 +154,16 @@
   def with_index(offset=0)
     return to_enum :with_index, offset unless block_given?
-    raise TypeError, "no implicit conversion of #{offset.class} into Integer" unless offset.respond_to?(:to_int)
-
-    n = offset.to_int - 1
-    enumerator_block_call do |i|
+    offset = if offset.nil?
+      0
+    elsif offset.respond_to?(:to_int)
+      offset.to_int
+    else
+      raise TypeError, "no implicit conversion of #{offset.class} into Integer"
+    end
+
+    n = offset - 1
+    enumerator_block_call do |*i|
       n += 1
-      yield [i,n]
+      yield i.__svalue, n
     end
   end
@@ -172,6 +178,6 @@
   # If no block is given, a new Enumerator is returned that includes the index.
   #
-  def each_with_index
-    with_index
+  def each_with_index(&block)
+    with_index(0, &block)
   end
 
@@ -517,4 +523,5 @@
   # just for internal
   class Generator
+    include Enumerable
     def initialize(&block)
       raise TypeError, "wrong argument type #{self.class} (expected Proc)" unless block.kind_of? Proc
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/test/enumerator.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-enumerator/test/enumerator.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/test/enumerator.rb	(revision 331)
@@ -51,4 +51,7 @@
   assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
   assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
+  a = []
+  @obj.to_enum(:foo, 1, 2, 3).with_index(10).with_index(20) { |*i| a << i }
+  assert_equal [[[1, 10], 20], [[2, 11], 21], [[3, 12], 22]], a
 end
 
@@ -61,4 +64,11 @@
 assert 'Enumerator#with_index string offset' do
   assert_raise(TypeError){ @obj.to_enum(:foo, 1, 2, 3).with_index('1').to_a }
+end
+
+assert 'Enumerator#each_with_index' do
+  assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).each_with_index.to_a)
+  a = []
+  @obj.to_enum(:foo, 1, 2, 3).each_with_index {|*i| a << i}
+  assert_equal([[1, 0], [2, 1], [3, 2]], a)
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-error/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/mrbgem.rake	(revision 331)
@@ -4,5 +4,5 @@
   spec.summary = 'extensional error handling'
 
-  if build.cxx_abi_enabled?
+  if build.cxx_exception_enabled?
     @objs << build.compile_as_cxx("#{spec.dir}/src/exception.c", "#{spec.build_dir}/src/exception.cxx")
     @objs.delete_if { |v| v == objfile("#{spec.build_dir}/src/exception") }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/src/exception.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-error/src/exception.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/src/exception.c	(revision 331)
@@ -1,5 +1,5 @@
-#include "mruby.h"
-#include "mruby/throw.h"
-#include "mruby/error.h"
+#include <mruby.h>
+#include <mruby/throw.h>
+#include <mruby/error.h>
 
 MRB_API mrb_value
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/test/exception.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-error/test/exception.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/test/exception.c	(revision 331)
@@ -1,5 +1,5 @@
-#include "mruby.h"
-#include "mruby/error.h"
-#include "mruby/array.h"
+#include <mruby.h>
+#include <mruby/error.h>
+#include <mruby/array.h>
 
 static mrb_value
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/test/exception.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-error/test/exception.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-error/test/exception.rb	(revision 331)
@@ -6,5 +6,5 @@
   # failure in protect returns [exception, true]
   result = ExceptionTest.mrb_protect { raise 'test' }
-  assert_kind_of RuntimeError, result[0]    
+  assert_kind_of RuntimeError, result[0]
   assert_true result[1]
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-eval/src/eval.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-eval/src/eval.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-eval/src/eval.c	(revision 331)
@@ -1,8 +1,12 @@
-#include "mruby.h"
-#include "mruby/class.h"
-#include "mruby/compile.h"
-#include "mruby/irep.h"
-#include "mruby/proc.h"
-#include "mruby/opcode.h"
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/compile.h>
+#include <mruby/irep.h>
+#include <mruby/proc.h>
+#include <mruby/opcode.h>
+#include <mruby/error.h>
+
+mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p);
+mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
 
 static struct mrb_irep *
@@ -27,4 +31,6 @@
 
   if (!e) return NULL;
+  if (!MRB_ENV_STACK_SHARED_P(e)) return NULL;
+  c = e->cxt.c;
   proc = c->cibase[e->cioff].proc;
 
@@ -127,10 +133,18 @@
       }
       break;
-    }
-  }
-}
+
+    case OP_STOP:
+      if (mrb->c->ci->acc >= 0) {
+        irep->iseq[i] = MKOP_AB(OP_RETURN, irep->nlocals, OP_R_NORMAL);
+      }
+      break;
+    }
+  }
+}
+
+void mrb_codedump_all(mrb_state*, struct RProc*);
 
 static struct RProc*
-create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, char *file, mrb_int line)
+create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, const char *file, mrb_int line)
 {
   mrbc_context *cxt;
@@ -146,7 +160,6 @@
   cxt = mrbc_context_new(mrb);
   cxt->lineno = line;
-  if (file) {
-    mrbc_filename(mrb, cxt, file);
-  }
+
+  mrbc_filename(mrb, cxt, file ? file : "(eval)");
   cxt->capture_errors = TRUE;
   cxt->no_optimize = TRUE;
@@ -161,10 +174,20 @@
   if (0 < p->nerr) {
     /* parse error */
-    char buf[256];
-    int n;
-    n = snprintf(buf, sizeof(buf), "line %d: %s\n", p->error_buffer[0].lineno, p->error_buffer[0].message);
+    mrb_value str;
+
+    if (file) {
+      str = mrb_format(mrb, " file %S line %S: %S",
+                       mrb_str_new_cstr(mrb, file),
+                       mrb_fixnum_value(p->error_buffer[0].lineno),
+                       mrb_str_new_cstr(mrb, p->error_buffer[0].message));
+    }
+    else {
+      str = mrb_format(mrb, " line %S: %S",
+                       mrb_fixnum_value(p->error_buffer[0].lineno),
+                       mrb_str_new_cstr(mrb, p->error_buffer[0].message));
+    }
     mrb_parser_free(p);
     mrbc_context_free(mrb, cxt);
-    mrb_exc_raise(mrb, mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
+    mrb_exc_raise(mrb, mrb_exc_new_str(mrb, E_SYNTAX_ERROR, str));
   }
 
@@ -182,9 +205,10 @@
   if (!e) e = c->ci[-1].env;
   e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, (struct RClass*)e);
-  e->mid = c->ci[-1].mid;
-  e->cioff = c->ci - c->cibase - 1;
+  e->cxt.c = c;
+  e->cioff = c->ci - c->cibase;
   e->stack = c->ci->stackent;
-  MRB_SET_ENV_STACK_LEN(e, c->ci[-1].proc->body.irep->nlocals);
-  c->ci->env = e;
+  MRB_SET_ENV_STACK_LEN(e, c->ci->proc->body.irep->nlocals);
+  c->ci->target_class = proc->target_class;
+  c->ci->env = 0;
   proc->env = e;
   patch_irep(mrb, proc->body.irep, 0);
@@ -194,4 +218,17 @@
 
   return proc;
+}
+
+static mrb_value
+exec_irep(mrb_state *mrb, mrb_value self, struct RProc *proc)
+{
+  if (mrb->c->ci->acc < 0) {
+    mrb_value ret = mrb_top_run(mrb, proc, mrb->c->stack[0], 0);
+    if (mrb->exc) {
+      mrb_exc_raise(mrb, mrb_obj_value(mrb->exc));
+    }
+    return ret;
+  }
+  return mrb_exec_irep(mrb, self, proc);
 }
 
@@ -204,5 +241,4 @@
   char *file = NULL;
   mrb_int line = 1;
-  mrb_value ret;
   struct RProc *proc;
 
@@ -210,20 +246,11 @@
 
   proc = create_proc_from_string(mrb, s, len, binding, file, line);
-  ret = mrb_toplevel_run(mrb, proc);
-  if (mrb->exc) {
-    mrb_exc_raise(mrb, mrb_obj_value(mrb->exc));
-  }
-
-  return ret;
-}
-
-mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
-
-#define CI_ACC_SKIP    -1
+  mrb_assert(!MRB_PROC_CFUNC_P(proc));
+  return exec_irep(mrb, self, proc);
+}
 
 static mrb_value
 f_instance_eval(mrb_state *mrb, mrb_value self)
 {
-  struct mrb_context *c = mrb->c;
   mrb_value b;
   mrb_int argc; mrb_value *argv;
@@ -237,10 +264,13 @@
     mrb_int line = 1;
     mrb_value cv;
+    struct RProc *proc;
 
     mrb_get_args(mrb, "s|zi", &s, &len, &file, &line);
-    c->ci->acc = CI_ACC_SKIP;
     cv = mrb_singleton_class(mrb, self);
-    c->ci->target_class = mrb_class_ptr(cv);
-    return mrb_run(mrb, create_proc_from_string(mrb, s, len, mrb_nil_value(), file, line), self);
+    proc = create_proc_from_string(mrb, s, len, mrb_nil_value(), file, line);
+    proc->target_class = mrb_class_ptr(cv);
+    mrb->c->ci->env = NULL;
+    mrb_assert(!MRB_PROC_CFUNC_P(proc));
+    return exec_irep(mrb, self, proc);
   }
   else {
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-eval/test/eval.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-eval/test/eval.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-eval/test/eval.rb	(revision 331)
@@ -65,4 +65,6 @@
   assert_equal('test') { obj.instance_eval('@test') }
   assert_equal('test') { obj.instance_eval { @test } }
+  o = Object.new
+  assert_equal ['', o, o], o.instance_eval("[''].each { |s| break [s, o, self] }")
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-exit/src/mruby-exit.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-exit/src/mruby-exit.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-exit/src/mruby-exit.c	(revision 331)
@@ -1,4 +1,4 @@
 #include <stdlib.h>
-#include "mruby.h"
+#include <mruby.h>
 
 static mrb_value
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-fiber/src/fiber.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-fiber/src/fiber.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-fiber/src/fiber.c	(revision 331)
@@ -1,6 +1,6 @@
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/proc.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/proc.h>
 
 #define fiber_ptr(o) ((struct RFiber*)mrb_ptr(o))
@@ -8,4 +8,5 @@
 #define FIBER_STACK_INIT_SIZE 64
 #define FIBER_CI_INIT_SIZE 8
+#define CI_ACC_RESUMED -3
 
 /*
@@ -74,4 +75,7 @@
   mrb_get_args(mrb, "&", &blk);
 
+  if (f->cxt) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "cannot initialize twice");
+  }
   if (mrb_nil_p(blk)) {
     mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Fiber object without a block");
@@ -82,7 +86,7 @@
   }
 
-  f->cxt = (struct mrb_context*)mrb_malloc(mrb, sizeof(struct mrb_context));
-  *f->cxt = mrb_context_zero;
-  c = f->cxt;
+  c = (struct mrb_context*)mrb_malloc(mrb, sizeof(struct mrb_context));
+  *c = mrb_context_zero;
+  f->cxt = c;
 
   /* initialize VM stack */
@@ -156,8 +160,7 @@
 #define MARK_CONTEXT_MODIFY(c) (c)->ci->target_class = NULL
 
-static mrb_value
-fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume)
-{
-  struct mrb_context *c = fiber_check(mrb, self);
+static void
+fiber_check_cfunc(mrb_state *mrb, struct mrb_context *c)
+{
   mrb_callinfo *ci;
 
@@ -167,39 +170,63 @@
     }
   }
+}
+
+static void
+fiber_switch_context(mrb_state *mrb, struct mrb_context *c)
+{
+  if (mrb->c->fib) {
+    mrb_write_barrier(mrb, (struct RBasic*)mrb->c->fib);
+  }
+  c->status = MRB_FIBER_RUNNING;
+  mrb->c = c;
+}
+
+static mrb_value
+fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mrb_bool resume, mrb_bool vmexec)
+{
+  struct mrb_context *c = fiber_check(mrb, self);
+  struct mrb_context *old_c = mrb->c;
+  mrb_value value;
+
+  fiber_check_cfunc(mrb, c);
   if (resume && c->status == MRB_FIBER_TRANSFERRED) {
     mrb_raise(mrb, E_FIBER_ERROR, "resuming transferred fiber");
   }
-  if (c->status == MRB_FIBER_RUNNING || c->status == MRB_FIBER_RESUMING) {
-    mrb_raise(mrb, E_FIBER_ERROR, "double resume");
+  if (c->status == MRB_FIBER_RUNNING || c->status == MRB_FIBER_RESUMED) {
+    mrb_raise(mrb, E_FIBER_ERROR, "double resume (fib)");
   }
   if (c->status == MRB_FIBER_TERMINATED) {
     mrb_raise(mrb, E_FIBER_ERROR, "resuming dead fiber");
   }
-  mrb->c->status = resume ? MRB_FIBER_RESUMING : MRB_FIBER_TRANSFERRED;
+  mrb->c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;
   c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);
   if (c->status == MRB_FIBER_CREATED) {
-    mrb_value *b = c->stack+1;
-    mrb_value *e = b + len;
-
+    mrb_value *b, *e;
+
+    if (len >= c->stend - c->stack) {
+      mrb_raise(mrb, E_FIBER_ERROR, "too many arguments to fiber");
+    }
+    b = c->stack+1;
+    e = b + len;
     while (b<e) {
       *b++ = *a++;
     }
     c->cibase->argc = len;
-    if (c->prev->fib)
-      mrb_field_write_barrier(mrb, (struct RBasic*)c->fib, (struct RBasic*)c->prev->fib);
-    mrb_write_barrier(mrb, (struct RBasic*)c->fib);
-    c->status = MRB_FIBER_RUNNING;
-    mrb->c = c;
-
+    value = c->stack[0] = c->ci->proc->env->stack[0];
+  }
+  else {
+    value = fiber_result(mrb, a, len);
+  }
+  fiber_switch_context(mrb, c);
+
+  if (vmexec) {
+    c->vmexec = TRUE;
+    value = mrb_vm_exec(mrb, c->ci[-1].proc, c->ci->pc);
+    mrb->c = old_c;
+  }
+  else {
     MARK_CONTEXT_MODIFY(c);
-    return c->ci->proc->env->stack[0];
-  }
-  MARK_CONTEXT_MODIFY(c);
-  if (c->prev->fib)
-    mrb_field_write_barrier(mrb, (struct RBasic*)c->fib, (struct RBasic*)c->prev->fib);
-  mrb_write_barrier(mrb, (struct RBasic*)c->fib);
-  c->status = MRB_FIBER_RUNNING;
-  mrb->c = c;
-  return fiber_result(mrb, a, len);
+  }
+  return value;
 }
 
@@ -224,7 +251,11 @@
   mrb_value *a;
   mrb_int len;
+  mrb_bool vmexec = FALSE;
 
   mrb_get_args(mrb, "*", &a, &len);
-  return fiber_switch(mrb, self, len, a, TRUE);
+  if (mrb->c->ci->acc < 0) {
+    vmexec = TRUE;
+  }
+  return fiber_switch(mrb, self, len, a, TRUE, vmexec);
 }
 
@@ -233,5 +264,5 @@
 mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int len, const mrb_value *a)
 {
-  return fiber_switch(mrb, fib, len, a, TRUE);
+  return fiber_switch(mrb, fib, len, a, TRUE, TRUE);
 }
 
@@ -281,12 +312,11 @@
   mrb_int len;
 
+  fiber_check_cfunc(mrb, mrb->c);
   mrb_get_args(mrb, "*", &a, &len);
 
   if (c == mrb->root_c) {
     mrb->c->status = MRB_FIBER_TRANSFERRED;
-    mrb->c = c;
-    c->status = MRB_FIBER_RUNNING;
+    fiber_switch_context(mrb, c);
     MARK_CONTEXT_MODIFY(c);
-    mrb_write_barrier(mrb, (struct RBasic*)c->fib);
     return fiber_result(mrb, a, len);
   }
@@ -296,5 +326,5 @@
   }
 
-  return fiber_switch(mrb, self, len, a, FALSE);
+  return fiber_switch(mrb, self, len, a, FALSE, FALSE);
 }
 
@@ -305,21 +335,19 @@
 {
   struct mrb_context *c = mrb->c;
-  mrb_callinfo *ci;
-
-  for (ci = c->ci; ci >= c->cibase; ci--) {
-    if (ci->acc < 0) {
-      mrb_raise(mrb, E_FIBER_ERROR, "can't cross C function boundary");
-    }
-  }
+
   if (!c->prev) {
     mrb_raise(mrb, E_FIBER_ERROR, "can't yield from root fiber");
   }
 
+  fiber_check_cfunc(mrb, c);
   c->prev->status = MRB_FIBER_RUNNING;
   c->status = MRB_FIBER_SUSPENDED;
-  mrb->c = c->prev;
+  fiber_switch_context(mrb, c->prev);
   c->prev = NULL;
+  if (c->vmexec) {
+    c->vmexec = FALSE;
+    mrb->c->ci->acc = CI_ACC_RESUMED;
+  }
   MARK_CONTEXT_MODIFY(mrb->c);
-  mrb_write_barrier(mrb, (struct RBasic*)c->fib);
   return fiber_result(mrb, a, len);
 }
@@ -333,5 +361,7 @@
  *  processing at this point when <code>resume</code> is called next.
  *  Any arguments passed to the next <code>resume</code> will be the
- *  value that this <code>Fiber.yield</code> expression evaluates to.
+ *
+ *  mruby limitation: Fiber resume/yield cannot cross C function boundary.
+ *  thus you cannot yield from #initialize which is called by mrb_funcall().
  */
 static mrb_value
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/mrblib/hash.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-hash-ext/mrblib/hash.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/mrblib/hash.rb	(revision 331)
@@ -29,9 +29,9 @@
       o = object[0]
       if o.respond_to?(:to_hash)
-        h = Hash.new
+        h = self.new
         object[0].to_hash.each { |k, v| h[k] = v }
         return h
       elsif o.respond_to?(:to_a)
-        h = Hash.new
+        h = self.new
         o.to_a.each do |i|
           raise ArgumentError, "wrong element type #{i.class} (expected array)" unless i.respond_to?(:to_a)
@@ -54,9 +54,28 @@
       raise ArgumentError, 'odd number of arguments for Hash'
     end
-    h = Hash.new
+    h = self.new
     0.step(length - 2, 2) do |i|
       h[object[i]] = object[i + 1]
     end
     h
+  end
+
+  ##
+  # call-seq:
+  #     Hash.try_convert(obj) -> hash or nil
+  #
+  # Try to convert <i>obj</i> into a hash, using to_hash method.
+  # Returns converted hash or nil if <i>obj</i> cannot be converted
+  # for any reason.
+  #
+  #     Hash.try_convert({1=>2})   # => {1=>2}
+  #     Hash.try_convert("1=>2")   # => nil
+  #
+  def self.try_convert(obj)
+    if obj.respond_to?(:to_hash)
+      obj.to_hash
+    else
+      nil
+    end
   end
 
@@ -193,5 +212,5 @@
 
   def invert
-    h = Hash.new
+    h = self.class.new
     self.each {|k, v| h[v] = k }
     h
@@ -347,3 +366,20 @@
     }
   end
+
+  ##
+  # call-seq:
+  #   hsh.dig(key,...)                 -> object
+  #
+  # Extracts the nested value specified by the sequence of <i>key</i>
+  # objects by calling +dig+ at each step, returning +nil+ if any
+  # intermediate step is +nil+.
+  #
+  def dig(idx,*args)
+    n = self[idx]
+    if args.size > 0
+      n&.dig(*args)
+    else
+      n
+    end
+  end
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/src/hash-ext.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-hash-ext/src/hash-ext.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/src/hash-ext.c	(revision 331)
@@ -5,7 +5,7 @@
 */
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/hash.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/hash.h>
 
 /*
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/test/hash.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-hash-ext/test/hash.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-hash-ext/test/hash.rb	(revision 331)
@@ -38,4 +38,16 @@
     Hash['d_key']
   end
+end
+
+assert('Hash.[] for sub class') do
+  sub_hash_class = Class.new(Hash)
+  sub_hash = sub_hash_class[]
+  assert_equal(sub_hash_class, sub_hash.class)
+end
+
+assert('Hash.try_convert') do
+  assert_nil Hash.try_convert(nil)
+  assert_nil Hash.try_convert("{1=>2}")
+  assert_equal({1=>2}, Hash.try_convert({1=>2}))
 end
 
@@ -138,4 +150,10 @@
 end
 
+assert("Hash#invert with sub class") do
+  sub_hash_class = Class.new(Hash)
+  sub_hash = sub_hash_class.new
+  assert_equal(sub_hash_class, sub_hash.invert.class)
+end
+
 assert("Hash#keep_if") do
   h = { 1 => 2, 3 => 4, 5 => 6 }
@@ -231,2 +249,8 @@
   assert_false(h2 > h2)
 end
+
+assert("Hash#dig") do
+  h = {a:{b:{c:1}}}
+  assert_equal(1, h.dig(:a, :b, :c))
+  assert_nil(h.dig(:d))
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/mrbgem.rake	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/mrbgem.rake	(revision 331)
@@ -0,0 +1,5 @@
+MRuby::Gem::Specification.new('mruby-inline-struct') do |spec|
+  spec.license = 'MIT'
+  spec.author  = 'mruby developers'
+  spec.summary = 'inline structure'
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/test/inline.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/test/inline.c	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/test/inline.c	(revision 331)
@@ -0,0 +1,83 @@
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/string.h>
+#include <mruby/istruct.h>
+
+static mrb_value
+istruct_test_initialize(mrb_state *mrb, mrb_value self)
+{
+  char *string = (char*)mrb_istruct_ptr(self);
+  mrb_int size = mrb_istruct_size();
+  mrb_value object;
+  mrb_get_args(mrb, "o", &object);
+
+  if (mrb_float_p(object))
+  {
+    snprintf(string, size, "float(%.3f)", mrb_float(object));
+  }
+  else if (mrb_fixnum_p(object))
+  {
+    snprintf(string, size, "fixnum(%" MRB_PRId ")", mrb_fixnum(object));
+  }
+  else if (mrb_string_p(object))
+  {
+    snprintf(string, size, "string(%s)", mrb_string_value_cstr(mrb, &object));
+  }
+
+  string[size - 1] = 0; // force NULL at the end
+  return self;
+}
+
+static mrb_value
+istruct_test_to_s(mrb_state *mrb, mrb_value self)
+{
+  return mrb_str_new_cstr(mrb, (const char*)mrb_istruct_ptr(self));
+}
+
+static mrb_value
+istruct_test_length(mrb_state *mrb, mrb_value self)
+{
+  return mrb_fixnum_value(mrb_istruct_size());
+}
+
+static mrb_value
+istruct_test_test_receive(mrb_state *mrb, mrb_value self)
+{
+  mrb_value object;
+  mrb_get_args(mrb, "o", &object);
+  if (mrb_obj_class(mrb, object) != mrb_class_get(mrb, "InlineStructTest"))
+  {
+    mrb_raisef(mrb, E_TYPE_ERROR, "Expected InlineStructTest");
+  }
+  return mrb_bool_value(((char*)mrb_istruct_ptr(object))[0] == 's');
+}
+
+static mrb_value
+istruct_test_test_receive_direct(mrb_state *mrb, mrb_value self)
+{
+  char *ptr;
+  mrb_get_args(mrb, "I", &ptr);
+  return mrb_bool_value(ptr[0] == 's');
+}
+
+static mrb_value
+istruct_test_mutate(mrb_state *mrb, mrb_value self)
+{
+  char *ptr = (char*)mrb_istruct_ptr(self);
+  memcpy(ptr, "mutate", 6);
+  return mrb_nil_value();
+}
+
+void mrb_mruby_inline_struct_gem_test(mrb_state *mrb)
+{
+  struct RClass *cls;
+
+  cls = mrb_define_class(mrb, "InlineStructTest", mrb->object_class);
+  MRB_SET_INSTANCE_TT(cls, MRB_TT_ISTRUCT);
+  mrb_define_method(mrb, cls, "initialize", istruct_test_initialize, MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, cls, "to_s", istruct_test_to_s, MRB_ARGS_NONE());
+  mrb_define_method(mrb, cls, "mutate", istruct_test_mutate, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, cls, "length", istruct_test_length, MRB_ARGS_NONE());
+  mrb_define_class_method(mrb, cls, "test_receive", istruct_test_test_receive, MRB_ARGS_REQ(1));
+  mrb_define_class_method(mrb, cls, "test_receive_direct", istruct_test_test_receive_direct, MRB_ARGS_REQ(1));
+}
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/test/inline.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/test/inline.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-inline-struct/test/inline.rb	(revision 331)
@@ -0,0 +1,151 @@
+##
+# InlineStruct Test
+
+class InlineStructTest
+  def extra_method
+    :ok
+  end
+
+  def test_ivar_set
+    @var = :ivar
+  end
+
+  def test_ivar_get
+    @vat
+  end
+end
+
+assert('InlineStructTest#dup') do
+  obj = InlineStructTest.new(1)
+  assert_equal obj.to_s, 'fixnum(1)'
+  assert_equal obj.dup.to_s, 'fixnum(1)'
+end
+
+assert('InlineStructTest#clone') do
+  obj = InlineStructTest.new(1)
+  assert_equal obj.to_s, 'fixnum(1)'
+  assert_equal obj.clone.to_s, 'fixnum(1)'
+end
+
+assert('InlineStruct#object_id') do
+  obj1 = InlineStructTest.new(1)
+  obj2 = InlineStructTest.new(1)
+  assert_not_equal obj1, obj2
+  assert_not_equal obj1.object_id, obj2.object_id
+  assert_not_equal obj1.object_id, obj1.dup.object_id
+  assert_not_equal obj1.object_id, obj1.clone.object_id
+end
+
+assert('InlineStructTest#mutate (dup)') do
+  obj1 = InlineStructTest.new("foo")
+  assert_equal obj1.to_s, "string(foo)"
+  obj2 = obj1.dup
+  assert_equal obj2.to_s, "string(foo)"
+  obj1.mutate
+  assert_equal obj1.to_s, "mutate(foo)"
+  assert_equal obj2.to_s, "string(foo)"
+end
+
+assert('InlineStructTest#mutate (clone)') do
+  obj1 = InlineStructTest.new("foo")
+  assert_equal obj1.to_s, "string(foo)"
+  obj2 = obj1.clone
+  assert_equal obj2.to_s, "string(foo)"
+  obj1.mutate
+  assert_equal obj1.to_s, "mutate(foo)"
+  assert_equal obj2.to_s, "string(foo)"
+end
+
+assert('InlineStructTest#test_receive(string)') do
+  assert_equal InlineStructTest.test_receive(InlineStructTest.new('a')), true
+end
+
+assert('InlineStructTest#test_receive(float)') do
+  assert_equal InlineStructTest.test_receive(InlineStructTest.new(1.25)), false
+end
+
+assert('InlineStructTest#test_receive(invalid object)') do
+  assert_raise(TypeError) do
+    InlineStructTest.test_receive([])
+  end
+end
+
+assert('InlineStructTest#test_receive(string)') do
+  assert_equal InlineStructTest.test_receive_direct(InlineStructTest.new('a')), true
+end
+
+assert('InlineStructTest#test_receive(float)') do
+  assert_equal InlineStructTest.test_receive_direct(InlineStructTest.new(1.25)), false
+end
+
+assert('InlineStructTest#test_receive(invalid object)') do
+  assert_raise(TypeError) do
+    InlineStructTest.test_receive_direct([])
+  end
+end
+
+assert('InlineStructTest#extra_method') do
+  assert_equal InlineStructTest.new(1).extra_method, :ok
+end
+
+assert('InlineStructTest instance variable') do
+  obj = InlineStructTest.new(1)
+  assert_raise(ArgumentError) do
+    obj.test_ivar_set
+  end
+  assert_equal obj.test_ivar_get, nil
+end
+
+# 64-bit mode
+if InlineStructTest.length == 24
+  assert('InlineStructTest length [64 bit]') do
+    assert_equal InlineStructTest.length, 3 * 8
+  end
+
+  assert('InlineStructTest w/float [64 bit]') do
+    obj = InlineStructTest.new(1.25)
+    assert_equal obj.to_s, "float(1.250)"
+  end
+
+  assert('InlineStructTest w/fixnum [64 bit]') do
+    obj = InlineStructTest.new(42)
+    assert_equal obj.to_s, "fixnum(42)"
+  end
+
+  assert('InlineStructTest w/string [64 bit]') do
+    obj = InlineStructTest.new("hello")
+    assert_equal obj.to_s, "string(hello)"
+  end
+
+  assert('InlineStructTest w/long string [64 bit]') do
+    obj = InlineStructTest.new("this won't fit in 3 * 8 bytes available for the structure")
+    assert_equal obj.to_s, "string(this won't fit i"
+  end
+end
+
+# 32-bit mode
+if InlineStructTest.length == 12
+  assert('InlineStructTest length [32 bit]') do
+    assert_equal InlineStructTest.length, 3 * 4
+  end
+
+  assert('InlineStructTest w/float [32 bit]') do
+    obj = InlineStructTest.new(1.25)
+    assert_equal obj.to_s, "float(1.250"
+  end
+
+  assert('InlineStructTest w/fixnum [32 bit]') do
+    obj = InlineStructTest.new(42)
+    assert_equal obj.to_s, "fixnum(42)"
+  end
+
+  assert('InlineStructTest w/string [32 bit]') do
+    obj = InlineStructTest.new("hello")
+    assert_equal obj.to_s, "string(hell"
+  end
+
+  assert('InlineStructTest w/long string [32 bit]') do
+    obj = InlineStructTest.new("this won't fit in 3 * 4 bytes available for the structure")
+    assert_equal obj.to_s, "string(this"
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-kernel-ext/src/kernel.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-kernel-ext/src/kernel.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-kernel-ext/src/kernel.c	(revision 331)
@@ -1,6 +1,64 @@
-#include "mruby.h"
-#include "mruby/error.h"
-#include "mruby/array.h"
-#include "mruby/hash.h"
+#include <mruby.h>
+#include <mruby/error.h>
+#include <mruby/array.h>
+#include <mruby/hash.h>
+#include <mruby/range.h>
+
+static mrb_value
+mrb_f_caller(mrb_state *mrb, mrb_value self)
+{
+  mrb_value bt, v, length;
+  mrb_int bt_len, argc, lev, n;
+
+  bt = mrb_get_backtrace(mrb);
+  bt_len = RARRAY_LEN(bt);
+  argc = mrb_get_args(mrb, "|oo", &v, &length);
+
+  switch (argc) {
+    case 0:
+      lev = 1;
+      n = bt_len - lev;
+      break;
+    case 1:
+      if (mrb_type(v) == MRB_TT_RANGE) {
+        mrb_int beg, len;
+        if (mrb_range_beg_len(mrb, v, &beg, &len, bt_len, TRUE) == 1) {
+          lev = beg;
+          n = len;
+        }
+        else {
+          return mrb_nil_value();
+        }
+      }
+      else {
+        v = mrb_to_int(mrb, v);
+        lev = mrb_fixnum(v);
+        if (lev < 0) {
+          mrb_raisef(mrb, E_ARGUMENT_ERROR, "negative level (%S)", v);
+        }
+        n = bt_len - lev;
+      }
+      break;
+    case 2:
+      lev = mrb_fixnum(mrb_to_int(mrb, v));
+      n = mrb_fixnum(mrb_to_int(mrb, length));
+      if (lev < 0) {
+        mrb_raisef(mrb, E_ARGUMENT_ERROR, "negative level (%S)", v);
+      }
+      if (n < 0) {
+        mrb_raisef(mrb, E_ARGUMENT_ERROR, "negative size (%S)", length);
+      }
+      break;
+    default:
+      lev = n = 0;
+      break;
+  }
+
+  if (n == 0) {
+    return mrb_ary_new(mrb);
+  }
+
+  return mrb_funcall(mrb, bt, "[]", 2, mrb_fixnum_value(lev), mrb_fixnum_value(n));
+}
 
 /*
@@ -62,5 +120,5 @@
  *
  *  Returns <i>arg</i> converted to a float. Numeric types are converted
- *  directly, the rest are converted using <i>arg</i>.to_f. 
+ *  directly, the rest are converted using <i>arg</i>.to_f.
  *
  *     Float(1)           #=> 1.0
@@ -171,4 +229,5 @@
 
   mrb_define_module_function(mrb, krn, "fail", mrb_f_raise, MRB_ARGS_OPT(2));
+  mrb_define_module_function(mrb, krn, "caller", mrb_f_caller, MRB_ARGS_OPT(2));
   mrb_define_method(mrb, krn, "__method__", mrb_f_method, MRB_ARGS_NONE());
   mrb_define_module_function(mrb, krn, "Integer", mrb_f_integer, MRB_ARGS_ANY());
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-kernel-ext/test/kernel.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-kernel-ext/test/kernel.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-kernel-ext/test/kernel.rb	(revision 331)
@@ -2,4 +2,35 @@
   assert_raise(RuntimeError) { fail }
   assert_raise(RuntimeError) { Kernel.fail }
+end
+
+assert('Kernel.caller, Kernel#caller') do
+  skip "backtrace isn't available" if caller(0).empty?
+
+  caller_lineno = __LINE__ + 3
+  c = Class.new do
+    def foo(*args)
+      caller(*args)
+    end
+
+    def bar(*args)
+      foo(*args)
+    end
+
+    def baz(*args)
+      bar(*args)
+    end
+  end
+  assert_equal "kernel.rb:#{caller_lineno}:in foo", c.new.baz(0)[0][-19..-1]
+  assert_equal "bar", c.new.baz[0][-3..-1]
+  assert_equal "foo", c.new.baz(0)[0][-3..-1]
+  assert_equal "bar", c.new.baz(1)[0][-3..-1]
+  assert_equal "baz", c.new.baz(2)[0][-3..-1]
+  assert_equal ["foo", "bar"], c.new.baz(0, 2).map { |i| i[-3..-1] }
+  assert_equal ["bar", "baz"], c.new.baz(1..2).map { |i| i[-3..-1] }
+  assert_nil c.new.baz(10..20)
+  assert_raise(ArgumentError) { c.new.baz(-1) }
+  assert_raise(ArgumentError) { c.new.baz(-1, 1) }
+  assert_raise(ArgumentError) { c.new.baz(1, -1) }
+  assert_raise(TypeError) { c.new.baz(nil) }
 end
 
@@ -23,4 +54,6 @@
   assert_equal(930, Integer("0930", 10))
   assert_equal(7, Integer("111", 2))
+  assert_equal(0, Integer("0"))
+  assert_equal(0, Integer("00000"))
   assert_raise(TypeError) { Integer(nil) }
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-math/src/math.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-math/src/math.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-math/src/math.c	(revision 331)
@@ -5,6 +5,6 @@
 */
 
-#include "mruby.h"
-#include "mruby/array.h"
+#include <mruby.h>
+#include <mruby/array.h>
 
 #include <math.h>
@@ -20,5 +20,5 @@
 
 /* math functions not provided by Microsoft Visual C++ 2012 or older */
-#if defined _MSC_VER && _MSC_VER < 1800
+#if defined _MSC_VER && _MSC_VER <= 1700
 
 #include <float.h>
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb	(revision 331)
@@ -3,3 +3,15 @@
     self.divmod(other)[0]
   end
+
+  def zero?
+    self == 0
+  end
+
+  def nonzero?
+    if self == 0
+      nil
+    else
+      self
+    end
+  end
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-numeric-ext/src/numeric_ext.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-numeric-ext/src/numeric_ext.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-numeric-ext/src/numeric_ext.c	(revision 331)
@@ -1,4 +1,4 @@
 #include <limits.h>
-#include "mruby.h"
+#include <mruby.h>
 
 static mrb_value
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-numeric-ext/test/numeric.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-numeric-ext/test/numeric.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-numeric-ext/test/numeric.rb	(revision 331)
@@ -17,2 +17,12 @@
   assert_float 52, 365.2425.div(7)
 end
+
+assert('Integer#zero?') do
+  assert_equal true, 0.zero?
+  assert_equal false, 1.zero?
+end
+
+assert('Integer#nonzero?') do
+  assert_equal nil, 0.nonzero?
+  assert_equal 1000, 1000.nonzero?
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-object-ext/src/object.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-object-ext/src/object.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-object-ext/src/object.c	(revision 331)
@@ -1,5 +1,6 @@
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/proc.h>
 
 /*
@@ -63,8 +64,9 @@
 mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
 {
-  mrb_value *argv;
+  const mrb_value *argv;
   mrb_int argc;
   mrb_value blk;
   struct RClass *c;
+  mrb_value args;
 
   mrb_get_args(mrb, "*&", &argv, &argc, &blk);
@@ -84,6 +86,8 @@
     break;
   }
-
-  return mrb_yield_with_class(mrb, blk, argc, argv, self, c);
+  args = mrb_ary_new_from_values(mrb, argc, argv);
+  argv = RARRAY_PTR(args);
+  mrb->c->ci->target_class = c;
+  return mrb_yield_cont(mrb, blk, self, argc, argv);
 }
 
@@ -97,5 +101,5 @@
   mrb_define_method(mrb, n, "to_i", nil_to_i,       MRB_ARGS_NONE());
 
-  mrb_define_method(mrb, mrb->object_class, "instance_exec", mrb_obj_instance_exec, MRB_ARGS_ANY() | MRB_ARGS_BLOCK());
+  mrb_define_method(mrb, mrb->kernel_module, "instance_exec", mrb_obj_instance_exec, MRB_ARGS_ANY() | MRB_ARGS_BLOCK());
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-object-ext/test/object.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-object-ext/test/object.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-object-ext/test/object.rb	(revision 331)
@@ -24,2 +24,30 @@
   assert_equal(:tap_ok, Class.new {def m; tap{return :tap_ok}; end}.new.m)
 end
+
+assert('instance_exec on primitives with class and module definition') do
+  begin
+    class A
+      1.instance_exec do
+        class B
+        end
+      end
+    end
+
+    assert_kind_of Class, A::B
+  ensure
+    Object.remove_const :A
+  end
+
+  begin
+    class A
+      1.instance_exec do
+        module B
+        end
+      end
+    end
+
+    assert_kind_of Module, A::B
+  ensure
+    Object.remove_const :A
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-objectspace/src/mruby_objectspace.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-objectspace/src/mruby_objectspace.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-objectspace/src/mruby_objectspace.c	(revision 331)
@@ -1,6 +1,6 @@
-#include "mruby.h"
-#include "mruby/gc.h"
-#include "mruby/hash.h"
-#include "mruby/class.h"
+#include <mruby.h>
+#include <mruby/gc.h>
+#include <mruby/hash.h>
+#include <mruby/class.h>
 
 struct os_count_struct {
@@ -10,5 +10,5 @@
 };
 
-static void
+static int
 os_count_object_type(mrb_state *mrb, struct RBasic *obj, void *data)
 {
@@ -24,4 +24,5 @@
     obj_count->counts[obj->tt]++;
   }
+  return MRB_EACH_OBJ_OK;
 }
 
@@ -50,5 +51,5 @@
 {
   struct os_count_struct obj_count = { 0 };
-  enum mrb_vtype i;
+  mrb_int i;
   mrb_value hash;
 
@@ -110,5 +111,5 @@
 };
 
-static void
+static int
 os_each_object_cb(mrb_state *mrb, struct RBasic *obj, void *ud)
 {
@@ -117,5 +118,5 @@
   /* filter dead objects */
   if (mrb_object_dead_p(mrb, obj)) {
-    return;
+    return MRB_EACH_OBJ_OK;
   }
 
@@ -124,5 +125,5 @@
   case MRB_TT_ENV:
   case MRB_TT_ICLASS:
-    return;
+    return MRB_EACH_OBJ_OK;
   default:
     break;
@@ -130,13 +131,14 @@
 
   /* filter half baked (or internal) objects */
-  if (!obj->c) return;
+  if (!obj->c) return MRB_EACH_OBJ_OK;
 
   /* filter class kind if target module defined */
   if (d->target_module && !mrb_obj_is_kind_of(mrb, mrb_obj_value(obj), d->target_module)) {
-    return;
+    return MRB_EACH_OBJ_OK;
   }
 
   mrb_yield(mrb, d->block, mrb_obj_value(obj));
   ++d->count;
+  return MRB_EACH_OBJ_OK;
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-print/src/print.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-print/src/print.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-print/src/print.c	(revision 331)
@@ -1,10 +1,14 @@
-#include "mruby.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/string.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(_WIN32)
 # include <windows.h>
 # include <io.h>
+#ifdef _MSC_VER
+# define isatty(x) _isatty(x)
+# define fileno(x) _fileno(x)
+#endif
 #endif
 
@@ -13,5 +17,5 @@
 {
   if (mrb_string_p(obj)) {
-#if defined(__MINGW32__) || defined(__MINGW64__)
+#if defined(_WIN32)
     if (isatty(fileno(stdout))) {
       DWORD written;
@@ -19,5 +23,5 @@
       char* utf8 = RSTRING_PTR(obj);
       int wlen = MultiByteToWideChar(CP_UTF8, 0, utf8, mlen, NULL, 0);
-      wchar_t* utf16 = mrb_malloc(mrb, (wlen+1) * sizeof(wchar_t));
+      wchar_t* utf16 = (wchar_t*)mrb_malloc(mrb, (wlen+1) * sizeof(wchar_t));
       if (utf16 == NULL) return;
       if (MultiByteToWideChar(CP_UTF8, 0, utf8, mlen, utf16, wlen) > 0) {
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-proc-ext/src/proc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-proc-ext/src/proc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-proc-ext/src/proc.c	(revision 331)
@@ -1,8 +1,8 @@
-#include "mruby.h"
-#include "mruby/proc.h"
-#include "mruby/opcode.h"
-#include "mruby/array.h"
-#include "mruby/string.h"
-#include "mruby/debug.h"
+#include <mruby.h>
+#include <mruby/proc.h>
+#include <mruby/opcode.h>
+#include <mruby/array.h>
+#include <mruby/string.h>
+#include <mruby/debug.h>
 
 static mrb_value
@@ -53,5 +53,5 @@
     line = mrb_debug_get_line(irep, 0);
     if (line != -1) {
-      mrb_str_append(mrb, str, mrb_fixnum_value(line));
+      str = mrb_format(mrb, "%S:%S", str, mrb_fixnum_value(line));
     }
     else {
@@ -108,9 +108,12 @@
   const struct mrb_irep *irep = proc->body.irep;
   mrb_aspec aspec;
-  mrb_value parameters;
+  mrb_value sname, parameters;
   int i, j;
 
   if (MRB_PROC_CFUNC_P(proc)) {
     // TODO cfunc aspec is not implemented yet
+    return mrb_ary_new(mrb);
+  }
+  if (!irep) {
     return mrb_ary_new(mrb);
   }
@@ -135,12 +138,15 @@
 
   parameters = mrb_ary_new_capa(mrb, irep->nlocals-1);
+
   for (i = 0, p = parameters_list; p->name; p++) {
-    mrb_value sname = mrb_symbol_value(mrb_intern_cstr(mrb, p->name));
+    if (p->size <= 0) continue;
+    sname = mrb_symbol_value(mrb_intern_cstr(mrb, p->name));
     for (j = 0; j < p->size; i++, j++) {
-      mrb_assert(i < (irep->nlocals-1));
-      mrb_ary_push(mrb, parameters, mrb_assoc_new(mrb,
-        sname,
-        mrb_symbol_value(irep->lv[i].name)
-      ));
+      mrb_value a = mrb_ary_new(mrb);
+      mrb_ary_push(mrb, a, sname);
+      if (irep->lv[i].name) {
+        mrb_ary_push(mrb, a, mrb_symbol_value(irep->lv[i].name));
+      }
+      mrb_ary_push(mrb, parameters, a);
     }
   }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-proc-ext/test/proc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-proc-ext/test/proc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-proc-ext/test/proc.c	(revision 331)
@@ -1,5 +1,5 @@
-#include "mruby.h"
-#include "mruby/proc.h"
-#include "mruby/class.h"
+#include <mruby.h>
+#include <mruby/proc.h>
+#include <mruby/class.h>
 
 static mrb_value
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-proc-ext/test/proc.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-proc-ext/test/proc.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-proc-ext/test/proc.rb	(revision 331)
@@ -54,4 +54,5 @@
   assert_equal([[:opt, :a]], lambda {|a=nil|}.parameters)
   assert_equal([[:req, :a]], ->(a){}.parameters)
+  assert_equal([[:rest]], lambda { |*| }.parameters)
   assert_equal([[:rest, :a]], Proc.new {|*a|}.parameters)
   assert_equal([[:opt, :a], [:opt, :b], [:opt, :c], [:opt, :d], [:rest, :e], [:opt, :f], [:opt, :g], [:block, :h]], Proc.new {|a,b,c=:c,d=:d,*e,f,g,&h|}.parameters)
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/mt19937ar.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-random/src/mt19937ar.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/mt19937ar.c	(revision 331)
@@ -2,8 +2,37 @@
 ** mt19937ar.c - MT Random functions
 **
-** See Copyright Notice in mruby.h
+** Copyright (C) 1997 - 2016, Makoto Matsumoto and Takuji Nishimura,
+** All rights reserved.
+**
+** Permission is hereby granted, free of charge, to any person obtaining
+** a copy of this software and associated documentation files (the
+** "Software"), to deal in the Software without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Software, and to
+** permit persons to whom the Software is furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be
+** included in all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**
+** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
+**
+** Any feedback is very welcome.
+** http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+** email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+**
+** This version is modified by mruby developers. If you see any problem,
+** contact us first at https://github.com/mruby/mruby/issues
 */
 
-#include "mruby.h"
+#include <mruby.h>
 #include "mt19937ar.h"
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/mt19937ar.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-random/src/mt19937ar.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/mt19937ar.h	(revision 331)
@@ -2,5 +2,34 @@
 ** mt19937ar.h - MT Random functions
 **
-** See Copyright Notice in mruby.h
+** Copyright (C) 1997 - 2016, Makoto Matsumoto and Takuji Nishimura,
+** All rights reserved.
+**
+** Permission is hereby granted, free of charge, to any person obtaining
+** a copy of this software and associated documentation files (the
+** "Software"), to deal in the Software without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Software, and to
+** permit persons to whom the Software is furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be
+** included in all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**
+** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
+**
+** Any feedback is very welcome.
+** http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+** email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+**
+** This version is modified by mruby developers. If you see any problem,
+** contact us first at https://github.com/mruby/mruby/issues
 */
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/random.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-random/src/random.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/random.c	(revision 331)
@@ -5,9 +5,9 @@
 */
 
-#include "mruby.h"
-#include "mruby/variable.h"
-#include "mruby/class.h"
-#include "mruby/data.h"
-#include "mruby/array.h"
+#include <mruby.h>
+#include <mruby/variable.h>
+#include <mruby/class.h>
+#include <mruby/data.h>
+#include <mruby/array.h>
 #include "mt19937ar.h"
 
@@ -80,8 +80,8 @@
 
   if (!mrb_nil_p(arg)) {
-    if (!mrb_fixnum_p(arg)) {
+    arg = mrb_check_convert_type(mrb, arg, MRB_TT_FIXNUM, "Fixnum", "to_int");
+    if (mrb_nil_p(arg)) {
       mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid argument type");
     }
-    arg = mrb_check_convert_type(mrb, arg, MRB_TT_FIXNUM, "Fixnum", "to_int");
     if (mrb_fixnum(arg) < 0) {
       arg = mrb_fixnum_value(0 - mrb_fixnum(arg));
@@ -125,4 +125,6 @@
   mt_state *t;
 
+  seed = get_opt(mrb);
+
   /* avoid memory leaks */
   t = (mt_state*)DATA_PTR(self);
@@ -135,5 +137,4 @@
   t->mti = N + 1;
 
-  seed = get_opt(mrb);
   seed = mrb_random_mt_srand(mrb, t, seed);
   if (mrb_nil_p(seed)) {
@@ -267,5 +268,5 @@
   mrb_bool given;
   mt_state *random = NULL;
-  mrb_int len = RARRAY_LEN(ary);
+  mrb_int len;
 
   mrb_get_args(mrb, "|i?d", &n, &given, &random, &mt_state_type);
@@ -275,4 +276,5 @@
   mrb_random_rand_seed(mrb, random);
   mt_rand(random);
+  len = RARRAY_LEN(ary);
   if (!given) {                 /* pick one element */
     switch (len) {
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/random.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-random/src/random.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/random.h	(revision 331)
@@ -5,6 +5,6 @@
 */
 
-#ifndef RANDOM_H
-#define RANDOM_H
+#ifndef MRUBY_RANDOM_H
+#define MRUBY_RANDOM_H
 
 void mrb_mruby_random_gem_init(mrb_state *mrb);
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/test/random.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-random/test/random.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/test/random.rb	(revision 331)
@@ -75,2 +75,14 @@
   ary1 != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and 10.times { |x| ary1.include? x } and ary1 == ary2
 end
+
+assert('Array#sample checks input length after reading arguments') do
+  $ary = [1, 2, 3]
+  class ArrayChange
+    def to_i
+      $ary << 4
+      4
+    end
+  end
+
+  assert_equal [1, 2, 3, 4], $ary.sample(ArrayChange.new).sort
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/mrblib/range.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/mrblib/range.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/mrblib/range.rb	(revision 331)
@@ -0,0 +1,31 @@
+class Range
+  ##
+  # call-seq:
+  #    rng.first    -> obj
+  #    rng.first(n) -> an_array
+  #
+  # Returns the first object in the range, or an array of the first +n+
+  # elements.
+  #
+  #   (10..20).first     #=> 10
+  #   (10..20).first(3)  #=> [10, 11, 12]
+  #
+  def first(*args)
+    return self.begin if args.empty?
+
+    raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 1)" unless args.length == 1
+    nv = args[0]
+    raise TypeError, "no implicit conversion from nil to integer" if nv.nil?
+    raise TypeError, "no implicit conversion of #{nv.class} into Integer" unless nv.respond_to?(:to_int)
+    n = nv.to_int
+    raise TypeError, "no implicit conversion of #{nv.class} into Integer" unless n.kind_of?(Integer)
+    raise ArgumentError, "negative array size (or size too big)" unless 0 <= n
+    ary = []
+    each do |i|
+      break if n <= 0
+      ary.push(i)
+      n -= 1
+    end
+    ary
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/src/range.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-range-ext/src/range.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/src/range.c	(revision 331)
@@ -1,5 +1,6 @@
-#include "mruby.h"
-#include "mruby/range.h"
+#include <mruby.h>
+#include <mruby/range.h>
 #include <math.h>
+#include <float.h>
 
 static mrb_bool
@@ -44,5 +45,5 @@
 {
   mrb_value val;
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
   mrb_value beg, end;
 
@@ -68,30 +69,4 @@
 /*
  *  call-seq:
- *     rng.first    -> obj
- *     rng.first(n) -> an_array
- *
- *  Returns the first object in the range, or an array of the first +n+
- *  elements.
- *
- *    (10..20).first     #=> 10
- *    (10..20).first(3)  #=> [10, 11, 12]
- */
-static mrb_value
-mrb_range_first(mrb_state *mrb, mrb_value range)
-{
-  mrb_int num;
-  mrb_value array;
-  struct RRange *r = mrb_range_ptr(range);
-
-  if (mrb_get_args(mrb, "|i", &num) == 0) {
-    return r->edges->beg;
-  }
-
-  array = mrb_funcall(mrb, range, "to_a", 0);
-  return mrb_funcall(mrb, array, "first", 1, mrb_fixnum_value(num));
-}
-
-/*
- *  call-seq:
  *     rng.last    -> obj
  *     rng.last(n) -> an_array
@@ -113,5 +88,5 @@
   mrb_value num;
   mrb_value array;
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
 
   if (mrb_get_args(mrb, "|o", &num) == 0) {
@@ -137,13 +112,15 @@
 mrb_range_size(mrb_state *mrb, mrb_value range)
 {
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
   mrb_value beg, end;
-  double beg_f, end_f;
+  mrb_float beg_f, end_f;
   mrb_bool num_p = TRUE;
+  mrb_bool excl;
 
   beg = r->edges->beg;
   end = r->edges->end;
+  excl = r->excl;
   if (mrb_fixnum_p(beg)) {
-    beg_f = (double)mrb_fixnum(beg);
+    beg_f = (mrb_float)mrb_fixnum(beg);
   }
   else if (mrb_float_p(beg)) {
@@ -154,5 +131,5 @@
   }
   if (mrb_fixnum_p(end)) {
-    end_f = (double)mrb_fixnum(end);
+    end_f = (mrb_float)mrb_fixnum(end);
   }
   else if (mrb_float_p(end)) {
@@ -163,12 +140,22 @@
   }
   if (num_p) {
-    double f;
+    mrb_float n = end_f - beg_f;
+    mrb_float err = (fabs(beg_f) + fabs(end_f) + fabs(end_f-beg_f)) * MRB_FLOAT_EPSILON;
 
-    if (beg_f > end_f) return mrb_fixnum_value(0);
-    f = end_f - beg_f;
-    if (!r->excl) {
-      return mrb_fixnum_value((mrb_int)ceil(f + 1));
+    if (err>0.5) err=0.5;
+    if (excl) {
+      if (n<=0) return mrb_fixnum_value(0);
+      if (n<1)
+        n = 0;
+      else
+        n = floor(n - err);
     }
-    return mrb_fixnum_value((mrb_int)ceil(f));
+    else {
+      if (n<0) return mrb_fixnum_value(0);
+      n = floor(n + err);
+    }
+    if (isinf(n+1))
+      return mrb_float_value(mrb, INFINITY);
+    return mrb_fixnum_value((mrb_int)n+1);
   }
   return mrb_nil_value();
@@ -181,5 +168,4 @@
 
   mrb_define_method(mrb, s, "cover?", mrb_range_cover, MRB_ARGS_REQ(1));
-  mrb_define_method(mrb, s, "first",  mrb_range_first, MRB_ARGS_OPT(1));
   mrb_define_method(mrb, s, "last",   mrb_range_last,  MRB_ARGS_OPT(1));
   mrb_define_method(mrb, s, "size",   mrb_range_size,  MRB_ARGS_NONE());
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/test/range.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-range-ext/test/range.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-range-ext/test/range.rb	(revision 331)
@@ -11,4 +11,5 @@
   assert_equal 10, (10..20).first
   assert_equal [10, 11, 12], (10..20).first(3)
+  assert_equal [0, 1, 2], (0..Float::INFINITY).first(3)
 end
 
@@ -26,4 +27,6 @@
   assert_equal 5, (1...6.0).size
   assert_equal 5, (1.1...6).size
+  assert_equal 15, (1.0..15.9).size
+  assert_equal Float::INFINITY, (0..Float::INFINITY).size
   assert_nil ('a'..'z').size
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-sprintf/src/kernel.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-sprintf/src/kernel.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-sprintf/src/kernel.c	(revision 331)
@@ -5,5 +5,5 @@
 */
 
-#include "mruby.h"
+#include <mruby.h>
 
 mrb_value mrb_f_sprintf(mrb_state *mrb, mrb_value obj); /* in sprintf.c */
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-sprintf/src/sprintf.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-sprintf/src/sprintf.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-sprintf/src/sprintf.c	(revision 331)
@@ -5,12 +5,12 @@
 */
 
-#include "mruby.h"
+#include <mruby.h>
 
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>
-#include "mruby/string.h"
-#include "mruby/hash.h"
-#include "mruby/numeric.h"
+#include <mruby/string.h>
+#include <mruby/hash.h>
+#include <mruby/numeric.h>
 #include <math.h>
 #include <ctype.h>
@@ -18,5 +18,5 @@
 #define BIT_DIGITS(N)   (((N)*146)/485 + 1)  /* log2(10) =~ 146/485 */
 #define BITSPERDIG MRB_INT_BIT
-#define EXTENDSIGN(n, l) (((~0 << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0 << (n)))
+#define EXTENDSIGN(n, l) (((~0U << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0U << (n)))
 
 mrb_value mrb_str_format(mrb_state *, int, const mrb_value *, mrb_value);
@@ -72,5 +72,5 @@
 mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
 {
-  char buf[64], *b = buf + sizeof buf;
+  char buf[66], *b = buf + sizeof buf;
   mrb_int num = mrb_fixnum(x);
   uint64_t val = (uint64_t)num;
@@ -80,8 +80,4 @@
     mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid radix %S", mrb_fixnum_value(base));
   }
-
-  if (val >= (1 << 10))
-    val &= 0x3ff;
-
   if (val == 0) {
     return mrb_str_new_lit(mrb, "0");
@@ -121,6 +117,7 @@
 #define CHECK(l) do {\
 /*  int cr = ENC_CODERANGE(result);*/\
-  while (blen + (l) >= bsiz) {\
+  while ((l) >= bsiz - blen) {\
     bsiz*=2;\
+    if (bsiz < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, "too big specifier"); \
   }\
   mrb_str_resize(mrb, result, bsiz);\
@@ -141,27 +138,61 @@
 } while (0)
 
-#define GETARG() (!mrb_undef_p(nextvalue) ? nextvalue : \
-  posarg == -1 ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%S) mixed with numbered", mrb_fixnum_value(nextarg)), mrb_undef_value()) : \
-  posarg == -2 ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%S) mixed with named", mrb_fixnum_value(nextarg)), mrb_undef_value()) : \
+static void
+check_next_arg(mrb_state *mrb, int posarg, int nextarg)
+{
+  switch (posarg) {
+  case -1:
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%S) mixed with numbered", mrb_fixnum_value(nextarg));
+    break;
+  case -2:
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "unnumbered(%S) mixed with named", mrb_fixnum_value(nextarg));
+    break;
+  default:
+    break;
+  }
+}
+
+static void
+check_pos_arg(mrb_state *mrb, int posarg, int n)
+{
+  if (posarg > 0) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%S) after unnumbered(%S)",
+               mrb_fixnum_value(n), mrb_fixnum_value(posarg));
+  }
+  if (posarg == -2) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%S) after named", mrb_fixnum_value(n));
+  }
+  if (n < 1) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid index - %S$", mrb_fixnum_value(n));
+  }
+}
+
+static void
+check_name_arg(mrb_state *mrb, int posarg, const char *name, int len)
+{
+  if (posarg > 0) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%S after unnumbered(%S)",
+               mrb_str_new(mrb, (name), (len)), mrb_fixnum_value(posarg));
+  }
+  if (posarg == -1) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%S after numbered", mrb_str_new(mrb, (name), (len)));
+  }
+}
+
+#define GETNEXTARG() (\
+  check_next_arg(mrb, posarg, nextarg),\
   (posarg = nextarg++, GETNTHARG(posarg)))
 
-#define GETPOSARG(n) (posarg > 0 ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%S) after unnumbered(%S)", mrb_fixnum_value(n), mrb_fixnum_value(posarg)), mrb_undef_value()) : \
-  posarg == -2 ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "numbered(%S) after named", mrb_fixnum_value(n)), mrb_undef_value()) : \
-  ((n < 1) ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid index - %S$", mrb_fixnum_value(n)), mrb_undef_value()) : \
-  (posarg = -1, GETNTHARG(n))))
+#define GETARG() (!mrb_undef_p(nextvalue) ? nextvalue : GETNEXTARG())
+
+#define GETPOSARG(n) (\
+  check_pos_arg(mrb, posarg, n),\
+  (posarg = -1, GETNTHARG(n)))
 
 #define GETNTHARG(nth) \
   ((nth >= argc) ? (mrb_raise(mrb, E_ARGUMENT_ERROR, "too few arguments"), mrb_undef_value()) : argv[nth])
 
-#define GETNAMEARG(id, name, len) ( \
-  posarg > 0 ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%S after unnumbered(%S)", mrb_str_new(mrb, (name), (len)), mrb_fixnum_value(posarg)), mrb_undef_value()) : \
-  posarg == -1 ? \
-  (mrb_raisef(mrb, E_ARGUMENT_ERROR, "named%S after numbered", mrb_str_new(mrb, (name), (len))), mrb_undef_value()) :    \
+#define GETNAMEARG(id, name, len) (\
+  check_name_arg(mrb, posarg, name, len),\
   (posarg = -2, mrb_hash_fetch(mrb, get_hash(mrb, &hash, argc, argv), id, mrb_undef_value())))
 
@@ -187,8 +218,8 @@
   } \
   else { \
-    tmp_v = GETARG(); \
+    tmp_v = GETNEXTARG(); \
     p = t; \
   } \
-  num = mrb_fixnum(tmp_v); \
+  num = mrb_int(mrb, tmp_v); \
 } while (0)
 
@@ -536,4 +567,5 @@
 
     for (t = p; t < end && *t != '%'; t++) ;
+    if (t + 1 == end) ++t;
     PUSH(p, t - p);
     if (t >= end)
@@ -680,22 +712,17 @@
           mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid character");
         }
+        mrb_check_type(mrb, tmp, MRB_TT_STRING);
         c = RSTRING_PTR(tmp);
         n = RSTRING_LEN(tmp);
         if (!(flags & FWIDTH)) {
-          CHECK(n);
-          memcpy(buf+blen, c, n);
-          blen += n;
+          PUSH(c, n);
         }
         else if ((flags & FMINUS)) {
-          CHECK(n);
-          memcpy(buf+blen, c, n);
-          blen += n;
-          FILL(' ', width-1);
+          PUSH(c, n);
+          if (width>0) FILL(' ', width-1);
         }
         else {
-          FILL(' ', width-1);
-          CHECK(n);
-          memcpy(buf+blen, c, n);
-          blen += n;
+          if (width>0) FILL(' ', width-1);
+          PUSH(c, n);
         }
       }
@@ -717,5 +744,6 @@
           RSTRING(result)->flags &= ~MRB_STR_EMBED_LEN_MASK;
           RSTRING(result)->flags |= tmp_n << MRB_STR_EMBED_LEN_SHIFT;
-        } else {
+        }
+        else {
           RSTRING(result)->as.heap.len = blen;
         }
@@ -734,17 +762,9 @@
             width -= (int)slen;
             if (!(flags&FMINUS)) {
-              CHECK(width);
-              while (width--) {
-                buf[blen++] = ' ';
-              }
+              FILL(' ', width);
             }
-            CHECK(len);
-            memcpy(&buf[blen], RSTRING_PTR(str), len);
-            blen += len;
+            PUSH(RSTRING_PTR(str), len);
             if (flags&FMINUS) {
-              CHECK(width);
-              while (width--) {
-                buf[blen++] = ' ';
-              }
+              FILL(' ', width);
             }
             break;
@@ -764,9 +784,9 @@
       case 'u': {
         mrb_value val = GETARG();
-        char fbuf[32], nbuf[64], *s;
+        char nbuf[68], *s;
         const char *prefix = NULL;
         int sign = 0, dots = 0;
         char sc = 0;
-        mrb_int v = 0, org_v = 0;
+        mrb_int v = 0;
         int base;
         mrb_int len;
@@ -775,13 +795,5 @@
           case 'd':
           case 'i':
-          case 'u':
             sign = 1; break;
-          case 'o':
-          case 'x':
-          case 'X':
-          case 'b':
-          case 'B':
-            if (flags&(FPLUS|FSPACE)) sign = 1;
-            break;
           default:
             break;
@@ -801,8 +813,4 @@
         switch (mrb_type(val)) {
           case MRB_TT_FLOAT:
-            if (FIXABLE(mrb_float(val))) {
-              val = mrb_fixnum_value((mrb_int)mrb_float(val));
-              goto bin_retry;
-            }
             val = mrb_flo_to_fixnum(mrb, val);
             if (mrb_fixnum_p(val)) goto bin_retry;
@@ -836,5 +844,4 @@
 
         if (base == 2) {
-          org_v = v;
           if (v < 0 && !sign) {
             val = mrb_fix2binstr(mrb, mrb_fixnum_value(v), base);
@@ -844,37 +851,51 @@
             val = mrb_fixnum_to_str(mrb, mrb_fixnum_value(v), base);
           }
-          v = mrb_fixnum(mrb_str_to_inum(mrb, val, 10, FALSE));
         }
         if (sign) {
-          char c = *p;
-          if (c == 'i') c = 'd'; /* %d and %i are identical */
-          if (base == 2) c = 'd';
-          if (v < 0) {
-            v = -v;
-            sc = '-';
-            width--;
-          }
-          else if (flags & FPLUS) {
-            sc = '+';
-            width--;
-          }
-          else if (flags & FSPACE) {
-            sc = ' ';
-            width--;
-          }
-          snprintf(fbuf, sizeof(fbuf), "%%l%c", c);
-          snprintf(nbuf, sizeof(nbuf), fbuf, v);
+          if (v > 0) {
+            if (flags & FPLUS) {
+              sc = '+';
+              width--;
+            }
+            else if (flags & FSPACE) {
+              sc = ' ';
+              width--;
+            }
+          }
+          switch (base) {
+          case 2:
+            strncpy(nbuf, RSTRING_PTR(val), sizeof(nbuf));
+            break;
+          case 8:
+            snprintf(nbuf, sizeof(nbuf), "%" MRB_PRIo, v);
+            break;
+          case 10:
+            snprintf(nbuf, sizeof(nbuf), "%" MRB_PRId, v);
+            break;
+          case 16:
+            snprintf(nbuf, sizeof(nbuf), "%" MRB_PRIx, v);
+            break;
+          }
           s = nbuf;
         }
         else {
-          char c = *p;
-          if (c == 'X') c = 'x';
-          if (base == 2) c = 'd';
           s = nbuf;
-          if (v < 0) {
+          if (base != 10 && v < 0) {
             dots = 1;
           }
-          snprintf(fbuf, sizeof(fbuf), "%%l%c", c);
-          snprintf(++s, sizeof(nbuf) - 1, fbuf, v);
+          switch (base) {
+          case 2:
+            strncpy(++s, RSTRING_PTR(val), sizeof(nbuf)-1);
+            break;
+          case 8:
+            snprintf(++s, sizeof(nbuf)-1, "%" MRB_PRIo, v);
+            break;
+          case 10:
+            snprintf(++s, sizeof(nbuf)-1, "%" MRB_PRId, v);
+            break;
+          case 16:
+            snprintf(++s, sizeof(nbuf)-1, "%" MRB_PRIx, v);
+            break;
+          }
           if (v < 0) {
             char d;
@@ -950,9 +971,6 @@
         }
 
-        if (!(flags&FMINUS)) {
-          CHECK(width);
-          while (width-- > 0) {
-            buf[blen++] = ' ';
-          }
+        if (!(flags&FMINUS) && width > 0) {
+          FILL(' ', width);
         }
 
@@ -963,24 +981,20 @@
           PUSH(prefix, plen);
         }
-        CHECK(prec - len);
         if (dots) PUSH("..", 2);
 
-        if (v < 0 || (base == 2 && org_v < 0)) {
-          char c = sign_bits(base, p);
-          while (len < prec--) {
-            buf[blen++] = c;
-          }
-        }
-        else if ((flags & (FMINUS|FPREC)) != FMINUS) {
-          char c = '0';
-          while (len < prec--) {
-            buf[blen++] = c;
-          }
-        }
-
+        if (prec > len) {
+          CHECK(prec - len);
+          if (v < 0) {
+            char c = sign_bits(base, p);
+            FILL(c, prec - len);
+          }
+          else if ((flags & (FMINUS|FPREC)) != FMINUS) {
+            char c = '0';
+            FILL(c, prec - len);
+          }
+        }
         PUSH(s, len);
-        CHECK(width);
-        while (width-- > 0) {
-          buf[blen++] = ' ';
+        if (width > 0) {
+          FILL(' ', width);
         }
       }
@@ -1003,4 +1017,5 @@
           const char *expr;
           const int elen = 3;
+          char sign = '\0';
 
           if (isnan(fval)) {
@@ -1011,30 +1026,27 @@
           }
           need = elen;
-          if ((!isnan(fval) && fval < 0.0) || (flags & FPLUS))
-            need++;
+          if (!isnan(fval) && fval < 0.0)
+            sign = '-';
+          else if (flags & (FPLUS|FSPACE))
+            sign = (flags & FPLUS) ? '+' : ' ';
+          if (sign)
+	    ++need;
           if ((flags & FWIDTH) && need < width)
             need = width;
 
-          CHECK(need + 1);
-          snprintf(&buf[blen], need + 1, "%*s", need, "");
+          if (need < 0) {
+            mrb_raise(mrb, E_ARGUMENT_ERROR, "width too big");
+          }
+          FILL(' ', need);
           if (flags & FMINUS) {
-            if (!isnan(fval) && fval < 0.0)
-              buf[blen++] = '-';
-            else if (flags & FPLUS)
-              buf[blen++] = '+';
-            else if (flags & FSPACE)
-              blen++;
-            memcpy(&buf[blen], expr, elen);
+            if (sign)
+              buf[blen - need--] = sign;
+            memcpy(&buf[blen - need], expr, elen);
           }
           else {
-            if (!isnan(fval) && fval < 0.0)
-              buf[blen + need - elen - 1] = '-';
-            else if (flags & FPLUS)
-              buf[blen + need - elen - 1] = '+';
-            else if ((flags & FSPACE) && need > width)
-              blen++;
-            memcpy(&buf[blen + need - elen], expr, elen);
-          }
-          blen += strlen(&buf[blen]);
+            if (sign)
+              buf[blen - elen - 1] = sign;
+            memcpy(&buf[blen - elen], expr, elen);
+          }
           break;
         }
@@ -1052,7 +1064,14 @@
           need = width;
         need += 20;
+        if (need <= 0) {
+          mrb_raise(mrb, E_ARGUMENT_ERROR,
+                    (width > prec ? "width too big" : "prec too big"));
+        }
 
         CHECK(need);
         n = snprintf(&buf[blen], need, fbuf, fval);
+        if (n < 0) {
+          mrb_raise(mrb, E_RUNTIME_ERROR, "formatting error");
+        }
         blen += n;
       }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-sprintf/test/sprintf.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-sprintf/test/sprintf.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-sprintf/test/sprintf.rb	(revision 331)
@@ -6,3 +6,98 @@
   assert_equal "1 one 1.0", "%d %s %3.1f" % [ 1, "one", 1.01 ]
   assert_equal "123 < 456", "%{num} < %<str>s" % { num: 123, str: "456" }
+  assert_equal 15, ("%b" % (1<<14)).size
 end
+
+assert('String#% with inf') do
+  inf = Float::INFINITY
+
+  assert_equal "Inf", "%f" % inf
+  assert_equal "Inf", "%2f" % inf
+  assert_equal "Inf", "%3f" % inf
+  assert_equal " Inf", "%4f" % inf
+  assert_equal "  Inf", "%5f" % inf
+
+  assert_equal "+Inf", "%+f" % inf
+  assert_equal "+Inf", "%+2f" % inf
+  assert_equal "+Inf", "%+3f" % inf
+  assert_equal "+Inf", "%+4f" % inf
+  assert_equal " +Inf", "%+5f" % inf
+
+  assert_equal "Inf", "%-f" % inf
+  assert_equal "Inf", "%-2f" % inf
+  assert_equal "Inf", "%-3f" % inf
+  assert_equal "Inf ", "%-4f" % inf
+  assert_equal "Inf  ", "%-5f" % inf
+
+  assert_equal " Inf", "% f" % inf
+  assert_equal " Inf", "% 2f" % inf
+  assert_equal " Inf", "% 3f" % inf
+  assert_equal " Inf", "% 4f" % inf
+  assert_equal "  Inf", "% 5f" % inf
+end
+
+assert('String#% with nan') do
+  nan = Float::NAN
+
+  assert_equal "NaN", "%f" % nan
+  assert_equal "NaN", "%2f" % nan
+  assert_equal "NaN", "%3f" % nan
+  assert_equal " NaN", "%4f" % nan
+  assert_equal "  NaN", "%5f" % nan
+
+  assert_equal "+NaN", "%+f" % nan
+  assert_equal "+NaN", "%+2f" % nan
+  assert_equal "+NaN", "%+3f" % nan
+  assert_equal "+NaN", "%+4f" % nan
+  assert_equal " +NaN", "%+5f" % nan
+
+  assert_equal "NaN", "%-f" % nan
+  assert_equal "NaN", "%-2f" % nan
+  assert_equal "NaN", "%-3f" % nan
+  assert_equal "NaN ", "%-4f" % nan
+  assert_equal "NaN  ", "%-5f" % nan
+
+  assert_equal " NaN", "% f" % nan
+  assert_equal " NaN", "% 2f" % nan
+  assert_equal " NaN", "% 3f" % nan
+  assert_equal " NaN", "% 4f" % nan
+  assert_equal "  NaN", "% 5f" % nan
+end
+
+assert("String#% with invalid chr") do
+  begin
+    class Fixnum
+      alias_method :chr_, :chr if method_defined?(:chr)
+
+      def chr
+        nil
+      end
+    end
+
+    assert_raise TypeError do
+      "%c" % 0
+    end
+  ensure
+    class Fixnum
+      if method_defined?(:chr_)
+        alias_method :chr, :chr_
+        remove_method :chr_
+      end
+    end
+  end
+end
+
+assert("String#% %b") do
+  assert_equal("..10115", "%0b5" % -5)
+end
+
+assert("String#% invalid format") do
+  assert_raise ArgumentError do
+    "%?" % ""
+  end
+end
+
+assert("String#% invalid format shared substring") do
+  fmt = ("x"*30+"%!")[0...-1]
+  assert_equal fmt, sprintf(fmt, "")
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-string-ext/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/mrbgem.rake	(revision 331)
@@ -3,3 +3,4 @@
   spec.author  = 'mruby developers'
   spec.summary = 'String class extension'
+  spec.add_test_dependency 'mruby-enumerator', core: 'mruby-enumerator'
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/mrblib/string.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-string-ext/mrblib/string.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/mrblib/string.rb	(revision 331)
@@ -1,3 +1,22 @@
 class String
+
+  ##
+  #  call-seq:
+  #     String.try_convert(obj) -> string or nil
+  #
+  # Try to convert <i>obj</i> into a String, using to_str method.
+  # Returns converted string or nil if <i>obj</i> cannot be converted
+  # for any reason.
+  #
+  #     String.try_convert("str")     #=> "str"
+  #     String.try_convert(/re/)      #=> nil
+  #
+  def self.try_convert(obj)
+    if obj.respond_to?(:to_str)
+      obj.to_str
+    else
+      nil
+    end
+  end
 
   ##
@@ -27,5 +46,5 @@
     a = 0
     z = self.size - 1
-    a += 1 while " \f\n\r\t\v".include?(self[a]) and a <= z
+    a += 1 while a <= z and " \f\n\r\t\v".include?(self[a])
     (z >= 0) ? self[a..z] : ""
   end
@@ -44,5 +63,5 @@
     a = 0
     z = self.size - 1
-    z -= 1 while " \f\n\r\t\v\0".include?(self[z]) and a <= z
+    z -= 1 while a <= z and " \f\n\r\t\v\0".include?(self[z])
     (z >= 0) ? self[a..z] : ""
   end
@@ -60,6 +79,6 @@
     a = 0
     z = self.size - 1
-    a += 1 while " \f\n\r\t\v".include?(self[a]) and a <= z
-    z -= 1 while " \f\n\r\t\v\0".include?(self[z]) and a <= z
+    a += 1 while a <= z and " \f\n\r\t\v".include?(self[a])
+    z -= 1 while a <= z and " \f\n\r\t\v\0".include?(self[z])
     (z >= 0) ? self[a..z] : ""
   end
@@ -77,4 +96,5 @@
   #
   def lstrip!
+    raise RuntimeError, "can't modify frozen String" if frozen?
     s = self.lstrip
     (s == self) ? nil : self.replace(s)
@@ -93,4 +113,5 @@
   #
   def rstrip!
+    raise RuntimeError, "can't modify frozen String" if frozen?
     s = self.rstrip
     (s == self) ? nil : self.replace(s)
@@ -105,4 +126,5 @@
   #
   def strip!
+    raise RuntimeError, "can't modify frozen String" if frozen?
     s = self.strip
     (s == self) ? nil : self.replace(s)
@@ -165,4 +187,5 @@
   #
   def slice!(arg1, arg2=nil)
+    raise RuntimeError, "can't modify frozen String" if frozen?
     raise "wrong number of arguments (for 1..2)" if arg1.nil? && arg2.nil?
 
@@ -189,5 +212,5 @@
         idx = arg1
         idx += self.size if arg1 < 0
-        validated = true if idx >=0 && arg1 < self.size   
+        validated = true if idx >=0 && arg1 < self.size
       end
       if validated
@@ -236,12 +259,11 @@
   #
   def insert(idx, str)
-    pos = idx.to_i
-    pos += self.size + 1 if pos < 0
-
-    raise IndexError, "index #{idx.to_i} out of string" if pos < 0 || pos > self.size
-
-    return self + str if pos == -1
-    return str + self if pos == 0
-    return self[0..pos - 1] + str + self[pos..-1]
+    if idx == -1
+      return self << str
+    elsif idx < 0
+      idx += 1
+    end
+    self[idx, 0] = str
+    self
   end
 
@@ -258,61 +280,33 @@
   #     "hello".ljust(20, '1234')   #=> "hello123412341234123"
   def ljust(idx, padstr = ' ')
-    if idx <= self.size
-      return self
-    end
-    newstr = self.dup
-    newstr << padstr
-    while newstr.size <= idx
-      newstr << padstr
-    end
-    return newstr.slice(0,idx)
-  end
-
-  #     str.upto(other_str, exclusive=false) {|s| block }   -> str
-  #     str.upto(other_str, exclusive=false)                -> an_enumerator
-  #
-  #  Iterates through successive values, starting at <i>str</i> and
-  #  ending at <i>other_str</i> inclusive, passing each value in turn to
-  #  the block. The <code>String#succ</code> method is used to generate
-  #  each value.  If optional second argument exclusive is omitted or is false,
-  #  the last value will be included; otherwise it will be excluded.
-  #
-  #  If no block is given, an enumerator is returned instead.
-  #
-  #     "a8".upto("b6") {|s| print s, ' ' }
-  #     for s in "a8".."b6"
-  #       print s, ' '
-  #     end
-  #
-  #  <em>produces:</em>
-  #
-  #     a8 a9 b0 b1 b2 b3 b4 b5 b6
-  #     a8 a9 b0 b1 b2 b3 b4 b5 b6
-  #
-  #  If <i>str</i> and <i>other_str</i> contains only ascii numeric characters,
-  #  both are recognized as decimal numbers. In addition, the width of
-  #  string (e.g. leading zeros) is handled appropriately.
-  #
-  #     "9".upto("11").to_a   #=> ["9", "10", "11"]
-  #     "25".upto("5").to_a   #=> []
-  #     "07".upto("11").to_a  #=> ["07", "08", "09", "10", "11"]
-  #
-  def upto(other_str, excl=false, &block)
-    return to_enum :upto, other_str, excl unless block
-
-    str = self
-    n = self.<=>other_str
-    return self if n > 0 || (self == other_str && excl)
-    while true
-      block.call(str)
-      return self if !excl && str == other_str
-      str = str.succ
-      return self if excl && str == other_str
-    end
+    raise ArgumentError, 'zero width padding' if padstr == ''
+    return self if idx <= self.size
+    pad_repetitions = (idx / padstr.length).ceil
+    padding = (padstr * pad_repetitions)[0...(idx - self.length)]
+    self + padding
+  end
+
+  ##
+  #  call-seq:
+  #     str.rjust(integer, padstr=' ')   -> new_str
+  #
+  #  If <i>integer</i> is greater than the length of <i>str</i>, returns a new
+  #  <code>String</code> of length <i>integer</i> with <i>str</i> right justified
+  #  and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
+  #
+  #     "hello".rjust(4)            #=> "hello"
+  #     "hello".rjust(20)           #=> "               hello"
+  #     "hello".rjust(20, '1234')   #=> "123412341234123hello"
+  def rjust(idx, padstr = ' ')
+    raise ArgumentError, 'zero width padding' if padstr == ''
+    return self if idx <= self.size
+    pad_repetitions = (idx / padstr.length).ceil
+    padding = (padstr * pad_repetitions)[0...(idx - self.length)]
+    padding + self
   end
 
   def chars(&block)
     if block_given?
-      self.split('').map do |i|
+      self.split('').each do |i|
         block.call(i)
       end
@@ -322,5 +316,13 @@
     end
   end
-  alias each_char chars
+
+  def each_char(&block)
+    return to_enum :each_char unless block
+
+    split('').each do |i|
+      block.call(i)
+    end
+    self
+  end
 
   def codepoints(&block)
@@ -328,5 +330,5 @@
 
     if block_given?
-      self.split('').map do|x|
+      self.split('').each do|x|
         block.call(x.ord)
       end
@@ -337,3 +339,17 @@
   end
   alias each_codepoint codepoints
+
+  ##
+  # call-seq:
+  #    str.prepend(other_str)  -> str
+  #
+  # Prepend---Prepend the given string to <i>str</i>.
+  #
+  #    a = "world"
+  #    a.prepend("hello ") #=> "hello world"
+  #    a                   #=> "hello world"
+  def prepend(arg)
+    self[0, 0] = arg
+    self
+  end
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/src/string.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-string-ext/src/string.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/src/string.c	(revision 331)
@@ -1,8 +1,8 @@
 #include <string.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/string.h"
-#include "mruby/range.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/string.h>
+#include <mruby/range.h>
 
 static mrb_value
@@ -24,8 +24,9 @@
 {
   mrb_int pos, byte;
-  long len = RSTRING_LEN(str);
+  long len;
 
   mrb_get_args(mrb, "ii", &pos, &byte);
 
+  len = RSTRING_LEN(str);
   if (pos < -len || len <= pos)
     mrb_raisef(mrb, E_INDEX_ERROR, "index %S is out of array", mrb_fixnum_value(pos));
@@ -56,6 +57,12 @@
 
       len = RSTRING_LEN(str);
-      if (mrb_range_beg_len(mrb, a1, &beg, &len, len)) {
+      switch (mrb_range_beg_len(mrb, a1, &beg, &len, len, TRUE)) {
+      case 0:                   /* not range */
+        break;
+      case 1:                   /* range */
         return mrb_str_substr(mrb, str, beg, len);
+      case 2:                   /* out of range */
+        mrb_raisef(mrb, E_RANGE_ERROR, "%S out of range", a1);
+        break;
       }
       return mrb_nil_value();
@@ -128,4 +135,6 @@
 }
 
+static mrb_value mrb_fixnum_chr(mrb_state *mrb, mrb_value num);
+
 /*
  *  call-seq:
@@ -147,5 +156,10 @@
 {
   mrb_value str;
-  mrb_get_args(mrb, "S", &str);
+
+  mrb_get_args(mrb, "o", &str);
+  if (mrb_fixnum_p(str))
+    str = mrb_fixnum_chr(mrb, str);
+  else
+    str = mrb_string_type(mrb, str);
   mrb_str_concat(mrb, self, str);
   return self;
@@ -308,11 +322,12 @@
   mrb_int len;
   mrb_value arg;
-  char *p = RSTRING_PTR(self), *t;
-  char *e = p + RSTRING_LEN(self);
+  char *b = RSTRING_PTR(self);
+  char *p = b, *t;
+  char *e = b + RSTRING_LEN(self);
 
   mrb_get_args(mrb, "&", &blk);
 
   result = mrb_ary_new(mrb);
-
+  ai = mrb_gc_arena_save(mrb);
   if (!mrb_nil_p(blk)) {
     while (p < e) {
@@ -323,9 +338,15 @@
       arg = mrb_str_new(mrb, t, len);
       mrb_yield_argv(mrb, blk, 1, &arg);
+      mrb_gc_arena_restore(mrb, ai);
+      if (b != RSTRING_PTR(self)) {
+        ptrdiff_t diff = p - b;
+        b = RSTRING_PTR(self);
+        p = b + diff;
+      }
+      e = b + RSTRING_LEN(self);
     }
     return self;
   }
   while (p < e) {
-    ai = mrb_gc_arena_save(mrb);
     t = p;
     while (p < e && *p != '\n') p++;
@@ -354,5 +375,5 @@
   const char *prepend;
   struct RString *s = mrb_str_ptr(self);
-  size_t l;
+  mrb_int l;
 
   if (RSTRING_LEN(self) == 0)
@@ -374,5 +395,6 @@
     e = p + l - 1;
     result = mrb_str_new_lit(mrb, "");
-  } else {
+  }
+  else {
     // find leading letter of the ascii/number
     b = e;
@@ -392,5 +414,6 @@
         mrb_str_cat_lit(mrb, result, "\x01");
         (*e) = 0;
-      } else
+      }
+      else
         (*e)++;
       break;
@@ -400,11 +423,14 @@
       if (e == b) prepend = "1";
       *e = '0';
-    } else if (*e == 'z') {
+    }
+    else if (*e == 'z') {
       if (e == b) prepend = "a";
       *e = 'a';
-    } else if (*e == 'Z') {
+    }
+    else if (*e == 'Z') {
       if (e == b) prepend = "A";
       *e = 'A';
-    } else {
+    }
+    else {
       (*e)++;
       break;
@@ -428,42 +454,4 @@
   mrb_str_succ_bang(mrb, str);
   return str;
-}
-
-/*
- *  call-seq:
- *     str.prepend(other_str)  -> str
- *
- *  Prepend---Prepend the given string to <i>str</i>.
- *
- *     a = "world"
- *     a.prepend("hello ") #=> "hello world"
- *     a                   #=> "hello world"
- */
-static mrb_value
-mrb_str_prepend(mrb_state *mrb, mrb_value self)
-{
-  struct RString *s1 = mrb_str_ptr(self), *s2, *temp_s;
-  mrb_int len;
-  mrb_value other, temp_str;
-
-  mrb_get_args(mrb, "S", &other);
-
-  mrb_str_modify(mrb, s1);
-  if (!mrb_string_p(other)) {
-    other = mrb_str_to_str(mrb, other);
-  }
-  s2 = mrb_str_ptr(other);
-  len = RSTR_LEN(s1) + RSTR_LEN(s2);
-  temp_str = mrb_str_new(mrb, NULL, RSTR_LEN(s1));
-  temp_s = mrb_str_ptr(temp_str);
-  memcpy(RSTR_PTR(temp_s), RSTR_PTR(s1), RSTR_LEN(s1));
-  if (RSTRING_CAPA(self) < len) {
-    mrb_str_resize(mrb, self, len);
-  }
-  memcpy(RSTR_PTR(s1), RSTR_PTR(s2), RSTR_LEN(s2));
-  memcpy(RSTR_PTR(s1) + RSTR_LEN(s2), RSTR_PTR(temp_s), RSTR_LEN(temp_s));
-  RSTR_SET_LEN(s1, len);
-  RSTR_PTR(s1)[len] = '\0';
-  return self;
 }
 
@@ -530,7 +518,128 @@
   if (RSTRING_LEN(str) == 0)
     mrb_raise(mrb, E_ARGUMENT_ERROR, "empty string");
-  return mrb_fixnum_value(RSTRING_PTR(str)[0]);
+  return mrb_fixnum_value((unsigned char)RSTRING_PTR(str)[0]);
 }
 #endif
+
+static mrb_bool
+all_digits_p(const char *s, mrb_int len)
+{
+  while (len-- > 0) {
+    if (!ISDIGIT(*s)) return FALSE;
+    s++;
+  }
+  return TRUE;
+}
+
+/*
+ *  call-seq:
+ *     str.upto(other_str, exclusive=false) {|s| block }   -> str
+ *     str.upto(other_str, exclusive=false)                -> an_enumerator
+ *
+ *  Iterates through successive values, starting at <i>str</i> and
+ *  ending at <i>other_str</i> inclusive, passing each value in turn to
+ *  the block. The <code>String#succ</code> method is used to generate
+ *  each value.  If optional second argument exclusive is omitted or is false,
+ *  the last value will be included; otherwise it will be excluded.
+ *
+ *  If no block is given, an enumerator is returned instead.
+ *
+ *     "a8".upto("b6") {|s| print s, ' ' }
+ *     for s in "a8".."b6"
+ *       print s, ' '
+ *     end
+ *
+ *  <em>produces:</em>
+ *
+ *     a8 a9 b0 b1 b2 b3 b4 b5 b6
+ *     a8 a9 b0 b1 b2 b3 b4 b5 b6
+ *
+ *  If <i>str</i> and <i>other_str</i> contains only ascii numeric characters,
+ *  both are recognized as decimal numbers. In addition, the width of
+ *  string (e.g. leading zeros) is handled appropriately.
+ *
+ *     "9".upto("11").to_a   #=> ["9", "10", "11"]
+ *     "25".upto("5").to_a   #=> []
+ *     "07".upto("11").to_a  #=> ["07", "08", "09", "10", "11"]
+ */
+static mrb_value
+mrb_str_upto(mrb_state *mrb, mrb_value beg)
+{
+  mrb_value end;
+  mrb_value exclusive = mrb_false_value();
+  mrb_value block = mrb_nil_value();
+  mrb_value current, after_end;
+  mrb_int n;
+  mrb_bool excl;
+
+  mrb_get_args(mrb, "o|o&", &end, &exclusive, &block);
+
+  if (mrb_nil_p(block)) {
+    return mrb_funcall(mrb, beg, "to_enum", 3, mrb_symbol_value(mrb_intern_lit(mrb, "upto")), end, exclusive);
+  }
+  end = mrb_string_type(mrb, end);
+  excl = mrb_test(exclusive);
+
+  /* single character */
+  if (RSTRING_LEN(beg) == 1 && RSTRING_LEN(end) == 1 &&
+  ISASCII(RSTRING_PTR(beg)[0]) && ISASCII(RSTRING_PTR(end)[0])) {
+    char c = RSTRING_PTR(beg)[0];
+    char e = RSTRING_PTR(end)[0];
+    int ai = mrb_gc_arena_save(mrb);
+
+    if (c > e || (excl && c == e)) return beg;
+    for (;;) {
+      mrb_yield(mrb, block, mrb_str_new(mrb, &c, 1));
+      mrb_gc_arena_restore(mrb, ai);
+      if (!excl && c == e) break;
+      c++;
+      if (excl && c == e) break;
+    }
+    return beg;
+  }
+  /* both edges are all digits */
+  if (ISDIGIT(RSTRING_PTR(beg)[0]) && ISDIGIT(RSTRING_PTR(end)[0]) &&
+      all_digits_p(RSTRING_PTR(beg), RSTRING_LEN(beg)) &&
+      all_digits_p(RSTRING_PTR(end), RSTRING_LEN(end))) {
+    int ai = mrb_gc_arena_save(mrb);
+    mrb_int min_width = RSTRING_LEN(beg);
+    mrb_int max_width = RSTRING_LEN(end);
+    mrb_int bi = mrb_int(mrb, mrb_str_to_inum(mrb, beg, 10, FALSE));
+    mrb_int ei = mrb_int(mrb, mrb_str_to_inum(mrb, end, 10, FALSE));
+    mrb_value str = mrb_str_new(mrb, NULL, max_width);
+    char *buf = RSTRING_PTR(str);
+
+    while (bi <= ei) {
+      if (excl && bi == ei) break;
+      snprintf(buf, max_width+1, "%.*" MRB_PRId, (int)min_width, bi);
+      mrb_yield(mrb, block, mrb_str_new(mrb, buf, strlen(buf)));
+      mrb_gc_arena_restore(mrb, ai);
+      bi++;
+    }
+
+    return beg;
+  }
+  /* normal case */
+  n = mrb_int(mrb, mrb_funcall(mrb, beg, "<=>", 1, end));
+  if (n > 0 || (excl && n == 0)) return beg;
+
+  after_end = mrb_funcall(mrb, end, "succ", 0);
+  current = mrb_str_dup(mrb, beg);
+  while (!mrb_str_equal(mrb, current, after_end)) {
+    int ai = mrb_gc_arena_save(mrb);
+    mrb_value next = mrb_nil_value();
+    if (excl || !mrb_str_equal(mrb, current, end))
+      next = mrb_funcall(mrb, current, "succ", 0);
+    mrb_yield(mrb, block, current);
+    if (mrb_nil_p(next)) break;
+    current = mrb_str_to_str(mrb, next);
+    if (excl && mrb_str_equal(mrb, current, end)) break;
+    if (RSTRING_LEN(current) > RSTRING_LEN(end) || RSTRING_LEN(current) == 0)
+      break;
+    mrb_gc_arena_restore(mrb, ai);
+  }
+
+  return beg;
+}
 
 void
@@ -555,8 +664,8 @@
   mrb_define_method(mrb, s, "succ",            mrb_str_succ,            MRB_ARGS_NONE());
   mrb_define_method(mrb, s, "succ!",           mrb_str_succ_bang,       MRB_ARGS_NONE());
-  mrb_define_method(mrb, s, "prepend",         mrb_str_prepend,         MRB_ARGS_REQ(1));
   mrb_alias_method(mrb, s, mrb_intern_lit(mrb, "next"), mrb_intern_lit(mrb, "succ"));
   mrb_alias_method(mrb, s, mrb_intern_lit(mrb, "next!"), mrb_intern_lit(mrb, "succ!"));
   mrb_define_method(mrb, s, "ord", mrb_str_ord, MRB_ARGS_NONE());
+  mrb_define_method(mrb, s, "upto", mrb_str_upto, MRB_ARGS_ANY());
 
   mrb_define_method(mrb, mrb->fixnum_class, "chr", mrb_fixnum_chr, MRB_ARGS_NONE());
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/test/string.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-string-ext/test/string.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-string-ext/test/string.rb	(revision 331)
@@ -3,4 +3,11 @@
 
 UTF8STRING = ("\343\201\202".size == 1)
+
+assert('String.try_convert') do
+  assert_nil String.try_convert(nil)
+  assert_nil String.try_convert(:foo)
+  assert_equal "", String.try_convert("")
+  assert_equal "1,2,3", String.try_convert("1,2,3")
+end
 
 assert('String#getbyte') do
@@ -22,4 +29,16 @@
   assert_equal(h, str1.getbyte(0))
   assert_equal("Hello", str1)
+end
+
+assert("String#setbyte raises IndexError if arg conversion resizes String") do
+  $s = "01234\n"
+  class Tmp
+      def to_i
+          $s.chomp! ''
+          95
+      end
+  end
+  tmp = Tmp.new
+  assert_raise(IndexError) { $s.setbyte(5, tmp) }
 end
 
@@ -104,10 +123,14 @@
 
 assert('String#concat') do
-  s = "Hello "
-  s.concat "World!"
-  t = "Hello "
-  t << "World!"
-  assert_equal "Hello World!", t
-  assert_equal "Hello World!", s
+  assert_equal "Hello World!", "Hello " << "World" << 33
+  assert_equal "Hello World!", "Hello ".concat("World").concat(33)
+
+  o = Object.new
+  def o.to_str
+    "to_str"
+  end
+  assert_equal "hi to_str", "hi " << o
+
+  assert_raise(TypeError) { "".concat(Object.new) }
 end
 
@@ -400,4 +423,8 @@
   assert_raise(IndexError) { "abcd".insert(5, 'X') }
   assert_raise(IndexError) { "abcd".insert(-6, 'X') }
+
+  a = "abcd"
+  a.insert(0, 'X')
+  assert_equal "Xabcd", a
 end
 
@@ -411,9 +438,73 @@
   assert_equal "hello", "hello".ljust(4)
   assert_equal "hello               ", "hello".ljust(20)
+  assert_equal 20, "hello".ljust(20).length
   assert_equal "hello123412341234123", "hello".ljust(20, '1234')
   assert_equal "hello", "hello".ljust(-3)
 end
 
+assert('String#rjust') do
+  assert_equal "hello", "hello".rjust(4)
+  assert_equal "               hello", "hello".rjust(20)
+  assert_equal 20, "hello".rjust(20).length
+  assert_equal "123412341234123hello", "hello".rjust(20, '1234')
+  assert_equal "hello", "hello".rjust(-3)
+end
+
+if UTF8STRING
+  assert('String#ljust with UTF8') do
+    assert_equal "helloん              ", "helloん".ljust(20)
+    assert_equal "helloó                            ", "helloó".ljust(34)
+    assert_equal 34, "helloó".ljust(34).length
+    assert_equal "helloんんんんんんんんんんんんんん", "hello".ljust(19, 'ん')
+    assert_equal "helloんんんんんんんんんんんんんんん", "hello".ljust(20, 'ん')
+  end
+
+  assert('String#rjust with UTF8') do
+    assert_equal "              helloん", "helloん".rjust(20)
+    assert_equal "                            helloó", "helloó".rjust(34)
+    # assert_equal 34, "helloó".rjust(34).length
+    assert_equal "んんんんんんんんんんんんんんhello", "hello".rjust(19, 'ん')
+    assert_equal "んんんんんんんんんんんんんんんhello", "hello".rjust(20, 'ん')
+  end
+
+  assert('UTF8 byte counting') do
+    ret = '                                  '
+    ret[-6..-1] = "helloó"
+    assert_equal 34, ret.length
+  end
+end
+
+assert('String#ljust should not change string') do
+  a = "hello"
+  a.ljust(20)
+  assert_equal "hello", a
+end
+
+assert('String#rjust should not change string') do
+  a = "hello"
+  a.rjust(20)
+  assert_equal "hello", a
+end
+
+assert('String#ljust should raise on zero width padding') do
+  assert_raise(ArgumentError) { "foo".ljust(10, '') }
+end
+
+assert('String#rjust should raise on zero width padding') do
+  assert_raise(ArgumentError) { "foo".rjust(10, '') }
+end
+
 assert('String#upto') do
+  assert_equal %w(a8 a9 b0 b1 b2 b3 b4 b5 b6), "a8".upto("b6").to_a
+  assert_equal ["9", "10", "11"], "9".upto("11").to_a
+  assert_equal [], "25".upto("5").to_a
+  assert_equal ["07", "08", "09", "10", "11"], "07".upto("11").to_a
+
+if UTF8STRING
+  assert_equal ["あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お"], "あ".upto("お").to_a
+end
+
+  assert_equal ["9", ":", ";", "<", "=", ">", "?", "@", "A"], "9".upto("A").to_a
+
   a     = "aa"
   start = "aa"
@@ -475,4 +566,6 @@
   })
   assert_equal(2, count)
+
+  assert_raise(TypeError) { "a".upto(:c) {} }
 end
 
@@ -480,4 +573,8 @@
   got = "hello!".split('').map {|x| x.ord}
   expect = [104, 101, 108, 108, 111, 33]
+  unless UTF8STRING
+    got << "\xff".ord
+    expect << 0xff
+  end
   assert_equal expect, got
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-struct/mrblib/struct.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-struct/mrblib/struct.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-struct/mrblib/struct.rb	(revision 331)
@@ -83,4 +83,21 @@
     alias to_s inspect
   end
+
+  ##
+  # call-seq:
+  #   hsh.dig(key,...)                 -> object
+  #
+  # Extracts the nested value specified by the sequence of <i>key</i>
+  # objects by calling +dig+ at each step, returning +nil+ if any
+  # intermediate step is +nil+.
+  #
+  def dig(idx,*args)
+    n = self[idx]
+    if args.size > 0
+      n&.dig(*args)
+    else
+      n
+    end
+  end
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-struct/src/struct.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-struct/src/struct.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-struct/src/struct.c	(revision 331)
@@ -6,11 +6,11 @@
 
 #include <string.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/string.h"
-#include "mruby/class.h"
-#include "mruby/variable.h"
-#include "mruby/hash.h"
-#include "mruby/range.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/string.h>
+#include <mruby/class.h>
+#include <mruby/variable.h>
+#include <mruby/hash.h>
+#include <mruby/range.h>
 
 #define RSTRUCT_LEN(st) mrb_ary_ptr(st)->len
@@ -62,7 +62,12 @@
   }
   if (RSTRUCT_LEN(s) != RARRAY_LEN(members)) {
-    mrb_raisef(mrb, E_TYPE_ERROR,
-               "struct size differs (%S required %S given)",
-               mrb_fixnum_value(RARRAY_LEN(members)), mrb_fixnum_value(RSTRUCT_LEN(s)));
+    if (RSTRUCT_LEN(s) == 0) {  /* probably uninitialized */
+      mrb_ary_resize(mrb, s, RARRAY_LEN(members));
+    }
+    else {
+      mrb_raisef(mrb, E_TYPE_ERROR,
+                 "struct size differs (%S required %S given)",
+                 mrb_fixnum_value(RARRAY_LEN(members)), mrb_fixnum_value(RSTRUCT_LEN(s)));
+    }
   }
   return members;
@@ -80,4 +85,14 @@
 }
 
+static void
+mrb_struct_modify(mrb_state *mrb, mrb_value strct)
+{
+  if (MRB_FROZEN_P(mrb_basic_ptr(strct))) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen struct");
+  }
+
+  mrb_write_barrier(mrb, mrb_basic_ptr(strct));
+}
+
 /* 15.2.18.4.6  */
 /*
@@ -99,57 +114,11 @@
 }
 
-static mrb_value
-mrb_struct_getmember(mrb_state *mrb, mrb_value obj, mrb_sym id)
-{
-  mrb_value members, slot, *ptr;
-  const mrb_value *ptr_members;
-  mrb_int i, len;
-
-  ptr = RSTRUCT_PTR(obj);
-  members = struct_members(mrb, obj);
-  ptr_members = RARRAY_PTR(members);
-  slot = mrb_symbol_value(id);
-  len = RARRAY_LEN(members);
-  for (i=0; i<len; i++) {
-    if (mrb_obj_equal(mrb, ptr_members[i], slot)) {
-      return ptr[i];
-    }
-  }
-  mrb_raisef(mrb, E_INDEX_ERROR, "'%S' is not a struct member", mrb_sym2str(mrb, id));
-  return mrb_nil_value();       /* not reached */
-}
+static mrb_value struct_aref_sym(mrb_state *mrb, mrb_value obj, mrb_sym id);
 
 static mrb_value
 mrb_struct_ref(mrb_state *mrb, mrb_value obj)
 {
-  return mrb_struct_getmember(mrb, obj, mrb->c->ci->mid);
-}
-
-static mrb_value mrb_struct_ref0(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[0];}
-static mrb_value mrb_struct_ref1(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[1];}
-static mrb_value mrb_struct_ref2(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[2];}
-static mrb_value mrb_struct_ref3(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[3];}
-static mrb_value mrb_struct_ref4(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[4];}
-static mrb_value mrb_struct_ref5(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[5];}
-static mrb_value mrb_struct_ref6(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[6];}
-static mrb_value mrb_struct_ref7(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[7];}
-static mrb_value mrb_struct_ref8(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[8];}
-static mrb_value mrb_struct_ref9(mrb_state* mrb, mrb_value obj) {return RSTRUCT_PTR(obj)[9];}
-
-#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
-#define N_REF_FUNC numberof(ref_func)
-
-static const mrb_func_t ref_func[] = {
-  mrb_struct_ref0,
-  mrb_struct_ref1,
-  mrb_struct_ref2,
-  mrb_struct_ref3,
-  mrb_struct_ref4,
-  mrb_struct_ref5,
-  mrb_struct_ref6,
-  mrb_struct_ref7,
-  mrb_struct_ref8,
-  mrb_struct_ref9,
-};
+  return struct_aref_sym(mrb, obj, mrb->c->ci->mid);
+}
 
 static mrb_sym
@@ -172,12 +141,16 @@
 }
 
-static mrb_value
-mrb_struct_set(mrb_state *mrb, mrb_value obj, mrb_value val)
-{
+static mrb_value mrb_struct_aset_sym(mrb_state *mrb, mrb_value s, mrb_sym id, mrb_value val);
+
+static mrb_value
+mrb_struct_set_m(mrb_state *mrb, mrb_value obj)
+{
+  mrb_value val;
+
   const char *name;
-  mrb_int i, len, slen;
+  mrb_int slen;
   mrb_sym mid;
-  mrb_value members, slot, *ptr;
-  const mrb_value *ptr_members;
+
+  mrb_get_args(mrb, "o", &val);
 
   /* get base id */
@@ -185,25 +158,5 @@
   mid = mrb_intern(mrb, name, slen-1); /* omit last "=" */
 
-  members = struct_members(mrb, obj);
-  ptr_members = RARRAY_PTR(members);
-  len = RARRAY_LEN(members);
-  ptr = RSTRUCT_PTR(obj);
-  for (i=0; i<len; i++) {
-    slot = ptr_members[i];
-    if (mrb_symbol(slot) == mid) {
-      return ptr[i] = val;
-    }
-  }
-  mrb_raisef(mrb, E_INDEX_ERROR, "'%S' is not a struct member", mrb_sym2str(mrb, mid));
-  return mrb_nil_value();       /* not reached */
-}
-
-static mrb_value
-mrb_struct_set_m(mrb_state *mrb, mrb_value obj)
-{
-  mrb_value val;
-
-  mrb_get_args(mrb, "o", &val);
-  return mrb_struct_set(mrb, obj, val);
+  return mrb_struct_aset_sym(mrb, obj, mid, val);
 }
 
@@ -235,10 +188,5 @@
 
     if (is_local_id(mrb, name) || is_const_id(mrb, name)) {
-      if (i < N_REF_FUNC) {
-        mrb_define_method_id(mrb, c, id, ref_func[i], MRB_ARGS_NONE());
-      }
-      else {
-        mrb_define_method_id(mrb, c, id, mrb_struct_ref, MRB_ARGS_NONE());
-      }
+      mrb_define_method_id(mrb, c, id, mrb_struct_ref, MRB_ARGS_NONE());
       mrb_define_method_id(mrb, c, mrb_id_attrset(mrb, id), mrb_struct_set_m, MRB_ARGS_REQ(1));
       mrb_gc_arena_restore(mrb, ai);
@@ -266,5 +214,5 @@
     if (mrb_const_defined_at(mrb, mrb_obj_value(klass), id)) {
       mrb_warn(mrb, "redefining constant Struct::%S", name);
-      /* ?rb_mod_remove_const(klass, mrb_sym2name(mrb, id)); */
+      mrb_const_remove(mrb, mrb_obj_value(klass), id);
     }
     c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass);
@@ -336,23 +284,13 @@
   else {
     if (argc > 0) name = argv[0];
-    if (argc > 1) rest = argv[1];
-    if (mrb_array_p(rest)) {
-      if (!mrb_nil_p(name) && mrb_symbol_p(name)) {
-        /* 1stArgument:symbol -> name=nil rest=argv[0]-[n] */
-        mrb_ary_unshift(mrb, rest, name);
-        name = mrb_nil_value();
-      }
-    }
-    else {
-      pargv = &argv[1];
-      argcnt = argc-1;
-      if (!mrb_nil_p(name) && mrb_symbol_p(name)) {
-        /* 1stArgument:symbol -> name=nil rest=argv[0]-[n] */
-        name = mrb_nil_value();
-        pargv = &argv[0];
-        argcnt++;
-      }
-      rest = mrb_ary_new_from_values(mrb, argcnt, pargv);
-    }
+    pargv = &argv[1];
+    argcnt = argc-1;
+    if (!mrb_nil_p(name) && mrb_symbol_p(name)) {
+      /* 1stArgument:symbol -> name=nil rest=argv[0]-[n] */
+      name = mrb_nil_value();
+      pargv = &argv[0];
+      argcnt++;
+    }
+    rest = mrb_ary_new_from_values(mrb, argcnt, pargv);
     for (i=0; i<RARRAY_LEN(rest); i++) {
       id = mrb_obj_to_sym(mrb, RARRAY_PTR(rest)[i]);
@@ -360,7 +298,7 @@
     }
   }
-  st = make_struct(mrb, name, rest, struct_class(mrb));
+  st = make_struct(mrb, name, rest, mrb_class_ptr(klass));
   if (!mrb_nil_p(b)) {
-    mrb_yield_with_class(mrb, b, 1, &st, st, mrb_class_ptr(klass));
+    mrb_yield_with_class(mrb, b, 1, &st, st, mrb_class_ptr(st));
   }
 
@@ -419,5 +357,4 @@
 {
   mrb_value s;
-  mrb_int i, len;
 
   mrb_get_args(mrb, "o", &s);
@@ -430,31 +367,26 @@
     mrb_raise(mrb, E_TYPE_ERROR, "corrupted struct");
   }
-  if (RSTRUCT_LEN(copy) != RSTRUCT_LEN(s)) {
-    mrb_raise(mrb, E_TYPE_ERROR, "struct size mismatch");
-  }
-  len = RSTRUCT_LEN(copy);
-  for (i = 0; i < len; i++) {
-    mrb_ary_set(mrb, copy, i, RSTRUCT_PTR(s)[i]);
-  }
+  mrb_ary_replace(mrb, copy, s);
   return copy;
 }
 
 static mrb_value
-struct_aref_sym(mrb_state *mrb, mrb_value s, mrb_sym id)
-{
-  mrb_value *ptr, members;
+struct_aref_sym(mrb_state *mrb, mrb_value obj, mrb_sym id)
+{
+  mrb_value members, *ptr;
   const mrb_value *ptr_members;
   mrb_int i, len;
 
-  ptr = RSTRUCT_PTR(s);
-  members = struct_members(mrb, s);
+  members = struct_members(mrb, obj);
   ptr_members = RARRAY_PTR(members);
   len = RARRAY_LEN(members);
+  ptr = RSTRUCT_PTR(obj);
   for (i=0; i<len; i++) {
-    if (mrb_symbol(ptr_members[i]) == id) {
+    mrb_value slot = ptr_members[i];
+    if (mrb_symbol_p(slot) && mrb_symbol(slot) == id) {
       return ptr[i];
     }
   }
-  mrb_raisef(mrb, E_INDEX_ERROR, "no member '%S' in struct", mrb_sym2str(mrb, id));
+  mrb_raisef(mrb, E_INDEX_ERROR, "'%S' is not a struct member", mrb_sym2str(mrb, id));
   return mrb_nil_value();       /* not reached */
 }
@@ -504,5 +436,5 @@
 
     if (mrb_nil_p(sym)) {
-      mrb_raisef(mrb, E_INDEX_ERROR, "no member '%S' in struct", idx);
+      mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%S' in struct", idx);
     }
     idx = sym;
@@ -523,18 +455,14 @@
   members = struct_members(mrb, s);
   len = RARRAY_LEN(members);
-  if (RSTRUCT_LEN(s) != len) {
-    mrb_raisef(mrb, E_TYPE_ERROR,
-               "struct size differs (%S required %S given)",
-               mrb_fixnum_value(len), mrb_fixnum_value(RSTRUCT_LEN(s)));
-  }
   ptr = RSTRUCT_PTR(s);
   ptr_members = RARRAY_PTR(members);
   for (i=0; i<len; i++) {
     if (mrb_symbol(ptr_members[i]) == id) {
+      mrb_struct_modify(mrb, s);
       ptr[i] = val;
       return val;
     }
   }
-  mrb_raisef(mrb, E_INDEX_ERROR, "no member '%S' in struct", mrb_sym2str(mrb, id));
+  mrb_name_error(mrb, id, "no member '%S' in struct", mrb_sym2str(mrb, id));
   return val;                   /* not reach */
 }
@@ -575,5 +503,5 @@
 
     if (mrb_nil_p(sym)) {
-      mrb_raisef(mrb, E_INDEX_ERROR, "no member '%S' in struct", idx);
+      mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%S' in struct", idx);
     }
     idx = sym;
@@ -595,4 +523,5 @@
                mrb_fixnum_value(i), mrb_fixnum_value(RSTRUCT_LEN(s)));
   }
+  mrb_struct_modify(mrb, s);
   return RSTRUCT_PTR(s)[i] = val;
 }
@@ -720,5 +649,5 @@
   mrb_int i;
 
-  members = struct_s_members(mrb, mrb_class(mrb, self));
+  members = struct_members(mrb, self);
   ret = mrb_hash_new_capa(mrb, RARRAY_LEN(members));
 
@@ -761,4 +690,5 @@
   struct RClass *st;
   st = mrb_define_class(mrb, "Struct",  mrb->object_class);
+  MRB_SET_INSTANCE_TT(st, MRB_TT_ARRAY);
 
   mrb_define_class_method(mrb, st, "new",             mrb_struct_s_def,       MRB_ARGS_ANY());  /* 15.2.18.3.1  */
@@ -777,5 +707,5 @@
   mrb_define_method(mrb, st,        "values",         mrb_struct_to_a,        MRB_ARGS_NONE());
   mrb_define_method(mrb, st,        "to_h",           mrb_struct_to_h,        MRB_ARGS_NONE());
-  mrb_define_method(mrb, st,        "values_at",      mrb_struct_values_at,   MRB_ARGS_NONE());
+  mrb_define_method(mrb, st,        "values_at",      mrb_struct_values_at,   MRB_ARGS_ANY());
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-struct/test/struct.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-struct/test/struct.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-struct/test/struct.rb	(revision 331)
@@ -3,11 +3,11 @@
 
 assert('Struct', '15.2.18') do
-  Struct.class == Class
+  assert_equal Class, Struct.class
 end
 
 assert('Struct.new', '15.2.18.3.1') do
   c = Struct.new(:m1, :m2)
-  c.superclass == Struct and
-    c.members == [:m1,:m2]
+  assert_equal Struct, c.superclass
+  assert_equal [:m1, :m2], c.members
 end
 
@@ -15,5 +15,6 @@
 assert('Struct.new', '15.2.18.3.1') do
   c = Struct.new()
-  c.superclass == Struct and c.members == []
+  assert_equal Struct, c.superclass
+  assert_equal [], c.members
 end
 
@@ -22,5 +23,8 @@
   cc1 = c.new(1,2)
   cc2 = c.new(1,2)
-  cc1 == cc2
+  assert_true cc1 == cc2
+
+  Struct.new(:m1, :m2) { def foo; end }
+  assert_raise(NoMethodError) { Struct.new(:m1).new.foo }
 end
 
@@ -28,5 +32,11 @@
   c = Struct.new(:m1, :m2)
   cc = c.new(1,2)
-  cc[:m1] == 1 and cc["m2"] == 2
+  assert_equal 1, cc[:m1]
+  assert_equal 2, cc["m2"]
+  assert_equal 1, cc[0]
+  assert_equal 2, cc[-1]
+  assert_raise(TypeError) { cc[[]] }
+  assert_raise(IndexError) { cc[2] }
+  assert_raise(NameError) { cc['tama'] }
 end
 
@@ -35,8 +45,14 @@
   cc = c.new(1,2)
   cc[:m1] = 3
-  cc[:m1] == 3
+  assert_equal 3, cc[:m1]
   cc["m2"] = 3
   assert_equal 3, cc["m2"]
+  cc[0] = 4
+  assert_equal 4, cc[0]
+  cc[-1] = 5
+  assert_equal 5, cc[-1]
   assert_raise(TypeError) { cc[[]] = 3 }
+  assert_raise(IndexError) { cc[2] = 7 }
+  assert_raise(NameError) { cc['pochi'] = 8 }
 end
 
@@ -48,5 +64,5 @@
     a << x
   }
-  a[0] == 1 and a[1] == 2
+  assert_equal [1, 2], a
 end
 
@@ -58,17 +74,15 @@
     a << [k,v]
   }
-  a[0] == [:m1, 1] and a[1] == [:m2, 2]
+  assert_equal [[:m1, 1], [:m2, 2]], a
 end
 
 assert('Struct#members', '15.2.18.4.6') do
   c = Struct.new(:m1, :m2)
-  cc = c.new(1,2)
-  cc.members == [:m1,:m2]
+  assert_equal [:m1, :m2], c.new(1,2).members
 end
 
 assert('Struct#select', '15.2.18.4.7') do
   c = Struct.new(:m1, :m2)
-  cc = c.new(1,2)
-  cc.select{|v| v % 2 == 0} == [2]
+  assert_equal([2]) { c.new(1,2).select{|v| v % 2 == 0} }
 end
 
@@ -101,4 +115,12 @@
 end
 
+assert('struct dup') do
+  c = Struct.new(:m1, :m2, :m3, :m4, :m5)
+  cc = c.new(1,2,3,4,5)
+  assert_nothing_raised {
+    assert_equal(cc, cc.dup)
+  }
+end
+
 assert('struct inspect') do
   c = Struct.new(:m1, :m2, :m3, :m4, :m5)
@@ -130,2 +152,61 @@
   assert_raise(IndexError) { a.values_at 2 }
 end
+
+assert("Struct#dig") do
+  a = Struct.new(:blue, :purple).new('aki', Struct.new(:red).new(1))
+  assert_equal 'aki', a.dig(:blue)
+  assert_equal 1, a.dig(:purple, :red)
+  assert_equal 1, a.dig(1, 0)
+end
+
+assert("Struct.new removes existing constant") do
+  skip "redefining Struct with same name cause warnings"
+  begin
+    assert_not_equal Struct.new("Test", :a), Struct.new("Test", :a, :b)
+  ensure
+    Struct.remove_const :Test
+  end
+end
+
+assert("Struct#initialize_copy requires struct to be the same type") do
+  begin
+    Struct.new("Test", :a)
+    a = Struct::Test.new("a")
+    Struct.remove_const :Test
+    Struct.new("Test", :a, :b)
+    assert_raise(TypeError) do
+      a.initialize_copy(Struct::Test.new("a", "b"))
+    end
+  ensure
+    Struct.remove_const :Test
+  end
+end
+
+assert("Struct.new does not allow array") do
+  assert_raise(TypeError) do
+    Struct.new("Test", [:a])
+  end
+end
+
+assert("Struct.new generates subclass of Struct") do
+  begin
+    original_struct = Struct
+    Struct = String
+    assert_equal original_struct, original_struct.new.superclass
+  ensure
+    Struct = original_struct
+  end
+end
+
+assert 'Struct#freeze' do
+  c = Struct.new :m
+
+  o = c.new
+  o.m = :test
+  assert_equal :test, o.m
+
+  o.freeze
+  assert_raise(RuntimeError) { o.m = :modify }
+  assert_raise(RuntimeError) { o[:m] = :modify }
+  assert_equal :test, o.m
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-symbol-ext/src/symbol.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-symbol-ext/src/symbol.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-symbol-ext/src/symbol.c	(revision 331)
@@ -1,5 +1,5 @@
-#include "mruby.h"
-#include "mruby/khash.h"
-#include "mruby/array.h"
+#include <mruby.h>
+#include <mruby/khash.h>
+#include <mruby/array.h>
 
 typedef struct symbol_name {
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-test/driver.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-test/driver.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-test/driver.c	(revision 331)
@@ -11,11 +11,11 @@
 #include <string.h>
 
-#include "mruby.h"
-#include "mruby/proc.h"
-#include "mruby/data.h"
-#include "mruby/compile.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
-#include "mruby/array.h"
+#include <mruby.h>
+#include <mruby/proc.h>
+#include <mruby/data.h>
+#include <mruby/compile.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
+#include <mruby/array.h>
 
 void
@@ -95,4 +95,10 @@
   mrb_define_const(mrb, mrbtest, "FIXNUM_BIT", mrb_fixnum_value(MRB_INT_BIT));
 
+#ifdef MRB_USE_FLOAT
+  mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-6));
+#else
+  mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-12));
+#endif
+
   if (verbose) {
     mrb_gv_set(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"), mrb_true_value());
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-test/init_mrbtest.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-test/init_mrbtest.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-test/init_mrbtest.c	(revision 331)
@@ -1,9 +1,8 @@
 #include <stdlib.h>
-#include "mruby.h"
-#include "mruby/irep.h"
-#include "mruby/variable.h"
+#include <mruby.h>
+#include <mruby/irep.h>
+#include <mruby/variable.h>
 
 extern const uint8_t mrbtest_assert_irep[];
-extern const uint8_t mrbtest_irep[];
 
 void mrbgemtest_init(mrb_state* mrb);
@@ -25,5 +24,4 @@
   mrb_init_test_driver(core_test, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));
   mrb_load_irep(core_test, mrbtest_assert_irep);
-  mrb_load_irep(core_test, mrbtest_irep);
   mrb_t_pass_result(mrb, core_test);
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-test/mrbgem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-test/mrbgem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-test/mrbgem.rake	(revision 331)
@@ -7,7 +7,8 @@
   spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
 
+  spec.test_rbfiles = Dir.glob("#{MRUBY_ROOT}/test/t/*.rb")
+
   clib = "#{build_dir}/mrbtest.c"
   mlib = clib.ext(exts.object)
-  mrbs = Dir.glob("#{MRUBY_ROOT}/test/t/*.rb")
   exec = exefile("#{build.build_dir}/bin/mrbtest")
 
@@ -27,5 +28,5 @@
 
   file assert_lib => assert_c
-  file assert_c => [build.mrbcfile, assert_rb] do |t|
+  file assert_c => assert_rb do |t|
     open(t.name, 'w') do |f|
       mrbc.run f, assert_rb, 'mrbtest_assert_irep'
@@ -41,5 +42,5 @@
 
     file test_rbobj => g.test_rbireps
-    file g.test_rbireps => [g.test_rbfiles].flatten + [File.join(g.dir, 'mrbgem.rake'), g.build.mrbcfile, "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"] do |t|
+    file g.test_rbireps => [g.test_rbfiles].flatten do |t|
       FileUtils.mkdir_p File.dirname(t.name)
       open(t.name, 'w') do |f|
@@ -146,6 +147,19 @@
 
   init = "#{spec.dir}/init_mrbtest.c"
+
+  # store the last gem selection and make the re-build
+  # of the test gem depending on a change to the gem
+  # selection
+  active_gems = "#{build_dir}/active_gems.lst"
+  FileUtils.mkdir_p File.dirname(active_gems)
+  open(active_gems, 'w+') do |f|
+    build.gems.each do |g|
+      f.puts g.name
+    end
+  end
+  file clib => active_gems
+
   file mlib => clib
-  file clib => [build.mrbcfile, init] + mrbs do |t|
+  file clib => init do |t|
     _pp "GEN", "*.rb", "#{clib.relative_path}"
     FileUtils.mkdir_p File.dirname(clib)
@@ -161,5 +175,4 @@
       f.puts %Q[]
       f.puts IO.read(init)
-      mrbc.run f, mrbs, 'mrbtest_irep'
       build.gems.each do |g|
         f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-time/src/time.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-time/src/time.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-time/src/time.c	(revision 331)
@@ -6,9 +6,27 @@
 
 #include <math.h>
+#include <time.h>
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/data.h>
+
+#ifndef DISABLE_STDIO
 #include <stdio.h>
-#include <time.h>
-#include "mruby.h"
-#include "mruby/class.h"
-#include "mruby/data.h"
+#else
+#include <string.h>
+#endif
+
+#define NDIV(x,y) (-(-((x)+1)/(y))-1)
+
+#if _MSC_VER < 1800
+double round(double x) {
+  if (x >= 0.0) {
+    return (double)((int)(x + 0.5));
+  }
+  else {
+    return (double)((int)(x - 0.5));
+  }
+}
+#endif
 
 #if !defined(__MINGW64__) && defined(_WIN32)
@@ -42,4 +60,11 @@
 #endif
 #endif
+
+/* asctime(3) */
+/* mruby usually use its own implementation of struct tm to string conversion */
+/* except when DISABLE_STDIO is set. In that case, it uses asctime() or asctime_r(). */
+/* By default mruby tries to use asctime_r() which is reentrant. */
+/* Undef following macro on platforms that does not have asctime_r(). */
+/* #define NO_ASCTIME_R */
 
 /* timegm(3) */
@@ -154,4 +179,5 @@
 };
 
+#ifndef DISABLE_STDIO
 static const char mon_names[12][4] = {
   "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
@@ -161,4 +187,5 @@
   "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
 };
+#endif
 
 struct mrb_time {
@@ -174,5 +201,5 @@
 seconds setting. Returns self on success, NULL of failure. */
 static struct mrb_time*
-mrb_time_update_datetime(struct mrb_time *self)
+time_update_datetime(mrb_state *mrb, struct mrb_time *self)
 {
   struct tm *aid;
@@ -184,5 +211,9 @@
     aid = localtime_r(&self->sec, &self->datetime);
   }
-  if (!aid) return NULL;
+  if (!aid) {
+    mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S out of Time range", mrb_float_value(mrb, (mrb_float)self->sec));
+    /* not reached */
+    return NULL;
+  }
 #ifdef NO_GMTIME_R
   self->datetime = *aid; /* copy data */
@@ -198,4 +229,5 @@
 }
 
+void mrb_check_num_exact(mrb_state *mrb, mrb_float num);
 
 /* Allocates a mrb_time object and initializes it. */
@@ -204,6 +236,9 @@
 {
   struct mrb_time *tm;
-
-  tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(struct mrb_time));
+  time_t tsec = 0;
+
+  mrb_check_num_exact(mrb, (mrb_float)sec);
+  mrb_check_num_exact(mrb, (mrb_float)usec);
+
   if (sizeof(time_t) == 4 && (sec > (double)INT32_MAX || (double)INT32_MIN > sec)) {
     goto out_of_range;
@@ -212,20 +247,24 @@
     goto out_of_range;
   }
-  tm->sec  = (time_t)sec;
-  if ((sec > 0 && tm->sec < 0) || (sec < 0 && (double)tm->sec > sec)) {
+  tsec  = (time_t)sec;
+  if ((sec > 0 && tsec < 0) || (sec < 0 && (double)tsec > sec)) {
   out_of_range:
     mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S out of Time range", mrb_float_value(mrb, sec));
   }
+  tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(struct mrb_time));
+  tm->sec  = tsec;
   tm->usec = (time_t)llround((sec - tm->sec) * 1.0e6 + usec);
-  while (tm->usec < 0) {
-    tm->sec--;
-    tm->usec += 1000000;
-  }
-  while (tm->usec >= 1000000) {
-    tm->sec++;
-    tm->usec -= 1000000;
+  if (tm->usec < 0) {
+    long sec2 = (long)NDIV(usec,1000000); /* negative div */
+    tm->usec -= sec2 * 1000000;
+    tm->sec += sec2;
+  }
+  else if (tm->usec >= 1000000) {
+    long sec2 = (long)(usec / 1000000);
+    tm->usec -= sec2 * 1000000;
+    tm->sec += sec2;
   }
   tm->timezone = timezone;
-  mrb_time_update_datetime(tm);
+  time_update_datetime(mrb, tm);
 
   return tm;
@@ -279,5 +318,5 @@
 #endif
   tm->timezone = MRB_TIMEZONE_LOCAL;
-  mrb_time_update_datetime(tm);
+  time_update_datetime(mrb, tm);
 
   return tm;
@@ -317,4 +356,13 @@
   nowtime.tm_sec   = (int)asec;
   nowtime.tm_isdst = -1;
+
+  if (nowtime.tm_mon  < 0 || nowtime.tm_mon  > 11
+      || nowtime.tm_mday < 1 || nowtime.tm_mday > 31
+      || nowtime.tm_hour < 0 || nowtime.tm_hour > 24
+      || (nowtime.tm_hour == 24 && (nowtime.tm_min > 0 || nowtime.tm_sec > 0))
+      || nowtime.tm_min  < 0 || nowtime.tm_min  > 59
+      || nowtime.tm_sec  < 0 || nowtime.tm_sec  > 60)
+    mrb_raise(mrb, E_RUNTIME_ERROR, "argument out of range");
+
   if (timezone == MRB_TIMEZONE_UTC) {
     nowsecs = timegm(&nowtime);
@@ -357,4 +405,15 @@
 }
 
+static struct mrb_time*
+time_get_ptr(mrb_state *mrb, mrb_value time)
+{
+  struct mrb_time *tm;
+
+  tm = DATA_GET_PTR(mrb, time, &mrb_time_type, struct mrb_time);
+  if (!tm) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "uninitialized time");
+  }
+  return tm;
+}
 
 static mrb_value
@@ -366,5 +425,5 @@
 
   mrb_get_args(mrb, "o", &other);
-  tm1 = DATA_CHECK_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm1 = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
   tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
   eq_p = tm1 && tm2 && tm1->sec == tm2->sec && tm1->usec == tm2->usec;
@@ -380,5 +439,5 @@
 
   mrb_get_args(mrb, "o", &other);
-  tm1 = DATA_CHECK_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm1 = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
   tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
   if (!tm1 || !tm2) return mrb_nil_value();
@@ -406,5 +465,5 @@
 
   mrb_get_args(mrb, "f", &f);
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_time_make(mrb, mrb_obj_class(mrb, self), (double)tm->sec+f, (double)tm->usec, tm->timezone);
 }
@@ -418,6 +477,5 @@
 
   mrb_get_args(mrb, "o", &other);
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
-
+  tm = time_get_ptr(mrb, self);
   tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time);
   if (tm2) {
@@ -439,5 +497,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_wday);
 }
@@ -450,5 +508,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_yday + 1);
 }
@@ -461,5 +519,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_year + 1900);
 }
@@ -472,5 +530,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   if (tm->timezone <= MRB_TIMEZONE_NONE) return mrb_nil_value();
   if (tm->timezone >= MRB_TIMEZONE_LAST) return mrb_nil_value();
@@ -485,11 +543,20 @@
 mrb_time_asctime(mrb_state *mrb, mrb_value self)
 {
-  struct mrb_time *tm;
-  struct tm *d;
+  struct mrb_time *tm = time_get_ptr(mrb, self);
+  struct tm *d = &tm->datetime;
+  int len;
+
+#if defined(DISABLE_STDIO)
+  char *s;
+# ifdef NO_ASCTIME_R
+  s = asctime(d);
+# else
+  char buf[32];
+  s = asctime_r(d, buf);
+# endif
+  len = strlen(s)-1;            /* truncate the last newline */
+#else
   char buf[256];
-  int len;
-
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
-  d = &tm->datetime;
+
   len = snprintf(buf, sizeof(buf), "%s %s %02d %02d:%02d:%02d %s%d",
     wday_names[d->tm_wday], mon_names[d->tm_mon], d->tm_mday,
@@ -497,4 +564,5 @@
     tm->timezone == MRB_TIMEZONE_UTC ? "UTC " : "",
     d->tm_year + 1900);
+#endif
   return mrb_str_new(mrb, buf, len);
 }
@@ -507,6 +575,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
-  if (!tm) return mrb_nil_value();
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_mday);
 }
@@ -520,5 +587,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_bool_value(tm->datetime.tm_isdst);
 }
@@ -532,9 +599,9 @@
   struct mrb_time *tm, *tm2;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   tm2 = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm));
   *tm2 = *tm;
   tm2->timezone = MRB_TIMEZONE_UTC;
-  mrb_time_update_datetime(tm2);
+  time_update_datetime(mrb, tm2);
   return mrb_time_wrap(mrb, mrb_obj_class(mrb, self), tm2);
 }
@@ -547,9 +614,9 @@
   struct mrb_time *tm, *tm2;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   tm2 = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm));
   *tm2 = *tm;
   tm2->timezone = MRB_TIMEZONE_LOCAL;
-  mrb_time_update_datetime(tm2);
+  time_update_datetime(mrb, tm2);
   return mrb_time_wrap(mrb, mrb_obj_class(mrb, self), tm2);
 }
@@ -562,5 +629,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_hour);
 }
@@ -576,4 +643,6 @@
   struct mrb_time *tm;
 
+  n = mrb_get_args(mrb, "|iiiiiii",
+       &ayear, &amonth, &aday, &ahour, &amin, &asec, &ausec);
   tm = (struct mrb_time*)DATA_PTR(self);
   if (tm) {
@@ -582,6 +651,4 @@
   mrb_data_init(self, NULL, &mrb_time_type);
 
-  n = mrb_get_args(mrb, "|iiiiiii",
-       &ayear, &amonth, &aday, &ahour, &amin, &asec, &ausec);
   if (n == 0) {
     tm = current_mrb_time(mrb);
@@ -600,4 +667,5 @@
 {
   mrb_value src;
+  struct mrb_time *t1, *t2;
 
   mrb_get_args(mrb, "o", &src);
@@ -606,8 +674,14 @@
     mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class");
   }
-  if (!DATA_PTR(copy)) {
-    mrb_data_init(copy, mrb_malloc(mrb, sizeof(struct mrb_time)), &mrb_time_type);
-  }
-  *(struct mrb_time *)DATA_PTR(copy) = *(struct mrb_time *)DATA_PTR(src);
+  t1 = (struct mrb_time *)DATA_PTR(copy);
+  t2 = (struct mrb_time *)DATA_PTR(src);
+  if (!t2) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "uninitialized time");
+  }
+  if (!t1) {
+    t1 = (struct mrb_time *)mrb_malloc(mrb, sizeof(struct mrb_time));
+    mrb_data_init(copy, t1, &mrb_time_type);
+  }
+  *t1 = *t2;
   return copy;
 }
@@ -620,7 +694,7 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   tm->timezone = MRB_TIMEZONE_LOCAL;
-  mrb_time_update_datetime(tm);
+  time_update_datetime(mrb, tm);
   return self;
 }
@@ -633,5 +707,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_mday);
 }
@@ -644,5 +718,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_min);
 }
@@ -655,5 +729,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_mon + 1);
 }
@@ -666,5 +740,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_fixnum_value(tm->datetime.tm_sec);
 }
@@ -678,5 +752,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_float_value(mrb, (mrb_float)tm->sec + (mrb_float)tm->usec/1.0e6);
 }
@@ -689,5 +763,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   if (tm->sec > MRB_INT_MAX || tm->sec < MRB_INT_MIN) {
     return mrb_float_value(mrb, (mrb_float)tm->sec);
@@ -703,5 +777,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   if (tm->usec > MRB_INT_MAX || tm->usec < MRB_INT_MIN) {
     return mrb_float_value(mrb, (mrb_float)tm->usec);
@@ -717,7 +791,7 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   tm->timezone = MRB_TIMEZONE_UTC;
-  mrb_time_update_datetime(tm);
+  time_update_datetime(mrb, tm);
   return self;
 }
@@ -730,5 +804,5 @@
   struct mrb_time *tm;
 
-  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
+  tm = time_get_ptr(mrb, self);
   return mrb_bool_value(tm->timezone == MRB_TIMEZONE_UTC);
 }
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-time/test/time.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-time/test/time.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-time/test/time.rb	(revision 331)
@@ -11,5 +11,12 @@
 
 assert('Time.at', '15.2.19.6.1') do
-  Time.at(1300000000.0)
+  assert_kind_of(Time, Time.at(1300000000.0))
+
+  assert_raise(FloatDomainError) { Time.at(Float::NAN) }
+  assert_raise(FloatDomainError) { Time.at(Float::INFINITY) }
+  assert_raise(FloatDomainError) { Time.at(-Float::INFINITY) }
+  assert_raise(FloatDomainError) { Time.at(0, Float::NAN) }
+  assert_raise(FloatDomainError) { Time.at(0, Float::INFINITY) }
+  assert_raise(FloatDomainError) { Time.at(0, -Float::INFINITY) }
 end
 
@@ -38,5 +45,9 @@
   t2 = t1.+(60)
 
-  t2.utc.asctime == "Sun Mar 13 07:07:40 UTC 2011"
+  assert_equal(t2.utc.asctime, "Sun Mar 13 07:07:40 UTC 2011")
+
+  assert_raise(FloatDomainError) { Time.at(0) + Float::NAN }
+  assert_raise(FloatDomainError) { Time.at(0) + Float::INFINITY }
+  assert_raise(FloatDomainError) { Time.at(0) + -Float::INFINITY }
 end
 
@@ -45,5 +56,9 @@
   t2 = t1.-(60)
 
-  t2.utc.asctime == "Sun Mar 13 07:05:40 UTC 2011"
+  assert_equal(t2.utc.asctime, "Sun Mar 13 07:05:40 UTC 2011")
+
+  assert_raise(FloatDomainError) { Time.at(0) - Float::NAN }
+  assert_raise(FloatDomainError) { Time.at(0) - Float::INFINITY }
+  assert_raise(FloatDomainError) { Time.at(0) - -Float::INFINITY }
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/00class.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrblib/00class.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/00class.rb	(revision 331)
@@ -0,0 +1,26 @@
+class Module
+   # 15.2.2.4.12
+  def attr_accessor(*names)
+    attr_reader(*names)
+    attr_writer(*names)
+  end
+  # 15.2.2.4.11
+  def attr(name)
+    attr_reader(name)
+  end
+
+  # 15.2.2.4.27
+  def include(*args)
+    args.reverse.each do |m|
+      m.append_features(self)
+      m.included(self)
+    end
+  end
+
+  def prepend(*args)
+    args.reverse.each do |m|
+      m.prepend_features(self)
+      m.prepended(self)
+    end
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/10error.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/mrblib/10error.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/10error.rb	(revision 331)
@@ -0,0 +1,56 @@
+# ISO 15.2.24
+class ArgumentError < StandardError
+end
+
+# ISO 15.2.25
+class LocalJumpError < StandardError
+end
+
+# ISO 15.2.26
+class RangeError < StandardError
+end
+
+class FloatDomainError < RangeError
+end
+
+# ISO 15.2.26
+class RegexpError < StandardError
+end
+
+# ISO 15.2.29
+class TypeError < StandardError
+end
+
+# ISO 15.2.31
+class NameError < StandardError
+  attr_accessor :name
+
+  def initialize(message=nil, name=nil)
+    @name = name
+    super(message)
+  end
+end
+
+# ISO 15.2.32
+class NoMethodError < NameError
+  attr_reader :args
+
+  def initialize(message=nil, name=nil, args=nil)
+    @args = args
+    super message, name
+  end
+end
+
+# ISO 15.2.33
+class IndexError < StandardError
+end
+
+class KeyError < IndexError
+end
+
+class NotImplementedError < ScriptError
+end
+
+class StopIteration < IndexError
+  attr_accessor :result
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/array.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/array.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/array.rb	(revision 331)
@@ -13,13 +13,8 @@
     return to_enum :each unless block_given?
 
-    idx, length = -1, self.length-1
-    while idx < length and length <= self.length and length = self.length-1
-      elm = self[idx += 1]
-      unless elm
-        if elm.nil? and length >= self.length
-          break
-        end
-      end
-      block.call(elm)
+    idx = 0
+    while idx < length
+      block.call(self[idx])
+      idx += 1
     end
     self
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/enum.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/enum.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/enum.rb	(revision 331)
@@ -384,5 +384,5 @@
     i = 0
     self.each do |e|
-      n = e.hash << (i % 16)
+      n = (e.hash & (0x7fffffff >> (i % 16))) << (i % 16)
       h ^= n
       i += 1
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/hash.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/hash.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/hash.rb	(revision 331)
@@ -155,4 +155,5 @@
   # ISO 15.2.13.4.23
   def replace(hash)
+    raise TypeError, "can't convert argument into Hash" unless hash.respond_to?(:to_hash)
     self.clear
     hash = hash.to_hash
@@ -201,5 +202,5 @@
   end
   ##
-  # Return the contents of this hash as a string. 
+  # Return the contents of this hash as a string.
  #
   # ISO 15.2.13.4.30 (x)
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/init_mrblib.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/init_mrblib.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/init_mrblib.c	(revision 331)
@@ -1,4 +1,4 @@
-#include "mruby.h"
-#include "mruby/irep.h"
+#include <mruby.h>
+#include <mruby/irep.h>
 
 extern const uint8_t mrblib_irep[];
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/numeric.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/numeric.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/numeric.rb	(revision 331)
@@ -101,9 +101,16 @@
   # incremented by +step+ (default 1).
   #
-  def step(num, step = 1, &block)
+  def step(num=nil, step=1, &block)
     raise ArgumentError, "step can't be 0" if step == 0
     return to_enum(:step, num, step) unless block_given?
 
     i = if num.kind_of? Float then self.to_f else self end
+    if num == nil
+      while true
+        block.call(i)
+        i+=step
+      end
+      return self
+    end
     if step > 0
       while i <= num
@@ -161,34 +168,6 @@
 # ISO 15.2.9
 class Float
-  include Integral
   # mruby special - since mruby integers may be upgraded to floats,
   # floats should be compatible to integers.
-  def >> other
-    n = self.to_i
-    other = other.to_i
-    if other < 0
-      n << -other
-    else
-      other.times { n /= 2 }
-      if n.abs < 1
-        if n >= 0
-          0
-        else
-          -1
-        end
-      else
-        n.to_i
-      end
-    end
-  end
-  def << other
-    n = self.to_i
-    other = other.to_i
-    if other < 0
-      n >> -other
-    else
-      other.times { n *= 2 }
-      n
-    end
-  end
+  include Integral
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/range.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/range.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/range.rb	(revision 331)
@@ -27,4 +27,12 @@
     end
 
+    if val.kind_of?(String) && last.kind_of?(String) # fixnums are special
+      if val.respond_to? :upto
+        return val.upto(last, exclude_end?, &block)
+      else
+        str_each = true
+      end
+    end
+
     raise TypeError, "can't iterate" unless val.respond_to? :succ
 
@@ -34,4 +42,7 @@
       block.call(val)
       val = val.succ
+      if str_each
+        break if val.size > last.size
+      end
     end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/mrblib/string.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/mrblib/string.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/mrblib/string.rb	(revision 331)
@@ -10,11 +10,16 @@
   #
   # ISO 15.2.10.5.15
-  def each_line(&block)
+  def each_line(rs = "\n", &block)
+    return to_enum(:each_line, rs, &block) unless block
+    return block.call(self) if rs.nil?
+    rs = rs.to_str
     offset = 0
-    while pos = self.index("\n", offset)
-      block.call(self[offset, pos + 1 - offset])
-      offset = pos + 1
-    end
-    block.call(self[offset, self.size - offset]) if self.size > offset
+    rs_len = rs.length
+    this = dup
+    while pos = this.index(rs, offset)
+      block.call(this[offset, pos + rs_len - offset])
+      offset = pos + rs_len
+    end
+    block.call(this[offset, this.size - offset]) if this.size > offset
     self
   end
@@ -35,4 +40,6 @@
           when "'"
             post
+          when "1", "2", "3", "4", "5", "6", "7", "8", "9"
+            ""
           else
             self[j, 2]
@@ -52,21 +59,32 @@
   # ISO 15.2.10.5.18
   def gsub(*args, &block)
-    if args.size == 2
-      s = ""
-      i = 0
-      while j = index(args[0], i)
-        seplen = args[0].length
-        k = j + seplen
-        pre = self[0, j]
-        post = self[k, length-k]
-        s += self[i, j-i] + args[1].__sub_replace(pre, args[0], post)
-        i = k
-      end
-      s + self[i, length-i]
-    elsif args.size == 1 && block
-      split(args[0], -1).join(block.call(args[0]))
-    else
-      raise ArgumentError, "wrong number of arguments"
-    end
+    return to_enum(:gsub, *args) if args.length == 1 && !block
+    raise ArgumentError, "wrong number of arguments" unless (1..2).include?(args.length)
+
+    pattern, replace = *args
+    plen = pattern.length
+    if args.length == 2 && block
+      block = nil
+    end
+    if !replace.nil? || !block
+      replace = replace.to_str
+    end
+    offset = 0
+    result = []
+    while found = index(pattern, offset)
+      result << self[offset, found - offset]
+      offset = found + plen
+      result << if block
+        block.call(pattern).to_s
+      else
+        replace.__sub_replace(self[0, found], pattern, self[offset..-1] || "")
+      end
+      if plen == 0
+        result << self[offset, 1]
+        offset += 1
+      end
+    end
+    result << self[offset..-1] if offset < length
+    result.join
   end
 
@@ -79,4 +97,6 @@
   # ISO 15.2.10.5.19
   def gsub!(*args, &block)
+    raise RuntimeError, "can't modify frozen String" if frozen?
+    return to_enum(:gsub!, *args) if args.length == 1 && !block
     str = self.gsub(*args, &block)
     return nil if str == self
@@ -105,13 +125,29 @@
   # ISO 15.2.10.5.36
   def sub(*args, &block)
-    if args.size == 2
-      pre, post = split(args[0], 2)
-      return self unless post # The sub target wasn't found in the string
-      pre + args[1].__sub_replace(pre, args[0], post) + post
-    elsif args.size == 1 && block
-      split(args[0], 2).join(block.call(args[0]))
+    unless (1..2).include?(args.length)
+      raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 2)"
+    end
+
+    pattern, replace = *args
+    pattern = pattern.to_str
+    if args.length == 2 && block
+      block = nil
+    end
+    if !block
+      replace = replace.to_str
+    end
+    result = []
+    this = dup
+    found = index(pattern)
+    return this unless found
+    result << this[0, found]
+    offset = found + pattern.length
+    result << if block
+      block.call(pattern).to_s
     else
-      raise ArgumentError, "wrong number of arguments"
-    end
+      replace.__sub_replace(this[0, found], pattern, this[offset..-1] || "")
+    end
+    result << this[offset..-1] if offset < length
+    result.join
   end
 
@@ -124,4 +160,5 @@
   # ISO 15.2.10.5.37
   def sub!(*args, &block)
+    raise RuntimeError, "can't modify frozen String" if frozen?
     str = self.sub(*args, &block)
     return nil if str == self
@@ -160,5 +197,6 @@
     if anum == 2
       pos, value = args
-      if pos.kind_of? String
+      case pos
+      when String
         posnum = self.index(pos)
         if posnum
@@ -166,8 +204,15 @@
           a = self[(posnum + pos.length)..-1]
           self.replace([b, value, a].join(''))
-          return value
         else
           raise IndexError, "string not matched"
         end
+      when Range
+        head = pos.begin
+        tail = pos.end
+        tail += self.length if tail < 0
+        unless pos.exclude_end?
+          tail += 1
+        end
+        return self[head, tail-head]=value
       else
         pos += self.length if pos < 0
@@ -178,6 +223,6 @@
         a = self[pos + 1..-1]
         self.replace([b, value, a].join(''))
-        return value
-      end
+      end
+      return value
     elsif anum == 3
       pos, len, value = args
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/array.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/array.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/array.c	(revision 331)
@@ -5,9 +5,9 @@
 */
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/string.h"
-#include "mruby/range.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/string.h>
+#include <mruby/range.h>
 #include "value_array.h"
 
@@ -17,18 +17,9 @@
 #define ARY_MAX_SIZE ((ARY_C_MAX_SIZE < (size_t)MRB_INT_MAX) ? (mrb_int)ARY_C_MAX_SIZE : MRB_INT_MAX-1)
 
-static inline mrb_value
-ary_elt(mrb_value ary, mrb_int offset)
-{
-  if (offset < 0 || RARRAY_LEN(ary) <= offset) {
-    return mrb_nil_value();
-  }
-  return RARRAY_PTR(ary)[offset];
-}
-
 static struct RArray*
 ary_new_capa(mrb_state *mrb, mrb_int capa)
 {
   struct RArray *a;
-  mrb_int blen;
+  size_t blen;
 
   if (capa > ARY_MAX_SIZE) {
@@ -36,7 +27,4 @@
   }
   blen = capa * sizeof(mrb_value);
-  if (blen < capa) {
-    mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
-  }
 
   a = (struct RArray*)mrb_obj_alloc(mrb, MRB_TT_ARRAY, mrb->array_class);
@@ -121,4 +109,8 @@
 ary_modify(mrb_state *mrb, struct RArray *a)
 {
+  if (MRB_FROZEN_P(a)) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen array");
+  }
+
   if (ARY_SHARED_P(a)) {
     mrb_shared_array *shared = a->aux.shared;
@@ -179,4 +171,5 @@
 
   if (len > ARY_MAX_SIZE) {
+  size_error:
     mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
   }
@@ -186,8 +179,14 @@
   }
   while (capa < len) {
-    capa *= 2;
-  }
-
-  if (capa > ARY_MAX_SIZE) capa = ARY_MAX_SIZE; /* len <= capa <= ARY_MAX_SIZE */
+    if (capa <= ARY_MAX_SIZE / 2) {
+      capa *= 2;
+    }
+    else {
+      capa = len;
+    }
+  }
+  if (capa < len || capa > ARY_MAX_SIZE) {
+    goto size_error;
+  }
 
   if (capa > a->aux.capa) {
@@ -244,22 +243,34 @@
 
 static mrb_value
-mrb_ary_s_create(mrb_state *mrb, mrb_value self)
-{
+mrb_ary_s_create(mrb_state *mrb, mrb_value klass)
+{
+  mrb_value ary;
   mrb_value *vals;
   mrb_int len;
+  struct RArray *a;
 
   mrb_get_args(mrb, "*", &vals, &len);
-
-  return mrb_ary_new_from_values(mrb, len, vals);
+  ary = mrb_ary_new_from_values(mrb, len, vals);
+  a = mrb_ary_ptr(ary);
+  a->c = mrb_class_ptr(klass);
+
+  return ary;
 }
 
 static void
-ary_concat(mrb_state *mrb, struct RArray *a, mrb_value *ptr, mrb_int blen)
-{
-  mrb_int len = a->len + blen;
+ary_concat(mrb_state *mrb, struct RArray *a, struct RArray *a2)
+{
+  mrb_int len;
+
+  if (a2->len > ARY_MAX_SIZE - a->len) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
+  }
+  len = a->len + a2->len;
 
   ary_modify(mrb, a);
-  if (a->aux.capa < len) ary_expand_capa(mrb, a, len);
-  array_copy(a->ptr+a->len, ptr, blen);
+  if (a->aux.capa < len) {
+    ary_expand_capa(mrb, a, len);
+  }
+  array_copy(a->ptr+a->len, a2->ptr, a2->len);
   mrb_write_barrier(mrb, (struct RBasic*)a);
   a->len = len;
@@ -271,5 +282,5 @@
   struct RArray *a2 = mrb_ary_ptr(other);
 
-  ary_concat(mrb, mrb_ary_ptr(self), a2->ptr, a2->len);
+  ary_concat(mrb, mrb_ary_ptr(self), a2);
 }
 
@@ -277,9 +288,8 @@
 mrb_ary_concat_m(mrb_state *mrb, mrb_value self)
 {
-  mrb_value *ptr;
-  mrb_int blen;
-
-  mrb_get_args(mrb, "a", &ptr, &blen);
-  ary_concat(mrb, mrb_ary_ptr(self), ptr, blen);
+  mrb_value ary;
+
+  mrb_get_args(mrb, "A", &ary);
+  mrb_ary_concat(mrb, self, ary);
   return self;
 }
@@ -319,7 +329,10 @@
 mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other)
 {
+  struct RArray *a1 = mrb_ary_ptr(self);
   struct RArray *a2 = mrb_ary_ptr(other);
 
-  ary_replace(mrb, mrb_ary_ptr(self), a2->ptr, a2->len);
+  if (a1 != a2) {
+    ary_replace(mrb, a1, a2->ptr, a2->len);
+  }
 }
 
@@ -433,4 +446,5 @@
   struct RArray *a = mrb_ary_ptr(ary);
 
+  ary_modify(mrb, a);
   if (a->len == 0) return mrb_nil_value();
   return a->ptr[--a->len];
@@ -445,4 +459,5 @@
   mrb_value val;
 
+  ary_modify(mrb, a);
   if (a->len == 0) return mrb_nil_value();
   if (ARY_SHARED_P(a)) {
@@ -507,4 +522,7 @@
 
   mrb_get_args(mrb, "*", &vals, &len);
+  if (len > ARY_MAX_SIZE - a->len) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
+  }
   if (ARY_SHARED_P(a)
       && a->aux.shared->refcnt == 1 /* shared only referenced from this array */
@@ -564,11 +582,20 @@
 }
 
+static struct RArray*
+ary_dup(mrb_state *mrb, struct RArray *a)
+{
+  struct RArray *d = ary_new_capa(mrb, a->len);
+
+  ary_replace(mrb, d, a->ptr, a->len);
+  return d;
+}
+
 MRB_API mrb_value
 mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_value rpl)
 {
   struct RArray *a = mrb_ary_ptr(ary);
-  mrb_int tail, size;
   const mrb_value *argv;
-  mrb_int i, argc;
+  mrb_int argc;
+  mrb_int tail;
 
   ary_modify(mrb, a);
@@ -584,8 +611,8 @@
     }
   }
-  if (a->len < len || a->len < head + len) {
+  tail = head + len;
+  if (a->len < len || a->len < tail) {
     len = a->len - head;
   }
-  tail = head + len;
 
   /* size check */
@@ -593,4 +620,13 @@
     argc = RARRAY_LEN(rpl);
     argv = RARRAY_PTR(rpl);
+    if (argv == a->ptr) {
+      struct RArray *r;
+
+      if (argc > 32767) {
+        mrb_raise(mrb, E_ARGUMENT_ERROR, "too big recursive splice");
+      }
+      r = ary_dup(mrb, a);
+      argv = r->ptr;
+    }
   }
   else {
@@ -598,24 +634,39 @@
     argv = &rpl;
   }
-  size = head + argc;
-
-  if (tail < a->len) size += a->len - tail;
-  if (size > a->aux.capa)
-    ary_expand_capa(mrb, a, size);
-
-  if (head > a->len) {
+  if (head >= a->len) {
+    if (head > ARY_MAX_SIZE - argc) {
+      mrb_raisef(mrb, E_INDEX_ERROR, "index %S too big", mrb_fixnum_value(head));
+    }
+    len = head + argc;
+    if (len > a->aux.capa) {
+      ary_expand_capa(mrb, a, head + argc);
+    }
     ary_fill_with_nil(a->ptr + a->len, head - a->len);
-  }
-  else if (head < a->len) {
-    value_move(a->ptr + head + argc, a->ptr + tail, a->len - tail);
-  }
-
-  for (i = 0; i < argc; i++) {
-    *(a->ptr + head + i) = *(argv + i);
-    mrb_field_write_barrier_value(mrb, (struct RBasic*)a, argv[i]);
-  }
-
-  a->len = size;
-
+    if (argc > 0) {
+      array_copy(a->ptr + head, argv, argc);
+    }
+    a->len = len;
+  }
+  else {
+    mrb_int alen;
+
+    if (a->len - len > ARY_MAX_SIZE - argc) {
+      mrb_raisef(mrb, E_INDEX_ERROR, "index %S too big", mrb_fixnum_value(a->len + argc - len));
+    }
+    alen = a->len + argc - len;
+    if (alen > a->aux.capa) {
+      ary_expand_capa(mrb, a, alen);
+    }
+
+    if (len != argc) {
+      tail = head + len;
+      value_move(a->ptr + head + argc, a->ptr + tail, a->len - tail);
+      a->len = alen;
+    }
+    if (argc > 0) {
+      value_move(a->ptr + head, argv, argc);
+    }
+  }
+  mrb_write_barrier(mrb, (struct RBasic*)a);
   return ary;
 }
@@ -703,5 +754,5 @@
       /* a[n..m] */
     case MRB_TT_RANGE:
-      if (mrb_range_beg_len(mrb, index, &i, &len, a->len)) {
+      if (mrb_range_beg_len(mrb, index, &i, &len, a->len, TRUE) == 1) {
         return ary_subseq(mrb, a, i, len);
       }
@@ -767,18 +818,16 @@
   mrb_int i, len;
 
+  mrb_ary_modify(mrb, mrb_ary_ptr(self));
   if (mrb_get_args(mrb, "oo|o", &v1, &v2, &v3) == 2) {
-    switch (mrb_type(v1)) {
     /* a[n..m] = v */
-    case MRB_TT_RANGE:
-      if (mrb_range_beg_len(mrb, v1, &i, &len, RARRAY_LEN(self))) {
-        mrb_ary_splice(mrb, self, i, len, v2);
-      }
+    switch (mrb_range_beg_len(mrb, v1, &i, &len, RARRAY_LEN(self), FALSE)) {
+    case 0:                   /* not range */
+      mrb_ary_set(mrb, self, aget_index(mrb, v1), v2);
       break;
-    /* a[n] = v */
-    case MRB_TT_FIXNUM:
-      mrb_ary_set(mrb, self, mrb_fixnum(v1), v2);
+    case 1:                   /* range */
+      mrb_ary_splice(mrb, self, i, len, v2);
       break;
-    default:
-      mrb_ary_set(mrb, self, aget_index(mrb, v1), v2);
+    case 2:                   /* out of range */
+      mrb_raisef(mrb, E_RANGE_ERROR, "%S out of range", v1);
       break;
     }
@@ -878,5 +927,5 @@
 {
   mrb_value obj;
-  mrb_int i;
+  mrb_int i, len;
 
   mrb_get_args(mrb, "o", &obj);
@@ -885,4 +934,7 @@
       return mrb_fixnum_value(i);
     }
+    if (i > (len = RARRAY_LEN(self))) {
+      i = len;
+    }
   }
   return mrb_nil_value();
@@ -892,12 +944,30 @@
 mrb_ary_splat(mrb_state *mrb, mrb_value v)
 {
+  mrb_value a, recv_class;
+
   if (mrb_array_p(v)) {
     return v;
   }
-  if (mrb_respond_to(mrb, v, mrb_intern_lit(mrb, "to_a"))) {
-    return mrb_funcall(mrb, v, "to_a", 0);
+
+  if (!mrb_respond_to(mrb, v, mrb_intern_lit(mrb, "to_a"))) {
+    return mrb_ary_new_from_values(mrb, 1, &v);
+  }
+
+  a = mrb_funcall(mrb, v, "to_a", 0);
+  if (mrb_array_p(a)) {
+    return a;
+  }
+  else if (mrb_nil_p(a)) {
+    return mrb_ary_new_from_values(mrb, 1, &v);
   }
   else {
-    return mrb_ary_new_from_values(mrb, 1, &v);
+    recv_class = mrb_obj_value(mrb_obj_class(mrb, v));
+    mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %S to Array (%S#to_a gives %S)",
+      recv_class,
+      recv_class,
+      mrb_obj_value(mrb_obj_class(mrb, a))
+    );
+    /* not reached */
+    return mrb_undef_value();
   }
 }
@@ -916,4 +986,5 @@
   struct RArray *a = mrb_ary_ptr(self);
 
+  ary_modify(mrb, a);
   if (ARY_SHARED_P(a)) {
     mrb_ary_decref(mrb, a->aux.shared);
@@ -988,13 +1059,15 @@
 
     default:
-      tmp = mrb_check_string_type(mrb, val);
-      if (!mrb_nil_p(tmp)) {
-        val = tmp;
-        goto str_join;
-      }
-      tmp = mrb_check_convert_type(mrb, val, MRB_TT_ARRAY, "Array", "to_ary");
-      if (!mrb_nil_p(tmp)) {
-        val = tmp;
-        goto ary_join;
+      if (!mrb_immediate_p(val)) {
+        tmp = mrb_check_string_type(mrb, val);
+        if (!mrb_nil_p(tmp)) {
+          val = tmp;
+          goto str_join;
+        }
+        tmp = mrb_check_convert_type(mrb, val, MRB_TT_ARRAY, "Array", "to_ary");
+        if (!mrb_nil_p(tmp)) {
+          val = tmp;
+          goto ary_join;
+        }
       }
       val = mrb_obj_as_string(mrb, val);
@@ -1011,5 +1084,7 @@
 mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep)
 {
-  sep = mrb_obj_as_string(mrb, sep);
+  if (!mrb_nil_p(sep)) {
+    sep = mrb_obj_as_string(mrb, sep);
+  }
   return join_ary(mrb, ary, sep, mrb_ary_new(mrb));
 }
@@ -1091,4 +1166,5 @@
   mrb_define_method(mrb, a, "pop",             mrb_ary_pop,          MRB_ARGS_NONE()); /* 15.2.12.5.21 */
   mrb_define_method(mrb, a, "push",            mrb_ary_push_m,       MRB_ARGS_ANY());  /* 15.2.12.5.22 */
+  mrb_define_method(mrb, a, "append",          mrb_ary_push_m,       MRB_ARGS_ANY());
   mrb_define_method(mrb, a, "replace",         mrb_ary_replace_m,    MRB_ARGS_REQ(1)); /* 15.2.12.5.23 */
   mrb_define_method(mrb, a, "reverse",         mrb_ary_reverse,      MRB_ARGS_NONE()); /* 15.2.12.5.24 */
@@ -1099,4 +1175,5 @@
   mrb_define_method(mrb, a, "slice",           mrb_ary_aget,         MRB_ARGS_ANY());  /* 15.2.12.5.29 */
   mrb_define_method(mrb, a, "unshift",         mrb_ary_unshift_m,    MRB_ARGS_ANY());  /* 15.2.12.5.30 */
+  mrb_define_method(mrb, a, "prepend",         mrb_ary_unshift_m,    MRB_ARGS_ANY());
 
   mrb_define_method(mrb, a, "__ary_eq",        mrb_ary_eq,           MRB_ARGS_REQ(1));
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/backtrace.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/backtrace.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/backtrace.c	(revision 331)
@@ -5,97 +5,34 @@
 */
 
-#include "mruby.h"
-#include "mruby/variable.h"
-#include "mruby/proc.h"
-#include "mruby/array.h"
-#include "mruby/string.h"
-#include "mruby/class.h"
-#include "mruby/debug.h"
-#include "mruby/error.h"
-#include "mruby/numeric.h"
+#include <mruby.h>
+#include <mruby/variable.h>
+#include <mruby/proc.h>
+#include <mruby/array.h>
+#include <mruby/string.h>
+#include <mruby/class.h>
+#include <mruby/debug.h>
+#include <mruby/error.h>
+#include <mruby/numeric.h>
+#include <mruby/data.h>
 
 struct backtrace_location {
-  int i;
   int lineno;
   const char *filename;
-  const char *method;
-  const char *sep;
-  const char *class_name;
+  mrb_sym method_id;
 };
 
-typedef void (*output_stream_func)(mrb_state*, struct backtrace_location*, void*);
-
-#ifndef MRB_DISABLE_STDIO
-
-struct print_backtrace_args {
-  FILE *stream;
-  int tracehead;
-};
-
-static void
-print_backtrace_i(mrb_state *mrb, struct backtrace_location *loc, void *data)
-{
-  struct print_backtrace_args *args;
-
-  args = (struct print_backtrace_args*)data;
-
-  if (args->tracehead) {
-    fprintf(args->stream, "trace:\n");
-    args->tracehead = FALSE;
-  }
-
-  fprintf(args->stream, "\t[%d] %s:%d", loc->i, loc->filename, loc->lineno);
-
-  if (loc->method) {
-    if (loc->class_name) {
-      fprintf(args->stream, ":in %s%s%s", loc->class_name, loc->sep, loc->method);
-    }
-    else {
-      fprintf(args->stream, ":in %s", loc->method);
-    }
-  }
-
-  fprintf(args->stream, "\n");
-}
-
-#endif
-
-static void
-get_backtrace_i(mrb_state *mrb, struct backtrace_location *loc, void *data)
-{
-  mrb_value ary, str;
-  int ai;
-
-  ai = mrb_gc_arena_save(mrb);
-  ary = mrb_obj_value((struct RArray*)data);
-
-  str = mrb_str_new_cstr(mrb, loc->filename);
-  mrb_str_cat_lit(mrb, str, ":");
-  mrb_str_concat(mrb, str, mrb_fixnum_to_str(mrb, mrb_fixnum_value(loc->lineno), 10));
-
-  if (loc->method) {
-    mrb_str_cat_lit(mrb, str, ":in ");
-
-    if (loc->class_name) {
-      mrb_str_cat_cstr(mrb, str, loc->class_name);
-      mrb_str_cat_cstr(mrb, str, loc->sep);
-    }
-
-    mrb_str_cat_cstr(mrb, str, loc->method);
-  }
-
-  mrb_ary_push(mrb, ary, str);
-  mrb_gc_arena_restore(mrb, ai);
-}
-
-static void
-output_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, output_stream_func func, void *data)
-{
-  int i;
+typedef void (*each_backtrace_func)(mrb_state*, int i, struct backtrace_location*, void*);
+
+static const mrb_data_type bt_type = { "Backtrace", mrb_free };
+
+static void
+each_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, each_backtrace_func func, void *data)
+{
+  int i, j;
 
   if (ciidx >= mrb->c->ciend - mrb->c->cibase)
     ciidx = 10; /* ciidx is broken... */
 
-  for (i = ciidx; i >= 0; i--) {
+  for (i=ciidx, j=0; i >= 0; i--,j++) {
     struct backtrace_location loc;
     mrb_callinfo *ci;
@@ -109,4 +46,5 @@
 
     irep = ci->proc->body.irep;
+    if (!irep) continue;
 
     if (mrb->c->cibase[i].err) {
@@ -124,62 +62,87 @@
     if (loc.lineno == -1) continue;
 
-    if (ci->target_class == ci->proc->target_class) {
-      loc.sep = ".";
-    }
-    else {
-      loc.sep = "#";
-    }
-
     if (!loc.filename) {
       loc.filename = "(unknown)";
     }
 
-    loc.method = mrb_sym2name(mrb, ci->mid);
-    loc.class_name = mrb_class_name(mrb, ci->proc->target_class);
-    loc.i = i;
-    func(mrb, &loc, data);
-  }
-}
-
-static void
-exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func func, void *stream)
-{
-  mrb_value lastpc;
-  mrb_code *code;
-
-  lastpc = mrb_obj_iv_get(mrb, exc, mrb_intern_lit(mrb, "lastpc"));
-  if (mrb_nil_p(lastpc)) {
-    code = NULL;
-  } else {
-    code = (mrb_code*)mrb_cptr(lastpc);
-  }
-
-  output_backtrace(mrb, mrb_fixnum(mrb_obj_iv_get(mrb, exc, mrb_intern_lit(mrb, "ciidx"))),
-                   code, func, stream);
-}
-
-/* mrb_print_backtrace/mrb_get_backtrace:
-
-   function to retrieve backtrace information from the exception.
-   note that if you call method after the exception, call stack will be
-   overwritten.  So invoke these functions just after detecting exceptions.
+    loc.method_id = ci->mid;
+    func(mrb, j, &loc, data);
+  }
+}
+
+#ifndef MRB_DISABLE_STDIO
+
+static void
+print_backtrace(mrb_state *mrb, mrb_value backtrace)
+{
+  int i, n;
+  FILE *stream = stderr;
+
+  if (!mrb_array_p(backtrace)) return;
+  fprintf(stream, "trace:\n");
+
+  n = RARRAY_LEN(backtrace);
+  for (i=0; n--; i++) {
+    mrb_value entry = RARRAY_PTR(backtrace)[n];
+
+    if (mrb_string_p(entry)) {
+      fprintf(stream, "\t[%d] %.*s\n", i, (int)RSTRING_LEN(entry), RSTRING_PTR(entry));
+    }
+  }
+}
+
+static void
+print_packed_backtrace(mrb_state *mrb, mrb_value packed)
+{
+  FILE *stream = stderr;
+  struct backtrace_location *bt;
+  int n, i;
+
+  bt = (struct backtrace_location*)mrb_data_check_get_ptr(mrb, packed, &bt_type);
+  if (bt == NULL) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "broken backtrace");
+  }
+  n = (mrb_int)RDATA(packed)->flags;
+
+  fprintf(stream, "trace:\n");
+  for (i = 0; n--; i++) {
+    int ai = mrb_gc_arena_save(mrb);
+    struct backtrace_location *entry = &bt[n];
+    if (entry->filename == NULL) continue;
+    fprintf(stream, "\t[%d] %s:%d", (int)i, entry->filename, entry->lineno);
+    if (entry->method_id != 0) {
+      const char *method_name;
+
+      method_name = mrb_sym2name(mrb, entry->method_id);
+      fprintf(stream, ":in %s", method_name);
+      mrb_gc_arena_restore(mrb, ai);
+    }
+    fprintf(stream, "\n");
+  }
+}
+
+/* mrb_print_backtrace
+
+   function to retrieve backtrace information from the last exception.
 */
-
-#ifndef MRB_DISABLE_STDIO
 
 MRB_API void
 mrb_print_backtrace(mrb_state *mrb)
 {
-  struct print_backtrace_args args;
-
-  if (!mrb->exc || mrb_obj_is_kind_of(mrb, mrb_obj_value(mrb->exc), E_SYSSTACK_ERROR)) {
+  mrb_value backtrace;
+
+  if (!mrb->exc) {
     return;
   }
 
-  args.stream = stderr;
-  args.tracehead = TRUE;
-  exc_output_backtrace(mrb, mrb->exc, print_backtrace_i, (void*)&args);
-}
-
+  backtrace = mrb_obj_iv_get(mrb, mrb->exc, mrb_intern_lit(mrb, "backtrace"));
+  if (mrb_nil_p(backtrace)) return;
+  if (mrb_array_p(backtrace)) {
+    print_backtrace(mrb, backtrace);
+  }
+  else {
+    print_packed_backtrace(mrb, backtrace);
+  }
+}
 #else
 
@@ -191,13 +154,90 @@
 #endif
 
+static void
+pack_backtrace_i(mrb_state *mrb,
+                 int i,
+                 struct backtrace_location *loc,
+                 void *data)
+{
+  struct backtrace_location *entry = (struct backtrace_location*)data;
+
+  entry[i] = *loc;
+}
+
+static mrb_value
+packed_backtrace(mrb_state *mrb)
+{
+  struct RData *backtrace;
+  ptrdiff_t ciidx = mrb->c->ci - mrb->c->cibase;
+  mrb_int len = (ciidx+1)*sizeof(struct backtrace_location);
+  void *ptr;
+
+  ptr = mrb_malloc(mrb, len);
+  memset(ptr, 0, len);
+  backtrace = mrb_data_object_alloc(mrb, NULL, ptr, &bt_type);
+  backtrace->flags = (unsigned int)ciidx+1;
+  each_backtrace(mrb, ciidx, mrb->c->ci->pc, pack_backtrace_i, ptr);
+  return mrb_obj_value(backtrace);
+}
+
+void
+mrb_keep_backtrace(mrb_state *mrb, mrb_value exc)
+{
+  mrb_value backtrace;
+  int ai = mrb_gc_arena_save(mrb);
+
+  backtrace = packed_backtrace(mrb);
+  mrb_iv_set(mrb, exc, mrb_intern_lit(mrb, "backtrace"), backtrace);
+  mrb_gc_arena_restore(mrb, ai);
+}
+
+mrb_value
+mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace)
+{
+  struct backtrace_location *bt;
+  mrb_int n, i;
+
+  if (mrb_nil_p(backtrace)) return mrb_ary_new_capa(mrb, 0);
+  if (mrb_array_p(backtrace)) return backtrace;
+  bt = (struct backtrace_location*)mrb_data_check_get_ptr(mrb, backtrace, &bt_type);
+  if (bt == NULL) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "broken backtrace");
+  }
+  n = (mrb_int)RDATA(backtrace)->flags;
+  backtrace = mrb_ary_new_capa(mrb, n);
+  for (i = 0; i < n; i++) {
+    int ai = mrb_gc_arena_save(mrb);
+    struct backtrace_location *entry = &bt[i];
+    mrb_value btline;
+
+    if (entry->filename == NULL) continue;
+    btline = mrb_format(mrb, "%S:%S",
+                              mrb_str_new_cstr(mrb, entry->filename),
+                              mrb_fixnum_value(entry->lineno));
+    if (entry->method_id != 0) {
+      mrb_str_cat_lit(mrb, btline, ":in ");
+      mrb_str_cat_cstr(mrb, btline, mrb_sym2name(mrb, entry->method_id));
+    }
+    mrb_ary_push(mrb, backtrace, btline);
+    mrb_gc_arena_restore(mrb, ai);
+  }
+
+  return backtrace;
+}
+
 MRB_API mrb_value
-mrb_exc_backtrace(mrb_state *mrb, mrb_value self)
-{
-  mrb_value ary;
-
-  ary = mrb_ary_new(mrb);
-  exc_output_backtrace(mrb, mrb_obj_ptr(self), get_backtrace_i, (void*)mrb_ary_ptr(ary));
-
-  return ary;
+mrb_exc_backtrace(mrb_state *mrb, mrb_value exc)
+{
+  mrb_sym attr_name;
+  mrb_value backtrace;
+
+  attr_name = mrb_intern_lit(mrb, "backtrace");
+  backtrace = mrb_iv_get(mrb, exc, attr_name);
+  if (mrb_nil_p(backtrace) || mrb_array_p(backtrace)) {
+    return backtrace;
+  }
+  backtrace = mrb_unpack_backtrace(mrb, backtrace);
+  mrb_iv_set(mrb, exc, attr_name, backtrace);
+  return backtrace;
 }
 
@@ -205,13 +245,4 @@
 mrb_get_backtrace(mrb_state *mrb)
 {
-  mrb_value ary;
-  mrb_callinfo *ci = mrb->c->ci;
-  mrb_code *pc = ci->pc;
-  mrb_int ciidx = (mrb_int)(ci - mrb->c->cibase - 1);
-
-  if (ciidx < 0) ciidx = 0;
-  ary = mrb_ary_new(mrb);
-  output_backtrace(mrb, ciidx, pc, get_backtrace_i, (void*)mrb_ary_ptr(ary));
-
-  return ary;
-}
+  return mrb_unpack_backtrace(mrb, packed_backtrace(mrb));
+}
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/class.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/class.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/class.c	(revision 331)
@@ -6,13 +6,14 @@
 
 #include <stdarg.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/numeric.h"
-#include "mruby/proc.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
-#include "mruby/error.h"
-#include "mruby/data.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/numeric.h>
+#include <mruby/proc.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
+#include <mruby/error.h>
+#include <mruby/data.h>
+#include <mruby/istruct.h>
 
 KHASH_DEFINE(mt, mrb_sym, struct RProc*, TRUE, kh_int_hash_func, kh_int_hash_equal)
@@ -97,4 +98,5 @@
   else {
     sc->super = o->c;
+    prepare_singleton_class(mrb, (struct RBasic*)sc);
   }
   o->c = sc;
@@ -122,16 +124,6 @@
 }
 
-MRB_API struct RClass*
-mrb_class_outer_module(mrb_state *mrb, struct RClass *c)
-{
-  mrb_value outer;
-
-  outer = mrb_obj_iv_get(mrb, (struct RObject*)c, mrb_intern_lit(mrb, "__outer__"));
-  if (mrb_nil_p(outer)) return NULL;
-  return mrb_class_ptr(outer);
-}
-
-static void
-check_if_class_or_module(mrb_state *mrb, mrb_value obj)
+static mrb_bool
+class_ptr_p(mrb_value obj)
 {
   switch (mrb_type(obj)) {
@@ -139,6 +131,35 @@
   case MRB_TT_SCLASS:
   case MRB_TT_MODULE:
-    return;
+    return TRUE;
   default:
+    return FALSE;
+  }
+}
+
+MRB_API struct RClass*
+mrb_class_outer_module(mrb_state *mrb, struct RClass *c)
+{
+  mrb_value outer;
+  struct RClass *cls;
+
+  outer = mrb_obj_iv_get(mrb, (struct RObject*)c, mrb_intern_lit(mrb, "__outer__"));
+  if (mrb_nil_p(outer)) return NULL;
+  cls = mrb_class_ptr(outer);
+  if (cls->tt == MRB_TT_SCLASS)
+  {
+    mrb_value klass;
+    klass = mrb_obj_iv_get(mrb, (struct RObject *)cls,
+                           mrb_intern_lit(mrb, "__attached__"));
+    if (class_ptr_p(klass)) {
+      cls = mrb_class_ptr(klass);
+    }
+  }
+  return cls;
+}
+
+static void
+check_if_class_or_module(mrb_state *mrb, mrb_value obj)
+{
+  if (!class_ptr_p(obj)) {
     mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a class/module", mrb_inspect(mrb, obj));
   }
@@ -175,4 +196,12 @@
 {
   check_if_class_or_module(mrb, outer);
+  if (mrb_const_defined_at(mrb, outer, id)) {
+    mrb_value old = mrb_const_get(mrb, outer, id);
+
+    if (mrb_type(old) != MRB_TT_MODULE) {
+      mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a module", mrb_inspect(mrb, old));
+    }
+    return mrb_class_ptr(old);
+  }
   return define_module(mrb, id, mrb_class_ptr(outer));
 }
@@ -232,10 +261,20 @@
 }
 
+static mrb_value mrb_bob_init(mrb_state *mrb, mrb_value cv);
+
 static void
 mrb_class_inherited(mrb_state *mrb, struct RClass *super, struct RClass *klass)
 {
+  mrb_value s;
+  mrb_sym mid;
+
   if (!super)
     super = mrb->object_class;
-  mrb_funcall(mrb, mrb_obj_value(super), "inherited", 1, mrb_obj_value(klass));
+  s = mrb_obj_value(super);
+  mid = mrb_intern_lit(mrb, "inherited");
+  if (!mrb_func_basic_p(mrb, s, mid, mrb_bob_init)) {
+    mrb_value c = mrb_obj_value(klass);
+    mrb_funcall_argv(mrb, mrb_obj_value(super), mid, 1, &c);
+  }
 }
 
@@ -248,5 +287,6 @@
   if (!mrb_nil_p(super)) {
     if (mrb_type(super) != MRB_TT_CLASS) {
-      mrb_raisef(mrb, E_TYPE_ERROR, "superclass must be a Class (%S given)", super);
+      mrb_raisef(mrb, E_TYPE_ERROR, "superclass must be a Class (%S given)",
+                 mrb_inspect(mrb, super));
     }
     s = mrb_class_ptr(super);
@@ -256,4 +296,19 @@
   }
   check_if_class_or_module(mrb, outer);
+  if (mrb_const_defined_at(mrb, outer, id)) {
+    mrb_value old = mrb_const_get(mrb, outer, id);
+
+    if (mrb_type(old) != MRB_TT_CLASS) {
+      mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a class", mrb_inspect(mrb, old));
+    }
+    c = mrb_class_ptr(old);
+    if (s) {
+      /* check super class */
+      if (mrb_class_real(c->super) != s) {
+        mrb_raisef(mrb, E_TYPE_ERROR, "superclass mismatch for class %S", old);
+      }
+    }
+    return c;
+  }
   c = define_class(mrb, id, s, mrb_class_ptr(outer));
   mrb_class_inherited(mrb, mrb_class_real(c->super), c);
@@ -272,4 +327,14 @@
 }
 
+MRB_API mrb_bool
+mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name)
+{
+  mrb_value sym = mrb_check_intern_cstr(mrb, name);
+  if (mrb_nil_p(sym)) {
+    return FALSE;
+  }
+  return mrb_const_defined_at(mrb, mrb_obj_value(outer), mrb_symbol(sym));
+}
+
 MRB_API struct RClass *
 mrb_class_get_under(mrb_state *mrb, struct RClass *outer, const char *name)
@@ -282,4 +347,24 @@
 {
   return mrb_class_get_under(mrb, mrb->object_class, name);
+}
+
+MRB_API struct RClass *
+mrb_exc_get(mrb_state *mrb, const char *name)
+{
+  struct RClass *exc, *e;
+  mrb_value c = mrb_const_get(mrb, mrb_obj_value(mrb->object_class),
+                              mrb_intern_cstr(mrb, name));
+
+  if (mrb_type(c) != MRB_TT_CLASS) {
+    mrb_raise(mrb, mrb->eException_class, "exception corrupted");
+  }
+  exc = e = mrb_class_ptr(c);
+
+  while (e) {
+    if (e == mrb->eException_class)
+      return exc;
+    e = e->super;
+  }
+  return mrb->eException_class;
 }
 
@@ -337,8 +422,15 @@
   h = c->mt;
 
+  if (MRB_FROZEN_P(c)) {
+    if (c->tt == MRB_TT_MODULE)
+      mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen module");
+    else
+      mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen class");
+  }
   if (!h) h = c->mt = kh_init(mt, mrb);
   k = kh_put(mt, mrb, h, mid);
   kh_value(h, k) = p;
   if (p) {
+    p->c = NULL;
     mrb_field_write_barrier(mrb, (struct RBasic *)c, (struct RBasic *)p);
   }
@@ -430,4 +522,6 @@
     mrb_value obj = mrb_funcall(mrb, ss, "inspect", 0);
     mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a symbol", obj);
+    /* not reached */
+    return 0;
   }
 }
@@ -457,4 +551,5 @@
     n:      Symbol         [mrb_sym]
     d:      Data           [void*,mrb_data_type const] 2nd argument will be used to check data type so it won't be modified
+    I:      Inline struct  [void*]
     &:      Block          [mrb_value]
     *:      rest argument  [mrb_value*,mrb_int]   Receive the rest of the arguments as an array.
@@ -467,7 +562,8 @@
   char c;
   int i = 0;
-  mrb_value *sp = mrb->c->stack + 1;
   va_list ap;
   int argc = mrb->c->ci->argc;
+  int arg_i = 0;
+  mrb_bool array_argv;
   mrb_bool opt = FALSE;
   mrb_bool given = TRUE;
@@ -478,6 +574,13 @@
 
     argc = a->len;
-    sp = a->ptr;
-  }
+    array_argv = TRUE;
+  }
+  else {
+    array_argv = FALSE;
+  }
+
+#define ARGV \
+  (array_argv ? mrb_ary_ptr(mrb->c->stack[1])->ptr : (mrb->c->stack + 1))
+
   while ((c = *format++)) {
     switch (c) {
@@ -503,5 +606,5 @@
         p = va_arg(ap, mrb_value*);
         if (i < argc) {
-          *p = *sp++;
+          *p = ARGV[arg_i++];
           i++;
         }
@@ -516,13 +619,7 @@
           mrb_value ss;
 
-          ss = *sp++;
-          switch (mrb_type(ss)) {
-          case MRB_TT_CLASS:
-          case MRB_TT_MODULE:
-          case MRB_TT_SCLASS:
-            break;
-          default:
+          ss = ARGV[arg_i++];
+          if (!class_ptr_p(ss)) {
             mrb_raisef(mrb, E_TYPE_ERROR, "%S is not class/module", ss);
-            break;
           }
           *p = ss;
@@ -538,6 +635,6 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
-            *p = *sp++;
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
+            *p = ARGV[arg_i++];
             i++;
             break;
@@ -545,5 +642,5 @@
         }
         if (i < argc) {
-          *p = to_str(mrb, *sp++);
+          *p = to_str(mrb, ARGV[arg_i++]);
           i++;
         }
@@ -557,6 +654,6 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
-            *p = *sp++;
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
+            *p = ARGV[arg_i++];
             i++;
             break;
@@ -564,5 +661,5 @@
         }
         if (i < argc) {
-          *p = to_ary(mrb, *sp++);
+          *p = to_ary(mrb, ARGV[arg_i++]);
           i++;
         }
@@ -576,6 +673,6 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
-            *p = *sp++;
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
+            *p = ARGV[arg_i++];
             i++;
             break;
@@ -583,5 +680,5 @@
         }
         if (i < argc) {
-          *p = to_hash(mrb, *sp++);
+          *p = to_hash(mrb, ARGV[arg_i++]);
           i++;
         }
@@ -598,13 +695,13 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
             *ps = NULL;
             *pl = 0;
-            i++;
+            i++; arg_i++;
             break;
           }
         }
         if (i < argc) {
-          ss = to_str(mrb, *sp++);
+          ss = to_str(mrb, ARGV[arg_i++]);
           *ps = RSTRING_PTR(ss);
           *pl = RSTRING_LEN(ss);
@@ -621,12 +718,12 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
             *ps = NULL;
-            i++; sp++;
+            i++; arg_i++;
             break;
           }
         }
         if (i < argc) {
-          ss = to_str(mrb, *sp++);
+          ss = to_str(mrb, ARGV[arg_i++]);
           *ps = mrb_string_value_cstr(mrb, &ss);
           i++;
@@ -645,13 +742,13 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
             *pb = 0;
             *pl = 0;
-            i++; sp++;
+            i++; arg_i++;
             break;
           }
         }
         if (i < argc) {
-          aa = to_ary(mrb, *sp++);
+          aa = to_ary(mrb, ARGV[arg_i++]);
           a = mrb_ary_ptr(aa);
           *pb = a->ptr;
@@ -661,4 +758,22 @@
       }
       break;
+    case 'I':
+      {
+        void* *p;
+        mrb_value ss;
+
+        p = va_arg(ap, void**);
+        if (i < argc) {
+          ss = ARGV[arg_i];
+          if (mrb_type(ss) != MRB_TT_ISTRUCT)
+          {
+            mrb_raisef(mrb, E_TYPE_ERROR, "%S is not inline struct", ss);
+          }
+          *p = mrb_istruct_ptr(ss);
+          arg_i++;
+          i++;
+        }
+      }
+      break;
     case 'f':
       {
@@ -667,6 +782,6 @@
         p = va_arg(ap, mrb_float*);
         if (i < argc) {
-          *p = mrb_to_flo(mrb, *sp);
-          sp++;
+          *p = mrb_to_flo(mrb, ARGV[arg_i]);
+          arg_i++;
           i++;
         }
@@ -679,13 +794,13 @@
         p = va_arg(ap, mrb_int*);
         if (i < argc) {
-          switch (mrb_type(*sp)) {
+          switch (mrb_type(ARGV[arg_i])) {
             case MRB_TT_FIXNUM:
-              *p = mrb_fixnum(*sp);
+              *p = mrb_fixnum(ARGV[arg_i]);
               break;
             case MRB_TT_FLOAT:
               {
-                mrb_float f = mrb_float(*sp);
-
-                if (!FIXABLE(f)) {
+                mrb_float f = mrb_float(ARGV[arg_i]);
+
+                if (!FIXABLE_FLOAT(f)) {
                   mrb_raise(mrb, E_RANGE_ERROR, "float too big for int");
                 }
@@ -697,8 +812,8 @@
               break;
             default:
-              *p = mrb_fixnum(mrb_Integer(mrb, *sp));
+              *p = mrb_fixnum(mrb_Integer(mrb, ARGV[arg_i]));
               break;
           }
-          sp++;
+          arg_i++;
           i++;
         }
@@ -710,5 +825,5 @@
 
         if (i < argc) {
-          mrb_value b = *sp++;
+          mrb_value b = ARGV[arg_i++];
           *boolp = mrb_test(b);
           i++;
@@ -724,5 +839,5 @@
           mrb_value ss;
 
-          ss = *sp++;
+          ss = ARGV[arg_i++];
           *symp = to_sym(mrb, ss);
           i++;
@@ -739,12 +854,12 @@
         if (*format == '!') {
           format++;
-          if (i < argc && mrb_nil_p(*sp)) {
+          if (i < argc && mrb_nil_p(ARGV[arg_i])) {
             *datap = 0;
-            i++; sp++;
+            i++; arg_i++;
             break;
           }
         }
         if (i < argc) {
-          *datap = mrb_data_get_ptr(mrb, *sp++, type);
+          *datap = mrb_data_get_ptr(mrb, ARGV[arg_i++], type);
           ++i;
         }
@@ -788,8 +903,8 @@
           *pl = argc-i;
           if (*pl > 0) {
-            *var = sp;
+            *var = ARGV + arg_i;
           }
           i = argc;
-          sp += *pl;
+          arg_i += *pl;
         }
         else {
@@ -804,4 +919,7 @@
     }
   }
+
+#undef ARGV
+
   if (!c && argc > i) {
     mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments");
@@ -831,5 +949,7 @@
 boot_initmod(mrb_state *mrb, struct RClass *mod)
 {
-  mod->mt = kh_init(mt, mrb);
+  if (!mod->mt) {
+    mod->mt = kh_init(mt, mrb);
+  }
 }
 
@@ -847,5 +967,6 @@
   if (m->tt == MRB_TT_ICLASS) {
     ic->c = m->c;
-  } else {
+  }
+  else {
     ic->c = m;
   }
@@ -873,5 +994,5 @@
         if (p->mt == m->mt) {
           if (!superclass_seen) {
-            ins_pos = p; // move insert point
+            ins_pos = p; /* move insert point */
           }
           goto skip;
@@ -937,22 +1058,4 @@
 
 static mrb_value
-mrb_mod_prepend(mrb_state *mrb, mrb_value klass)
-{
-  mrb_value *argv;
-  mrb_int argc, i;
-
-  mrb_get_args(mrb, "*", &argv, &argc);
-  for (i=0; i<argc; i++) {
-    mrb_check_type(mrb, argv[i], MRB_TT_MODULE);
-  }
-  while (argc--) {
-    mrb_funcall(mrb, argv[argc], "prepend_features", 1, klass);
-    mrb_funcall(mrb, argv[argc], "prepended", 1, klass);
-  }
-
-  return klass;
-}
-
-static mrb_value
 mrb_mod_append_features(mrb_state *mrb, mrb_value mod)
 {
@@ -963,22 +1066,4 @@
   mrb_include_module(mrb, mrb_class_ptr(klass), mrb_class_ptr(mod));
   return mod;
-}
-
-static mrb_value
-mrb_mod_include(mrb_state *mrb, mrb_value klass)
-{
-  mrb_value *argv;
-  mrb_int argc, i;
-
-  mrb_get_args(mrb, "*", &argv, &argc);
-  for (i=0; i<argc; i++) {
-    mrb_check_type(mrb, argv[i], MRB_TT_MODULE);
-  }
-  while (argc--) {
-    mrb_funcall(mrb, argv[argc], "append_features", 1, klass);
-    mrb_funcall(mrb, argv[argc], "included", 1, klass);
-  }
-
-  return klass;
 }
 
@@ -1076,5 +1161,5 @@
   mrb_value b;
   struct RClass *m = mrb_class_ptr(mod);
-  boot_initmod(mrb, m); // bootstrap a newly initialized module
+  boot_initmod(mrb, m); /* bootstrap a newly initialized module */
   mrb_get_args(mrb, "|&", &b);
   if (!mrb_nil_p(b)) {
@@ -1156,8 +1241,4 @@
   obj = mrb_basic_ptr(v);
   prepare_singleton_class(mrb, obj);
-  if (mrb->c && mrb->c->ci && mrb->c->ci->target_class) {
-    mrb_obj_iv_set(mrb, (struct RObject*)obj->c, mrb_intern_lit(mrb, "__outer__"),
-                   mrb_obj_value(mrb->c->ci->target_class));
-  }
   return mrb_obj_value(obj->c);
 }
@@ -1320,4 +1401,7 @@
 
   if (ttype == 0) ttype = MRB_TT_OBJECT;
+  if (ttype <= MRB_TT_CPTR) {
+    mrb_raisef(mrb, E_TYPE_ERROR, "can't create instance of %S", cv);
+  }
   o = (struct RObject*)mrb_obj_alloc(mrb, ttype, c);
   return mrb_obj_value(o);
@@ -1354,8 +1438,11 @@
 {
   mrb_value obj;
+  mrb_sym mid;
 
   obj = mrb_instance_alloc(mrb, mrb_obj_value(c));
-  mrb_funcall_argv(mrb, obj, mrb_intern_lit(mrb, "initialize"), argc, argv);
-
+  mid = mrb_intern_lit(mrb, "initialize");
+  if (!mrb_func_basic_p(mrb, obj, mid, mrb_bob_init)) {
+    mrb_funcall_argv(mrb, obj, mid, argc, argv);
+  }
   return obj;
 }
@@ -1379,4 +1466,5 @@
   mrb_value super, blk;
   mrb_value new_class;
+  mrb_sym mid;
 
   n = mrb_get_args(mrb, "|C&", &super, &blk);
@@ -1385,5 +1473,8 @@
   }
   new_class = mrb_obj_value(mrb_class_new(mrb, mrb_class_ptr(super)));
-  mrb_funcall_with_block(mrb, new_class, mrb_intern_lit(mrb, "initialize"), n, &super, blk);
+  mid = mrb_intern_lit(mrb, "initialize");
+  if (!mrb_func_basic_p(mrb, new_class, mid, mrb_bob_init)) {
+    mrb_funcall_with_block(mrb, new_class, mid, n, &super, blk);
+  }
   mrb_class_inherited(mrb, mrb_class_ptr(super), mrb_class_ptr(new_class));
   return new_class;
@@ -1416,73 +1507,51 @@
 }
 
-void
-mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args)
-{
-  mrb_sym inspect;
-  mrb_value repr;
-
-  inspect = mrb_intern_lit(mrb, "inspect");
-  if (mrb->c->ci > mrb->c->cibase && mrb->c->ci[-1].mid == inspect) {
-    /* method missing in inspect; avoid recursion */
-    repr = mrb_any_to_s(mrb, self);
-  }
-  else if (mrb_respond_to(mrb, self, inspect) && mrb->c->ci - mrb->c->cibase < 64) {
-    repr = mrb_funcall_argv(mrb, self, inspect, 0, 0);
-    if (mrb_string_p(repr) && RSTRING_LEN(repr) > 64) {
-      repr = mrb_any_to_s(mrb, self);
-    }
-  }
-  else {
-    repr = mrb_any_to_s(mrb, self);
-  }
-
-  mrb_no_method_error(mrb, name, args, "undefined method '%S' for %S",
-                      mrb_sym2str(mrb, name), repr);
-}
-
-/* 15.3.1.3.30 */
+/* 15.3.1.3.1  */
+/* 15.3.1.3.10 */
+/* 15.3.1.3.11 */
 /*
  *  call-seq:
- *     obj.method_missing(symbol [, *args] )   -> result
- *
- *  Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
- *  <i>symbol</i> is the symbol for the method called, and <i>args</i>
- *  are any arguments that were passed to it. By default, the interpreter
- *  raises an error when this method is called. However, it is possible
- *  to override the method to provide more dynamic behavior.
- *  If it is decided that a particular method should not be handled, then
- *  <i>super</i> should be called, so that ancestors can pick up the
- *  missing method.
- *  The example below creates
- *  a class <code>Roman</code>, which responds to methods with names
- *  consisting of roman numerals, returning the corresponding integer
- *  values.
- *
- *     class Roman
- *       def romanToInt(str)
- *         # ...
- *       end
- *       def method_missing(methId)
- *         str = methId.id2name
- *         romanToInt(str)
- *       end
- *     end
- *
- *     r = Roman.new
- *     r.iv      #=> 4
- *     r.xxiii   #=> 23
- *     r.mm      #=> 2000
+ *     obj == other        -> true or false
+ *     obj.equal?(other)   -> true or false
+ *     obj.eql?(other)     -> true or false
+ *
+ *  Equality---At the <code>Object</code> level, <code>==</code> returns
+ *  <code>true</code> only if <i>obj</i> and <i>other</i> are the
+ *  same object. Typically, this method is overridden in descendant
+ *  classes to provide class-specific meaning.
+ *
+ *  Unlike <code>==</code>, the <code>equal?</code> method should never be
+ *  overridden by subclasses: it is used to determine object identity
+ *  (that is, <code>a.equal?(b)</code> iff <code>a</code> is the same
+ *  object as <code>b</code>).
+ *
+ *  The <code>eql?</code> method returns <code>true</code> if
+ *  <i>obj</i> and <i>anObject</i> have the same value. Used by
+ *  <code>Hash</code> to test members for equality.  For objects of
+ *  class <code>Object</code>, <code>eql?</code> is synonymous with
+ *  <code>==</code>. Subclasses normally continue this tradition, but
+ *  there are exceptions. <code>Numeric</code> types, for example,
+ *  perform type conversion across <code>==</code>, but not across
+ *  <code>eql?</code>, so:
+ *
+ *     1 == 1.0     #=> true
+ *     1.eql? 1.0   #=> false
  */
-static mrb_value
-mrb_bob_missing(mrb_state *mrb, mrb_value mod)
-{
-  mrb_sym name;
-  mrb_value *a;
-  mrb_int alen;
-
-  mrb_get_args(mrb, "n*", &name, &a, &alen);
-  mrb_method_missing(mrb, name, mod, mrb_ary_new_from_values(mrb, alen, a));
-  /* not reached */
-  return mrb_nil_value();
+mrb_value
+mrb_obj_equal_m(mrb_state *mrb, mrb_value self)
+{
+  mrb_value arg;
+
+  mrb_get_args(mrb, "o", &arg);
+  return mrb_bool_value(mrb_obj_equal(mrb, self, arg));
+}
+
+static mrb_value
+mrb_obj_not_equal_m(mrb_state *mrb, mrb_value self)
+{
+  mrb_value arg;
+
+  mrb_get_args(mrb, "o", &arg);
+  return mrb_bool_value(!mrb_equal(mrb, self, arg));
 }
 
@@ -1533,5 +1602,5 @@
       return mrb_nil_value();
     }
-    else if (outer && outer != mrb->object_class) {
+    else if (outer && outer != c && outer != mrb->object_class) {
       mrb_value base = mrb_class_path(mrb, outer);
       path = mrb_str_buf_new(mrb, 0);
@@ -1552,7 +1621,9 @@
       path = mrb_str_new(mrb, name, len);
     }
-    mrb_obj_iv_set(mrb, (struct RObject*)c, classpath, path);
-  }
-  return path;
+    if (!MRB_FROZEN_P(c)) {
+      mrb_obj_iv_set(mrb, (struct RObject*)c, classpath, path);
+    }
+  }
+  return mrb_str_dup(mrb, path);
 }
 
@@ -1699,13 +1770,9 @@
     str = mrb_str_new_lit(mrb, "#<Class:");
 
-    switch (mrb_type(v)) {
-      case MRB_TT_CLASS:
-      case MRB_TT_MODULE:
-      case MRB_TT_SCLASS:
-        mrb_str_cat_str(mrb, str, mrb_inspect(mrb, v));
-        break;
-      default:
-        mrb_str_cat_str(mrb, str, mrb_any_to_s(mrb, v));
-        break;
+    if (class_ptr_p(v)) {
+      mrb_str_cat_str(mrb, str, mrb_inspect(mrb, v));
+    }
+    else {
+      mrb_str_cat_str(mrb, str, mrb_any_to_s(mrb, v));
     }
     return mrb_str_cat_lit(mrb, str, ">");
@@ -1786,5 +1853,5 @@
   mrb_get_args(mrb, "*", &argv, &argc);
   while (argc--) {
-    undef_method(mrb, c, mrb_symbol(*argv));
+    undef_method(mrb, c, to_sym(mrb, *argv));
     argv++;
   }
@@ -1798,7 +1865,19 @@
   struct RProc *p;
   mrb_sym mid;
+  mrb_value proc = mrb_undef_value();
   mrb_value blk;
 
-  mrb_get_args(mrb, "n&", &mid, &blk);
+  mrb_get_args(mrb, "n|o&", &mid, &proc, &blk);
+  switch (mrb_type(proc)) {
+    case MRB_TT_PROC:
+      blk = proc;
+      break;
+    case MRB_TT_UNDEF:
+      /* ignored */
+      break;
+    default:
+      mrb_raisef(mrb, E_TYPE_ERROR, "wrong argument type %S (expected Proc)", mrb_obj_value(mrb_obj_class(mrb, proc)));
+      break;
+  }
   if (mrb_nil_p(blk)) {
     mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
@@ -2028,5 +2107,5 @@
   mrb_get_args(mrb, "*", &argv, &argc);
   while (argc--) {
-    remove_method(mrb, mod, mrb_symbol(*argv));
+    remove_method(mrb, mod, to_sym(mrb, *argv));
     argv++;
   }
@@ -2159,5 +2238,5 @@
 
   mrb_get_args(mrb, "*", &argv, &argc);
-  if(argc == 0) {
+  if (argc == 0) {
     /* set MODFUNC SCOPE if implemented */
     return mod;
@@ -2182,4 +2261,9 @@
   return mod;
 }
+
+/* implementation of __id__ */
+mrb_value mrb_obj_id_m(mrb_state *mrb, mrb_value self);
+/* implementation of instance_eval */
+mrb_value mrb_obj_instance_eval(mrb_state*, mrb_value);
 
 void
@@ -2222,5 +2306,9 @@
   mrb_define_method(mrb, bob, "initialize",              mrb_bob_init,             MRB_ARGS_NONE());
   mrb_define_method(mrb, bob, "!",                       mrb_bob_not,              MRB_ARGS_NONE());
-  mrb_define_method(mrb, bob, "method_missing",          mrb_bob_missing,          MRB_ARGS_ANY());  /* 15.3.1.3.30 */
+  mrb_define_method(mrb, bob, "==",                      mrb_obj_equal_m,          MRB_ARGS_REQ(1)); /* 15.3.1.3.1  */
+  mrb_define_method(mrb, bob, "!=",                      mrb_obj_not_equal_m,      MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, bob, "__id__",                  mrb_obj_id_m,             MRB_ARGS_NONE()); /* 15.3.1.3.3  */
+  mrb_define_method(mrb, bob, "__send__",                mrb_f_send,               MRB_ARGS_ANY());  /* 15.3.1.3.4  */
+  mrb_define_method(mrb, bob, "instance_eval",           mrb_obj_instance_eval,    MRB_ARGS_ANY());  /* 15.3.1.3.18 */
 
   mrb_define_class_method(mrb, cls, "new",               mrb_class_new_class,      MRB_ARGS_OPT(1));
@@ -2236,8 +2324,6 @@
   mrb_define_method(mrb, mod, "extend_object",           mrb_mod_extend_object,    MRB_ARGS_REQ(1)); /* 15.2.2.4.25 */
   mrb_define_method(mrb, mod, "extended",                mrb_bob_init,             MRB_ARGS_REQ(1)); /* 15.2.2.4.26 */
-  mrb_define_method(mrb, mod, "prepend",                 mrb_mod_prepend,          MRB_ARGS_ANY());
   mrb_define_method(mrb, mod, "prepended",               mrb_bob_init,             MRB_ARGS_REQ(1));
   mrb_define_method(mrb, mod, "prepend_features",        mrb_mod_prepend_features, MRB_ARGS_REQ(1));
-  mrb_define_method(mrb, mod, "include",                 mrb_mod_include,          MRB_ARGS_ANY());  /* 15.2.2.4.27 */
   mrb_define_method(mrb, mod, "include?",                mrb_mod_include_p,        MRB_ARGS_REQ(1)); /* 15.2.2.4.28 */
   mrb_define_method(mrb, mod, "append_features",         mrb_mod_append_features,  MRB_ARGS_REQ(1)); /* 15.2.2.4.10 */
@@ -2269,5 +2355,5 @@
   mrb_define_method(mrb, mod, "remove_const",            mrb_mod_remove_const,     MRB_ARGS_REQ(1)); /* 15.2.2.4.40 */
   mrb_define_method(mrb, mod, "const_missing",           mrb_mod_const_missing,    MRB_ARGS_REQ(1));
-  mrb_define_method(mrb, mod, "define_method",           mod_define_method,        MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, mod, "define_method",           mod_define_method,        MRB_ARGS_ARG(1,1));
   mrb_define_method(mrb, mod, "class_variables",         mrb_mod_class_variables,  MRB_ARGS_NONE()); /* 15.2.2.4.19 */
   mrb_define_method(mrb, mod, "===",                     mrb_mod_eqq,              MRB_ARGS_REQ(1));
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/codedump.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/codedump.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/codedump.c	(revision 331)
@@ -1,8 +1,8 @@
-#include "mruby.h"
-#include "mruby/irep.h"
-#include "mruby/debug.h"
-#include "mruby/opcode.h"
-#include "mruby/string.h"
-#include "mruby/proc.h"
+#include <mruby.h>
+#include <mruby/irep.h>
+#include <mruby/debug.h>
+#include <mruby/opcode.h>
+#include <mruby/string.h>
+#include <mruby/proc.h>
 
 #ifndef MRB_DISABLE_STDIO
@@ -240,4 +240,5 @@
       switch (GETARG_B(c)) {
       case OP_R_NORMAL:
+        printf("\tnormal\t"); break;
       case OP_R_RETURN:
         printf("\treturn\t"); break;
@@ -246,5 +247,4 @@
       default:
         printf("\tbroken\t"); break;
-        break;
       }
       print_lv(mrb, irep, c, RA);
@@ -260,5 +260,13 @@
 
     case OP_LAMBDA:
-      printf("OP_LAMBDA\tR%d\tI(%+d)\t%d", GETARG_A(c), GETARG_b(c)+1, GETARG_c(c));
+      printf("OP_LAMBDA\tR%d\tI(%+d)\t", GETARG_A(c), GETARG_b(c)+1);
+      switch (GETARG_c(c)) {
+      case OP_L_METHOD:
+        printf("method"); break;
+      case OP_L_BLOCK:
+        printf("block"); break;
+      case OP_L_LAMBDA:
+        printf("lambda"); break;
+      }
       print_lv(mrb, irep, c, RA);
       break;
@@ -324,5 +332,5 @@
       break;
     case OP_EQ:
-      printf("OP_EQ\tR%d\t:%s\t%d\n", GETARG_A(c),
+      printf("OP_EQ\t\tR%d\t:%s\t%d\n", GETARG_A(c),
              mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
              GETARG_C(c));
@@ -410,6 +418,20 @@
       break;
     case OP_RESCUE:
-      printf("OP_RESCUE\tR%d\t\t", GETARG_A(c));
-      print_lv(mrb, irep, c, RA);
+      {
+        int a = GETARG_A(c);
+        int b = GETARG_B(c);
+        int cnt = GETARG_C(c);
+
+        if (b == 0) {
+          printf("OP_RESCUE\tR%d\t\t%s", a, cnt ? "cont" : "");
+          print_lv(mrb, irep, c, RA);
+          break;
+        }
+        else {
+          printf("OP_RESCUE\tR%d\tR%d\t%s", a, b, cnt ? "cont" : "");
+          print_lv(mrb, irep, c, RAB);
+          break;
+        }
+      }
       break;
     case OP_RAISE:
@@ -418,6 +440,5 @@
       break;
     case OP_POPERR:
-      printf("OP_POPERR\t%d\t\t", GETARG_A(c));
-      print_lv(mrb, irep, c, RA);
+      printf("OP_POPERR\t%d\t\t\n", GETARG_A(c));
       break;
     case OP_EPOP:
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/compar.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/compar.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/compar.c	(revision 331)
@@ -5,5 +5,5 @@
 */
 
-#include "mruby.h"
+#include <mruby.h>
 
 void
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/debug.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/debug.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/debug.c	(revision 331)
@@ -1,6 +1,6 @@
 #include <string.h>
-#include "mruby.h"
-#include "mruby/irep.h"
-#include "mruby/debug.h"
+#include <mruby.h>
+#include <mruby/irep.h>
+#include <mruby/debug.h>
 
 static mrb_irep_debug_info_file *
@@ -20,5 +20,6 @@
       ret = it + 1;
       count -= step + 1;
-    } else { count = step; }
+    }
+    else { count = step; }
   }
 
@@ -87,5 +88,6 @@
               ret = it + 1;
               count -= step + 1;
-            } else { count = step; }
+            }
+            else { count = step; }
           }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/dump.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/dump.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/dump.c	(revision 331)
@@ -7,9 +7,9 @@
 #include <string.h>
 #include <limits.h>
-#include "mruby/dump.h"
-#include "mruby/string.h"
-#include "mruby/irep.h"
-#include "mruby/numeric.h"
-#include "mruby/debug.h"
+#include <mruby/dump.h>
+#include <mruby/string.h>
+#include <mruby/irep.h>
+#include <mruby/numeric.h>
+#include <mruby/debug.h>
 
 #define FLAG_BYTEORDER_NATIVE 2
@@ -55,5 +55,5 @@
   uint8_t *cur = buf;
 
-  cur += uint32_to_bin(get_irep_record_size_1(mrb, irep), cur);  /* record size */
+  cur += uint32_to_bin((uint32_t)get_irep_record_size_1(mrb, irep), cur);  /* record size */
   cur += uint16_to_bin((uint16_t)irep->nlocals, cur);  /* number of local variable */
   cur += uint16_to_bin((uint16_t)irep->nregs, cur);  /* number of register variable */
@@ -408,5 +408,6 @@
   if (irep->filename) {
     filename_len = strlen(irep->filename);
-  } else {
+  }
+  else {
     filename_len = 0;
   }
@@ -1060,4 +1061,5 @@
     }
     if (fprintf(fp,
+          "extern const uint8_t %s[];\n"
           "const uint8_t\n"
           "#if defined __GNUC__\n"
@@ -1067,4 +1069,5 @@
           "#endif\n"
           "%s[] = {",
+          initname,
           (uint16_t)MRB_DUMP_ALIGNMENT, (uint16_t)MRB_DUMP_ALIGNMENT, initname) < 0) {
       mrb_free(mrb, bin);
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/enum.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/enum.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/enum.c	(revision 331)
@@ -5,5 +5,5 @@
 */
 
-#include "mruby.h"
+#include <mruby.h>
 
 void
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/error.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/error.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/error.c	(revision 331)
@@ -8,14 +8,14 @@
 #include <stdarg.h>
 #include <stdlib.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/irep.h"
-#include "mruby/proc.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
-#include "mruby/debug.h"
-#include "mruby/error.h"
-#include "mruby/class.h"
-#include "mruby/throw.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/irep.h>
+#include <mruby/proc.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
+#include <mruby/debug.h>
+#include <mruby/error.h>
+#include <mruby/class.h>
+#include <mruby/throw.h>
 
 MRB_API mrb_value
@@ -45,6 +45,8 @@
 {
   mrb_value mesg;
-
-  if (mrb_get_args(mrb, "|o", &mesg) == 1) {
+  mrb_int argc;
+  mrb_value *argv;
+
+  if (mrb_get_args(mrb, "|o*", &mesg, &argv, &argc) >= 1) {
     mrb_iv_set(mrb, exc, mrb_intern_lit(mrb, "mesg"), mesg);
   }
@@ -61,5 +63,5 @@
  *  return the receiver. Otherwise, create a new
  *  exception object of the same class as the receiver, but with a
- *  message equal to <code>string.to_str</code>.
+ *  message equal to <code>string</code>.
  *
  */
@@ -110,7 +112,5 @@
  *
  * Returns the result of invoking <code>exception.to_s</code>.
- * Normally this returns the exception's message or name. By
- * supplying a to_str method, exceptions are agreeing to
- * be used where Strings are expected.
+ * Normally this returns the exception's message or name.
  */
 
@@ -136,4 +136,5 @@
   mrb_value str, mesg, file, line;
   mrb_bool append_mesg;
+  const char *cname;
 
   mesg = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "mesg"));
@@ -147,32 +148,50 @@
   }
 
-  if (!mrb_nil_p(file) && !mrb_nil_p(line)) {
-    str = mrb_str_dup(mrb, file);
-    mrb_str_cat_lit(mrb, str, ":");
-    mrb_str_append(mrb, str, line);
-    mrb_str_cat_lit(mrb, str, ": ");
+  cname = mrb_obj_classname(mrb, exc);
+  str = mrb_str_new_cstr(mrb, cname);
+  if (mrb_string_p(file) && mrb_fixnum_p(line)) {
     if (append_mesg) {
-      mrb_str_cat_str(mrb, str, mesg);
-      mrb_str_cat_lit(mrb, str, " (");
-    }
-    mrb_str_cat_cstr(mrb, str, mrb_obj_classname(mrb, exc));
-    if (append_mesg) {
-      mrb_str_cat_lit(mrb, str, ")");
-    }
+      str = mrb_format(mrb, "%S:%S:%S (%S)", file, line, mesg, str);
+    }
+    else {
+      str = mrb_format(mrb, "%S:%S:%S", file, line, str);
+    }
+  }
+  else if (append_mesg) {
+    str = mrb_format(mrb, "%S:%S", str, mesg);
+  }
+  return str;
+}
+
+void mrb_keep_backtrace(mrb_state *mrb, mrb_value exc);
+
+static void
+set_backtrace(mrb_state *mrb, mrb_value exc, mrb_value backtrace)
+{
+  if (!mrb_array_p(backtrace)) {
+  type_err:
+    mrb_raise(mrb, E_TYPE_ERROR, "backtrace must be Array of String");
   }
   else {
-    const char *cname = mrb_obj_classname(mrb, exc);
-    str = mrb_str_new_cstr(mrb, cname);
-    mrb_str_cat_lit(mrb, str, ": ");
-    if (append_mesg) {
-      mrb_str_cat_str(mrb, str, mesg);
-    }
-    else {
-      mrb_str_cat_cstr(mrb, str, cname);
-    }
-  }
-  return str;
-}
-
+    const mrb_value *p = RARRAY_PTR(backtrace);
+    const mrb_value *pend = p + RARRAY_LEN(backtrace);
+
+    while (p < pend) {
+      if (!mrb_string_p(*p)) goto type_err;
+      p++;
+    }
+  }
+  mrb_iv_set(mrb, exc, mrb_intern_lit(mrb, "backtrace"), backtrace);
+}
+
+static mrb_value
+exc_set_backtrace(mrb_state *mrb, mrb_value exc)
+{
+  mrb_value backtrace;
+
+  mrb_get_args(mrb, "o", &backtrace);
+  set_backtrace(mrb, exc, backtrace);
+  return backtrace;
+}
 
 static void
@@ -182,5 +201,4 @@
   mrb_code *pc = ci->pc;
 
-  mrb_obj_iv_set(mrb, exc, mrb_intern_lit(mrb, "ciidx"), mrb_fixnum_value((mrb_int)(ci - mrb->c->cibase)));
   while (ci >= mrb->c->cibase) {
     mrb_code *err = ci->err;
@@ -203,11 +221,26 @@
 }
 
+void
+mrb_exc_set(mrb_state *mrb, mrb_value exc)
+{
+  if (mrb_nil_p(exc)) {
+    mrb->exc = 0;
+  }
+  else {
+    mrb->exc = mrb_obj_ptr(exc);
+    if (!mrb->gc.out_of_memory) {
+      exc_debug_info(mrb, mrb->exc);
+      mrb_keep_backtrace(mrb, exc);
+    }
+  }
+}
+
 MRB_API mrb_noreturn void
 mrb_exc_raise(mrb_state *mrb, mrb_value exc)
 {
-  mrb->exc = mrb_obj_ptr(exc);
-  if (!mrb->gc.out_of_memory) {
-    exc_debug_info(mrb, mrb->exc);
-  }
+  if (!mrb_obj_is_kind_of(mrb, exc, mrb->eException_class)) {
+    mrb_raise(mrb, E_TYPE_ERROR, "exception object expected");
+  }
+  mrb_exc_set(mrb, exc);
   if (!mrb->jmp) {
     mrb_p(mrb, exc);
@@ -220,7 +253,5 @@
 mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg)
 {
-  mrb_value mesg;
-  mesg = mrb_str_new_cstr(mrb, msg);
-  mrb_exc_raise(mrb, mrb_exc_new_str(mrb, c, mesg));
+  mrb_exc_raise(mrb, mrb_exc_new_str(mrb, c, mrb_str_new_cstr(mrb, msg)));
 }
 
@@ -232,4 +263,5 @@
   ptrdiff_t size;
   mrb_value ary = mrb_ary_new_capa(mrb, 4);
+  int ai = mrb_gc_arena_save(mrb);
 
   while (*p) {
@@ -255,4 +287,5 @@
       }
     }
+    mrb_gc_arena_restore(mrb, ai);
   }
   if (b == format) {
@@ -261,6 +294,9 @@
   else {
     size = p - b;
-    mrb_ary_push(mrb, ary, mrb_str_new(mrb, b, size));
-    return mrb_ary_join(mrb, ary, mrb_str_new(mrb, NULL, 0));
+    if (size > 0) {
+      mrb_ary_push(mrb, ary, mrb_str_new(mrb, b, size));
+      mrb_gc_arena_restore(mrb, ai);
+    }
+    return mrb_ary_join(mrb, ary, mrb_nil_value());
   }
 }
@@ -279,14 +315,27 @@
 }
 
+static mrb_noreturn void
+raise_va(mrb_state *mrb, struct RClass *c, const char *fmt, va_list ap, int argc, mrb_value *argv)
+{
+  mrb_value mesg;
+
+  mesg = mrb_vformat(mrb, fmt, ap);
+  if (argv == NULL) {
+    argv = &mesg;
+  }
+  else {
+    argv[0] = mesg;
+  }
+  mrb_exc_raise(mrb, mrb_obj_new(mrb, c, argc+1, argv));
+}
+
 MRB_API mrb_noreturn void
 mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...)
 {
   va_list args;
-  mrb_value mesg;
 
   va_start(args, fmt);
-  mesg = mrb_vformat(mrb, fmt, args);
+  raise_va(mrb, c, fmt, args, 0, NULL);
   va_end(args);
-  mrb_exc_raise(mrb, mrb_exc_new_str(mrb, c, mesg));
 }
 
@@ -294,15 +343,11 @@
 mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...)
 {
-  mrb_value exc;
   mrb_value argv[2];
   va_list args;
 
   va_start(args, fmt);
-  argv[0] = mrb_vformat(mrb, fmt, args);
+  argv[1] = mrb_symbol_value(id);
+  raise_va(mrb, E_NAME_ERROR, fmt, args, 1, argv);
   va_end(args);
-
-  argv[1] = mrb_symbol_value(id);
-  exc = mrb_obj_new(mrb, E_NAME_ERROR, 2, argv);
-  mrb_exc_raise(mrb, exc);
 }
 
@@ -338,12 +383,6 @@
 }
 
-static void
-set_backtrace(mrb_state *mrb, mrb_value info, mrb_value bt)
-{
-  mrb_funcall(mrb, info, "set_backtrace", 1, bt);
-}
-
-static mrb_value
-make_exception(mrb_state *mrb, int argc, const mrb_value *argv, mrb_bool isstr)
+MRB_API mrb_value
+mrb_make_exception(mrb_state *mrb, int argc, const mrb_value *argv)
 {
   mrb_value mesg;
@@ -357,10 +396,7 @@
       if (mrb_nil_p(argv[0]))
         break;
-      if (isstr) {
-        mesg = mrb_check_string_type(mrb, argv[0]);
-        if (!mrb_nil_p(mesg)) {
-          mesg = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, mesg);
-          break;
-        }
+      if (mrb_string_p(argv[0])) {
+        mesg = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, argv[0]);
+        break;
       }
       n = 0;
@@ -389,16 +425,10 @@
   if (argc > 0) {
     if (!mrb_obj_is_kind_of(mrb, mesg, mrb->eException_class))
-      mrb_raise(mrb, E_TYPE_ERROR, "exception object expected");
+      mrb_raise(mrb, mrb->eException_class, "exception object expected");
     if (argc > 2)
-        set_backtrace(mrb, mesg, argv[2]);
+      set_backtrace(mrb, mesg, argv[2]);
   }
 
   return mesg;
-}
-
-MRB_API mrb_value
-mrb_make_exception(mrb_state *mrb, int argc, const mrb_value *argv)
-{
-  return make_exception(mrb, argc, argv, TRUE);
 }
 
@@ -428,10 +458,13 @@
 {
   mrb_value exc;
+  mrb_value argv[3];
   va_list ap;
 
   va_start(ap, fmt);
-  exc = mrb_funcall(mrb, mrb_obj_value(E_NOMETHOD_ERROR), "new", 3,
-                    mrb_vformat(mrb, fmt, ap), mrb_symbol_value(id), args);
+  argv[0] = mrb_vformat(mrb, fmt, ap);
+  argv[1] = mrb_symbol_value(id);
+  argv[2] = args;
   va_end(ap);
+  exc = mrb_obj_new(mrb, E_NOMETHOD_ERROR, 3, argv);
   mrb_exc_raise(mrb, exc);
 }
@@ -440,5 +473,5 @@
 mrb_init_exception(mrb_state *mrb)
 {
-  struct RClass *exception, *runtime_error, *script_error;
+  struct RClass *exception, *script_error, *stack_error, *nomem_error;
 
   mrb->eException_class = exception = mrb_define_class(mrb, "Exception", mrb->object_class); /* 15.2.22 */
@@ -451,10 +484,17 @@
   mrb_define_method(mrb, exception, "inspect",         exc_inspect,       MRB_ARGS_NONE());
   mrb_define_method(mrb, exception, "backtrace",       mrb_exc_backtrace, MRB_ARGS_NONE());
+  mrb_define_method(mrb, exception, "set_backtrace",   exc_set_backtrace, MRB_ARGS_REQ(1));
 
   mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
-  runtime_error = mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class);          /* 15.2.28 */
-  mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, runtime_error, "Out of memory"));
+  mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class);          /* 15.2.28 */
   script_error = mrb_define_class(mrb, "ScriptError", mrb->eException_class);                /* 15.2.37 */
   mrb_define_class(mrb, "SyntaxError", script_error);                                        /* 15.2.38 */
-  mrb_define_class(mrb, "SystemStackError", exception);
-}
+  stack_error = mrb_define_class(mrb, "SystemStackError", exception);
+  mrb->stack_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, stack_error, "stack level too deep"));
+
+  nomem_error = mrb_define_class(mrb, "NoMemoryError", exception);
+  mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, nomem_error, "Out of memory"));
+#ifdef MRB_GC_FIXED_ARENA
+  mrb->arena_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, nomem_error, "arena overflow error"));
+#endif
+}
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/error.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/error.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/error.h	(revision 331)
@@ -1,3 +1,3 @@
 /* this header file is to be removed soon.
    added for compatibility purpose (1.0.0) */
-#include "mruby/error.h"
+#include <mruby/error.h>
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/etc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/etc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/etc.c	(revision 331)
@@ -5,10 +5,10 @@
 */
 
-#include "mruby.h"
-#include "mruby/string.h"
-#include "mruby/data.h"
-#include "mruby/class.h"
-#include "mruby/re.h"
-#include "mruby/irep.h"
+#include <mruby.h>
+#include <mruby/string.h>
+#include <mruby/data.h>
+#include <mruby/class.h>
+#include <mruby/re.h>
+#include <mruby/irep.h>
 
 MRB_API struct RData*
@@ -140,4 +140,5 @@
   case MRB_TT_FILE:
   case MRB_TT_DATA:
+  case MRB_TT_ISTRUCT:
   default:
     return MakeID(mrb_ptr(obj));
@@ -180,5 +181,16 @@
 mrb_regexp_p(mrb_state *mrb, mrb_value v)
 {
-  return mrb_class_defined(mrb, REGEXP_CLASS) && mrb_obj_is_kind_of(mrb, v, mrb_class_get(mrb, REGEXP_CLASS));
+  if (mrb->flags & MRB_STATE_NO_REGEXP) {
+    return FALSE;
+  }
+  if ((mrb->flags & MRB_STATE_REGEXP) || mrb_class_defined(mrb, REGEXP_CLASS)) {
+    mrb->flags |= MRB_STATE_REGEXP;
+    return mrb_obj_is_kind_of(mrb, v, mrb_class_get(mrb, REGEXP_CLASS));
+  }
+  else {
+    mrb->flags |= MRB_STATE_REGEXP;
+    mrb->flags |= MRB_STATE_NO_REGEXP;
+  }
+  return FALSE;
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/fmt_fp.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/fmt_fp.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/fmt_fp.c	(revision 331)
@@ -34,6 +34,6 @@
 #include <ctype.h>
 
-#include "mruby.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/string.h>
 
 struct fmt_args {
@@ -157,5 +157,5 @@
     s=buf;
     do {
-      int x=y;
+      int x=(int)y;
       *s++=xdigits[x]|(t&32);
       y=16*(y-x);
@@ -185,5 +185,5 @@
 
   do {
-    *z = y;
+    *z = (uint32_t)y;
     y = 1000000000*(y-*z++);
   } while (y);
@@ -195,5 +195,5 @@
       uint64_t x = ((uint64_t)*d<<sh)+carry;
       *d = x % 1000000000;
-      carry = x / 1000000000;
+      carry = (uint32_t)(x / 1000000000);
     }
     if (carry) *--a = carry;
@@ -254,5 +254,5 @@
   }
   for (; z>a && !z[-1]; z--);
-  
+
   if ((t|32)=='g') {
     if (!p) p++;
@@ -355,5 +355,5 @@
   default:
     return -1;
-  } 
+  }
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/gc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/gc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/gc.c	(revision 331)
@@ -7,15 +7,16 @@
 #include <string.h>
 #include <stdlib.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/data.h"
-#include "mruby/hash.h"
-#include "mruby/proc.h"
-#include "mruby/range.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
-#include "mruby/gc.h"
-#include "mruby/error.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/data.h>
+#include <mruby/hash.h>
+#include <mruby/proc.h>
+#include <mruby/range.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
+#include <mruby/gc.h>
+#include <mruby/error.h>
+#include <mruby/throw.h>
 
 /*
@@ -66,5 +67,5 @@
   mruby implementer and C extension library writer must insert a write
   barrier when updating a reference from a field of an object.
-  When updating a reference from a field of object A to object B, 
+  When updating a reference from a field of object A to object B,
   two different types of write barrier are available:
 
@@ -110,5 +111,7 @@
     struct RData data;
     struct RProc proc;
+    struct REnv env;
     struct RException exc;
+    struct RBreak brk;
 #ifdef MRB_WORD_BOXING
     struct RFloat floatv;
@@ -138,5 +141,5 @@
   fprintf(stderr, "gc_invoke: %19.3f\n", gettimeofday_time() - program_invoke_time);\
   fprintf(stderr, "is_generational: %d\n", is_generational(gc));\
-  fprintf(stderr, "is_major_gc: %d\n", is_major_gc(mrb));\
+  fprintf(stderr, "is_major_gc: %d\n", is_major_gc(gc));\
 } while(0)
 
@@ -214,6 +217,8 @@
 
   p2 = mrb_realloc_simple(mrb, p, len);
-  if (!p2 && len) {
+  if (len == 0) return p2;
+  if (p2 == NULL) {
     if (mrb->gc.out_of_memory) {
+      mrb_exc_raise(mrb, mrb_obj_value(mrb->nomem_err));
       /* mrb_panic(mrb); */
     }
@@ -367,5 +372,5 @@
 }
 
-static void obj_free(mrb_state *mrb, struct RBasic *obj);
+static void obj_free(mrb_state *mrb, struct RBasic *obj, int end);
 
 void
@@ -381,5 +386,5 @@
     for (p = objects(tmp), e=p+MRB_HEAP_PAGE_SIZE; p<e; p++) {
       if (p->as.free.tt != MRB_TT_FREE)
-        obj_free(mrb, &p->as.basic);
+        obj_free(mrb, &p->as.basic, TRUE);
     }
     mrb_free(mrb, tmp);
@@ -403,5 +408,5 @@
     /* arena overflow error */
     gc->arena_idx = MRB_GC_ARENA_SIZE - 4; /* force room in arena */
-    mrb_raise(mrb, E_RUNTIME_ERROR, "arena overflow error");
+    mrb_exc_raise(mrb, mrb_obj_value(mrb->arena_err));
   }
 #else
@@ -429,5 +434,5 @@
    Register your object when it's exported to C world,
    without reference from Ruby world, e.g. callback
-   arguments.  Don't forget to remove the obejct using
+   arguments.  Don't forget to remove the object using
    mrb_gc_unregister, otherwise your object will leak.
 */
@@ -453,5 +458,5 @@
   mrb_value table = mrb_gv_get(mrb, root);
   struct RArray *a;
-  mrb_int i, j;
+  mrb_int i;
 
   if (mrb_nil_p(table)) return;
@@ -462,10 +467,11 @@
   a = mrb_ary_ptr(table);
   mrb_ary_modify(mrb, a);
-  for (i=j=0; i<a->len; i++) {
-    if (!mrb_obj_eq(mrb, a->ptr[i], obj)) {
-      a->ptr[j++] = a->ptr[i];
-    }
-  }
-  a->len = j;
+  for (i = 0; i < a->len; i++) {
+    if (mrb_obj_eq(mrb, a->ptr[i], obj)) {
+      a->len--;
+      memmove(&a->ptr[i], &a->ptr[i + 1], (a->len - i) * sizeof(a->ptr[i]));
+      break;
+    }
+  }
 }
 
@@ -476,4 +482,26 @@
   static const RVALUE RVALUE_zero = { { { MRB_TT_FALSE } } };
   mrb_gc *gc = &mrb->gc;
+
+  if (cls) {
+    enum mrb_vtype tt;
+
+    switch (cls->tt) {
+    case MRB_TT_CLASS:
+    case MRB_TT_SCLASS:
+    case MRB_TT_MODULE:
+    case MRB_TT_ENV:
+      break;
+    default:
+      mrb_raise(mrb, E_TYPE_ERROR, "allocation failure");
+    }
+    tt = MRB_INSTANCE_TT(cls);
+    if (tt != MRB_TT_FALSE &&
+        ttype != MRB_TT_SCLASS &&
+        ttype != MRB_TT_ICLASS &&
+        ttype != MRB_TT_ENV &&
+        ttype != tt) {
+      mrb_raisef(mrb, E_TYPE_ERROR, "allocation failure of %S", mrb_obj_value(cls));
+    }
+  }
 
 #ifdef MRB_GC_STRESS
@@ -520,7 +548,15 @@
   size_t i;
   size_t e;
-
+  mrb_value nil;
+  int nregs;
+
+  if (c->stack == NULL) return;
   e = c->stack - c->stbase;
-  if (c->ci) e += c->ci->nregs;
+  if (c->ci) {
+    nregs = c->ci->argc + 2;
+    if (c->ci->nregs > nregs)
+      nregs = c->ci->nregs;
+    e += nregs;
+  }
   if (c->stbase + e > c->stend) e = c->stend - c->stbase;
   for (i=0; i<e; i++) {
@@ -528,11 +564,11 @@
 
     if (!mrb_immediate_p(v)) {
-      if (mrb_basic_ptr(v)->tt == MRB_TT_FREE) {
-        c->stbase[i] = mrb_nil_value();
-      }
-      else {
-        mrb_gc_mark(mrb, mrb_basic_ptr(v));
-      }
-    }
+      mrb_gc_mark(mrb, mrb_basic_ptr(v));
+    }
+  }
+  e = c->stend - c->stbase;
+  nil = mrb_nil_value();
+  for (; i<e; i++) {
+    c->stbase[i] = nil;
   }
 }
@@ -541,16 +577,13 @@
 mark_context(mrb_state *mrb, struct mrb_context *c)
 {
-  int i, e = 0;
+  int i;
   mrb_callinfo *ci;
 
-  /* mark stack */
+  /* mark VM stack */
   mark_context_stack(mrb, c);
 
-  /* mark VM stack */
+  /* mark call stack */
   if (c->cibase) {
     for (ci = c->cibase; ci <= c->ci; ci++) {
-      if (ci->eidx > e) {
-        e = ci->eidx;
-      }
       mrb_gc_mark(mrb, (struct RBasic*)ci->env);
       mrb_gc_mark(mrb, (struct RBasic*)ci->proc);
@@ -559,10 +592,12 @@
   }
   /* mark ensure stack */
-  for (i=0; i<e; i++) {
+  for (i=0; i<c->esize; i++) {
+    if (c->ensure[i] == NULL) break;
     mrb_gc_mark(mrb, (struct RBasic*)c->ensure[i]);
   }
   /* mark fibers */
-  if (c->prev && c->prev->fib) {
-    mrb_gc_mark(mrb, (struct RBasic*)c->prev->fib);
+  mrb_gc_mark(mrb, (struct RBasic*)c->fib);
+  if (c->prev) {
+    mark_context(mrb, c->prev);
   }
 }
@@ -614,12 +649,15 @@
     {
       struct REnv *e = (struct REnv*)obj;
-
-      if (!MRB_ENV_STACK_SHARED_P(e)) {
-        mrb_int i, len;
-
-        len = MRB_ENV_STACK_LEN(e);
-        for (i=0; i<len; i++) {
-          mrb_gc_mark_value(mrb, e->stack[i]);
+      mrb_int i, len;
+
+      if (MRB_ENV_STACK_SHARED_P(e)) {
+        if (e->cxt.c->fib) {
+          mrb_gc_mark(mrb, (struct RBasic*)e->cxt.c->fib);
         }
+        break;
+      }
+      len = MRB_ENV_STACK_LEN(e);
+      for (i=0; i<len; i++) {
+        mrb_gc_mark_value(mrb, e->stack[i]);
       }
     }
@@ -679,7 +717,7 @@
 
 static void
-obj_free(mrb_state *mrb, struct RBasic *obj)
-{
-  DEBUG(printf("obj_free(%p,tt=%d)\n",obj,obj->tt));
+obj_free(mrb_state *mrb, struct RBasic *obj, int end)
+{
+  DEBUG(fprintf(stderr, "obj_free(%p,tt=%d)\n",obj,obj->tt));
   switch (obj->tt) {
     /* immediate - no mark */
@@ -698,4 +736,7 @@
 
   case MRB_TT_OBJECT:
+    mrb_gc_free_iv(mrb, (struct RObject*)obj);
+    break;
+
   case MRB_TT_EXCEPTION:
     mrb_gc_free_iv(mrb, (struct RObject*)obj);
@@ -716,8 +757,10 @@
       struct REnv *e = (struct REnv*)obj;
 
-      if (!MRB_ENV_STACK_SHARED_P(e)) {
-        mrb_free(mrb, e->stack);
-        e->stack = NULL;
+      if (MRB_ENV_STACK_SHARED_P(e)) {
+        /* cannot be freed */
+        return;
       }
+      mrb_free(mrb, e->stack);
+      e->stack = NULL;
     }
     break;
@@ -727,6 +770,18 @@
       struct mrb_context *c = ((struct RFiber*)obj)->cxt;
 
-      if (c != mrb->root_c)
+      if (!end && c && c != mrb->root_c) {
+        mrb_callinfo *ci = c->ci;
+        mrb_callinfo *ce = c->cibase;
+
+        while (ce <= ci) {
+          struct REnv *e = ci->env;
+          if (e && !is_dead(&mrb->gc, e) &&
+              e->tt == MRB_TT_ENV && MRB_ENV_STACK_SHARED_P(e)) {
+            mrb_env_unshare(mrb, e);
+          }
+          ci--;
+        }
         mrb_free_context(mrb, c);
+      }
     }
     break;
@@ -781,5 +836,5 @@
 root_scan_phase(mrb_state *mrb, mrb_gc *gc)
 {
-  size_t i, e;
+  int i, e;
 
   if (!is_minor_gc(gc)) {
@@ -795,4 +850,24 @@
   /* mark class hierarchy */
   mrb_gc_mark(mrb, (struct RBasic*)mrb->object_class);
+
+  /* mark built-in classes */
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->class_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->module_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->proc_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->string_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->array_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->hash_class);
+
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->float_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->fixnum_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->true_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->false_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->nil_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->symbol_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->kernel_module);
+
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->eException_class);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->eStandardError_class);
+
   /* mark top_self */
   mrb_gc_mark(mrb, (struct RBasic*)mrb->top_self);
@@ -801,11 +876,12 @@
   /* mark pre-allocated exception */
   mrb_gc_mark(mrb, (struct RBasic*)mrb->nomem_err);
-
-  mark_context(mrb, mrb->root_c);
-  if (mrb->root_c->fib) {
-    mrb_gc_mark(mrb, (struct RBasic*)mrb->root_c->fib);
-  }
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->stack_err);
+#ifdef MRB_GC_FIXED_ARENA
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->arena_err);
+#endif
+
+  mark_context(mrb, mrb->c);
   if (mrb->root_c != mrb->c) {
-    mark_context(mrb, mrb->c);
+    mark_context(mrb, mrb->root_c);
   }
 }
@@ -859,5 +935,5 @@
 
       /* mark ensure stack */
-      children += (c->ci) ? c->ci->eidx : 0;
+      children += c->eidx;
 
       /* mark closure */
@@ -920,5 +996,14 @@
 final_marking_phase(mrb_state *mrb, mrb_gc *gc)
 {
-  mark_context_stack(mrb, mrb->root_c);
+  int i, e;
+
+  /* mark arena */
+  for (i=0,e=gc->arena_idx; i<e; i++) {
+    mrb_gc_mark(mrb, gc->arena[i]);
+  }
+  mrb_gc_mark_gv(mrb);
+  mark_context(mrb, mrb->c);
+  mark_context(mrb, mrb->root_c);
+  mrb_gc_mark(mrb, (struct RBasic*)mrb->exc);
   gc_mark_gray_list(mrb, gc);
   mrb_assert(gc->gray_list == NULL);
@@ -958,8 +1043,13 @@
       if (is_dead(gc, &p->as.basic)) {
         if (p->as.basic.tt != MRB_TT_FREE) {
-          obj_free(mrb, &p->as.basic);
-          p->as.free.next = page->freelist;
-          page->freelist = (struct RBasic*)p;
-          freed++;
+          obj_free(mrb, &p->as.basic, FALSE);
+          if (p->as.basic.tt == MRB_TT_FREE) {
+            p->as.free.next = page->freelist;
+            page->freelist = (struct RBasic*)p;
+            freed++;
+          }
+          else {
+            dead_slot = FALSE;
+          }
         }
       }
@@ -967,5 +1057,5 @@
         if (!is_generational(gc))
           paint_partial_white(gc, &p->as.basic); /* next gc target */
-        dead_slot = 0;
+        dead_slot = FALSE;
       }
       p++;
@@ -1080,5 +1170,5 @@
   mrb_gc *gc = &mrb->gc;
 
-  if (gc->disabled) return;
+  if (gc->disabled || gc->iterating) return;
 
   GC_INVOKE_TIME_REPORT("mrb_incremental_gc()");
@@ -1120,5 +1210,5 @@
   mrb_gc *gc = &mrb->gc;
 
-  if (gc->disabled) return;
+  if (gc->disabled || gc->iterating) return;
 
   GC_INVOKE_TIME_REPORT("mrb_full_gc()");
@@ -1357,4 +1447,8 @@
 change_gen_gc_mode(mrb_state *mrb, mrb_gc *gc, mrb_bool enable)
 {
+  if (gc->disabled || gc->iterating) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "generational mode changed when GC disabled");
+    return;
+  }
   if (is_generational(gc) && !enable) {
     clear_all_old(mrb, gc);
@@ -1408,15 +1502,16 @@
 gc_each_objects(mrb_state *mrb, mrb_gc *gc, mrb_each_object_callback *callback, void *data)
 {
-  mrb_heap_page* page = gc->heaps;
-
+  mrb_heap_page* page;
+
+  page = gc->heaps;
   while (page != NULL) {
-    RVALUE *p, *pend;
+    RVALUE *p;
+    int i;
 
     p = objects(page);
-    pend = p + MRB_HEAP_PAGE_SIZE;
-    for (;p < pend; p++) {
-      (*callback)(mrb, &p->as.basic, data);
-    }
-
+    for (i=0; i < MRB_HEAP_PAGE_SIZE; i++) {
+      if ((*callback)(mrb, &p[i].as.basic, data) == MRB_EACH_OBJ_BREAK)
+        return;
+    }
     page = page->next;
   }
@@ -1426,5 +1521,25 @@
 mrb_objspace_each_objects(mrb_state *mrb, mrb_each_object_callback *callback, void *data)
 {
-  gc_each_objects(mrb, &mrb->gc, callback, data);
+  mrb_bool iterating = mrb->gc.iterating;
+
+  mrb->gc.iterating = TRUE;
+  if (iterating) {
+    gc_each_objects(mrb, &mrb->gc, callback, data);
+  }
+  else {
+    struct mrb_jmpbuf *prev_jmp = mrb->jmp;
+    struct mrb_jmpbuf c_jmp;
+
+    MRB_TRY(&c_jmp) {
+      mrb->jmp = &c_jmp;
+      gc_each_objects(mrb, &mrb->gc, callback, data);
+      mrb->jmp = prev_jmp;
+      mrb->gc.iterating = iterating; 
+   } MRB_CATCH(&c_jmp) {
+      mrb->gc.iterating = iterating;
+      mrb->jmp = prev_jmp;
+      MRB_THROW(prev_jmp);
+    } MRB_END_EXC(&c_jmp);
+  }
 }
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/hash.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/hash.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/hash.c	(revision 331)
@@ -5,11 +5,11 @@
 */
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/hash.h"
-#include "mruby/khash.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/hash.h>
+#include <mruby/khash.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
 
 /* a function to get hash value of a float number */
@@ -92,10 +92,4 @@
 }
 
-typedef struct {
-  mrb_value v;
-  mrb_int n;
-} mrb_hash_value;
-
-KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
 KHASH_DEFINE (ht, mrb_value, mrb_hash_value, TRUE, mrb_hash_ht_hash_func, mrb_hash_ht_hash_equal)
 
@@ -105,7 +99,7 @@
 mrb_hash_ht_key(mrb_state *mrb, mrb_value key)
 {
-  if (mrb_string_p(key) && !RSTR_FROZEN_P(mrb_str_ptr(key))) {
+  if (mrb_string_p(key) && !MRB_FROZEN_P(mrb_str_ptr(key))) {
     key = mrb_str_dup(mrb, key);
-    RSTR_SET_FROZEN_FLAG(mrb_str_ptr(key));
+    MRB_SET_FROZEN_FLAG(mrb_str_ptr(key));
   }
   return key;
@@ -147,5 +141,5 @@
 
 MRB_API mrb_value
-mrb_hash_new_capa(mrb_state *mrb, int capa)
+mrb_hash_new_capa(mrb_state *mrb, mrb_int capa)
 {
   struct RHash *h;
@@ -166,4 +160,7 @@
 }
 
+static mrb_value mrb_hash_default(mrb_state *mrb, mrb_value hash);
+static mrb_value hash_default(mrb_state *mrb, mrb_value hash, mrb_value key);
+
 MRB_API mrb_value
 mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key)
@@ -171,4 +168,5 @@
   khash_t(ht) *h = RHASH_TBL(hash);
   khiter_t k;
+  mrb_sym mid;
 
   if (h) {
@@ -178,9 +176,10 @@
   }
 
-  /* not found */
-  if (MRB_RHASH_PROCDEFAULT_P(hash)) {
-    return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, key);
-  }
-  return RHASH_IFNONE(hash);
+  mid = mrb_intern_lit(mrb, "default");
+  if (mrb_func_basic_p(mrb, hash, mid, mrb_hash_default)) {
+    return hash_default(mrb, hash, key);
+  }
+  /* xxx mrb_funcall_tailcall(mrb, hash, "default", 1, key); */
+  return mrb_funcall_argv(mrb, hash, mid, 1, &key);
 }
 
@@ -234,4 +233,5 @@
   khash_t(ht) *h, *ret_h;
   khiter_t k, ret_k;
+  mrb_value ifnone, vret;
 
   h = RHASH_TBL(hash);
@@ -239,5 +239,5 @@
   ret->ht = kh_init(ht, mrb);
 
-  if (kh_size(h) > 0) {
+  if (h && kh_size(h) > 0) {
     ret_h = ret->ht;
 
@@ -247,10 +247,22 @@
         ret_k = kh_put(ht, mrb, ret_h, KEY(kh_key(h, k)));
         mrb_gc_arena_restore(mrb, ai);
-        kh_val(ret_h, ret_k) = kh_val(h, k);
+        kh_val(ret_h, ret_k).v = kh_val(h, k).v;
+        kh_val(ret_h, ret_k).n = kh_size(ret_h)-1;
       }
     }
   }
 
-  return mrb_obj_value(ret);
+  if (MRB_RHASH_DEFAULT_P(hash)) {
+    ret->flags |= MRB_HASH_DEFAULT;
+  }
+  if (MRB_RHASH_PROCDEFAULT_P(hash)) {
+    ret->flags |= MRB_HASH_PROC_DEFAULT;
+  }
+  vret = mrb_obj_value(ret);
+  ifnone = RHASH_IFNONE(hash);
+  if (!mrb_nil_p(ifnone)) {
+      mrb_iv_set(mrb, vret, mrb_intern_lit(mrb, "ifnone"), ifnone);
+  }
+  return vret;
 }
 
@@ -275,4 +287,7 @@
 mrb_hash_modify(mrb_state *mrb, mrb_value hash)
 {
+  if (MRB_FROZEN_P(mrb_hash_ptr(hash))) {
+    mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen hash");
+  }
   mrb_hash_tbl(mrb, hash);
 }
@@ -330,5 +345,8 @@
     ifnone = block;
   }
-  mrb_iv_set(mrb, hash, mrb_intern_lit(mrb, "ifnone"), ifnone);
+  if (!mrb_nil_p(ifnone)) {
+    RHASH(hash)->flags |= MRB_HASH_DEFAULT;
+    mrb_iv_set(mrb, hash, mrb_intern_lit(mrb, "ifnone"), ifnone);
+  }
   return hash;
 }
@@ -357,4 +375,18 @@
 }
 
+static mrb_value
+hash_default(mrb_state *mrb, mrb_value hash, mrb_value key)
+{
+  if (MRB_RHASH_DEFAULT_P(hash)) {
+    if (MRB_RHASH_PROCDEFAULT_P(hash)) {
+      return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, key);
+    }
+    else {
+      return RHASH_IFNONE(hash);
+    }
+  }
+  return mrb_nil_value();
+}
+
 /* 15.2.13.4.5  */
 /*
@@ -386,11 +418,14 @@
 
   mrb_get_args(mrb, "|o?", &key, &given);
-  if (MRB_RHASH_PROCDEFAULT_P(hash)) {
-    if (!given) return mrb_nil_value();
-    return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, key);
-  }
-  else {
-    return RHASH_IFNONE(hash);
-  }
+  if (MRB_RHASH_DEFAULT_P(hash)) {
+    if (MRB_RHASH_PROCDEFAULT_P(hash)) {
+      if (!given) return mrb_nil_value();
+      return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, key);
+    }
+    else {
+      return RHASH_IFNONE(hash);
+    }
+  }
+  return mrb_nil_value();
 }
 
@@ -424,6 +459,11 @@
   mrb_hash_modify(mrb, hash);
   mrb_iv_set(mrb, hash, mrb_intern_lit(mrb, "ifnone"), ifnone);
-  RHASH(hash)->flags &= ~(MRB_HASH_PROC_DEFAULT);
-
+  RHASH(hash)->flags &= ~MRB_HASH_PROC_DEFAULT;
+  if (!mrb_nil_p(ifnone)) {
+    RHASH(hash)->flags |= MRB_HASH_DEFAULT;
+  }
+  else {
+    RHASH(hash)->flags &= ~MRB_HASH_DEFAULT;
+  }
   return ifnone;
 }
@@ -475,5 +515,12 @@
   mrb_hash_modify(mrb, hash);
   mrb_iv_set(mrb, hash, mrb_intern_lit(mrb, "ifnone"), ifnone);
-  RHASH(hash)->flags |= MRB_HASH_PROC_DEFAULT;
+  if (!mrb_nil_p(ifnone)) {
+    RHASH(hash)->flags |= MRB_HASH_PROC_DEFAULT;
+    RHASH(hash)->flags |= MRB_HASH_DEFAULT;
+  }
+  else {
+    RHASH(hash)->flags &= ~MRB_HASH_DEFAULT;
+    RHASH(hash)->flags &= ~MRB_HASH_PROC_DEFAULT;
+  }
 
   return ifnone;
@@ -530,4 +577,5 @@
 
   mrb_get_args(mrb, "o", &key);
+  mrb_hash_modify(mrb, self);
   return mrb_hash_delete_key(mrb, self, key);
 }
@@ -568,10 +616,13 @@
   }
 
-  if (MRB_RHASH_PROCDEFAULT_P(hash)) {
-    return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, mrb_nil_value());
-  }
-  else {
-    return RHASH_IFNONE(hash);
-  }
+  if (MRB_RHASH_DEFAULT_P(hash)) {
+    if (MRB_RHASH_PROCDEFAULT_P(hash)) {
+      return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, mrb_nil_value());
+    }
+    else {
+      return RHASH_IFNONE(hash);
+    }
+  }
+  return mrb_nil_value();
 }
 
@@ -593,4 +644,5 @@
   khash_t(ht) *h = RHASH_TBL(hash);
 
+  mrb_hash_modify(mrb, hash);
   if (h) kh_clear(ht, mrb, h);
   return hash;
@@ -700,4 +752,5 @@
   khash_t(ht) *h = RHASH_TBL(hash);
   khiter_t k;
+  mrb_int end;
   mrb_value ary;
   mrb_value *p;
@@ -705,5 +758,6 @@
   if (!h || kh_size(h) == 0) return mrb_ary_new(mrb);
   ary = mrb_ary_new_capa(mrb, kh_size(h));
-  mrb_ary_set(mrb, ary, kh_size(h)-1, mrb_nil_value());
+  end = kh_size(h)-1;
+  mrb_ary_set(mrb, ary, end, mrb_nil_value());
   p = mrb_ary_ptr(ary)->ptr;
   for (k = kh_begin(h); k != kh_end(h); k++) {
@@ -712,5 +766,10 @@
       mrb_hash_value hv = kh_value(h, k);
 
-      p[hv.n] = kv;
+      if (hv.n <= end) {
+        p[hv.n] = kv;
+      }
+      else {
+        p[end] = kv;
+      }
     }
   }
@@ -731,5 +790,5 @@
  */
 
-static mrb_value
+MRB_API mrb_value
 mrb_hash_values(mrb_state *mrb, mrb_value hash)
 {
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/init.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/init.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/init.c	(revision 331)
@@ -5,5 +5,5 @@
 */
 
-#include "mruby.h"
+#include <mruby.h>
 
 void mrb_init_symtbl(mrb_state*);
@@ -14,7 +14,7 @@
 void mrb_init_enumerable(mrb_state*);
 void mrb_init_symbol(mrb_state*);
+void mrb_init_string(mrb_state*);
 void mrb_init_exception(mrb_state*);
 void mrb_init_proc(mrb_state*);
-void mrb_init_string(mrb_state*);
 void mrb_init_array(mrb_state*);
 void mrb_init_hash(mrb_state*);
@@ -39,7 +39,7 @@
 
   mrb_init_symbol(mrb); DONE;
+  mrb_init_string(mrb); DONE;
   mrb_init_exception(mrb); DONE;
   mrb_init_proc(mrb); DONE;
-  mrb_init_string(mrb); DONE;
   mrb_init_array(mrb); DONE;
   mrb_init_hash(mrb); DONE;
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/kernel.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/kernel.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/kernel.c	(revision 331)
@@ -5,11 +5,13 @@
 */
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/proc.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
-#include "mruby/error.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/hash.h>
+#include <mruby/class.h>
+#include <mruby/proc.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
+#include <mruby/error.h>
+#include <mruby/istruct.h>
 
 typedef enum {
@@ -27,11 +29,17 @@
 } mrb_method_flag_t;
 
+MRB_API mrb_bool
+mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mrb_func_t func)
+{
+  struct RProc *me = mrb_method_search(mrb, mrb_class(mrb, obj), mid);
+  if (MRB_PROC_CFUNC_P(me) && (me->body.func == func))
+    return TRUE;
+  return FALSE;
+}
+
 static mrb_bool
 mrb_obj_basic_to_s_p(mrb_state *mrb, mrb_value obj)
 {
-  struct RProc *me = mrb_method_search(mrb, mrb_class(mrb, obj), mrb_intern_lit(mrb, "to_s"));
-  if (MRB_PROC_CFUNC_P(me) && (me->body.func == mrb_any_to_s))
-    return TRUE;
-  return FALSE;
+  return mrb_func_basic_p(mrb, obj, mrb_intern_lit(mrb, "to_s"), mrb_any_to_s);
 }
 
@@ -57,53 +65,4 @@
   }
   return mrb_any_to_s(mrb, obj);
-}
-
-/* 15.3.1.3.1  */
-/* 15.3.1.3.10 */
-/* 15.3.1.3.11 */
-/*
- *  call-seq:
- *     obj == other        -> true or false
- *     obj.equal?(other)   -> true or false
- *     obj.eql?(other)     -> true or false
- *
- *  Equality---At the <code>Object</code> level, <code>==</code> returns
- *  <code>true</code> only if <i>obj</i> and <i>other</i> are the
- *  same object. Typically, this method is overridden in descendant
- *  classes to provide class-specific meaning.
- *
- *  Unlike <code>==</code>, the <code>equal?</code> method should never be
- *  overridden by subclasses: it is used to determine object identity
- *  (that is, <code>a.equal?(b)</code> iff <code>a</code> is the same
- *  object as <code>b</code>).
- *
- *  The <code>eql?</code> method returns <code>true</code> if
- *  <i>obj</i> and <i>anObject</i> have the same value. Used by
- *  <code>Hash</code> to test members for equality.  For objects of
- *  class <code>Object</code>, <code>eql?</code> is synonymous with
- *  <code>==</code>. Subclasses normally continue this tradition, but
- *  there are exceptions. <code>Numeric</code> types, for example,
- *  perform type conversion across <code>==</code>, but not across
- *  <code>eql?</code>, so:
- *
- *     1 == 1.0     #=> true
- *     1.eql? 1.0   #=> false
- */
-static mrb_value
-mrb_obj_equal_m(mrb_state *mrb, mrb_value self)
-{
-  mrb_value arg;
-
-  mrb_get_args(mrb, "o", &arg);
-  return mrb_bool_value(mrb_obj_equal(mrb, self, arg));
-}
-
-static mrb_value
-mrb_obj_not_equal_m(mrb_state *mrb, mrb_value self)
-{
-  mrb_value arg;
-
-  mrb_get_args(mrb, "o", &arg);
-  return mrb_bool_value(!mrb_equal(mrb, self, arg));
 }
 
@@ -143,5 +102,5 @@
  *  <code>name</code>. Replaces the deprecated <code>Object#id</code>.
  */
-static mrb_value
+mrb_value
 mrb_obj_id_m(mrb_state *mrb, mrb_value self)
 {
@@ -178,36 +137,36 @@
   mrb_callinfo *ci = mrb->c->ci;
   mrb_value *bp;
-  mrb_bool given_p;
 
   bp = ci->stackent + 1;
   ci--;
   if (ci <= mrb->c->cibase) {
-    given_p = FALSE;
-  }
-  else {
-    /* block_given? called within block; check upper scope */
-    if (ci->proc->env) {
-      struct REnv *e = ci->proc->env;
-      mrb_value *sp;
-
-      while (e->c) {
-        e = (struct REnv*)e->c;
-      }
-      sp = e->stack;
-      if (sp) {
-        /* top-level does not have block slot (alway false) */
-        if (sp == mrb->c->stbase)
-          return mrb_false_value();
-        ci = mrb->c->cibase + e->cioff;
-        bp = ci[1].stackent + 1;
-      }
-    }
-    if (ci->argc > 0) {
-      bp += ci->argc;
-    }
-    given_p = !mrb_nil_p(*bp);
-  }
-
-  return mrb_bool_value(given_p);
+    return mrb_false_value();
+  }
+  /* block_given? called within block; check upper scope */
+  if (ci->proc->env) {
+    struct REnv *e = ci->proc->env;
+
+    while (e->c) {
+      e = (struct REnv*)e->c;
+    }
+    /* top-level does not have block slot (always false) */
+    if (e->stack == mrb->c->stbase)
+      return mrb_false_value();
+    if (e->stack && e->cioff < 0) {
+      /* use saved block arg position */
+      bp = &e->stack[-e->cioff];
+      ci = 0;                 /* no callinfo available */
+    }
+    else {
+      ci = e->cxt.c->cibase + e->cioff;
+      bp = ci[1].stackent + 1;
+    }
+  }
+  if (ci && ci->argc > 0) {
+    bp += ci->argc;
+  }
+  if (mrb_nil_p(*bp))
+    return mrb_false_value();
+  return mrb_true_value();
 }
 
@@ -241,9 +200,11 @@
     struct RClass *clone = (struct RClass*)mrb_obj_alloc(mrb, klass->tt, mrb->class_class);
 
-    if ((mrb_type(obj) == MRB_TT_CLASS) || (mrb_type(obj) == MRB_TT_SCLASS)) {
-      clone->c = clone;
-    }
-    else {
+    switch (mrb_type(obj)) {
+    case MRB_TT_CLASS:
+    case MRB_TT_SCLASS:
+      break;
+    default:
       clone->c = mrb_singleton_class_clone(mrb, mrb_obj_value(klass));
+      break;
     }
     clone->super = klass->super;
@@ -283,6 +244,12 @@
     c1->super->flags |= MRB_FLAG_IS_ORIGIN;
   }
-  dc->mt = kh_copy(mt, mrb, sc->mt);
+  if (sc->mt) {
+    dc->mt = kh_copy(mt, mrb, sc->mt);
+  }
+  else {
+    dc->mt = kh_init(mt, mrb);
+  }
   dc->super = sc->super;
+  MRB_SET_INSTANCE_TT(dc, MRB_INSTANCE_TT(sc));
 }
 
@@ -302,4 +269,7 @@
       mrb_iv_copy(mrb, dest, obj);
       break;
+    case MRB_TT_ISTRUCT:
+      mrb_istruct_copy(dest, obj);
+      break;
 
     default:
@@ -441,7 +411,56 @@
   mrb_value *argv;
   mrb_int argc;
+  mrb_value args;
 
   mrb_get_args(mrb, "*", &argv, &argc);
+  args = mrb_ary_new_from_values(mrb, argc, argv);
+  argv = (mrb_value*)RARRAY_PTR(args);
   return mrb_obj_extend(mrb, argc, argv, self);
+}
+
+static mrb_value
+mrb_obj_freeze(mrb_state *mrb, mrb_value self)
+{
+  struct RBasic *b;
+
+  switch (mrb_type(self)) {
+    case MRB_TT_FALSE:
+    case MRB_TT_TRUE:
+    case MRB_TT_FIXNUM:
+    case MRB_TT_SYMBOL:
+    case MRB_TT_FLOAT:
+      return self;
+    default:
+      break;
+  }
+
+  b = mrb_basic_ptr(self);
+  if (!MRB_FROZEN_P(b)) {
+    MRB_SET_FROZEN_FLAG(b);
+  }
+  return self;
+}
+
+static mrb_value
+mrb_obj_frozen(mrb_state *mrb, mrb_value self)
+{
+  struct RBasic *b;
+
+  switch (mrb_type(self)) {
+    case MRB_TT_FALSE:
+    case MRB_TT_TRUE:
+    case MRB_TT_FIXNUM:
+    case MRB_TT_SYMBOL:
+    case MRB_TT_FLOAT:
+      return mrb_true_value();
+    default:
+      break;
+  }
+
+  b = mrb_basic_ptr(self);
+  if (!MRB_FROZEN_P(b)) {
+    return mrb_false_value();
+  }
+  return mrb_true_value();
 }
 
@@ -477,7 +496,4 @@
 }
 
-
-/* implementation of instance_eval */
-mrb_value mrb_obj_instance_eval(mrb_state*, mrb_value);
 
 MRB_API mrb_bool
@@ -723,7 +739,5 @@
 mrb_obj_methods(mrb_state *mrb, mrb_bool recur, mrb_value obj, mrb_method_flag_t flag)
 {
-  if (recur)
-    return mrb_class_instance_method_list(mrb, recur, mrb_class(mrb, obj), 0);
-  return mrb_obj_singleton_methods(mrb, recur, obj);
+  return mrb_class_instance_method_list(mrb, recur, mrb_class(mrb, obj), 0);
 }
 /* 15.3.1.3.31 */
@@ -853,6 +867,6 @@
     break;
   case 1:
-    a[1] = mrb_check_string_type(mrb, a[0]);
-    if (!mrb_nil_p(a[1])) {
+    if (mrb_string_p(a[0])) {
+      a[1] = a[0];
       argc = 2;
       a[0] = mrb_obj_value(E_RUNTIME_ERROR);
@@ -861,5 +875,4 @@
   default:
     exc = mrb_make_exception(mrb, argc, a);
-    mrb_obj_iv_set(mrb, mrb_obj_ptr(exc), mrb_intern_lit(mrb, "lastpc"), mrb_cptr_value(mrb, mrb->c->ci->pc));
     mrb_exc_raise(mrb, exc);
     break;
@@ -905,4 +918,77 @@
 }
 
+void
+mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args)
+{
+  mrb_sym inspect;
+  mrb_value repr;
+
+  inspect = mrb_intern_lit(mrb, "inspect");
+  if (mrb->c->ci > mrb->c->cibase && mrb->c->ci[-1].mid == inspect) {
+    /* method missing in inspect; avoid recursion */
+    repr = mrb_any_to_s(mrb, self);
+  }
+  else if (mrb_respond_to(mrb, self, inspect) && mrb->c->ci - mrb->c->cibase < 16) {
+    repr = mrb_funcall_argv(mrb, self, inspect, 0, 0);
+    if (mrb_string_p(repr) && RSTRING_LEN(repr) > 64) {
+      repr = mrb_any_to_s(mrb, self);
+    }
+  }
+  else {
+    repr = mrb_any_to_s(mrb, self);
+  }
+
+  mrb_no_method_error(mrb, name, args, "undefined method '%S' for %S",
+                      mrb_sym2str(mrb, name), repr);
+}
+
+/* 15.3.1.3.30 */
+/*
+ *  call-seq:
+ *     obj.method_missing(symbol [, *args] )   -> result
+ *
+ *  Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
+ *  <i>symbol</i> is the symbol for the method called, and <i>args</i>
+ *  are any arguments that were passed to it. By default, the interpreter
+ *  raises an error when this method is called. However, it is possible
+ *  to override the method to provide more dynamic behavior.
+ *  If it is decided that a particular method should not be handled, then
+ *  <i>super</i> should be called, so that ancestors can pick up the
+ *  missing method.
+ *  The example below creates
+ *  a class <code>Roman</code>, which responds to methods with names
+ *  consisting of roman numerals, returning the corresponding integer
+ *  values.
+ *
+ *     class Roman
+ *       def romanToInt(str)
+ *         # ...
+ *       end
+ *       def method_missing(methId)
+ *         str = methId.id2name
+ *         romanToInt(str)
+ *       end
+ *     end
+ *
+ *     r = Roman.new
+ *     r.iv      #=> 4
+ *     r.xxiii   #=> 23
+ *     r.mm      #=> 2000
+ */
+#ifdef MRB_DEFAULT_METHOD_MISSING
+static mrb_value
+mrb_obj_missing(mrb_state *mrb, mrb_value mod)
+{
+  mrb_sym name;
+  mrb_value *a;
+  mrb_int alen;
+
+  mrb_get_args(mrb, "n*", &name, &a, &alen);
+  mrb_method_missing(mrb, name, mod, mrb_ary_new_from_values(mrb, alen, a));
+  /* not reached */
+  return mrb_nil_value();
+}
+#endif
+
 static inline mrb_bool
 basic_obj_respond_to(mrb_state *mrb, mrb_value obj, mrb_sym id, int pub)
@@ -940,5 +1026,8 @@
   else {
     mrb_value tmp;
-    if (!mrb_string_p(mid)) {
+    if (mrb_string_p(mid)) {
+      tmp = mrb_check_intern_str(mrb, mid);
+    }
+    else {
       tmp = mrb_check_string_type(mrb, mid);
       if (mrb_nil_p(tmp)) {
@@ -946,6 +1035,6 @@
         mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a symbol", tmp);
       }
-    }
-    tmp = mrb_check_intern_str(mrb, mid);
+      tmp = mrb_check_intern_str(mrb, tmp);
+    }
     if (mrb_nil_p(tmp)) {
       respond_to_p = FALSE;
@@ -963,8 +1052,9 @@
     rtm_id = mrb_intern_lit(mrb, "respond_to_missing?");
     if (basic_obj_respond_to(mrb, self, rtm_id, !priv)) {
-      mrb_value args[2];
+      mrb_value args[2], v;
       args[0] = mid;
       args[1] = mrb_bool_value(priv);
-      return mrb_funcall_argv(mrb, self, rtm_id, 2, args);
+      v = mrb_funcall_argv(mrb, self, rtm_id, 2, args);
+      return mrb_bool_value(mrb_bool(v));
     }
   }
@@ -1051,6 +1141,6 @@
 mrb_local_variables(mrb_state *mrb, mrb_value self)
 {
-  mrb_value ret;
   struct RProc *proc;
+  mrb_value vars;
   struct mrb_irep *irep;
   size_t i;
@@ -1066,8 +1156,8 @@
     return mrb_ary_new(mrb);
   }
-  ret = mrb_ary_new_capa(mrb, irep->nlocals - 1);
+  vars = mrb_hash_new(mrb);
   for (i = 0; i + 1 < irep->nlocals; ++i) {
     if (irep->lv[i].name) {
-      mrb_ary_push(mrb, ret, mrb_symbol_value(irep->lv[i].name));
+      mrb_hash_set(mrb, vars, mrb_symbol_value(irep->lv[i].name), mrb_true_value());
     }
   }
@@ -1076,10 +1166,11 @@
 
     while (e) {
-      if (!MRB_PROC_CFUNC_P(mrb->c->cibase[e->cioff].proc)) {
-        irep = mrb->c->cibase[e->cioff].proc->body.irep;
+      if (MRB_ENV_STACK_SHARED_P(e) &&
+          !MRB_PROC_CFUNC_P(e->cxt.c->cibase[e->cioff].proc)) {
+        irep = e->cxt.c->cibase[e->cioff].proc->body.irep;
         if (irep->lv) {
           for (i = 0; i + 1 < irep->nlocals; ++i) {
             if (irep->lv[i].name) {
-              mrb_ary_push(mrb, ret, mrb_symbol_value(irep->lv[i].name));
+              mrb_hash_set(mrb, vars, mrb_symbol_value(irep->lv[i].name), mrb_true_value());
             }
           }
@@ -1090,7 +1181,8 @@
   }
 
-  return ret;
-}
-
+  return mrb_hash_keys(mrb, vars);
+}
+
+mrb_value mrb_obj_equal_m(mrb_state *mrb, mrb_value);
 void
 mrb_init_kernel(mrb_state *mrb)
@@ -1108,9 +1200,5 @@
   mrb_define_method(mrb, krn, "singleton_class",            mrb_singleton_class,             MRB_ARGS_NONE());
 
-  mrb_define_method(mrb, krn, "==",                         mrb_obj_equal_m,                 MRB_ARGS_REQ(1));    /* 15.3.1.3.1  */
-  mrb_define_method(mrb, krn, "!=",                         mrb_obj_not_equal_m,             MRB_ARGS_REQ(1));
   mrb_define_method(mrb, krn, "===",                        mrb_equal_m,                     MRB_ARGS_REQ(1));    /* 15.3.1.3.2  */
-  mrb_define_method(mrb, krn, "__id__",                     mrb_obj_id_m,                    MRB_ARGS_NONE());    /* 15.3.1.3.3  */
-  mrb_define_method(mrb, krn, "__send__",                   mrb_f_send,                      MRB_ARGS_ANY());     /* 15.3.1.3.4  */
   mrb_define_method(mrb, krn, "block_given?",               mrb_f_block_given_p_m,           MRB_ARGS_NONE());    /* 15.3.1.3.6  */
   mrb_define_method(mrb, krn, "class",                      mrb_obj_class_m,                 MRB_ARGS_NONE());    /* 15.3.1.3.7  */
@@ -1120,9 +1208,10 @@
   mrb_define_method(mrb, krn, "equal?",                     mrb_obj_equal_m,                 MRB_ARGS_REQ(1));    /* 15.3.1.3.11 */
   mrb_define_method(mrb, krn, "extend",                     mrb_obj_extend_m,                MRB_ARGS_ANY());     /* 15.3.1.3.13 */
+  mrb_define_method(mrb, krn, "freeze",                     mrb_obj_freeze,                  MRB_ARGS_NONE());
+  mrb_define_method(mrb, krn, "frozen?",                    mrb_obj_frozen,                  MRB_ARGS_NONE());
   mrb_define_method(mrb, krn, "global_variables",           mrb_f_global_variables,          MRB_ARGS_NONE());    /* 15.3.1.3.14 */
   mrb_define_method(mrb, krn, "hash",                       mrb_obj_hash,                    MRB_ARGS_NONE());    /* 15.3.1.3.15 */
   mrb_define_method(mrb, krn, "initialize_copy",            mrb_obj_init_copy,               MRB_ARGS_REQ(1));    /* 15.3.1.3.16 */
   mrb_define_method(mrb, krn, "inspect",                    mrb_obj_inspect,                 MRB_ARGS_NONE());    /* 15.3.1.3.17 */
-  mrb_define_method(mrb, krn, "instance_eval",              mrb_obj_instance_eval,           MRB_ARGS_ANY());     /* 15.3.1.3.18 */
   mrb_define_method(mrb, krn, "instance_of?",               obj_is_instance_of,              MRB_ARGS_REQ(1));    /* 15.3.1.3.19 */
   mrb_define_method(mrb, krn, "instance_variable_defined?", mrb_obj_ivar_defined,            MRB_ARGS_REQ(1));    /* 15.3.1.3.20 */
@@ -1134,4 +1223,7 @@
   mrb_define_method(mrb, krn, "kind_of?",                   mrb_obj_is_kind_of_m,            MRB_ARGS_REQ(1));    /* 15.3.1.3.26 */
   mrb_define_method(mrb, krn, "local_variables",            mrb_local_variables,             MRB_ARGS_NONE());    /* 15.3.1.3.28 */
+#ifdef MRB_DEFAULT_METHOD_MISSING
+  mrb_define_method(mrb, krn, "method_missing",             mrb_obj_missing,                 MRB_ARGS_ANY());     /* 15.3.1.3.30 */
+#endif
   mrb_define_method(mrb, krn, "methods",                    mrb_obj_methods_m,               MRB_ARGS_OPT(1));    /* 15.3.1.3.31 */
   mrb_define_method(mrb, krn, "nil?",                       mrb_false,                       MRB_ARGS_NONE());    /* 15.3.1.3.32 */
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/load.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/load.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/load.c	(revision 331)
@@ -8,10 +8,10 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby/dump.h"
-#include "mruby/irep.h"
-#include "mruby/proc.h"
-#include "mruby/string.h"
-#include "mruby/debug.h"
-#include "mruby/error.h"
+#include <mruby/dump.h>
+#include <mruby/irep.h>
+#include <mruby/proc.h>
+#include <mruby/string.h>
+#include <mruby/debug.h>
+#include <mruby/error.h>
 
 #if SIZE_MAX < UINT32_MAX
@@ -524,5 +524,5 @@
     if (bigendian_p())
       *flags |= FLAG_BYTEORDER_NATIVE;
-    else 
+    else
       *flags |= FLAG_BYTEORDER_BIG;
   }
@@ -545,5 +545,5 @@
 }
 
-MRB_API mrb_irep*
+static mrb_irep*
 read_irep(mrb_state *mrb, const uint8_t *bin, uint8_t flags)
 {
@@ -603,5 +603,5 @@
 }
 
-MRB_API mrb_irep*
+mrb_irep*
 mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
 {
@@ -615,8 +615,10 @@
 }
 
+void mrb_exc_set(mrb_state *mrb, mrb_value exc);
+
 static void
 irep_error(mrb_state *mrb)
 {
-  mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "irep load error"));
+  mrb_exc_set(mrb, mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "irep load error"));
 }
 
@@ -634,5 +636,5 @@
   mrb_irep_decref(mrb, irep);
   if (c && c->no_exec) return mrb_obj_value(proc);
-  return mrb_toplevel_run(mrb, proc);
+  return mrb_top_run(mrb, proc, mrb_top_self(mrb), 0);
 }
 
@@ -645,5 +647,5 @@
 #ifndef MRB_DISABLE_STDIO
 
-MRB_API mrb_irep*
+mrb_irep*
 mrb_read_irep_file(mrb_state *mrb, FILE* fp)
 {
@@ -696,5 +698,5 @@
   if (c && c->dump_result) mrb_codedump_all(mrb, proc);
   if (c && c->no_exec) return mrb_obj_value(proc);
-  val = mrb_toplevel_run(mrb, proc);
+  val = mrb_top_run(mrb, proc, mrb_top_self(mrb), 0);
   return val;
 }
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/mruby_core.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/mruby_core.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/mruby_core.rake	(revision 331)
@@ -5,9 +5,9 @@
 
   objs = Dir.glob("#{current_dir}/*.c").map { |f|
-    next nil if cxx_abi_enabled? and f =~ /(error|vm).c$/
+    next nil if cxx_exception_enabled? and f =~ /(error|vm).c$/
     objfile(f.pathmap("#{current_build_dir}/%n"))
   }.compact
 
-  if cxx_abi_enabled?
+  if cxx_exception_enabled?
     objs += %w(vm error).map { |v| compile_as_cxx "#{current_dir}/#{v}.c", "#{current_build_dir}/#{v}.cxx" }
   end
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/numeric.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/numeric.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/numeric.c	(revision 331)
@@ -10,10 +10,12 @@
 #include <stdlib.h>
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/numeric.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/numeric.h>
+#include <mruby/string.h>
+#include <mruby/class.h>
 
 #ifdef MRB_USE_FLOAT
+#define trunc(f) truncf(f)
 #define floor(f) floorf(f)
 #define ceil(f) ceilf(f)
@@ -51,12 +53,30 @@
 {
   mrb_value y;
-  mrb_float d, yv;
-
-  mrb_get_args(mrb, "o", &y);
-  yv = mrb_to_flo(mrb, y);
-  d = pow(mrb_to_flo(mrb, x), yv);
-  if (mrb_fixnum_p(x) && mrb_fixnum_p(y) && FIXABLE(d) && yv > 0 && 
-      (d < 0 || (d > 0 && (mrb_int)d > 0)))
-    return mrb_fixnum_value((mrb_int)d);
+  mrb_float d;
+
+  mrb_get_args(mrb, "o", &y);
+  if (mrb_fixnum_p(x) && mrb_fixnum_p(y)) {
+    /* try ipow() */
+    mrb_int base = mrb_fixnum(x);
+    mrb_int exp = mrb_fixnum(y);
+    mrb_int result = 1;
+
+    if (exp < 0) goto float_pow;
+    for (;;) {
+      if (exp & 1) {
+        if (mrb_int_mul_overflow(result, base, &result)) {
+          goto float_pow;
+        }
+      }
+      exp >>= 1;
+      if (exp == 0) break;
+      if (mrb_int_mul_overflow(base, base, &base)) {
+        goto float_pow;
+      }
+    }
+    return mrb_fixnum_value(result);
+  }
+ float_pow:
+  d = pow(mrb_to_flo(mrb, x), mrb_to_flo(mrb, y));
   return mrb_float_value(mrb, d);
 }
@@ -272,4 +292,126 @@
 }
 
+static int64_t
+value_int64(mrb_state *mrb, mrb_value x)
+{
+  switch (mrb_type(x)) {
+  case MRB_TT_FIXNUM:
+    return (int64_t)mrb_fixnum(x);
+    break;
+  case MRB_TT_FLOAT:
+    return (int64_t)mrb_float(x);
+  default:
+    mrb_raise(mrb, E_TYPE_ERROR, "cannot convert to Integer");
+    break;
+  }
+  /* not reached */
+  return 0;
+}
+
+static mrb_value
+int64_value(mrb_state *mrb, int64_t v)
+{
+  if (FIXABLE(v)) {
+    return mrb_fixnum_value((mrb_int)v);
+  }
+  return mrb_float_value(mrb, (mrb_float)v);
+}
+
+static mrb_value
+flo_rev(mrb_state *mrb, mrb_value x)
+{
+  int64_t v1;
+  mrb_get_args(mrb, "");
+  v1 = (int64_t)mrb_float(x);
+  return int64_value(mrb, ~v1);
+}
+
+static mrb_value
+flo_and(mrb_state *mrb, mrb_value x)
+{
+  mrb_value y;
+  int64_t v1, v2;
+  mrb_get_args(mrb, "o", &y);
+
+  v1 = (int64_t)mrb_float(x);
+  v2 = value_int64(mrb, y);
+  return int64_value(mrb, v1 & v2);
+}
+
+static mrb_value
+flo_or(mrb_state *mrb, mrb_value x)
+{
+  mrb_value y;
+  int64_t v1, v2;
+  mrb_get_args(mrb, "o", &y);
+
+  v1 = (int64_t)mrb_float(x);
+  v2 = value_int64(mrb, y);
+  return int64_value(mrb, v1 | v2);
+}
+
+static mrb_value
+flo_xor(mrb_state *mrb, mrb_value x)
+{
+  mrb_value y;
+  int64_t v1, v2;
+  mrb_get_args(mrb, "o", &y);
+
+  v1 = (int64_t)mrb_float(x);
+  v2 = value_int64(mrb, y);
+  return int64_value(mrb, v1 ^ v2);
+}
+
+static mrb_value
+flo_shift(mrb_state *mrb, mrb_value x, mrb_int width)
+{
+  mrb_float val;
+
+  if (width == 0) {
+    return x;
+  }
+  val = mrb_float(x);
+  if (width < 0) {
+    while (width++) {
+      val /= 2;
+    }
+#if defined(_ISOC99_SOURCE)
+    val = trunc(val);
+#else
+    val = val > 0 ? floor(val) : ceil(val);
+#endif
+    if (val == 0 && mrb_float(x) < 0) {
+      return mrb_fixnum_value(-1);
+    }
+  }
+  else {
+    while (width--) {
+      val *= 2;
+    }
+  }
+  if (FIXABLE_FLOAT(val)) {
+    return mrb_fixnum_value((mrb_int)val);
+  }
+  return mrb_float_value(mrb, val);
+}
+
+static mrb_value
+flo_lshift(mrb_state *mrb, mrb_value x)
+{
+  mrb_int width;
+
+  mrb_get_args(mrb, "i", &width);
+  return flo_shift(mrb, x, -width);
+}
+
+static mrb_value
+flo_rshift(mrb_state *mrb, mrb_value x)
+{
+  mrb_int width;
+
+  mrb_get_args(mrb, "i", &width);
+  return flo_shift(mrb, x, width);
+}
+
 /* 15.2.8.3.18 */
 /*
@@ -285,5 +427,5 @@
   char *c;
   size_t i;
-  int hash;
+  mrb_int hash;
 
   d = (mrb_float)mrb_fixnum(num);
@@ -291,5 +433,5 @@
   if (d == 0) d = 0.0;
   c = (char*)&d;
-  for (hash=0, i=0; i<sizeof(mrb_float);i++) {
+  for (hash=0,i=0; i<sizeof(mrb_float); i++) {
     hash = (hash * 971) ^ (unsigned char)c[i];
   }
@@ -351,4 +493,15 @@
 {
   return mrb_bool_value(isfinite(mrb_float(num)));
+}
+
+void
+mrb_check_num_exact(mrb_state *mrb, mrb_float num)
+{
+  if (isinf(num)) {
+    mrb_raise(mrb, E_FLOATDOMAIN_ERROR, num < 0 ? "-Infinity" : "Infinity");
+  }
+  if (isnan(num)) {
+    mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
+  }
 }
 
@@ -371,5 +524,6 @@
   mrb_float f = floor(mrb_float(num));
 
-  if (!FIXABLE(f)) {
+  mrb_check_num_exact(mrb, f);
+  if (!FIXABLE_FLOAT(f)) {
     return mrb_float_value(mrb, f);
   }
@@ -396,5 +550,6 @@
   mrb_float f = ceil(mrb_float(num));
 
-  if (!FIXABLE(f)) {
+  mrb_check_num_exact(mrb, f);
+  if (!FIXABLE_FLOAT(f)) {
     return mrb_float_value(mrb, f);
   }
@@ -443,12 +598,8 @@
   number = mrb_float(num);
 
-  if (isinf(number)) {
-    if (0 < ndigits) return num;
-    else mrb_raise(mrb, E_FLOATDOMAIN_ERROR, number < 0 ? "-Infinity" : "Infinity");
-  }
-  if (isnan(number)) {
-    if (0 < ndigits) return num;
-    else mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
-  }
+  if (0 < ndigits && (isinf(number) || isnan(number))) {
+    return num;
+  }
+  mrb_check_num_exact(mrb, number);
 
   f = 1.0;
@@ -506,5 +657,6 @@
   if (f < 0.0) f = ceil(f);
 
-  if (!FIXABLE(f)) {
+  mrb_check_num_exact(mrb, f);
+  if (!FIXABLE_FLOAT(f)) {
     return mrb_float_value(mrb, f);
   }
@@ -542,8 +694,4 @@
 }
 
-/*tests if N*N would overflow*/
-#define SQRT_INT_MAX ((mrb_int)1<<((MRB_INT_BIT-1-MRB_FIXNUM_SHIFT)/2))
-#define FIT_SQRT_INT(n) (((n)<SQRT_INT_MAX)&&((n)>=-SQRT_INT_MAX))
-
 mrb_value
 mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y)
@@ -553,16 +701,12 @@
   a = mrb_fixnum(x);
   if (mrb_fixnum_p(y)) {
-    mrb_float c;
-    mrb_int b;
+    mrb_int b, c;
 
     if (a == 0) return x;
     b = mrb_fixnum(y);
-    if (FIT_SQRT_INT(a) && FIT_SQRT_INT(b))
-      return mrb_fixnum_value(a*b);
-    c = a * b;
-    if ((a != 0 && c/a != b) || !FIXABLE(c)) {
-      return mrb_float_value(mrb, (mrb_float)a*(mrb_float)b);
-    }
-    return mrb_fixnum_value((mrb_int)c);
+    if (mrb_int_mul_overflow(a, b, &c)) {
+      return mrb_float_value(mrb, (mrb_float)a * (mrb_float)b);
+    }
+    return mrb_fixnum_value(c);
   }
   return mrb_float_value(mrb, (mrb_float)a * mrb_to_flo(mrb, y));
@@ -747,15 +891,11 @@
 }
 
-static mrb_value
-bit_coerce(mrb_state *mrb, mrb_value x)
-{
-  while (!mrb_fixnum_p(x)) {
-    if (mrb_float_p(x)) {
-      mrb_raise(mrb, E_TYPE_ERROR, "can't convert Float into Integer");
-    }
-    x = mrb_to_int(mrb, x);
-  }
-  return x;
-}
+static mrb_value flo_and(mrb_state *mrb, mrb_value x);
+static mrb_value flo_or(mrb_state *mrb, mrb_value x);
+static mrb_value flo_xor(mrb_state *mrb, mrb_value x);
+#define bit_op(x,y,op1,op2) do {\
+  if (mrb_fixnum_p(y)) return mrb_fixnum_value(mrb_fixnum(x) op2 mrb_fixnum(y));\
+  return flo_ ## op1(mrb, mrb_float_value(mrb, mrb_fixnum(x)));\
+} while(0)
 
 /* 15.2.8.3.9  */
@@ -773,7 +913,5 @@
 
   mrb_get_args(mrb, "o", &y);
-
-  y = bit_coerce(mrb, y);
-  return mrb_fixnum_value(mrb_fixnum(x) & mrb_fixnum(y));
+  bit_op(x, y, and, &);
 }
 
@@ -792,7 +930,5 @@
 
   mrb_get_args(mrb, "o", &y);
-
-  y = bit_coerce(mrb, y);
-  return mrb_fixnum_value(mrb_fixnum(x) | mrb_fixnum(y));
+  bit_op(x, y, or, |);
 }
 
@@ -811,7 +947,5 @@
 
   mrb_get_args(mrb, "o", &y);
-
-  y = bit_coerce(mrb, y);
-  return mrb_fixnum_value(mrb_fixnum(x) ^ mrb_fixnum(y));
+  bit_op(x, y, or, ^);
 }
 
@@ -821,6 +955,24 @@
 lshift(mrb_state *mrb, mrb_int val, mrb_int width)
 {
-  mrb_assert(width > 0);
-  if (width > NUMERIC_SHIFT_WIDTH_MAX) {
+  if (width < 0) {              /* mrb_int overflow */
+    return mrb_float_value(mrb, INFINITY);
+  }
+  if (val > 0) {
+    if ((width > NUMERIC_SHIFT_WIDTH_MAX) ||
+        (val   > (MRB_INT_MAX >> width))) {
+      goto bit_overflow;
+    }
+  }
+  else {
+    if ((width > NUMERIC_SHIFT_WIDTH_MAX) ||
+        (val   < (MRB_INT_MIN >> width))) {
+      goto bit_overflow;
+    }
+  }
+
+  return mrb_fixnum_value(val << width);
+
+bit_overflow:
+  {
     mrb_float f = (mrb_float)val;
     while (width--) {
@@ -829,5 +981,4 @@
     return mrb_float_value(mrb, f);
   }
-  return mrb_fixnum_value(val << width);
 }
 
@@ -835,5 +986,7 @@
 rshift(mrb_int val, mrb_int width)
 {
-  mrb_assert(width > 0);
+  if (width < 0) {              /* mrb_int overflow */
+    return mrb_fixnum_value(0);
+  }
   if (width >= NUMERIC_SHIFT_WIDTH_MAX) {
     if (val < 0) {
@@ -845,13 +998,4 @@
 }
 
-static inline void
-fix_shift_get_width(mrb_state *mrb, mrb_int *width)
-{
-  mrb_value y;
-
-  mrb_get_args(mrb, "o", &y);
-  *width = mrb_fixnum(bit_coerce(mrb, y));
-}
-
 /* 15.2.8.3.12 */
 /*
@@ -867,10 +1011,10 @@
   mrb_int width, val;
 
-  fix_shift_get_width(mrb, &width);
-
+  mrb_get_args(mrb, "i", &width);
   if (width == 0) {
     return x;
   }
   val = mrb_fixnum(x);
+  if (val == 0) return x;
   if (width < 0) {
     return rshift(val, -width);
@@ -892,10 +1036,10 @@
   mrb_int width, val;
 
-  fix_shift_get_width(mrb, &width);
-
+  mrb_get_args(mrb, "i", &width);
   if (width == 0) {
     return x;
   }
   val = mrb_fixnum(x);
+  if (val == 0) return x;
   if (width < 0) {
     return lshift(mrb, val, -width);
@@ -936,5 +1080,5 @@
 mrb_flo_to_fixnum(mrb_state *mrb, mrb_value x)
 {
-  mrb_int z;
+  mrb_int z = 0;
 
   if (!mrb_float_p(x)) {
@@ -951,5 +1095,10 @@
       mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
     }
-    z = (mrb_int)d;
+    if (FIXABLE_FLOAT(d)) {
+      z = (mrb_int)d;
+    }
+    else {
+      mrb_raisef(mrb, E_ARGUMENT_ERROR, "number (%S) too big for integer", x);
+    }
   }
   return mrb_fixnum_value(z);
@@ -1150,58 +1299,70 @@
   numeric = mrb_define_class(mrb, "Numeric",  mrb->object_class);                /* 15.2.7 */
 
-  mrb_define_method(mrb, numeric, "**",       num_pow,        MRB_ARGS_REQ(1));
-  mrb_define_method(mrb, numeric, "/",        num_div,        MRB_ARGS_REQ(1));  /* 15.2.8.3.4  */
-  mrb_define_method(mrb, numeric, "quo",      num_div,        MRB_ARGS_REQ(1));  /* 15.2.7.4.5 (x) */
-  mrb_define_method(mrb, numeric, "<=>",      num_cmp,        MRB_ARGS_REQ(1));  /* 15.2.9.3.6  */
+  mrb_define_method(mrb, numeric, "**",       num_pow,         MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, numeric, "/",        num_div,         MRB_ARGS_REQ(1)); /* 15.2.8.3.4  */
+  mrb_define_method(mrb, numeric, "quo",      num_div,         MRB_ARGS_REQ(1)); /* 15.2.7.4.5 (x) */
+  mrb_define_method(mrb, numeric, "<=>",      num_cmp,         MRB_ARGS_REQ(1)); /* 15.2.9.3.6  */
 
   /* Integer Class */
   integer = mrb_define_class(mrb, "Integer",  numeric);                          /* 15.2.8 */
+  MRB_SET_INSTANCE_TT(integer, MRB_TT_FIXNUM);
   mrb_undef_class_method(mrb, integer, "new");
-  mrb_define_method(mrb, integer, "to_i", int_to_i, MRB_ARGS_NONE());            /* 15.2.8.3.24 */
-  mrb_define_method(mrb, integer, "to_int", int_to_i, MRB_ARGS_NONE());
+  mrb_define_method(mrb, integer, "to_i",     int_to_i,        MRB_ARGS_NONE()); /* 15.2.8.3.24 */
+  mrb_define_method(mrb, integer, "to_int",   int_to_i,        MRB_ARGS_NONE());
+  mrb_define_method(mrb, integer, "ceil",     int_to_i,        MRB_ARGS_REQ(1)); /* 15.2.8.3.8 (x) */
+  mrb_define_method(mrb, integer, "floor",    int_to_i,        MRB_ARGS_REQ(1)); /* 15.2.8.3.10 (x) */
+  mrb_define_method(mrb, integer, "round",    int_to_i,        MRB_ARGS_REQ(1)); /* 15.2.8.3.12 (x) */
+  mrb_define_method(mrb, integer, "truncate", int_to_i,        MRB_ARGS_REQ(1)); /* 15.2.8.3.15 (x) */
 
   /* Fixnum Class */
   mrb->fixnum_class = fixnum = mrb_define_class(mrb, "Fixnum", integer);
-  mrb_define_method(mrb, fixnum,  "+",        fix_plus,          MRB_ARGS_REQ(1)); /* 15.2.8.3.1  */
-  mrb_define_method(mrb, fixnum,  "-",        fix_minus,         MRB_ARGS_REQ(1)); /* 15.2.8.3.2  */
-  mrb_define_method(mrb, fixnum,  "*",        fix_mul,           MRB_ARGS_REQ(1)); /* 15.2.8.3.3  */
-  mrb_define_method(mrb, fixnum,  "%",        fix_mod,           MRB_ARGS_REQ(1)); /* 15.2.8.3.5  */
-  mrb_define_method(mrb, fixnum,  "==",       fix_equal,         MRB_ARGS_REQ(1)); /* 15.2.8.3.7  */
-  mrb_define_method(mrb, fixnum,  "~",        fix_rev,           MRB_ARGS_NONE()); /* 15.2.8.3.8  */
-  mrb_define_method(mrb, fixnum,  "&",        fix_and,           MRB_ARGS_REQ(1)); /* 15.2.8.3.9  */
-  mrb_define_method(mrb, fixnum,  "|",        fix_or,            MRB_ARGS_REQ(1)); /* 15.2.8.3.10 */
-  mrb_define_method(mrb, fixnum,  "^",        fix_xor,           MRB_ARGS_REQ(1)); /* 15.2.8.3.11 */
-  mrb_define_method(mrb, fixnum,  "<<",       fix_lshift,        MRB_ARGS_REQ(1)); /* 15.2.8.3.12 */
-  mrb_define_method(mrb, fixnum,  ">>",       fix_rshift,        MRB_ARGS_REQ(1)); /* 15.2.8.3.13 */
-  mrb_define_method(mrb, fixnum,  "eql?",     fix_eql,           MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */
-  mrb_define_method(mrb, fixnum,  "hash",     flo_hash,          MRB_ARGS_NONE()); /* 15.2.8.3.18 */
-  mrb_define_method(mrb, fixnum,  "to_f",     fix_to_f,          MRB_ARGS_NONE()); /* 15.2.8.3.23 */
-  mrb_define_method(mrb, fixnum,  "to_s",     fix_to_s,          MRB_ARGS_NONE()); /* 15.2.8.3.25 */
-  mrb_define_method(mrb, fixnum,  "inspect",  fix_to_s,          MRB_ARGS_NONE());
-  mrb_define_method(mrb, fixnum,  "divmod",   fix_divmod,        MRB_ARGS_REQ(1)); /* 15.2.8.3.30 (x) */
+  mrb_define_method(mrb, fixnum,  "+",        fix_plus,        MRB_ARGS_REQ(1)); /* 15.2.8.3.1  */
+  mrb_define_method(mrb, fixnum,  "-",        fix_minus,       MRB_ARGS_REQ(1)); /* 15.2.8.3.2  */
+  mrb_define_method(mrb, fixnum,  "*",        fix_mul,         MRB_ARGS_REQ(1)); /* 15.2.8.3.3  */
+  mrb_define_method(mrb, fixnum,  "%",        fix_mod,         MRB_ARGS_REQ(1)); /* 15.2.8.3.5  */
+  mrb_define_method(mrb, fixnum,  "==",       fix_equal,       MRB_ARGS_REQ(1)); /* 15.2.8.3.7  */
+  mrb_define_method(mrb, fixnum,  "~",        fix_rev,         MRB_ARGS_NONE()); /* 15.2.8.3.8  */
+  mrb_define_method(mrb, fixnum,  "&",        fix_and,         MRB_ARGS_REQ(1)); /* 15.2.8.3.9  */
+  mrb_define_method(mrb, fixnum,  "|",        fix_or,          MRB_ARGS_REQ(1)); /* 15.2.8.3.10 */
+  mrb_define_method(mrb, fixnum,  "^",        fix_xor,         MRB_ARGS_REQ(1)); /* 15.2.8.3.11 */
+  mrb_define_method(mrb, fixnum,  "<<",       fix_lshift,      MRB_ARGS_REQ(1)); /* 15.2.8.3.12 */
+  mrb_define_method(mrb, fixnum,  ">>",       fix_rshift,      MRB_ARGS_REQ(1)); /* 15.2.8.3.13 */
+  mrb_define_method(mrb, fixnum,  "eql?",     fix_eql,         MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */
+  mrb_define_method(mrb, fixnum,  "hash",     flo_hash,        MRB_ARGS_NONE()); /* 15.2.8.3.18 */
+  mrb_define_method(mrb, fixnum,  "to_f",     fix_to_f,        MRB_ARGS_NONE()); /* 15.2.8.3.23 */
+  mrb_define_method(mrb, fixnum,  "to_s",     fix_to_s,        MRB_ARGS_NONE()); /* 15.2.8.3.25 */
+  mrb_define_method(mrb, fixnum,  "inspect",  fix_to_s,        MRB_ARGS_NONE());
+  mrb_define_method(mrb, fixnum,  "divmod",   fix_divmod,      MRB_ARGS_REQ(1)); /* 15.2.8.3.30 (x) */
 
   /* Float Class */
   mrb->float_class = fl = mrb_define_class(mrb, "Float", numeric);                 /* 15.2.9 */
+  MRB_SET_INSTANCE_TT(fl, MRB_TT_FLOAT);
   mrb_undef_class_method(mrb,  fl, "new");
-  mrb_define_method(mrb, fl,      "+",         flo_plus,         MRB_ARGS_REQ(1)); /* 15.2.9.3.1  */
-  mrb_define_method(mrb, fl,      "-",         flo_minus,        MRB_ARGS_REQ(1)); /* 15.2.9.3.2  */
-  mrb_define_method(mrb, fl,      "*",         flo_mul,          MRB_ARGS_REQ(1)); /* 15.2.9.3.3  */
-  mrb_define_method(mrb, fl,      "%",         flo_mod,          MRB_ARGS_REQ(1)); /* 15.2.9.3.5  */
-  mrb_define_method(mrb, fl,      "==",        flo_eq,           MRB_ARGS_REQ(1)); /* 15.2.9.3.7  */
-  mrb_define_method(mrb, fl,      "ceil",      flo_ceil,         MRB_ARGS_NONE()); /* 15.2.9.3.8  */
-  mrb_define_method(mrb, fl,      "finite?",   flo_finite_p,     MRB_ARGS_NONE()); /* 15.2.9.3.9  */
-  mrb_define_method(mrb, fl,      "floor",     flo_floor,        MRB_ARGS_NONE()); /* 15.2.9.3.10 */
-  mrb_define_method(mrb, fl,      "infinite?", flo_infinite_p,   MRB_ARGS_NONE()); /* 15.2.9.3.11 */
-  mrb_define_method(mrb, fl,      "round",     flo_round,        MRB_ARGS_OPT(1)); /* 15.2.9.3.12 */
-  mrb_define_method(mrb, fl,      "to_f",      flo_to_f,         MRB_ARGS_NONE()); /* 15.2.9.3.13 */
-  mrb_define_method(mrb, fl,      "to_i",      flo_truncate,     MRB_ARGS_NONE()); /* 15.2.9.3.14 */
-  mrb_define_method(mrb, fl,      "to_int",    flo_truncate,     MRB_ARGS_NONE());
-  mrb_define_method(mrb, fl,      "truncate",  flo_truncate,     MRB_ARGS_NONE()); /* 15.2.9.3.15 */
-  mrb_define_method(mrb, fl,      "divmod",    flo_divmod,       MRB_ARGS_REQ(1));
-  mrb_define_method(mrb, fl,      "eql?",      flo_eql,          MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */
-
-  mrb_define_method(mrb, fl,      "to_s",      flo_to_s,         MRB_ARGS_NONE()); /* 15.2.9.3.16(x) */
-  mrb_define_method(mrb, fl,      "inspect",   flo_to_s,         MRB_ARGS_NONE());
-  mrb_define_method(mrb, fl,      "nan?",      flo_nan_p,        MRB_ARGS_NONE());
+  mrb_define_method(mrb, fl,      "+",         flo_plus,       MRB_ARGS_REQ(1)); /* 15.2.9.3.1  */
+  mrb_define_method(mrb, fl,      "-",         flo_minus,      MRB_ARGS_REQ(1)); /* 15.2.9.3.2  */
+  mrb_define_method(mrb, fl,      "*",         flo_mul,        MRB_ARGS_REQ(1)); /* 15.2.9.3.3  */
+  mrb_define_method(mrb, fl,      "%",         flo_mod,        MRB_ARGS_REQ(1)); /* 15.2.9.3.5  */
+  mrb_define_method(mrb, fl,      "==",        flo_eq,         MRB_ARGS_REQ(1)); /* 15.2.9.3.7  */
+  mrb_define_method(mrb, fl,      "~",         flo_rev,        MRB_ARGS_NONE());
+  mrb_define_method(mrb, fl,      "&",         flo_and,        MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, fl,      "|",         flo_or,         MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, fl,      "^",         flo_xor,        MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, fl,      ">>",        flo_lshift,     MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, fl,      "<<",        flo_rshift,     MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, fl,      "ceil",      flo_ceil,       MRB_ARGS_NONE()); /* 15.2.9.3.8  */
+  mrb_define_method(mrb, fl,      "finite?",   flo_finite_p,   MRB_ARGS_NONE()); /* 15.2.9.3.9  */
+  mrb_define_method(mrb, fl,      "floor",     flo_floor,      MRB_ARGS_NONE()); /* 15.2.9.3.10 */
+  mrb_define_method(mrb, fl,      "infinite?", flo_infinite_p, MRB_ARGS_NONE()); /* 15.2.9.3.11 */
+  mrb_define_method(mrb, fl,      "round",     flo_round,      MRB_ARGS_OPT(1)); /* 15.2.9.3.12 */
+  mrb_define_method(mrb, fl,      "to_f",      flo_to_f,       MRB_ARGS_NONE()); /* 15.2.9.3.13 */
+  mrb_define_method(mrb, fl,      "to_i",      flo_truncate,   MRB_ARGS_NONE()); /* 15.2.9.3.14 */
+  mrb_define_method(mrb, fl,      "to_int",    flo_truncate,   MRB_ARGS_NONE());
+  mrb_define_method(mrb, fl,      "truncate",  flo_truncate,   MRB_ARGS_NONE()); /* 15.2.9.3.15 */
+  mrb_define_method(mrb, fl,      "divmod",    flo_divmod,     MRB_ARGS_REQ(1));
+  mrb_define_method(mrb, fl,      "eql?",      flo_eql,        MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */
+
+  mrb_define_method(mrb, fl,      "to_s",      flo_to_s,       MRB_ARGS_NONE()); /* 15.2.9.3.16(x) */
+  mrb_define_method(mrb, fl,      "inspect",   flo_to_s,       MRB_ARGS_NONE());
+  mrb_define_method(mrb, fl,      "nan?",      flo_nan_p,      MRB_ARGS_NONE());
 
 #ifdef INFINITY
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/object.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/object.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/object.c	(revision 331)
@@ -5,8 +5,9 @@
 */
 
-#include "mruby.h"
-#include "mruby/class.h"
-#include "mruby/numeric.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/numeric.h>
+#include <mruby/string.h>
+#include <mruby/class.h>
 
 MRB_API mrb_bool
@@ -266,4 +267,5 @@
 
   mrb->nil_class   = n = mrb_define_class(mrb, "NilClass",   mrb->object_class);
+  MRB_SET_INSTANCE_TT(n, MRB_TT_TRUE);
   mrb_undef_class_method(mrb, n, "new");
   mrb_define_method(mrb, n, "&",    false_and,      MRB_ARGS_REQ(1));  /* 15.2.4.3.1  */
@@ -275,4 +277,5 @@
 
   mrb->true_class  = t = mrb_define_class(mrb, "TrueClass",  mrb->object_class);
+  MRB_SET_INSTANCE_TT(t, MRB_TT_TRUE);
   mrb_undef_class_method(mrb, t, "new");
   mrb_define_method(mrb, t, "&",    true_and,       MRB_ARGS_REQ(1));  /* 15.2.5.3.1  */
@@ -283,4 +286,5 @@
 
   mrb->false_class = f = mrb_define_class(mrb, "FalseClass", mrb->object_class);
+  MRB_SET_INSTANCE_TT(f, MRB_TT_TRUE);
   mrb_undef_class_method(mrb, f, "new");
   mrb_define_method(mrb, f, "&",    false_and,      MRB_ARGS_REQ(1));  /* 15.2.6.3.1  */
@@ -349,5 +353,5 @@
   mrb_value v;
 
-  if (mrb_type(val) == type && type != MRB_TT_DATA) return val;
+  if (mrb_type(val) == type && type != MRB_TT_DATA && type != MRB_TT_ISTRUCT) return val;
   v = convert_type(mrb, val, tname, method, FALSE);
   if (mrb_nil_p(v) || mrb_type(v) != type) return mrb_nil_value();
@@ -381,5 +385,5 @@
 /*    {MRB_TT_NODE,  "Node"}, */ /* internal use: syntax tree node */
 /*    {MRB_TT_UNDEF,  "undef"}, */ /* internal use: #undef; should not happen */
-    {-1,  0}
+  {MRB_TT_MAXDEFINE,  0}
 };
 
@@ -391,5 +395,5 @@
 
   xt = mrb_type(x);
-  if ((xt != t) || (xt == MRB_TT_DATA)) {
+  if ((xt != t) || (xt == MRB_TT_DATA) || (xt == MRB_TT_ISTRUCT)) {
     while (type->type < MRB_TT_MAXDEFINE) {
       if (type->type == t) {
@@ -441,5 +445,5 @@
   mrb_str_cat_cstr(mrb, str, cname);
   mrb_str_cat_lit(mrb, str, ":");
-  mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_cptr(obj)));
+  mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
   mrb_str_cat_lit(mrb, str, ">");
 
@@ -482,4 +486,5 @@
     case MRB_TT_CLASS:
     case MRB_TT_ICLASS:
+    case MRB_TT_SCLASS:
       break;
 
@@ -530,6 +535,9 @@
     case MRB_TT_FLOAT:
       if (base != 0) goto arg_error;
-      if (FIXABLE(mrb_float(val))) {
-        break;
+      else {
+        mrb_float f = mrb_float(val);
+        if (FIXABLE_FLOAT(f)) {
+          break;
+        }
       }
       return mrb_flo_to_fixnum(mrb, val);
@@ -549,4 +557,5 @@
     tmp = mrb_check_string_type(mrb, val);
     if (!mrb_nil_p(tmp)) {
+      val = tmp;
       goto string_conv;
     }
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/opcode.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/opcode.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/opcode.h	(revision 331)
@@ -1,2 +1,2 @@
 /* this header file is to be removed soon. */
-#include "mruby/opcode.h"
+#include <mruby/opcode.h>
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/pool.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/pool.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/pool.c	(revision 331)
@@ -8,5 +8,5 @@
 #include <stdint.h>
 #include <string.h>
-#include "mruby.h"
+#include <mruby.h>
 
 /* configuration section */
@@ -14,5 +14,9 @@
 /* or undef it if alignment does not matter */
 #ifndef POOL_ALIGNMENT
+#if INTPTR_MAX == INT64_MAX
+#define POOL_ALIGNMENT 8
+#else
 #define POOL_ALIGNMENT 4
+#endif
 #endif
 /* page size of memory pool */
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/print.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/print.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/print.c	(revision 331)
@@ -5,7 +5,7 @@
 */
 
-#include "mruby.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
+#include <mruby.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
 
 #ifndef MRB_DISABLE_STDIO
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/proc.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/proc.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/proc.c	(revision 331)
@@ -5,8 +5,8 @@
 */
 
-#include "mruby.h"
-#include "mruby/class.h"
-#include "mruby/proc.h"
-#include "mruby/opcode.h"
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/proc.h>
+#include <mruby/opcode.h>
 
 static mrb_code call_iseq[] = {
@@ -42,5 +42,5 @@
   e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, (struct RClass*)mrb->c->ci->proc->env);
   MRB_SET_ENV_STACK_LEN(e, nlocals);
-  e->mid = mrb->c->ci->mid;
+  e->cxt.c = mrb->c;
   e->cioff = mrb->c->ci - mrb->c->cibase;
   e->stack = mrb->c->stack;
@@ -62,4 +62,5 @@
   }
   p->env = e;
+  mrb_field_write_barrier(mrb, (struct RBasic *)p, (struct RBasic *)p->env);
 }
 
@@ -136,10 +137,10 @@
 }
 
-MRB_API void
+void
 mrb_proc_copy(struct RProc *a, struct RProc *b)
 {
   a->flags = b->flags;
   a->body = b->body;
-  if (!MRB_PROC_CFUNC_P(a)) {
+  if (!MRB_PROC_CFUNC_P(a) && a->body.irep) {
     a->body.irep->refcnt++;
   }
@@ -149,7 +150,9 @@
 
 static mrb_value
-mrb_proc_initialize(mrb_state *mrb, mrb_value self)
+mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
 {
   mrb_value blk;
+  mrb_value proc;
+  struct RProc *p;
 
   mrb_get_args(mrb, "&", &blk);
@@ -158,8 +161,9 @@
     mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Proc object without a block");
   }
-  else {
-    mrb_proc_copy(mrb_proc_ptr(self), mrb_proc_ptr(blk));
-  }
-  return self;
+  p = (struct RProc *)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb_class_ptr(proc_class));
+  mrb_proc_copy(p, mrb_proc_ptr(blk));
+  proc = mrb_obj_value(p);
+  mrb_funcall_with_block(mrb, proc, mrb_intern_lit(mrb, "initialize"), 0, NULL, blk);
+  return proc;
 }
 
@@ -189,10 +193,4 @@
 }
 
-mrb_code*
-mrb_proc_iseq(mrb_state *mrb, struct RProc *p)
-{
-  return p->body.irep->iseq;
-}
-
 /* 15.2.17.4.2 */
 static mrb_value
@@ -200,5 +198,6 @@
 {
   struct RProc *p = mrb_proc_ptr(self);
-  mrb_code *iseq = mrb_proc_iseq(mrb, p);
+  struct mrb_irep *irep;
+  mrb_code *iseq;
   mrb_aspec aspec;
   int ma, op, ra, pa, arity;
@@ -209,4 +208,10 @@
   }
 
+  irep = p->body.irep;
+  if (!irep) {
+    return mrb_fixnum_value(0);
+  }
+
+  iseq = irep->iseq;
   /* arity is depend on OP_ENTER */
   if (GET_OPCODE(*iseq) != OP_ENTER) {
@@ -267,6 +272,7 @@
   call_irep->iseq = call_iseq;
   call_irep->ilen = 1;
-
-  mrb_define_method(mrb, mrb->proc_class, "initialize", mrb_proc_initialize, MRB_ARGS_NONE());
+  call_irep->nregs = 2;         /* receiver and block */
+
+  mrb_define_class_method(mrb, mrb->proc_class, "new", mrb_proc_s_new, MRB_ARGS_ANY());
   mrb_define_method(mrb, mrb->proc_class, "initialize_copy", mrb_proc_init_copy, MRB_ARGS_REQ(1));
   mrb_define_method(mrb, mrb->proc_class, "arity", mrb_proc_arity, MRB_ARGS_NONE());
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/range.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/range.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/range.c	(revision 331)
@@ -5,11 +5,22 @@
 */
 
-#include "mruby.h"
-#include "mruby/class.h"
-#include "mruby/range.h"
-#include "mruby/string.h"
-#include "mruby/array.h"
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/range.h>
+#include <mruby/string.h>
+#include <mruby/array.h>
 
 #define RANGE_CLASS (mrb_class_get(mrb, "Range"))
+
+MRB_API struct RRange*
+mrb_range_ptr(mrb_state *mrb, mrb_value v)
+{
+  struct RRange *r = (struct RRange*)mrb_ptr(v);
+
+  if (r->edges == NULL) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "uninitialized range");
+  }
+  return r;
+}
 
 static void
@@ -58,5 +69,5 @@
 mrb_range_beg(mrb_state *mrb, mrb_value range)
 {
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
 
   return r->edges->beg;
@@ -77,5 +88,5 @@
 mrb_range_end(mrb_state *mrb, mrb_value range)
 {
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
 
   return r->edges->end;
@@ -91,5 +102,5 @@
 mrb_range_excl(mrb_state *mrb, mrb_value range)
 {
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
 
   return mrb_bool_value(r->excl);
@@ -99,5 +110,5 @@
 range_init(mrb_state *mrb, mrb_value range, mrb_value beg, mrb_value end, mrb_bool exclude_end)
 {
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_raw_ptr(range);
 
   range_check(mrb, beg, end);
@@ -130,4 +141,7 @@
   }
   /* Ranges are immutable, so that they should be initialized only once. */
+  if (mrb_range_raw_ptr(range)->edges) {
+    mrb_name_error(mrb, mrb_intern_lit(mrb, "initialize"), "`initialize' called twice");
+  }
   range_init(mrb, range, beg, end, exclusive);
   return range;
@@ -153,5 +167,5 @@
   struct RRange *rr;
   struct RRange *ro;
-  mrb_value obj;
+  mrb_value obj, v1, v2;
 
   mrb_get_args(mrb, "o", &obj);
@@ -162,9 +176,9 @@
   }
 
-  rr = mrb_range_ptr(range);
-  ro = mrb_range_ptr(obj);
-  if (!mrb_bool(mrb_funcall(mrb, rr->edges->beg, "==", 1, ro->edges->beg)) ||
-      !mrb_bool(mrb_funcall(mrb, rr->edges->end, "==", 1, ro->edges->end)) ||
-      rr->excl != ro->excl) {
+  rr = mrb_range_ptr(mrb, range);
+  ro = mrb_range_ptr(mrb, obj);
+  v1 = mrb_funcall(mrb, rr->edges->beg, "==", 1, ro->edges->beg);
+  v2 = mrb_funcall(mrb, rr->edges->end, "==", 1, ro->edges->end);
+  if (!mrb_bool(v1) || !mrb_bool(v2) || rr->excl != ro->excl) {
     return mrb_false_value();
   }
@@ -220,5 +234,5 @@
 {
   mrb_value val;
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
   mrb_value beg, end;
   mrb_bool include_p;
@@ -228,18 +242,19 @@
   beg = r->edges->beg;
   end = r->edges->end;
-  include_p = r_le(mrb, beg, val) && /* beg <= val */
-              ((r->excl && r_gt(mrb, end, val)) || /* end >  val */
-              (r_ge(mrb, end, val))); /* end >= val */
+  include_p = r_le(mrb, beg, val) &&           /* beg <= val */
+              (r->excl ? r_gt(mrb, end, val)   /* end >  val */
+                       : r_ge(mrb, end, val)); /* end >= val */
 
   return mrb_bool_value(include_p);
 }
 
-static mrb_bool
-range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc)
+MRB_API mrb_int
+mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc)
 {
   mrb_int beg, end;
-  struct RRange *r = mrb_range_ptr(range);
-
-  if (mrb_type(range) != MRB_TT_RANGE) return FALSE;
+  struct RRange *r;
+
+  if (mrb_type(range) != MRB_TT_RANGE) return 0;
+  r = mrb_range_ptr(mrb, range);
 
   beg = mrb_int(mrb, r->edges->beg);
@@ -248,9 +263,9 @@
   if (beg < 0) {
     beg += len;
-    if (beg < 0) return FALSE;
+    if (beg < 0) return 2;
   }
 
   if (trunc) {
-    if (beg > len) return FALSE;
+    if (beg > len) return 2;
     if (end > len) end = len;
   }
@@ -264,11 +279,5 @@
   *begp = beg;
   *lenp = len;
-  return TRUE;
-}
-
-MRB_API mrb_bool
-mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len)
-{
-  return range_beg_len(mrb, range, begp, lenp, len, TRUE);
+  return 1;
 }
 
@@ -285,5 +294,5 @@
 {
   mrb_value str, str2;
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
 
   str  = mrb_obj_as_string(mrb, r->edges->beg);
@@ -310,5 +319,5 @@
 {
   mrb_value str, str2;
-  struct RRange *r = mrb_range_ptr(range);
+  struct RRange *r = mrb_range_ptr(mrb, range);
 
   str  = mrb_inspect(mrb, r->edges->beg);
@@ -350,6 +359,6 @@
   if (mrb_type(obj) != MRB_TT_RANGE) return mrb_false_value();
 
-  r = mrb_range_ptr(range);
-  o = mrb_range_ptr(obj);
+  r = mrb_range_ptr(mrb, range);
+  o = mrb_range_ptr(mrb, obj);
   if (!mrb_eql(mrb, r->edges->beg, o->edges->beg) ||
       !mrb_eql(mrb, r->edges->end, o->edges->end) ||
@@ -374,5 +383,5 @@
   }
 
-  r = mrb_range_ptr(src);
+  r = mrb_range_ptr(mrb, src);
   range_init(mrb, copy, r->edges->beg, r->edges->end, r->excl);
 
@@ -391,5 +400,5 @@
       mrb_ary_push(mrb, result, func(mrb, obj, mrb_fixnum(argv[i])));
     }
-    else if (range_beg_len(mrb, argv[i], &beg, &len, olen, FALSE)) {
+    else if (mrb_range_beg_len(mrb, argv[i], &beg, &len, olen, FALSE) == 1) {
       mrb_int const end = olen < beg + len ? olen : beg + len;
       for (j = beg; j < end; ++j) {
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/state.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/state.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/state.c	(revision 331)
@@ -7,9 +7,9 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/irep.h"
-#include "mruby/variable.h"
-#include "mruby/debug.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/irep.h>
+#include <mruby/variable.h>
+#include <mruby/debug.h>
+#include <mruby/string.h>
 
 void mrb_init_core(mrb_state*);
@@ -142,5 +142,5 @@
   if (!(irep->flags & MRB_ISEQ_NO_FREE))
     mrb_free(mrb, irep->iseq);
-  for (i=0; i<irep->plen; i++) {
+  if (irep->pool) for (i=0; i<irep->plen; i++) {
     if (mrb_type(irep->pool[i]) == MRB_TT_STRING) {
       mrb_gc_free_str(mrb, RSTRING(irep->pool[i]));
@@ -160,5 +160,7 @@
   mrb_free(mrb, irep->reps);
   mrb_free(mrb, irep->lv);
-  mrb_free(mrb, (void *)irep->filename);
+  if (irep->own_filename) {
+    mrb_free(mrb, (void *)irep->filename);
+  }
   mrb_free(mrb, irep->lines);
   mrb_debug_info_free(mrb, irep->debug_info);
@@ -216,4 +218,6 @@
 }
 
+void mrb_free_backtrace(mrb_state *mrb);
+
 MRB_API void
 mrb_free_context(mrb_state *mrb, struct mrb_context *c)
@@ -259,4 +263,5 @@
   *irep = mrb_irep_zero;
   irep->refcnt = 1;
+  irep->own_filename = FALSE;
 
   return irep;
@@ -287,5 +292,6 @@
   if (mrb->atexit_stack_len == 0) {
     mrb->atexit_stack = (mrb_atexit_func*)mrb_malloc(mrb, stack_size);
-  } else {
+  }
+  else {
     mrb->atexit_stack = (mrb_atexit_func*)mrb_realloc(mrb, mrb->atexit_stack, stack_size);
   }
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/string.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/string.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/string.c	(revision 331)
@@ -4,4 +4,8 @@
 ** See Copyright Notice in mruby.h
 */
+
+#ifdef _MSC_VER
+# define _CRT_NONSTDC_NO_DEPRECATE
+#endif
 
 #include <float.h>
@@ -10,10 +14,10 @@
 #include <stdlib.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/range.h"
-#include "mruby/string.h"
-#include "mruby/re.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/range.h>
+#include <mruby/string.h>
+#include <mruby/re.h>
 
 typedef struct mrb_shared_string {
@@ -60,5 +64,6 @@
       memcpy(s->as.ary, p, len);
     }
-  } else {
+  }
+  else {
     if (len >= MRB_INT_MAX) {
       mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
@@ -115,7 +120,10 @@
 }
 
-static inline void
-resize_capa(mrb_state *mrb, struct RString *s, mrb_int capacity)
-{
+static void
+resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
+{
+#if SIZE_MAX > MRB_INT_MAX
+    mrb_assert(capacity < MRB_INT_MAX);
+#endif
   if (RSTR_EMBED_P(s)) {
     if (RSTRING_EMBED_LEN_MAX < capacity) {
@@ -126,10 +134,10 @@
       s->as.heap.ptr = tmp;
       s->as.heap.len = len;
-      s->as.heap.aux.capa = capacity;
+      s->as.heap.aux.capa = (mrb_int)capacity;
     }
   }
   else {
-    s->as.heap.ptr = (char *)mrb_realloc(mrb, RSTR_PTR(s), capacity+1);
-    s->as.heap.aux.capa = capacity;
+    s->as.heap.ptr = (char*)mrb_realloc(mrb, RSTR_PTR(s), capacity+1);
+    s->as.heap.aux.capa = (mrb_int)capacity;
   }
 }
@@ -148,20 +156,24 @@
   }
 
-  if (RSTR_EMBED_P(s))
-    capa = RSTRING_EMBED_LEN_MAX;
-  else
-    capa = s->as.heap.aux.capa;
-
-  if (RSTR_LEN(s) >= MRB_INT_MAX - (mrb_int)len) {
+  capa = RSTR_CAPA(s);
+  if (capa <= RSTRING_EMBED_LEN_MAX)
+    capa = RSTRING_EMBED_LEN_MAX+1;
+
+  total = RSTR_LEN(s)+len;
+  if (total >= MRB_INT_MAX) {
+  size_error:
     mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
   }
-  total = RSTR_LEN(s)+len;
   if (capa <= total) {
     while (total > capa) {
-      if (capa + 1 >= MRB_INT_MAX / 2) {
-        capa = (total + 4095) / 4096;
-        break;
-      }
-      capa = (capa + 1) * 2;
+      if (capa <= MRB_INT_MAX / 2) {
+        capa *= 2;
+      }
+      else {
+        capa = total;
+      }
+    }
+    if (capa < total || capa > MRB_INT_MAX) {
+      goto size_error;
     }
     resize_capa(mrb, s, capa);
@@ -270,4 +282,7 @@
   char* p = RSTRING_PTR(str);
   char* e = p;
+  if (RSTRING(str)->flags & MRB_STR_NO_UTF) {
+    return RSTRING_LEN(str);
+  }
   e += len < 0 ? RSTRING_LEN(str) : len;
   while (p<e) {
@@ -275,4 +290,7 @@
     total++;
   }
+  if (RSTRING_LEN(str) == total) {
+    RSTRING(str)->flags |= MRB_STR_NO_UTF;
+  }
   return total;
 }
@@ -303,15 +321,18 @@
 
   for (b=i=0; b<bi; i++) {
-    n = utf8len(p, p+bi);
+    n = utf8len_codepage[(unsigned char)*p];
     b += n;
     p += n;
   }
+  if (b != bi) return -1;
   return i;
 }
 
+#define BYTES_ALIGN_CHECK(pos) if (pos < 0) return mrb_nil_value();
 #else
 #define RSTRING_CHAR_LEN(s) RSTRING_LEN(s)
 #define chars2bytes(p, off, ci) (ci)
 #define bytes2chars(p, bi) (bi)
+#define BYTES_ALIGN_CHECK(pos)
 #endif
 
@@ -349,10 +370,10 @@
   }
   else if (m == 1) {
-    const unsigned char *ys = y, *ye = ys + n;
-    for (; y < ye; ++y) {
-      if (*x == *y)
-        return y - ys;
-    }
-    return -1;
+    const unsigned char *ys = (const unsigned char *)memchr(y, *x, n);
+
+    if (ys)
+      return ys - y;
+    else
+      return -1;
   }
   return mrb_memsearch_qs((const unsigned char *)x0, m, (const unsigned char *)y0, n);
@@ -404,5 +425,5 @@
 
   orig = mrb_str_ptr(str);
-  if (RSTR_EMBED_P(orig)) {
+  if (RSTR_EMBED_P(orig) || RSTR_LEN(orig) == 0) {
     s = str_new(mrb, orig->as.ary+beg, len);
   }
@@ -450,5 +471,5 @@
     if (beg < 0) return mrb_nil_value();
   }
-  if (beg + len > clen)
+  if (len > clen - beg)
     len = clen - beg;
   if (len <= 0) {
@@ -489,5 +510,5 @@
 check_frozen(mrb_state *mrb, struct RString *s)
 {
-  if (RSTR_FROZEN_P(s)) {
+  if (MRB_FROZEN_P(s)) {
     mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen string");
   }
@@ -500,4 +521,7 @@
 
   check_frozen(mrb, s1);
+  if (s1 == s2) return mrb_obj_value(s1);
+  s1->flags &= ~MRB_STR_NO_UTF;
+  s1->flags |= s2->flags&MRB_STR_NO_UTF;
   len = RSTR_LEN(s2);
   if (RSTR_SHARED_P(s1)) {
@@ -646,8 +670,9 @@
 {
   check_frozen(mrb, s);
+  s->flags &= ~MRB_STR_NO_UTF;
   if (RSTR_SHARED_P(s)) {
     mrb_shared_string *shared = s->as.heap.aux.shared;
 
-    if (shared->refcnt == 1 && s->as.heap.ptr == shared->ptr) {
+    if (shared->nofree == 0 && shared->refcnt == 1 && s->as.heap.ptr == shared->ptr) {
       s->as.heap.ptr = shared->ptr;
       s->as.heap.aux.capa = shared->len;
@@ -661,11 +686,18 @@
       p = RSTR_PTR(s);
       len = s->as.heap.len;
-      ptr = (char *)mrb_malloc(mrb, (size_t)len + 1);
+      if (len < RSTRING_EMBED_LEN_MAX) {
+        RSTR_SET_EMBED_FLAG(s);
+        RSTR_SET_EMBED_LEN(s, len);
+        ptr = RSTR_PTR(s);
+      }
+      else {
+        ptr = (char *)mrb_malloc(mrb, (size_t)len + 1);
+        s->as.heap.ptr = ptr;
+        s->as.heap.aux.capa = len;
+      }
       if (p) {
         memcpy(ptr, p, len);
       }
       ptr[len] = '\0';
-      s->as.heap.ptr = ptr;
-      s->as.heap.aux.capa = len;
       str_decref(mrb, shared);
     }
@@ -675,23 +707,21 @@
   if (RSTR_NOFREE_P(s)) {
     char *p = s->as.heap.ptr;
-
-    s->as.heap.ptr = (char *)mrb_malloc(mrb, (size_t)s->as.heap.len+1);
+    mrb_int len = s->as.heap.len;
+
+    RSTR_UNSET_NOFREE_FLAG(s);
+    if (len < RSTRING_EMBED_LEN_MAX) {
+      RSTR_SET_EMBED_FLAG(s);
+      RSTR_SET_EMBED_LEN(s, len);
+    }
+    else {
+      s->as.heap.ptr = (char *)mrb_malloc(mrb, (size_t)len+1);
+      s->as.heap.aux.capa = len;
+    }
     if (p) {
-      memcpy(RSTR_PTR(s), p, s->as.heap.len);
-    }
-    RSTR_PTR(s)[s->as.heap.len] = '\0';
-    s->as.heap.aux.capa = s->as.heap.len;
-    RSTR_UNSET_NOFREE_FLAG(s);
+      memcpy(RSTR_PTR(s), p, len);
+    }
+    RSTR_PTR(s)[len] = '\0';
     return;
   }
-}
-
-static mrb_value
-mrb_str_freeze(mrb_state *mrb, mrb_value str)
-{
-  struct RString *s = mrb_str_ptr(str);
-
-  RSTR_SET_FROZEN_FLAG(s);
-  return str;
 }
 
@@ -747,6 +777,12 @@
   }
   s2 = mrb_str_ptr(other);
+  if (RSTR_LEN(s2) == 0) {
+    return;
+  }
   len = RSTR_LEN(s1) + RSTR_LEN(s2);
 
+  if (len < 0 || len >= MRB_INT_MAX) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
+  }
   if (RSTRING_CAPA(self) < len) {
     resize_capa(mrb, s1, len);
@@ -932,6 +968,6 @@
       mrb_value tmp = mrb_funcall(mrb, str2, "<=>", 1, str1);
 
-      if (mrb_nil_p(tmp)) return mrb_nil_value();
-      if (!mrb_fixnum(tmp)) {
+      if (!mrb_nil_p(tmp)) return mrb_nil_value();
+      if (!mrb_fixnum_p(tmp)) {
         return mrb_funcall(mrb, mrb_fixnum_value(0), "-", 1, tmp);
       }
@@ -1014,4 +1050,11 @@
 }
 
+MRB_API mrb_int
+mrb_string_value_len(mrb_state *mrb, mrb_value ptr)
+{
+  mrb_value str = mrb_str_to_str(mrb, ptr);
+  return RSTRING_LEN(str);
+}
+
 void
 mrb_noregexp(mrb_state *mrb, mrb_value self)
@@ -1059,20 +1102,23 @@
 
     case MRB_TT_RANGE:
-      /* check if indx is Range */
-      {
-        mrb_int beg, len;
-
-        len = RSTRING_CHAR_LEN(str);
-        if (mrb_range_beg_len(mrb, indx, &beg, &len, len)) {
-          return str_subseq(mrb, str, beg, len);
-        }
-        else {
-          return mrb_nil_value();
-        }
-      }
-    case MRB_TT_FLOAT:
+      goto range_arg;
+
     default:
       indx = mrb_Integer(mrb, indx);
       if (mrb_nil_p(indx)) {
+      range_arg:
+        {
+          mrb_int beg, len;
+
+          len = RSTRING_CHAR_LEN(str);
+          switch (mrb_range_beg_len(mrb, indx, &beg, &len, len, TRUE)) {
+          case 1:
+            return str_subseq(mrb, str, beg, len);
+          case 2:
+            return mrb_nil_value();
+          default:
+            break;
+          }
+        }
         mrb_raise(mrb, E_TYPE_ERROR, "can't convert to Fixnum");
       }
@@ -1131,6 +1177,9 @@
   argc = mrb_get_args(mrb, "o|o", &a1, &a2);
   if (argc == 2) {
+    mrb_int n1, n2;
+
     mrb_regexp_check(mrb, a1);
-    return str_substr(mrb, str, mrb_fixnum(a1), mrb_fixnum(a2));
+    mrb_get_args(mrb, "ii", &n1, &n2);
+    return str_substr(mrb, str, n1, n2);
   }
   if (argc != 1) {
@@ -1215,9 +1264,11 @@
   mrb_int rslen;
   mrb_int len;
+  mrb_int argc;
   struct RString *s = mrb_str_ptr(str);
 
   mrb_str_modify(mrb, s);
+  argc = mrb_get_args(mrb, "|S", &rs);
   len = RSTR_LEN(s);
-  if (mrb_get_args(mrb, "|S", &rs) == 0) {
+  if (argc == 0) {
     if (len == 0) return mrb_nil_value();
   smart_chomp:
@@ -1510,20 +1561,10 @@
 mrb_str_include(mrb_state *mrb, mrb_value self)
 {
-  mrb_int i;
   mrb_value str2;
-  mrb_bool include_p;
-
-  mrb_get_args(mrb, "o", &str2);
-  if (mrb_fixnum_p(str2)) {
-    include_p = (memchr(RSTRING_PTR(self), mrb_fixnum(str2), RSTRING_LEN(self)) != NULL);
-  }
-  else {
-    str2 = mrb_str_to_str(mrb, str2);
-    i = str_index(mrb, self, str2, 0);
-
-    include_p = (i != -1);
-  }
-
-  return mrb_bool_value(include_p);
+
+  mrb_get_args(mrb, "S", &str2);
+  if (str_index(mrb, self, str2, 0) < 0)
+    return mrb_bool_value(FALSE);
+  return mrb_bool_value(TRUE);
 }
 
@@ -1559,6 +1600,5 @@
   mrb_get_args(mrb, "*", &argv, &argc);
   if (argc == 2) {
-    pos = mrb_fixnum(argv[1]);
-    sub = argv[0];
+    mrb_get_args(mrb, "oi", &sub, &pos);
   }
   else {
@@ -1577,5 +1617,5 @@
     }
   }
-  if (pos >= clen) return mrb_nil_value();
+  if (pos > clen) return mrb_nil_value();
   pos = chars2bytes(str, 0, pos);
 
@@ -1598,4 +1638,5 @@
   if (pos == -1) return mrb_nil_value();
   pos = bytes2chars(RSTRING_PTR(str), pos);
+  BYTES_ALIGN_CHECK(pos);
   return mrb_fixnum_value(pos);
 }
@@ -1633,7 +1674,9 @@
   mrb_value str2;
 
-  if (mrb_get_args(mrb, "|S", &str2) == 1) {
-    str_replace(mrb, mrb_str_ptr(self), mrb_str_ptr(str2));
-  }
+  if (mrb_get_args(mrb, "|S", &str2) == 0) {
+    struct RString *s = str_new(mrb, 0, 0);
+    str2 = mrb_obj_value(s);
+  }
+  str_replace(mrb, mrb_str_ptr(self), mrb_str_ptr(str2));
   return self;
 }
@@ -1743,5 +1786,5 @@
     mrb_str_modify(mrb, mrb_str_ptr(str));
     len = RSTRING_LEN(str);
-    buf = mrb_malloc(mrb, (size_t)len);
+    buf = (char*)mrb_malloc(mrb, (size_t)len);
     p = buf;
     e = buf + len;
@@ -1824,12 +1867,9 @@
   mrb_int argc;
   mrb_value sub;
-  mrb_value vpos;
   mrb_int pos, len = RSTRING_CHAR_LEN(str);
 
   mrb_get_args(mrb, "*", &argv, &argc);
   if (argc == 2) {
-    sub = argv[0];
-    vpos = argv[1];
-    pos = mrb_fixnum(vpos);
+    mrb_get_args(mrb, "oi", &sub, &pos);
     if (pos < 0) {
       pos += len;
@@ -1849,5 +1889,4 @@
   }
   pos = chars2bytes(str, 0, pos);
-  len = chars2bytes(str, pos, len);
   mrb_regexp_check(mrb, sub);
 
@@ -1867,4 +1906,5 @@
       if (pos >= 0) {
         pos = bytes2chars(RSTRING_PTR(str), pos);
+        BYTES_ALIGN_CHECK(pos);
         return mrb_fixnum_value(pos);
       }
@@ -1922,8 +1962,9 @@
   mrb_value spat = mrb_nil_value();
   enum {awk, string, regexp} split_type = string;
-  long i = 0, lim_p;
+  mrb_int i = 0;
   mrb_int beg;
   mrb_int end;
   mrb_int lim = 0;
+  mrb_bool lim_p;
   mrb_value result, tmp;
 
@@ -1998,5 +2039,6 @@
         end = mrb_memsearch(RSTRING_PTR(spat), pat_len, RSTRING_PTR(str)+idx, str_len - idx);
         if (end < 0) break;
-      } else {
+      }
+      else {
         end = chars2bytes(str, idx, 1);
       }
@@ -2031,9 +2073,10 @@
 
 MRB_API mrb_value
-mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
-{
-  const char *p;
+mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int badcheck)
+{
+  const char *p = str;
+  const char *pend = str + len;
   char sign = 1;
-  int c, uscore;
+  int c;
   uint64_t n = 0;
   mrb_int val;
@@ -2045,24 +2088,21 @@
      -1)
 
-  if (!str) {
+  if (!p) {
     if (badcheck) goto bad;
     return mrb_fixnum_value(0);
   }
-  while (ISSPACE(*str)) str++;
-
-  if (str[0] == '+') {
-    str++;
-  }
-  else if (str[0] == '-') {
-    str++;
+  while (p<pend && ISSPACE(*p))
+    p++;
+
+  if (p[0] == '+') {
+    p++;
+  }
+  else if (p[0] == '-') {
+    p++;
     sign = 0;
   }
-  if (str[0] == '+' || str[0] == '-') {
-    if (badcheck) goto bad;
-    return mrb_fixnum_value(0);
-  }
   if (base <= 0) {
-    if (str[0] == '0') {
-      switch (str[1]) {
+    if (p[0] == '0') {
+      switch (p[1]) {
         case 'x': case 'X':
           base = 16;
@@ -2079,4 +2119,5 @@
         default:
           base = 8;
+          break;
       }
     }
@@ -2090,6 +2131,6 @@
   switch (base) {
     case 2:
-      if (str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) {
-        str += 2;
+      if (p[0] == '0' && (p[1] == 'b'||p[1] == 'B')) {
+        p += 2;
       }
       break;
@@ -2097,18 +2138,18 @@
       break;
     case 8:
-      if (str[0] == '0' && (str[1] == 'o'||str[1] == 'O')) {
-        str += 2;
+      if (p[0] == '0' && (p[1] == 'o'||p[1] == 'O')) {
+        p += 2;
       }
     case 4: case 5: case 6: case 7:
       break;
     case 10:
-      if (str[0] == '0' && (str[1] == 'd'||str[1] == 'D')) {
-        str += 2;
+      if (p[0] == '0' && (p[1] == 'd'||p[1] == 'D')) {
+        p += 2;
       }
     case 9: case 11: case 12: case 13: case 14: case 15:
       break;
     case 16:
-      if (str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) {
-        str += 2;
+      if (p[0] == '0' && (p[1] == 'x'||p[1] == 'X')) {
+        p += 2;
       }
       break;
@@ -2119,57 +2160,79 @@
       break;
   } /* end of switch (base) { */
-  if (*str == '0') {    /* squeeze preceding 0s */
-    uscore = 0;
-    while ((c = *++str) == '0' || c == '_') {
-      if (c == '_') {
-        if (++uscore >= 2)
-          break;
-      }
-      else
-        uscore = 0;
-    }
-    if (!(c = *str) || ISSPACE(c)) --str;
-  }
-  c = *str;
-  c = conv_digit(c);
-  if (c < 0 || c >= base) {
+  if (p>=pend) {
     if (badcheck) goto bad;
     return mrb_fixnum_value(0);
   }
-
-  uscore = 0;
-  for (p=str;*p;p++) {
+  if (*p == '0') {    /* squeeze preceding 0s */
+    p++;
+    while (p<pend) {
+      c = *p++;
+      if (c == '_') {
+        if (p<pend && *p == '_') {
+          if (badcheck) goto bad;
+          break;
+        }
+        continue;
+      }
+      if (c != '0') {
+        p--;
+        break;
+      }
+    }
+    if (*(p - 1) == '0')
+      p--;
+  }
+  if (p == pend) {
+    if (badcheck) goto bad;
+    return mrb_fixnum_value(0);
+  }
+  for ( ;p<pend;p++) {
     if (*p == '_') {
-      if (uscore == 0) {
-        uscore++;
+      p++;
+      if (p==pend) {
+        if (badcheck) goto bad;
         continue;
       }
-      if (badcheck) goto bad;
-      break;
-    }
-    uscore = 0;
+      if (*p == '_') {
+        if (badcheck) goto bad;
+        break;
+      }
+    }
+    if (badcheck && *p == '\0') {
+      goto nullbyte;
+    }
     c = conv_digit(*p);
     if (c < 0 || c >= base) {
-      if (badcheck) goto bad;
       break;
     }
     n *= base;
     n += c;
-    if (n > MRB_INT_MAX) {
-      mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer", mrb_str_new_cstr(mrb, str));
-    }
-  }
-  val = n;
+    if (n > (uint64_t)MRB_INT_MAX + (sign ? 0 : 1)) {
+      mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer",
+                 mrb_str_new(mrb, str, pend-str));
+    }
+  }
+  val = (mrb_int)n;
   if (badcheck) {
     if (p == str) goto bad; /* no number */
-    while (*p && ISSPACE(*p)) p++;
-    if (*p) goto bad;           /* trailing garbage */
+    while (p<pend && ISSPACE(*p)) p++;
+    if (p<pend) goto bad;       /* trailing garbage */
   }
 
   return mrb_fixnum_value(sign ? val : -val);
-bad:
-  mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid string for number(%S)", mrb_str_new_cstr(mrb, str));
+ nullbyte:
+  mrb_raise(mrb, E_ARGUMENT_ERROR, "string contains null byte");
+  /* not reached */
+ bad:
+  mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid string for number(%S)",
+             mrb_inspect(mrb, mrb_str_new(mrb, str, pend-str)));
   /* not reached */
   return mrb_fixnum_value(0);
+}
+
+MRB_API mrb_value
+mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
+{
+  return mrb_str_len_to_inum(mrb, str, strlen(str), base, badcheck);
 }
 
@@ -2183,4 +2246,8 @@
 
   if (!p || p[len] != '\0') {
+    if (MRB_FROZEN_P(ps)) {
+      *ptr = str = mrb_str_dup(mrb, str);
+      ps = mrb_str_ptr(str);
+    }
     mrb_str_modify(mrb, ps);
     return RSTR_PTR(ps);
@@ -2195,19 +2262,7 @@
   mrb_int len;
 
-  if (badcheck) {
-    /* Raises if the string contains a null character (the badcheck) */
-    s = mrb_string_value_cstr(mrb, &str);
-  }
-  else {
-    s = mrb_string_value_ptr(mrb, str);
-  }
-  if (s) {
-    len = RSTRING_LEN(str);
-    if (s[len]) {    /* no sentinel somehow */
-      struct RString *temp_str = str_new(mrb, s, len);
-      s = RSTR_PTR(temp_str);
-    }
-  }
-  return mrb_cstr_to_inum(mrb, s, base, badcheck);
+  s = mrb_string_value_ptr(mrb, str);
+  len = RSTRING_LEN(str);
+  return mrb_str_len_to_inum(mrb, s, len, base, badcheck);
 }
 
@@ -2260,5 +2315,5 @@
     return 0.0;
   }
-  d = strtod(p, &end);
+  d = mrb_float_read(p, &end);
   if (p == end) {
     if (badcheck) {
@@ -2298,5 +2353,5 @@
     }
 
-    d = strtod(p, &end);
+    d = mrb_float_read(p, &end);
     if (badcheck) {
       if (!end || p == end) goto bad;
@@ -2603,5 +2658,5 @@
 #endif
     c = *p;
-    if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) {
+    if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p+1, pend))) {
       buf[0] = '\\'; buf[1] = c;
       mrb_str_cat(mrb, result, buf, 2);
@@ -2689,6 +2744,6 @@
   mrb_define_method(mrb, s, "chomp",           mrb_str_chomp,           MRB_ARGS_ANY());  /* 15.2.10.5.9  */
   mrb_define_method(mrb, s, "chomp!",          mrb_str_chomp_bang,      MRB_ARGS_ANY());  /* 15.2.10.5.10 */
-  mrb_define_method(mrb, s, "chop",            mrb_str_chop,            MRB_ARGS_REQ(1)); /* 15.2.10.5.11 */
-  mrb_define_method(mrb, s, "chop!",           mrb_str_chop_bang,       MRB_ARGS_REQ(1)); /* 15.2.10.5.12 */
+  mrb_define_method(mrb, s, "chop",            mrb_str_chop,            MRB_ARGS_NONE()); /* 15.2.10.5.11 */
+  mrb_define_method(mrb, s, "chop!",           mrb_str_chop_bang,       MRB_ARGS_NONE()); /* 15.2.10.5.12 */
   mrb_define_method(mrb, s, "downcase",        mrb_str_downcase,        MRB_ARGS_NONE()); /* 15.2.10.5.13 */
   mrb_define_method(mrb, s, "downcase!",       mrb_str_downcase_bang,   MRB_ARGS_NONE()); /* 15.2.10.5.14 */
@@ -2720,5 +2775,248 @@
   mrb_define_method(mrb, s, "inspect",         mrb_str_inspect,         MRB_ARGS_NONE()); /* 15.2.10.5.46(x) */
   mrb_define_method(mrb, s, "bytes",           mrb_str_bytes,           MRB_ARGS_NONE());
-
-  mrb_define_method(mrb, s, "freeze",          mrb_str_freeze,          MRB_ARGS_NONE());
-}
+}
+
+/*
+ *	Source code for the "strtod" library procedure.
+ *
+ * Copyright (c) 1988-1993 The Regents of the University of California.
+ * Copyright (c) 1994 Sun Microsystems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * RCS: @(#) $Id$
+ */
+
+#include <ctype.h>
+#include <errno.h>
+
+static const int maxExponent = 511; /* Largest possible base 10 exponent.  Any
+                                     * exponent larger than this will already
+                                     * produce underflow or overflow, so there's
+                                     * no need to worry about additional digits.
+                                     */
+static const double powersOf10[] = {/* Table giving binary powers of 10.  Entry */
+    10.,                            /* is 10^2^i.  Used to convert decimal */
+    100.,			    /* exponents into floating-point numbers. */
+    1.0e4,
+    1.0e8,
+    1.0e16,
+    1.0e32,
+    1.0e64,
+    1.0e128,
+    1.0e256
+};
+
+MRB_API double
+mrb_float_read(const char *string, char **endPtr)
+/*  const char *string;		   A decimal ASCII floating-point number,
+				 * optionally preceded by white space.
+				 * Must have form "-I.FE-X", where I is the
+				 * integer part of the mantissa, F is the
+				 * fractional part of the mantissa, and X
+				 * is the exponent.  Either of the signs
+				 * may be "+", "-", or omitted.  Either I
+				 * or F may be omitted, or both.  The decimal
+				 * point isn't necessary unless F is present.
+				 * The "E" may actually be an "e".  E and X
+				 * may both be omitted (but not just one).
+				 */
+/*  char **endPtr;		   If non-NULL, store terminating character's
+				 * address here. */
+{
+    int sign, expSign = FALSE;
+    double fraction, dblExp;
+    const double *d;
+    register const char *p;
+    register int c;
+    int exp = 0;		/* Exponent read from "EX" field. */
+    int fracExp = 0;		/* Exponent that derives from the fractional
+				 * part.  Under normal circumstatnces, it is
+				 * the negative of the number of digits in F.
+				 * However, if I is very long, the last digits
+				 * of I get dropped (otherwise a long I with a
+				 * large negative exponent could cause an
+				 * unnecessary overflow on I alone).  In this
+				 * case, fracExp is incremented one for each
+				 * dropped digit. */
+    int mantSize;		/* Number of digits in mantissa. */
+    int decPt;			/* Number of mantissa digits BEFORE decimal
+				 * point. */
+    const char *pExp;		/* Temporarily holds location of exponent
+				 * in string. */
+
+    /*
+     * Strip off leading blanks and check for a sign.
+     */
+
+    p = string;
+    while (isspace(*p)) {
+	p += 1;
+    }
+    if (*p == '-') {
+	sign = TRUE;
+	p += 1;
+    }
+    else {
+	if (*p == '+') {
+	    p += 1;
+	}
+	sign = FALSE;
+    }
+
+    /*
+     * Count the number of digits in the mantissa (including the decimal
+     * point), and also locate the decimal point.
+     */
+
+    decPt = -1;
+    for (mantSize = 0; ; mantSize += 1)
+    {
+	c = *p;
+	if (!isdigit(c)) {
+	    if ((c != '.') || (decPt >= 0)) {
+		break;
+	    }
+	    decPt = mantSize;
+	}
+	p += 1;
+    }
+
+    /*
+     * Now suck up the digits in the mantissa.  Use two integers to
+     * collect 9 digits each (this is faster than using floating-point).
+     * If the mantissa has more than 18 digits, ignore the extras, since
+     * they can't affect the value anyway.
+     */
+
+    pExp  = p;
+    p -= mantSize;
+    if (decPt < 0) {
+	decPt = mantSize;
+    }
+    else {
+	mantSize -= 1;			/* One of the digits was the point. */
+    }
+    if (mantSize > 18) {
+	if (decPt - 18 > 29999) {
+	    fracExp = 29999;
+	}
+        else {
+	    fracExp = decPt - 18;
+	}
+	mantSize = 18;
+    }
+    else {
+	fracExp = decPt - mantSize;
+    }
+    if (mantSize == 0) {
+	fraction = 0.0;
+	p = string;
+	goto done;
+    }
+    else {
+	int frac1, frac2;
+	frac1 = 0;
+	for ( ; mantSize > 9; mantSize -= 1)
+	{
+	    c = *p;
+	    p += 1;
+	    if (c == '.') {
+		c = *p;
+		p += 1;
+	    }
+	    frac1 = 10*frac1 + (c - '0');
+	}
+	frac2 = 0;
+	for (; mantSize > 0; mantSize -= 1)
+	{
+	    c = *p;
+	    p += 1;
+	    if (c == '.') {
+		c = *p;
+		p += 1;
+	    }
+	    frac2 = 10*frac2 + (c - '0');
+	}
+	fraction = (1.0e9 * frac1) + frac2;
+    }
+
+    /*
+     * Skim off the exponent.
+     */
+
+    p = pExp;
+    if ((*p == 'E') || (*p == 'e')) {
+	p += 1;
+	if (*p == '-') {
+	    expSign = TRUE;
+	    p += 1;
+	}
+        else {
+	    if (*p == '+') {
+		p += 1;
+	    }
+	    expSign = FALSE;
+	}
+	while (isdigit(*p)) {
+	    exp = exp * 10 + (*p - '0');
+	    if (exp > 19999) {
+		exp = 19999;
+	    }
+	    p += 1;
+	}
+    }
+    if (expSign) {
+	exp = fracExp - exp;
+    }
+    else {
+	exp = fracExp + exp;
+    }
+
+    /*
+     * Generate a floating-point number that represents the exponent.
+     * Do this by processing the exponent one bit at a time to combine
+     * many powers of 2 of 10. Then combine the exponent with the
+     * fraction.
+     */
+
+    if (exp < 0) {
+	expSign = TRUE;
+	exp = -exp;
+    }
+    else {
+	expSign = FALSE;
+    }
+    if (exp > maxExponent) {
+	exp = maxExponent;
+	errno = ERANGE;
+    }
+    dblExp = 1.0;
+    for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {
+	if (exp & 01) {
+	    dblExp *= *d;
+	}
+    }
+    if (expSign) {
+	fraction /= dblExp;
+    }
+    else {
+	fraction *= dblExp;
+    }
+
+done:
+    if (endPtr != NULL) {
+	*endPtr = (char *) p;
+    }
+
+    if (sign) {
+	return -fraction;
+    }
+    return fraction;
+}
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/symbol.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/symbol.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/symbol.c	(revision 331)
@@ -7,8 +7,9 @@
 #include <limits.h>
 #include <string.h>
-#include "mruby.h"
-#include "mruby/khash.h"
-#include "mruby/string.h"
-#include "mruby/dump.h"
+#include <mruby.h>
+#include <mruby/khash.h>
+#include <mruby/string.h>
+#include <mruby/dump.h>
+#include <mruby/class.h>
 
 /* ------------------------------------------------------ */
@@ -355,5 +356,7 @@
       break;
     case '!':
-      if (*++m == '=') ++m;
+      switch (*++m) {
+        case '=': case '~': ++m;
+      }
       break;
     case '+': case '-':
@@ -480,4 +483,6 @@
 
   mrb->symbol_class = sym = mrb_define_class(mrb, "Symbol", mrb->object_class);                 /* 15.2.11 */
+  MRB_SET_INSTANCE_TT(sym, MRB_TT_SYMBOL);
+  mrb_undef_class_method(mrb,  sym, "new");
 
   mrb_define_method(mrb, sym, "===",             sym_equal,      MRB_ARGS_REQ(1));              /* 15.2.11.3.1  */
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/value_array.h
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/value_array.h	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/value_array.h	(revision 331)
@@ -2,5 +2,5 @@
 #define MRB_VALUE_ARRAY_H__
 
-#include "mruby.h"
+#include <mruby.h>
 
 static inline void
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/variable.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/variable.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/variable.c	(revision 331)
@@ -5,9 +5,9 @@
 */
 
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/proc.h"
-#include "mruby/string.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/proc.h>
+#include <mruby/string.h>
 
 typedef int (iv_foreach_func)(mrb_state*,mrb_sym,mrb_value,void*);
@@ -45,5 +45,5 @@
   iv_tbl *t;
 
-  t = mrb_malloc(mrb, sizeof(iv_tbl));
+  t = (iv_tbl*)mrb_malloc(mrb, sizeof(iv_tbl));
   t->size = 0;
   t->rootseg =  NULL;
@@ -103,5 +103,5 @@
   }
 
-  seg = mrb_malloc(mrb, sizeof(segment));
+  seg = (segment*)mrb_malloc(mrb, sizeof(segment));
   if (!seg) return;
   seg->next = NULL;
@@ -283,5 +283,5 @@
 #else
 
-#include "mruby/khash.h"
+#include <mruby/khash.h>
 
 #ifndef MRB_IVHASH_INIT_SIZE
@@ -490,4 +490,7 @@
   iv_tbl *t = obj->iv;
 
+  if (MRB_FROZEN_P(obj)) {
+    mrb_raisef(mrb, E_RUNTIME_ERROR, "can't modify frozen %S", mrb_obj_value(obj));
+  }
   if (!t) {
     t = obj->iv = iv_new(mrb);
@@ -757,15 +760,17 @@
 
 MRB_API mrb_value
-mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
+mrb_mod_cv_get(mrb_state *mrb, struct RClass *c, mrb_sym sym)
 {
   struct RClass * cls = c;
   mrb_value v;
+  int given = FALSE;
 
   while (c) {
     if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
-      return v;
+      given = TRUE;
     }
     c = c->super;
   }
+  if (given) return v;
   if (cls && cls->tt == MRB_TT_SCLASS) {
     mrb_value klass;
@@ -774,11 +779,13 @@
                            mrb_intern_lit(mrb, "__attached__"));
     c = mrb_class_ptr(klass);
-    if (c->tt == MRB_TT_CLASS) {
+    if (c->tt == MRB_TT_CLASS || c->tt == MRB_TT_MODULE) {
+      given = FALSE;
       while (c) {
         if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
-          return v;
+          given = TRUE;
         }
         c = c->super;
       }
+      if (given) return v;
     }
   }
@@ -813,10 +820,30 @@
   }
 
-  if (!cls->iv) {
-    cls->iv = iv_new(mrb);
-  }
-
-  mrb_write_barrier(mrb, (struct RBasic*)cls);
-  iv_put(mrb, cls->iv, sym, v);
+  if (cls && cls->tt == MRB_TT_SCLASS) {
+    mrb_value klass;
+
+    klass = mrb_obj_iv_get(mrb, (struct RObject*)cls,
+                           mrb_intern_lit(mrb, "__attached__"));
+    switch (mrb_type(klass)) {
+    case MRB_TT_CLASS:
+    case MRB_TT_MODULE:
+    case MRB_TT_SCLASS:
+      c = mrb_class_ptr(klass);
+      break;
+    default:
+      c = cls;
+      break;
+    }
+  }
+  else{
+    c = cls;
+  }
+
+  if (!c->iv) {
+    c->iv = iv_new(mrb);
+  }
+
+  mrb_write_barrier(mrb, (struct RBasic*)c);
+  iv_put(mrb, c->iv, sym, v);
 }
 
@@ -927,12 +954,12 @@
       return v;
     }
-    if (c->tt == MRB_TT_SCLASS) {
+    c2 = c;
+    while (c2 && c2->tt == MRB_TT_SCLASS) {
       mrb_value klass;
-      klass = mrb_obj_iv_get(mrb, (struct RObject *)c,
+      klass = mrb_obj_iv_get(mrb, (struct RObject *)c2,
                              mrb_intern_lit(mrb, "__attached__"));
       c2 = mrb_class_ptr(klass);
-      if (c2->tt == MRB_TT_CLASS)
-        c = c2;
-    }
+    }
+    if (c2->tt == MRB_TT_CLASS || c2->tt == MRB_TT_MODULE) c = c2;
     c2 = c;
     for (;;) {
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/version.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/version.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/version.c	(revision 331)
@@ -1,4 +1,4 @@
-#include "mruby.h"
-#include "mruby/variable.h"
+#include <mruby.h>
+#include <mruby/variable.h>
 
 void
@@ -10,5 +10,5 @@
   mrb_define_global_const(mrb, "RUBY_ENGINE", mrb_str_new_lit(mrb, MRUBY_RUBY_ENGINE));
   mrb_define_global_const(mrb, "RUBY_ENGINE_VERSION", mruby_version);
-  mrb_define_global_const(mrb, "MRUBY_VERSION", mrb_str_new_lit(mrb, MRUBY_VERSION));
+  mrb_define_global_const(mrb, "MRUBY_VERSION", mruby_version);
   mrb_define_global_const(mrb, "MRUBY_RELEASE_NO", mrb_fixnum_value(MRUBY_RELEASE_NO));
   mrb_define_global_const(mrb, "MRUBY_RELEASE_DATE", mrb_str_new_lit(mrb, MRUBY_RELEASE_DATE));
Index: EcnlProtoTool/trunk/mruby-1.3.0/src/vm.c
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/src/vm.c	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/src/vm.c	(revision 331)
@@ -8,20 +8,20 @@
 #include <stdarg.h>
 #include <math.h>
-#include "mruby.h"
-#include "mruby/array.h"
-#include "mruby/class.h"
-#include "mruby/hash.h"
-#include "mruby/irep.h"
-#include "mruby/numeric.h"
-#include "mruby/proc.h"
-#include "mruby/range.h"
-#include "mruby/string.h"
-#include "mruby/variable.h"
-#include "mruby/error.h"
-#include "mruby/opcode.h"
+#include <mruby.h>
+#include <mruby/array.h>
+#include <mruby/class.h>
+#include <mruby/hash.h>
+#include <mruby/irep.h>
+#include <mruby/numeric.h>
+#include <mruby/proc.h>
+#include <mruby/range.h>
+#include <mruby/string.h>
+#include <mruby/variable.h>
+#include <mruby/error.h>
+#include <mruby/opcode.h>
 #include "value_array.h"
-#include "mruby/throw.h"
-
-#ifdef MRB_DISABLE_STDIO
+#include <mruby/throw.h>
+
+#ifndef MRB_DISABLE_STDIO
 #if defined(__cplusplus)
 extern "C" {
@@ -36,7 +36,20 @@
 #define CALLINFO_INIT_SIZE 32
 
+#ifndef ENSURE_STACK_INIT_SIZE
+#define ENSURE_STACK_INIT_SIZE 16
+#endif
+
+#ifndef RESCUE_STACK_INIT_SIZE
+#define RESCUE_STACK_INIT_SIZE 16
+#endif
+
 /* Define amount of linear stack growth. */
 #ifndef MRB_STACK_GROWTH
 #define MRB_STACK_GROWTH 128
+#endif
+
+/* Maximum mrb_funcall() depth. Should be set lower on memory constrained systems. */
+#ifndef MRB_FUNCALL_DEPTH_MAX
+#define MRB_FUNCALL_DEPTH_MAX 512
 #endif
 
@@ -54,4 +67,8 @@
 
 #define ARENA_RESTORE(mrb,ai) (mrb)->gc.arena_idx = (ai)
+
+#define CALL_MAXARGS 127
+
+void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
 
 static inline void
@@ -99,5 +116,5 @@
 
 static inline void
-envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase)
+envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t size)
 {
   mrb_callinfo *ci = mrb->c->cibase;
@@ -106,5 +123,8 @@
   while (ci <= mrb->c->ci) {
     struct REnv *e = ci->env;
-    if (e && MRB_ENV_STACK_SHARED_P(e)) {
+    mrb_value *st;
+
+    if (e && MRB_ENV_STACK_SHARED_P(e) &&
+        (st = e->stack) && oldbase <= st && st < oldbase+size) {
       ptrdiff_t off = e->stack - oldbase;
 
@@ -116,22 +136,16 @@
 }
 
-static inline void
-init_new_stack_space(mrb_state *mrb, int room, int keep)
-{
-  if (room > keep) {
-    /* do not leave uninitialized malloc region */
-    stack_clear(&(mrb->c->stack[keep]), room - keep);
-  }
-}
-
 /** def rec ; $deep =+ 1 ; if $deep > 1000 ; return 0 ; end ; rec ; end  */
 
 static void
-stack_extend_alloc(mrb_state *mrb, int room, int keep)
+stack_extend_alloc(mrb_state *mrb, int room)
 {
   mrb_value *oldbase = mrb->c->stbase;
-  int size = mrb->c->stend - mrb->c->stbase;
-  int off = mrb->c->stack - mrb->c->stbase;
-
+  mrb_value *newstack;
+  size_t oldsize = mrb->c->stend - mrb->c->stbase;
+  size_t size = oldsize;
+  size_t off = mrb->c->stack - mrb->c->stbase;
+
+  if (off > size) size = off;
 #ifdef MRB_STACK_EXTEND_DOUBLING
   if (room <= size)
@@ -149,24 +163,27 @@
 #endif
 
-  mrb->c->stbase = (mrb_value *)mrb_realloc(mrb, mrb->c->stbase, sizeof(mrb_value) * size);
+  newstack = (mrb_value *)mrb_realloc(mrb, mrb->c->stbase, sizeof(mrb_value) * size);
+  if (newstack == NULL) {
+    mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
+  }
+  stack_clear(&(newstack[oldsize]), size - oldsize);
+  envadjust(mrb, oldbase, newstack, size);
+  mrb->c->stbase = newstack;
   mrb->c->stack = mrb->c->stbase + off;
   mrb->c->stend = mrb->c->stbase + size;
-  envadjust(mrb, oldbase, mrb->c->stbase);
 
   /* Raise an exception if the new stack size will be too large,
      to prevent infinite recursion. However, do this only after resizing the stack, so mrb_raise has stack space to work with. */
   if (size > MRB_STACK_MAX) {
-    init_new_stack_space(mrb, room, keep);
-    mrb_raise(mrb, E_SYSSTACK_ERROR, "stack level too deep. (limit=" MRB_STRINGIZE(MRB_STACK_MAX) ")");
+    mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
   }
 }
 
 static inline void
-stack_extend(mrb_state *mrb, int room, int keep)
+stack_extend(mrb_state *mrb, int room)
 {
   if (mrb->c->stack + room >= mrb->c->stend) {
-    stack_extend_alloc(mrb, room, keep);
-  }
-  init_new_stack_space(mrb, room, keep);
+    stack_extend_alloc(mrb, room);
+  }
 }
 
@@ -188,6 +205,6 @@
   int cioff = e->cioff;
 
-  if (MRB_ENV_STACK_SHARED_P(e) && mrb->c->cibase[cioff].proc &&
-      MRB_PROC_STRICT_P(mrb->c->cibase[cioff].proc)) {
+  if (MRB_ENV_STACK_SHARED_P(e) && e->cxt.c->cibase[cioff].proc &&
+      MRB_PROC_STRICT_P(e->cxt.c->cibase[cioff].proc)) {
     return TRUE;
   }
@@ -210,4 +227,5 @@
 #define CI_ACC_SKIP    -1
 #define CI_ACC_DIRECT  -2
+#define CI_ACC_RESUMED -3
 
 static mrb_callinfo*
@@ -217,5 +235,4 @@
   mrb_callinfo *ci = c->ci;
 
-  int eidx = ci->eidx;
   int ridx = ci->ridx;
 
@@ -228,5 +245,5 @@
   }
   ci = ++c->ci;
-  ci->eidx = eidx;
+  ci->epos = mrb->c->eidx;
   ci->ridx = ridx;
   ci->env = 0;
@@ -234,6 +251,31 @@
   ci->err = 0;
   ci->proc = 0;
+  ci->acc = 0;
 
   return ci;
+}
+
+MRB_API void
+mrb_env_unshare(mrb_state *mrb, struct REnv *e)
+{
+  size_t len = (size_t)MRB_ENV_STACK_LEN(e);
+  ptrdiff_t cioff = e->cioff;
+  mrb_value *p;
+
+  if (!MRB_ENV_STACK_SHARED_P(e)) return;
+  if (e->cxt.c != mrb->c) return;
+  if (e->cioff == 0 && e->cxt.c == mrb->root_c) return;
+  MRB_ENV_UNSHARE_STACK(e);
+  if (!e->c) {
+    /* save block argument position (negated) */
+    e->cioff = -e->cxt.c->cibase[cioff].argc-1;
+  }
+  e->cxt.mid = e->cxt.c->cibase[cioff].mid;
+  p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
+  if (len > 0) {
+    stack_copy(p, e->stack, len);
+  }
+  e->stack = p;
+  mrb_write_barrier(mrb, (struct RBasic *)e);
 }
 
@@ -242,20 +284,14 @@
 {
   struct mrb_context *c = mrb->c;
-
-  if (c->ci->env) {
-    struct REnv *e = c->ci->env;
-    size_t len = (size_t)MRB_ENV_STACK_LEN(e);
-    mrb_value *p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
-
-    MRB_ENV_UNSHARE_STACK(e);
-    if (len > 0) {
-      stack_copy(p, e->stack, len);
-    }
-    e->stack = p;
-    mrb_write_barrier(mrb, (struct RBasic *)e);
-  }
+  struct REnv *env = c->ci->env;
 
   c->ci--;
-}
+
+  if (env) {
+    mrb_env_unshare(mrb, env);
+  }
+}
+
+void mrb_exc_set(mrb_state *mrb, mrb_value exc);
 
 static void
@@ -263,13 +299,18 @@
 {
   struct RProc *p;
-  mrb_callinfo *ci;
+  mrb_callinfo *ci = mrb->c->ci;
   mrb_value *self = mrb->c->stack;
   struct RObject *exc;
+  ptrdiff_t cioff;
+  int ai = mrb_gc_arena_save(mrb);
 
   if (i<0) return;
+  if (ci - mrb->c->cibase > MRB_FUNCALL_DEPTH_MAX) {
+    mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
+  }
   p = mrb->c->ensure[i];
   if (!p) return;
-  if (mrb->c->ci->eidx > i)
-    mrb->c->ci->eidx = i;
+  mrb->c->ensure[i] = NULL;
+  cioff = ci - mrb->c->cibase;
   ci = cipush(mrb);
   ci->stackent = mrb->c->stack;
@@ -282,7 +323,11 @@
   mrb->c->stack = mrb->c->stack + ci[-1].nregs;
   exc = mrb->exc; mrb->exc = 0;
+  if (exc) {
+    mrb_gc_protect(mrb, mrb_obj_value(exc));
+  }
   mrb_run(mrb, p, *self);
-  mrb->c->ensure[i] = NULL;
+  mrb->c->ci = mrb->c->cibase + cioff;
   if (!mrb->exc) mrb->exc = exc;
+  mrb_gc_arena_restore(mrb, ai);
 }
 
@@ -335,9 +380,9 @@
     }
     MRB_END_EXC(&c_jmp);
+    mrb->jmp = 0;
   }
   else {
     struct RProc *p;
     struct RClass *c;
-    mrb_sym undef = 0;
     mrb_callinfo *ci;
     int n;
@@ -354,8 +399,17 @@
     p = mrb_method_search_vm(mrb, &c, mid);
     if (!p) {
-      undef = mid;
-      mid = mrb_intern_lit(mrb, "method_missing");
-      p = mrb_method_search_vm(mrb, &c, mid);
-      n++; argc++;
+      mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
+      mrb_value args = mrb_ary_new_from_values(mrb, argc, argv);
+      p = mrb_method_search_vm(mrb, &c, missing);
+      if (!p) {
+        mrb_method_missing(mrb, mid, self, args);
+      }
+      mrb_ary_unshift(mrb, args, mrb_symbol_value(mid));
+      stack_extend(mrb, n+2);
+      mrb->c->stack[n+1] = args;
+      argc = -1;
+    }
+    if (mrb->c->ci - mrb->c->cibase > MRB_FUNCALL_DEPTH_MAX) {
+      mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
     }
     ci = cipush(mrb);
@@ -371,9 +425,17 @@
     if (MRB_PROC_CFUNC_P(p)) {
       ci->nregs = argc + 2;
-      stack_extend(mrb, ci->nregs, 0);
+      stack_extend(mrb, ci->nregs);
+    }
+    else if (argc >= CALL_MAXARGS) {
+      mrb_value args = mrb_ary_new_from_values(mrb, argc, argv);
+      stack_extend(mrb, ci->nregs);
+      mrb->c->stack[1] = args;
+      ci->argc = -1;
+      argc = 1;
     }
     else {
-      ci->nregs = p->body.irep->nregs + n;
-      stack_extend(mrb, ci->nregs, argc+2);
+      if (argc < 0) argc = 1;
+      ci->nregs = p->body.irep->nregs + argc;
+      stack_extend(mrb, ci->nregs);
     }
     if (voff >= 0) {
@@ -381,11 +443,5 @@
     }
     mrb->c->stack[0] = self;
-    if (undef) {
-      mrb->c->stack[1] = mrb_symbol_value(undef);
-      if (argc > 1) {
-        stack_copy(mrb->c->stack+2, argv, argc-1);
-      }
-    }
-    else if (argc > 0) {
+    if (ci->argc > 0) {
       stack_copy(mrb->c->stack+1, argv, argc);
     }
@@ -414,4 +470,33 @@
 {
   return mrb_funcall_with_block(mrb, self, mid, argc, argv, mrb_nil_value());
+}
+
+mrb_value
+mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p)
+{
+  mrb_callinfo *ci = mrb->c->ci;
+
+  mrb->c->stack[0] = self;
+  ci->proc = p;
+  ci->target_class = p->target_class;
+  if (MRB_PROC_CFUNC_P(p)) {
+    return p->body.func(mrb, self);
+  }
+  if (ci->argc < 0) {
+    stack_extend(mrb, (p->body.irep->nregs < 3) ? 3 : p->body.irep->nregs);
+  }
+  else {
+    stack_extend(mrb, p->body.irep->nregs);
+  }
+
+  ci->nregs = p->body.irep->nregs;
+  ci = cipush(mrb);
+  ci->nregs = 0;
+  ci->target_class = 0;
+  ci->pc = p->body.irep->iseq;
+  ci->stackent = mrb->c->stack;
+  ci->acc = 0;
+
+  return self;
 }
 
@@ -446,4 +531,9 @@
 
   mrb_get_args(mrb, "n*&", &name, &argv, &argc, &block);
+  ci = mrb->c->ci;
+  if (ci->acc < 0) {
+  funcall:
+    return mrb_funcall_with_block(mrb, self, name, argc, argv, block);
+  }
 
   c = mrb_class(mrb, self);
@@ -451,11 +541,9 @@
 
   if (!p) {                     /* call method_mising */
-    return mrb_funcall_with_block(mrb, self, name, argc, argv, block);
-  }
-
-  ci = mrb->c->ci;
+    goto funcall;
+  }
+
   ci->mid = name;
   ci->target_class = c;
-  ci->proc = p;
   regs = mrb->c->stack+1;
   /* remove first symbol from arguments */
@@ -470,24 +558,5 @@
   }
 
-  if (MRB_PROC_CFUNC_P(p)) {
-    return p->body.func(mrb, self);
-  }
-
-  if (ci->argc < 0) {
-    stack_extend(mrb, (p->body.irep->nregs < 3) ? 3 : p->body.irep->nregs, 3);
-  }
-  else {
-    stack_extend(mrb, p->body.irep->nregs, ci->argc+2);
-  }
-
-  ci->nregs = p->body.irep->nregs;
-  ci = cipush(mrb);
-  ci->nregs = 0;
-  ci->target_class = 0;
-  ci->pc = p->body.irep->iseq;
-  ci->stackent = mrb->c->stack;
-  ci->acc = 0;
-
-  return self;
+  return mrb_exec_irep(mrb, self, p);
 }
 
@@ -497,4 +566,5 @@
   struct RProc *p;
   mrb_callinfo *ci;
+  mrb_int max = 3;
 
   if (mrb_nil_p(blk)) {
@@ -503,13 +573,25 @@
   ci = mrb->c->ci;
   if (ci->acc == CI_ACC_DIRECT) {
-    return mrb_yield_with_class(mrb, blk, 0, 0, self, c);
+    ci->target_class = c;
+    return mrb_yield_cont(mrb, blk, self, 1, &self);
   }
   ci->target_class = c;
   p = mrb_proc_ptr(blk);
   ci->proc = p;
+  ci->argc = 1;
+  ci->mid = ci[-1].mid;
   if (MRB_PROC_CFUNC_P(p)) {
+    stack_extend(mrb, 3);
+    mrb->c->stack[0] = self;
+    mrb->c->stack[1] = self;
+    mrb->c->stack[2] = mrb_nil_value();
     return p->body.func(mrb, self);
   }
   ci->nregs = p->body.irep->nregs;
+  if (max < ci->nregs) max = ci->nregs;
+  stack_extend(mrb, max);
+  mrb->c->stack[0] = self;
+  mrb->c->stack[1] = self;
+  mrb->c->stack[2] = mrb_nil_value();
   ci = cipush(mrb);
   ci->nregs = 0;
@@ -600,4 +682,7 @@
     mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
   }
+  if (mrb->c->ci - mrb->c->cibase > MRB_FUNCALL_DEPTH_MAX) {
+    mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
+  }
   p = mrb_proc_ptr(b);
   ci = cipush(mrb);
@@ -611,9 +696,9 @@
   if (MRB_PROC_CFUNC_P(p)) {
     ci->nregs = argc + 2;
-    stack_extend(mrb, ci->nregs, 0);
+    stack_extend(mrb, ci->nregs);
   }
   else {
     ci->nregs = p->body.irep->nregs;
-    stack_extend(mrb, ci->nregs, argc+2);
+    stack_extend(mrb, ci->nregs);
   }
 
@@ -627,9 +712,11 @@
     val = p->body.func(mrb, self);
     mrb->c->stack = mrb->c->ci->stackent;
-    cipop(mrb);
   }
   else {
+    int cioff = mrb->c->ci - mrb->c->cibase;
     val = mrb_run(mrb, p, self);
-  }
+    mrb->c->ci = mrb->c->cibase + cioff;
+  }
+  cipop(mrb);
   return val;
 }
@@ -649,4 +736,40 @@
 
   return mrb_yield_with_class(mrb, b, 1, &arg, p->env->stack[0], p->target_class);
+}
+
+mrb_value
+mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const mrb_value *argv)
+{
+  struct RProc *p;
+  mrb_callinfo *ci;
+
+  if (mrb_nil_p(b)) {
+    mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
+  }
+  if (mrb_type(b) != MRB_TT_PROC) {
+    mrb_raise(mrb, E_TYPE_ERROR, "not a block");
+  }
+
+  p = mrb_proc_ptr(b);
+  ci = mrb->c->ci;
+
+  stack_extend(mrb, 3);
+  mrb->c->stack[1] = mrb_ary_new_from_values(mrb, argc, argv);
+  mrb->c->stack[2] = mrb_nil_value();
+  ci->argc = -1;
+  return mrb_exec_irep(mrb, self, p);
+}
+
+static struct RBreak*
+break_new(mrb_state *mrb, struct RProc *p, mrb_value val)
+{
+  struct RBreak *brk;
+
+  brk = (struct RBreak*)mrb_obj_alloc(mrb, MRB_TT_BREAK, NULL);
+  brk->iv = NULL;
+  brk->proc = p;
+  brk->val = val;
+
+  return brk;
 }
 
@@ -670,5 +793,5 @@
   mrb_str_cat(mrb, msg, kind_str[kind], kind_str_len[kind]);
   exc = mrb_exc_new_str(mrb, E_LOCALJUMP_ERROR, msg);
-  mrb->exc = mrb_obj_ptr(exc);
+  mrb_exc_set(mrb, exc);
 }
 
@@ -678,16 +801,23 @@
   mrb_value exc;
   mrb_value str;
-
+  mrb_int argc = mrb->c->ci->argc;
+
+  if (argc < 0) {
+    mrb_value args = mrb->c->stack[1];
+    if (mrb_array_p(args)) {
+      argc = RARRAY_LEN(args);
+    }
+  }
   if (mrb->c->ci->mid) {
     str = mrb_format(mrb, "'%S': wrong number of arguments (%S for %S)",
                   mrb_sym2str(mrb, mrb->c->ci->mid),
-                  mrb_fixnum_value(mrb->c->ci->argc), mrb_fixnum_value(num));
+                  mrb_fixnum_value(argc), mrb_fixnum_value(num));
   }
   else {
     str = mrb_format(mrb, "wrong number of arguments (%S for %S)",
-                  mrb_fixnum_value(mrb->c->ci->argc), mrb_fixnum_value(num));
+                     mrb_fixnum_value(argc), mrb_fixnum_value(num));
   }
   exc = mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str);
-  mrb->exc = mrb_obj_ptr(exc);
+  mrb_exc_set(mrb, exc);
 }
 
@@ -700,4 +830,11 @@
 #endif
 
+#ifdef MRB_BYTECODE_DECODE_OPTION
+#define BYTECODE_DECODER(x) ((mrb)->bytecode_decoder)?(mrb)->bytecode_decoder((mrb), (x)):(x)
+#else
+#define BYTECODE_DECODER(x) (x)
+#endif
+
+
 #if defined __GNUC__ || defined __clang__ || defined __INTEL_COMPILER
 #define DIRECT_THREADED
@@ -706,5 +843,5 @@
 #ifndef DIRECT_THREADED
 
-#define INIT_DISPATCH for (;;) { i = *pc; CODE_FETCH_HOOK(mrb, irep, pc, regs); switch (GET_OPCODE(i)) {
+#define INIT_DISPATCH for (;;) { i = BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); switch (GET_OPCODE(i)) {
 #define CASE(op) case op:
 #define NEXT pc++; break
@@ -716,6 +853,6 @@
 #define INIT_DISPATCH JUMP; return mrb_nil_value();
 #define CASE(op) L_ ## op:
-#define NEXT i=*++pc; CODE_FETCH_HOOK(mrb, irep, pc, regs); goto *optable[GET_OPCODE(i)]
-#define JUMP i=*pc; CODE_FETCH_HOOK(mrb, irep, pc, regs); goto *optable[GET_OPCODE(i)]
+#define NEXT i=BYTECODE_DECODER(*++pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); goto *optable[GET_OPCODE(i)]
+#define JUMP i=BYTECODE_DECODER(*pc); CODE_FETCH_HOOK(mrb, irep, pc, regs); goto *optable[GET_OPCODE(i)]
 
 #define END_DISPATCH
@@ -723,17 +860,41 @@
 #endif
 
-#define CALL_MAXARGS 127
-
-void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
-
 MRB_API mrb_value
-mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
+mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
+{
+  mrb_irep *irep = proc->body.irep;
+  mrb_value result;
+  struct mrb_context *c = mrb->c;
+  int cioff = c->ci - c->cibase;
+  unsigned int nregs = irep->nregs;
+
+  if (!c->stack) {
+    stack_init(mrb);
+  }
+  if (stack_keep > nregs)
+    nregs = stack_keep;
+  stack_extend(mrb, nregs);
+  stack_clear(c->stack + stack_keep, nregs - stack_keep);
+  c->stack[0] = self;
+  result = mrb_vm_exec(mrb, proc, irep->iseq);
+  if (c->ci - c->cibase > cioff) {
+    c->ci = c->cibase + cioff;
+  }
+  if (mrb->c != c) {
+    if (mrb->c->fib) {
+      mrb_write_barrier(mrb, (struct RBasic*)mrb->c->fib);
+    }
+    mrb->c = c;
+  }
+  return result;
+}
+
+MRB_API mrb_value
+mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
 {
   /* mrb_assert(mrb_proc_cfunc_p(proc)) */
   mrb_irep *irep = proc->body.irep;
-  mrb_code *pc = irep->iseq;
   mrb_value *pool = irep->pool;
   mrb_sym *syms = irep->syms;
-  mrb_value *regs = NULL;
   mrb_code i;
   int ai = mrb_gc_arena_save(mrb);
@@ -773,16 +934,13 @@
   if (exc_catched) {
     exc_catched = FALSE;
+    if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)
+      goto L_BREAK;
     goto L_RAISE;
   }
   mrb->jmp = &c_jmp;
-  if (!mrb->c->stack) {
-    stack_init(mrb);
-  }
-  stack_extend(mrb, irep->nregs, stack_keep);
   mrb->c->ci->proc = proc;
   mrb->c->ci->nregs = irep->nregs;
-  regs = mrb->c->stack;
-  regs[0] = self;
-
+
+#define regs (mrb->c->stack)
   INIT_DISPATCH {
     CASE(OP_NOP) {
@@ -793,5 +951,7 @@
     CASE(OP_MOVE) {
       /* A B    R(A) := R(B) */
-      regs[GETARG_A(i)] = regs[GETARG_B(i)];
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      regs[a] = regs[b];
       NEXT;
     }
@@ -799,5 +959,15 @@
     CASE(OP_LOADL) {
       /* A Bx   R(A) := Pool(Bx) */
-      regs[GETARG_A(i)] = pool[GETARG_Bx(i)];
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+#ifdef MRB_WORD_BOXING
+      mrb_value val = pool[bx];
+      if (mrb_float_p(val)) {
+        val = mrb_float_value(mrb, mrb_float(val));
+      }
+      regs[a] = val;
+#else
+      regs[a] = pool[bx];
+#endif
       NEXT;
     }
@@ -811,5 +981,7 @@
     CASE(OP_LOADSYM) {
       /* A Bx   R(A) := Syms(Bx) */
-      SET_SYM_VALUE(regs[GETARG_A(i)], syms[GETARG_Bx(i)]);
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      SET_SYM_VALUE(regs[a], syms[bx]);
       NEXT;
     }
@@ -817,5 +989,6 @@
     CASE(OP_LOADSELF) {
       /* A      R(A) := self */
-      regs[GETARG_A(i)] = regs[0];
+      int a = GETARG_A(i);
+      regs[a] = regs[0];
       NEXT;
     }
@@ -823,5 +996,6 @@
     CASE(OP_LOADT) {
       /* A      R(A) := true */
-      SET_TRUE_VALUE(regs[GETARG_A(i)]);
+      int a = GETARG_A(i);
+      SET_TRUE_VALUE(regs[a]);
       NEXT;
     }
@@ -829,5 +1003,6 @@
     CASE(OP_LOADF) {
       /* A      R(A) := false */
-      SET_FALSE_VALUE(regs[GETARG_A(i)]);
+      int a = GETARG_A(i);
+      SET_FALSE_VALUE(regs[a]);
       NEXT;
     }
@@ -835,11 +1010,16 @@
     CASE(OP_GETGLOBAL) {
       /* A Bx   R(A) := getglobal(Syms(Bx)) */
-      regs[GETARG_A(i)] = mrb_gv_get(mrb, syms[GETARG_Bx(i)]);
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_value val = mrb_gv_get(mrb, syms[bx]);
+      regs[a] = val;
       NEXT;
     }
 
     CASE(OP_SETGLOBAL) {
-      /* setglobal(Syms(Bx), R(A)) */
-      mrb_gv_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
+      /* A Bx   setglobal(Syms(Bx), R(A)) */
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_gv_set(mrb, syms[bx], regs[a]);
       NEXT;
     }
@@ -847,5 +1027,8 @@
     CASE(OP_GETSPECIAL) {
       /* A Bx   R(A) := Special[Bx] */
-      regs[GETARG_A(i)] = mrb_vm_special_get(mrb, GETARG_Bx(i));
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_value val = mrb_vm_special_get(mrb, bx);
+      regs[a] = val;
       NEXT;
     }
@@ -853,5 +1036,7 @@
     CASE(OP_SETSPECIAL) {
       /* A Bx   Special[Bx] := R(A) */
-      mrb_vm_special_set(mrb, GETARG_Bx(i), regs[GETARG_A(i)]);
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_vm_special_set(mrb, bx, regs[a]);
       NEXT;
     }
@@ -859,11 +1044,16 @@
     CASE(OP_GETIV) {
       /* A Bx   R(A) := ivget(Bx) */
-      regs[GETARG_A(i)] = mrb_vm_iv_get(mrb, syms[GETARG_Bx(i)]);
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_value val = mrb_vm_iv_get(mrb, syms[bx]);
+      regs[a] = val;
       NEXT;
     }
 
     CASE(OP_SETIV) {
-      /* ivset(Syms(Bx),R(A)) */
-      mrb_vm_iv_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
+      /* A Bx   ivset(Syms(Bx),R(A)) */
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_vm_iv_set(mrb, syms[bx], regs[a]);
       NEXT;
     }
@@ -871,13 +1061,19 @@
     CASE(OP_GETCV) {
       /* A Bx   R(A) := cvget(Syms(Bx)) */
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_value val;
       ERR_PC_SET(mrb, pc);
-      regs[GETARG_A(i)] = mrb_vm_cv_get(mrb, syms[GETARG_Bx(i)]);
+      val = mrb_vm_cv_get(mrb, syms[bx]);
       ERR_PC_CLR(mrb);
+      regs[a] = val;
       NEXT;
     }
 
     CASE(OP_SETCV) {
-      /* cvset(Syms(Bx),R(A)) */
-      mrb_vm_cv_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
+      /* A Bx   cvset(Syms(Bx),R(A)) */
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_vm_cv_set(mrb, syms[bx], regs[a]);
       NEXT;
     }
@@ -886,10 +1082,12 @@
       /* A Bx    R(A) := constget(Syms(Bx)) */
       mrb_value val;
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_sym sym = syms[bx];
 
       ERR_PC_SET(mrb, pc);
-      val = mrb_vm_const_get(mrb, syms[GETARG_Bx(i)]);
+      val = mrb_vm_const_get(mrb, sym);
       ERR_PC_CLR(mrb);
-      regs = mrb->c->stack;
-      regs[GETARG_A(i)] = val;
+      regs[a] = val;
       NEXT;
     }
@@ -897,5 +1095,7 @@
     CASE(OP_SETCONST) {
       /* A Bx   constset(Syms(Bx),R(A)) */
-      mrb_vm_const_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
+      int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
+      mrb_vm_const_set(mrb, syms[bx], regs[a]);
       NEXT;
     }
@@ -905,9 +1105,9 @@
       mrb_value val;
       int a = GETARG_A(i);
+      int bx = GETARG_Bx(i);
 
       ERR_PC_SET(mrb, pc);
-      val = mrb_const_get(mrb, regs[a], syms[GETARG_Bx(i)]);
+      val = mrb_const_get(mrb, regs[a], syms[bx]);
       ERR_PC_CLR(mrb);
-      regs = mrb->c->stack;
       regs[a] = val;
       NEXT;
@@ -917,6 +1117,6 @@
       /* A Bx    R(A+1)::Syms(Bx) := R(A) */
       int a = GETARG_A(i);
-
-      mrb_const_set(mrb, regs[a+1], syms[GETARG_Bx(i)], regs[a]);
+      int bx = GETARG_Bx(i);
+      mrb_const_set(mrb, regs[a+1], syms[bx], regs[a]);
       NEXT;
     }
@@ -924,8 +1124,9 @@
     CASE(OP_GETUPVAR) {
       /* A B C  R(A) := uvget(B,C) */
-      mrb_value *regs_a = regs + GETARG_A(i);
-      int up = GETARG_C(i);
-
-      struct REnv *e = uvenv(mrb, up);
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      int c = GETARG_C(i);
+      mrb_value *regs_a = regs + a;
+      struct REnv *e = uvenv(mrb, c);
 
       if (!e) {
@@ -933,6 +1134,5 @@
       }
       else {
-        int idx = GETARG_B(i);
-        *regs_a = e->stack[idx];
+        *regs_a = e->stack[b];
       }
       NEXT;
@@ -941,13 +1141,17 @@
     CASE(OP_SETUPVAR) {
       /* A B C  uvset(B,C,R(A)) */
-      int up = GETARG_C(i);
-
-      struct REnv *e = uvenv(mrb, up);
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      int c = GETARG_C(i);
+
+      struct REnv *e = uvenv(mrb, c);
 
       if (e) {
-        mrb_value *regs_a = regs + GETARG_A(i);
-        int idx = GETARG_B(i);
-        e->stack[idx] = *regs_a;
-        mrb_write_barrier(mrb, (struct RBasic*)e);
+        mrb_value *regs_a = regs + a;
+
+        if (b < MRB_ENV_STACK_LEN(e)) {
+          e->stack[b] = *regs_a;
+          mrb_write_barrier(mrb, (struct RBasic*)e);
+        }
       }
       NEXT;
@@ -956,5 +1160,6 @@
     CASE(OP_JMP) {
       /* sBx    pc+=sBx */
-      pc += GETARG_sBx(i);
+      int sbx = GETARG_sBx(i);
+      pc += sbx;
       JUMP;
     }
@@ -962,6 +1167,8 @@
     CASE(OP_JMPIF) {
       /* A sBx  if R(A) pc+=sBx */
-      if (mrb_test(regs[GETARG_A(i)])) {
-        pc += GETARG_sBx(i);
+      int a = GETARG_A(i);
+      int sbx = GETARG_sBx(i);
+      if (mrb_test(regs[a])) {
+        pc += sbx;
         JUMP;
       }
@@ -971,6 +1178,8 @@
     CASE(OP_JMPNOT) {
       /* A sBx  if !R(A) pc+=sBx */
-      if (!mrb_test(regs[GETARG_A(i)])) {
-        pc += GETARG_sBx(i);
+      int a = GETARG_A(i);
+      int sbx = GETARG_sBx(i);
+      if (!mrb_test(regs[a])) {
+        pc += sbx;
         JUMP;
       }
@@ -980,17 +1189,52 @@
     CASE(OP_ONERR) {
       /* sBx    pc+=sBx on exception */
+      int sbx = GETARG_sBx(i);
       if (mrb->c->rsize <= mrb->c->ci->ridx) {
-        if (mrb->c->rsize == 0) mrb->c->rsize = 16;
+        if (mrb->c->rsize == 0) mrb->c->rsize = RESCUE_STACK_INIT_SIZE;
         else mrb->c->rsize *= 2;
         mrb->c->rescue = (mrb_code **)mrb_realloc(mrb, mrb->c->rescue, sizeof(mrb_code*) * mrb->c->rsize);
       }
-      mrb->c->rescue[mrb->c->ci->ridx++] = pc + GETARG_sBx(i);
+      mrb->c->rescue[mrb->c->ci->ridx++] = pc + sbx;
       NEXT;
     }
 
     CASE(OP_RESCUE) {
-      /* A      R(A) := exc; clear(exc) */
-      SET_OBJ_VALUE(regs[GETARG_A(i)], mrb->exc);
-      mrb->exc = 0;
+      /* A B    R(A) := exc; clear(exc); R(B) := matched (bool) */
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      int c = GETARG_C(i);
+      mrb_value exc;
+
+      if (c == 0) {
+        exc = mrb_obj_value(mrb->exc);
+        mrb->exc = 0;
+      }
+      else {           /* continued; exc taken from R(A) */
+        exc = regs[a];
+      }
+      if (b != 0) {
+        mrb_value e = regs[b];
+        struct RClass *ec;
+
+        switch (mrb_type(e)) {
+        case MRB_TT_CLASS:
+        case MRB_TT_MODULE:
+          break;
+        default:
+          {
+            mrb_value exc;
+
+            exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR,
+                  "class or module required for rescue clause");
+            mrb_exc_set(mrb, exc);
+            goto L_RAISE;
+          }
+        }
+        ec = mrb_class_ptr(e);
+        regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));
+      }
+      if (a != 0 && c == 0) {
+        regs[a] = exc;
+      }
       NEXT;
     }
@@ -1008,5 +1252,7 @@
     CASE(OP_RAISE) {
       /* A      raise(R(A)) */
-      mrb->exc = mrb_obj_ptr(regs[GETARG_A(i)]);
+      int a = GETARG_A(i);
+
+      mrb_exc_set(mrb, regs[a]);
       goto L_RAISE;
     }
@@ -1014,14 +1260,16 @@
     CASE(OP_EPUSH) {
       /* Bx     ensure_push(SEQ[Bx]) */
+      int bx = GETARG_Bx(i);
       struct RProc *p;
 
-      p = mrb_closure_new(mrb, irep->reps[GETARG_Bx(i)]);
+      p = mrb_closure_new(mrb, irep->reps[bx]);
       /* push ensure_stack */
-      if (mrb->c->esize <= mrb->c->ci->eidx) {
-        if (mrb->c->esize == 0) mrb->c->esize = 16;
+      if (mrb->c->esize <= mrb->c->eidx+1) {
+        if (mrb->c->esize == 0) mrb->c->esize = ENSURE_STACK_INIT_SIZE;
         else mrb->c->esize *= 2;
         mrb->c->ensure = (struct RProc **)mrb_realloc(mrb, mrb->c->ensure, sizeof(struct RProc*) * mrb->c->esize);
       }
-      mrb->c->ensure[mrb->c->ci->eidx++] = p;
+      mrb->c->ensure[mrb->c->eidx++] = p;
+      mrb->c->ensure[mrb->c->eidx] = NULL;
       ARENA_RESTORE(mrb, ai);
       NEXT;
@@ -1032,8 +1280,8 @@
       int a = GETARG_A(i);
       mrb_callinfo *ci = mrb->c->ci;
-      int n, eidx = ci->eidx;
-
-      for (n=0; n<a && (ci == mrb->c->cibase || eidx > ci[-1].eidx); n++) {
-        ecall(mrb, --eidx);
+      int n, epos = ci->epos;
+
+      for (n=0; n<a && mrb->c->eidx > epos; n++) {
+        ecall(mrb, --mrb->c->eidx);
         ARENA_RESTORE(mrb, ai);
       }
@@ -1061,15 +1309,34 @@
       struct RProc *m;
       struct RClass *c;
-      mrb_callinfo *ci;
+      mrb_callinfo *ci = mrb->c->ci;
       mrb_value recv, result;
       mrb_sym mid = syms[GETARG_B(i)];
+      int bidx;
+      mrb_value blk;
 
       recv = regs[a];
+      if (n == CALL_MAXARGS) {
+        bidx = a+2;
+      }
+      else {
+        bidx = a+n+1;
+      }
       if (GET_OPCODE(i) != OP_SENDB) {
-        if (n == CALL_MAXARGS) {
-          SET_NIL_VALUE(regs[a+2]);
-        }
-        else {
-          SET_NIL_VALUE(regs[a+n+1]);
+        if (bidx >= ci->nregs) {
+          stack_extend(mrb, bidx+1);
+          ci->nregs = bidx+1;
+        }
+        SET_NIL_VALUE(regs[bidx]);
+        blk = mrb_nil_value();
+      }
+      else {
+        blk = regs[bidx];
+        if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
+          if (bidx >= ci->nregs) {
+            stack_extend(mrb, bidx+1);
+            ci->nregs = bidx+1;
+          }
+          result = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
+          blk = regs[bidx] = result;
         }
       }
@@ -1090,14 +1357,17 @@
             args = mrb_ary_new_from_values(mrb, n, regs+a+1);
           }
+          ERR_PC_SET(mrb, pc);
           mrb_method_missing(mrb, mid, recv, args);
         }
         mid = missing;
-        if (n == CALL_MAXARGS) {
-          mrb_ary_unshift(mrb, regs[a+1], sym);
-        }
-        else {
-          value_move(regs+a+2, regs+a+1, ++n);
-          regs[a+1] = sym;
-        }
+        if (n != CALL_MAXARGS) {
+          if (a+2 >= irep->nregs) {
+            stack_extend(mrb, a+3);
+          }
+          regs[a+1] = mrb_ary_new_from_values(mrb, n, regs+a+1);
+          regs[a+2] = blk;
+          n = CALL_MAXARGS;
+        }
+        mrb_ary_unshift(mrb, regs[a+1], sym);
       }
 
@@ -1125,11 +1395,23 @@
         }
         result = m->body.func(mrb, recv);
-        mrb->c->stack[0] = result;
         mrb_gc_arena_restore(mrb, ai);
         if (mrb->exc) goto L_RAISE;
-        /* pop stackpos */
         ci = mrb->c->ci;
+        if (GET_OPCODE(i) == OP_SENDB) {
+          if (mrb_type(blk) == MRB_TT_PROC) {
+            struct RProc *p = mrb_proc_ptr(blk);
+
+            if (p && !MRB_PROC_STRICT_P(p) && p->env == ci[-1].env) {
+              p->flags |= MRB_PROC_ORPHAN;
+            }
+          }
+        }
         if (!ci->target_class) { /* return from context modifying method (resume/yield) */
-          if (!MRB_PROC_CFUNC_P(ci[-1].proc)) {
+          if (ci->acc == CI_ACC_RESUMED) {
+            mrb->jmp = prev_jmp;
+            return result;
+          }
+          else {
+            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));
             proc = ci[-1].proc;
             irep = proc->body.irep;
@@ -1138,5 +1420,7 @@
           }
         }
-        regs = mrb->c->stack = ci->stackent;
+        mrb->c->stack[0] = result;
+        /* pop stackpos */
+        mrb->c->stack = ci->stackent;
         pc = ci->pc;
         cipop(mrb);
@@ -1152,11 +1436,10 @@
         if (n == CALL_MAXARGS) {
           ci->argc = -1;
-          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs, 3);
+          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs);
         }
         else {
           ci->argc = n;
-          stack_extend(mrb, irep->nregs,  n+2);
-        }
-        regs = mrb->c->stack;
+          stack_extend(mrb, irep->nregs);
+        }
         pc = irep->iseq;
         JUMP;
@@ -1166,4 +1449,5 @@
     CASE(OP_FSEND) {
       /* A B C  R(A) := fcall(R(A),Syms(B),R(A+1),... ,R(A+C-1)) */
+      /* not implemented yet */
       NEXT;
     }
@@ -1180,7 +1464,13 @@
       ci->proc = m;
       if (m->env) {
-        if (m->env->mid) {
-          ci->mid = m->env->mid;
-        }
+        mrb_sym mid;
+
+        if (MRB_ENV_STACK_SHARED_P(m->env)) {
+          mid = m->env->cxt.c->cibase[m->env->cioff].mid;
+        }
+        else {
+          mid = m->env->cxt.mid;
+        }
+        if (mid) ci->mid = mid;
         if (!m->env->stack) {
           m->env->stack = mrb->c->stack;
@@ -1195,5 +1485,5 @@
         /* pop stackpos */
         ci = mrb->c->ci;
-        regs = mrb->c->stack = ci->stackent;
+        mrb->c->stack = ci->stackent;
         regs[ci->acc] = recv;
         pc = ci->pc;
@@ -1215,12 +1505,16 @@
         syms = irep->syms;
         ci->nregs = irep->nregs;
+        stack_extend(mrb, irep->nregs);
         if (ci->argc < 0) {
-          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs, 3);
-        }
-        else {
-          stack_extend(mrb, irep->nregs, ci->argc+2);
-        }
-        regs = mrb->c->stack;
-        regs[0] = m->env->stack[0];
+          if (irep->nregs > 3) {
+            stack_clear(regs+3, irep->nregs-3);
+          }
+        }
+        else if (ci->argc+2 < irep->nregs) {
+          stack_clear(regs+ci->argc+2, irep->nregs-ci->argc-2);
+        }
+        if (m->env) {
+          regs[0] = m->env->stack[0];
+        }
         pc = irep->iseq;
         JUMP;
@@ -1237,10 +1531,12 @@
       int a = GETARG_A(i);
       int n = GETARG_C(i);
-
-      if (mid == 0) {
+      mrb_value blk;
+      int bidx;
+
+      if (mid == 0 || !ci->target_class) {
         mrb_value exc;
 
         exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
-        mrb->exc = mrb_obj_ptr(exc);
+        mrb_exc_set(mrb, exc);
         goto L_RAISE;
       }
@@ -1249,6 +1545,23 @@
       m = mrb_method_search_vm(mrb, &c, mid);
       if (!m) {
-        mid = mrb_intern_lit(mrb, "method_missing");
-        m = mrb_method_search_vm(mrb, &c, mid);
+        mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
+        m = mrb_method_search_vm(mrb, &c, missing);
+        if (!m) {
+          mrb_value args;
+
+          if (n == CALL_MAXARGS) {
+            args = regs[a+1];
+          }
+          else {
+            args = mrb_ary_new_from_values(mrb, n, regs+a+1);
+          }
+          ERR_PC_SET(mrb, pc);
+          mrb_method_missing(mrb, mid, recv, args);
+        }
+        mid = missing;
+        if (n == CALL_MAXARGS-1) {
+          regs[a+1] = mrb_ary_new_from_values(mrb, n, regs+a+1);
+          n++;
+        }
         if (n == CALL_MAXARGS) {
           mrb_ary_unshift(mrb, regs[a+1], mrb_symbol_value(ci->mid));
@@ -1258,4 +1571,22 @@
           SET_SYM_VALUE(regs[a+1], ci->mid);
         }
+      }
+
+      if (n == CALL_MAXARGS) {
+        bidx = a+2;
+      }
+      else {
+        bidx = a+n+1;
+      }
+      blk = regs[bidx];
+      if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
+        mrb_value result;
+
+        if (bidx >= ci->nregs) {
+          stack_extend(mrb, bidx+1);
+          ci->nregs = bidx+1;
+        }
+        result = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
+        regs[bidx] = result;
       }
 
@@ -1265,4 +1596,6 @@
       ci->proc = m;
       ci->stackent = mrb->c->stack;
+      ci->target_class = c;
+      ci->pc = pc + 1;
       if (n == CALL_MAXARGS) {
         ci->argc = -1;
@@ -1271,6 +1604,4 @@
         ci->argc = n;
       }
-      ci->target_class = c;
-      ci->pc = pc + 1;
 
       /* prepare stack */
@@ -1279,4 +1610,6 @@
 
       if (MRB_PROC_CFUNC_P(m)) {
+        mrb_value v;
+
         if (n == CALL_MAXARGS) {
           ci->nregs = 3;
@@ -1285,11 +1618,27 @@
           ci->nregs = n + 2;
         }
-        mrb->c->stack[0] = m->body.func(mrb, recv);
+        v = m->body.func(mrb, recv);
         mrb_gc_arena_restore(mrb, ai);
         if (mrb->exc) goto L_RAISE;
+        ci = mrb->c->ci;
+        if (!ci->target_class) { /* return from context modifying method (resume/yield) */
+          if (ci->acc == CI_ACC_RESUMED) {
+            mrb->jmp = prev_jmp;
+            return v;
+          }
+          else {
+            mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));
+            proc = ci[-1].proc;
+            irep = proc->body.irep;
+            pool = irep->pool;
+            syms = irep->syms;
+          }
+        }
+        mrb->c->stack[0] = v;
         /* pop stackpos */
-        regs = mrb->c->stack = mrb->c->ci->stackent;
+        mrb->c->stack = ci->stackent;
+        pc = ci->pc;
         cipop(mrb);
-        NEXT;
+        JUMP;
       }
       else {
@@ -1304,10 +1653,9 @@
         ci->nregs = irep->nregs;
         if (n == CALL_MAXARGS) {
-          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs, 3);
+          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs);
         }
         else {
-          stack_extend(mrb, irep->nregs, ci->argc+2);
-        }
-        regs = mrb->c->stack;
+          stack_extend(mrb, irep->nregs);
+        }
         pc = irep->iseq;
         JUMP;
@@ -1325,14 +1673,16 @@
       mrb_value *stack;
 
+      if (mrb->c->ci->mid == 0 || mrb->c->ci->target_class == NULL) {
+        mrb_value exc;
+
+      L_NOSUPER:
+        exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
+        mrb_exc_set(mrb, exc);
+        goto L_RAISE;
+      }
       if (lv == 0) stack = regs + 1;
       else {
         struct REnv *e = uvenv(mrb, lv-1);
-        if (!e) {
-          mrb_value exc;
-
-          exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
-          mrb->exc = mrb_obj_ptr(exc);
-          goto L_RAISE;
-        }
+        if (!e) goto L_NOSUPER;
         stack = e->stack + 1;
       }
@@ -1388,7 +1738,4 @@
       mrb_value *blk = &argv[argc < 0 ? 1 : argc];
 
-      if (!mrb_nil_p(*blk) && mrb_type(*blk) != MRB_TT_PROC) {
-        *blk = mrb_convert_type(mrb, *blk, MRB_TT_PROC, "Proc", "to_proc");
-      }
       if (argc < 0) {
         struct RArray *ary = mrb_ary_ptr(regs[1]);
@@ -1410,5 +1757,4 @@
         argv = mrb_ary_ptr(argv[0])->ptr;
       }
-      mrb->c->ci->argc = len;
       if (argc < len) {
         int mlen = m2;
@@ -1424,6 +1770,12 @@
           value_move(&regs[1], argv, argc-mlen); /* m1 + o */
         }
+        if (argc < m1) {
+          stack_clear(&regs[argc+1], m1-argc);
+        }
         if (mlen) {
           value_move(&regs[len-m2+1], &argv[argc-mlen], mlen);
+        }
+        if (mlen < m2) {
+          stack_clear(&regs[len-m2+mlen+1], m2-mlen);
         }
         if (r) {
@@ -1454,4 +1806,9 @@
         pc += o + 1;
       }
+      mrb->c->ci->argc = len;
+      /* clear local (but non-argument) variables */
+      if (irep->nlocals-len-2 > 0) {
+        stack_clear(&regs[len+2], irep->nlocals-len-2);
+      }
       JUMP;
     }
@@ -1474,32 +1831,51 @@
     CASE(OP_RETURN) {
       /* A B     return R(A) (B=normal,in-block return/break) */
+      mrb_callinfo *ci;
+
+      ci = mrb->c->ci;
+      if (ci->mid) {
+        mrb_value blk;
+
+        if (ci->argc < 0) {
+          blk = regs[2];
+        }
+        else {
+          blk = regs[ci->argc+1];
+        }
+        if (mrb_type(blk) == MRB_TT_PROC) {
+          struct RProc *p = mrb_proc_ptr(blk);
+
+          if (!MRB_PROC_STRICT_P(proc) &&
+              ci > mrb->c->cibase && p->env == ci[-1].env) {
+            p->flags |= MRB_PROC_ORPHAN;
+          }
+        }
+      }
+
       if (mrb->exc) {
-        mrb_callinfo *ci;
-        int eidx;
+        mrb_callinfo *ci0;
+        mrb_value *stk;
 
       L_RAISE:
-        ci = mrb->c->ci;
-        mrb_obj_iv_ifnone(mrb, mrb->exc, mrb_intern_lit(mrb, "lastpc"), mrb_cptr_value(mrb, pc));
-        mrb_obj_iv_ifnone(mrb, mrb->exc, mrb_intern_lit(mrb, "ciidx"), mrb_fixnum_value(ci - mrb->c->cibase));
-        eidx = ci->eidx;
+        ci0 = ci = mrb->c->ci;
         if (ci == mrb->c->cibase) {
-          if (ci->ridx == 0) goto L_STOP;
+          if (ci->ridx == 0) goto L_FTOP;
           goto L_RESCUE;
         }
+        stk = mrb->c->stack;
         while (ci[0].ridx == ci[-1].ridx) {
           cipop(mrb);
-          ci = mrb->c->ci;
-          mrb->c->stack = ci[1].stackent;
-          if (ci[1].acc == CI_ACC_SKIP && prev_jmp) {
+          mrb->c->stack = ci->stackent;
+          if (ci->acc == CI_ACC_SKIP && prev_jmp) {
             mrb->jmp = prev_jmp;
             MRB_THROW(prev_jmp);
           }
+          ci = mrb->c->ci;
           if (ci == mrb->c->cibase) {
-            while (eidx > 0) {
-              ecall(mrb, --eidx);
-            }
+            mrb->c->stack = stk;
             if (ci->ridx == 0) {
+            L_FTOP:             /* fiber top */
               if (mrb->c == mrb->root_c) {
-                regs = mrb->c->stack = mrb->c->stbase;
+                mrb->c->stack = mrb->c->stbase;
                 goto L_STOP;
               }
@@ -1507,4 +1883,7 @@
                 struct mrb_context *c = mrb->c;
 
+                if (c->fib) {
+                  mrb_write_barrier(mrb, (struct RBasic*)c->fib);
+                }
                 mrb->c = c->prev;
                 c->prev = NULL;
@@ -1516,6 +1895,7 @@
           /* call ensure only when we skip this callinfo */
           if (ci[0].ridx == ci[-1].ridx) {
-            while (eidx > ci[-1].eidx) {
-              ecall(mrb, --eidx);
+            while (mrb->c->eidx > ci->epos) {
+              ecall(mrb, --mrb->c->eidx);
+              ci = mrb->c->ci;
             }
           }
@@ -1527,32 +1907,49 @@
         pool = irep->pool;
         syms = irep->syms;
-        regs = mrb->c->stack = ci[1].stackent;
+        if (ci != ci0) {
+          mrb->c->stack = ci[1].stackent;
+        }
+        stack_extend(mrb, irep->nregs);
         pc = mrb->c->rescue[--ci->ridx];
       }
       else {
-        mrb_callinfo *ci = mrb->c->ci;
-        int acc, eidx = mrb->c->ci->eidx;
-        mrb_value v = regs[GETARG_A(i)];
-
+        int acc;
+        mrb_value v;
+
+        v = regs[GETARG_A(i)];
+        mrb_gc_protect(mrb, v);
         switch (GETARG_B(i)) {
         case OP_R_RETURN:
           /* Fall through to OP_R_NORMAL otherwise */
-          if (proc->env && !MRB_PROC_STRICT_P(proc)) {
+          if (ci->acc >=0 && proc->env && !MRB_PROC_STRICT_P(proc)) {
             struct REnv *e = top_env(mrb, proc);
-
-            if (!MRB_ENV_STACK_SHARED_P(e)) {
+            mrb_callinfo *ce;
+
+            if (!MRB_ENV_STACK_SHARED_P(e) || e->cxt.c != mrb->c) {
               localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
               goto L_RAISE;
             }
-            ci = mrb->c->cibase + e->cioff;
-            if (ci == mrb->c->cibase) {
+            
+            ce = mrb->c->cibase + e->cioff;
+            while (ci >= ce) {
+              if (ci->env) {
+                mrb_env_unshare(mrb, ci->env);
+              }
+              if (ci->acc < 0) {
+                localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
+                goto L_RAISE;
+              }
+              ci--;
+            }
+            if (ce == mrb->c->cibase) {
               localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
               goto L_RAISE;
             }
             mrb->c->stack = mrb->c->ci->stackent;
-            mrb->c->ci = ci;
+            mrb->c->ci = ce;
             break;
           }
         case OP_R_NORMAL:
+        NORMAL_RETURN:
           if (ci == mrb->c->cibase) {
             if (!mrb->c->prev) { /* toplevel return */
@@ -1562,6 +1959,9 @@
             if (mrb->c->prev->ci == mrb->c->prev->cibase) {
               mrb_value exc = mrb_exc_new_str_lit(mrb, E_FIBER_ERROR, "double resume");
-              mrb->exc = mrb_obj_ptr(exc);
+              mrb_exc_set(mrb, exc);
               goto L_RAISE;
+            }
+            while (mrb->c->eidx > 0) {
+              ecall(mrb, --mrb->c->eidx);
             }
             /* automatic yield at the end */
@@ -1573,7 +1973,16 @@
           break;
         case OP_R_BREAK:
+          if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;
+          if (MRB_PROC_ORPHAN_P(proc)) { 
+            mrb_value exc;
+
+          L_BREAK_ERROR:
+            exc = mrb_exc_new_str_lit(mrb, E_LOCALJUMP_ERROR,
+                                      "break from proc-closure");
+            mrb_exc_set(mrb, exc);
+            goto L_RAISE;
+          }
           if (!proc->env || !MRB_ENV_STACK_SHARED_P(proc->env)) {
-            localjump_error(mrb, LOCALJUMP_ERROR_BREAK);
-            goto L_RAISE;
+            goto L_BREAK_ERROR;
           }
           /* break from fiber block */
@@ -1581,14 +1990,37 @@
             struct mrb_context *c = mrb->c;
 
+            while (mrb->c->eidx > 0) {
+              ecall(mrb, --mrb->c->eidx);
+            }
             mrb->c = c->prev;
             c->prev = NULL;
-          }
-          ci = mrb->c->ci;
+            ci = mrb->c->ci;
+          }
+          if (ci->acc < 0) {
+            while (mrb->c->eidx > mrb->c->ci->epos) {
+              ecall(mrb, --mrb->c->eidx);
+            }
+            ARENA_RESTORE(mrb, ai);
+            mrb->c->vmexec = FALSE;
+            mrb->exc = (struct RObject*)break_new(mrb, proc, v);
+            mrb->jmp = prev_jmp;
+            MRB_THROW(prev_jmp);
+          }
+          if (FALSE) {
+          L_BREAK:
+            v = ((struct RBreak*)mrb->exc)->val;
+            proc = ((struct RBreak*)mrb->exc)->proc;
+            mrb->exc = NULL;
+            ci = mrb->c->ci;
+          }
           mrb->c->stack = ci->stackent;
           mrb->c->ci = mrb->c->cibase + proc->env->cioff + 1;
           while (ci > mrb->c->ci) {
+            if (ci->env) {
+              mrb_env_unshare(mrb, ci->env);
+            }
             if (ci[-1].acc == CI_ACC_SKIP) {
               mrb->c->ci = ci;
-              break;
+              goto L_BREAK_ERROR;
             }
             ci--;
@@ -1599,16 +2031,24 @@
           break;
         }
-        while (eidx > mrb->c->ci[-1].eidx) {
-          ecall(mrb, --eidx);
-        }
-        cipop(mrb);
-        acc = ci->acc;
-        pc = ci->pc;
-        regs = mrb->c->stack = ci->stackent;
-        if (acc == CI_ACC_SKIP) {
+        while (mrb->c->eidx > mrb->c->ci->epos) {
+          ecall(mrb, --mrb->c->eidx);
+        }
+        if (mrb->c->vmexec && !mrb->c->ci->target_class) {
+          ARENA_RESTORE(mrb, ai);
+          mrb->c->vmexec = FALSE;
           mrb->jmp = prev_jmp;
           return v;
         }
-        DEBUG(printf("from :%s\n", mrb_sym2name(mrb, ci->mid)));
+        ci = mrb->c->ci;
+        acc = ci->acc;
+        mrb->c->stack = ci->stackent;
+        cipop(mrb);
+        if (acc == CI_ACC_SKIP || acc == CI_ACC_DIRECT) {
+          ARENA_RESTORE(mrb, ai);
+          mrb->jmp = prev_jmp;
+          return v;
+        }
+        pc = ci->pc;
+        DEBUG(fprintf(stderr, "from :%s\n", mrb_sym2name(mrb, ci->mid)));
         proc = mrb->c->ci->proc;
         irep = proc->body.irep;
@@ -1617,4 +2057,5 @@
 
         regs[acc] = v;
+        ARENA_RESTORE(mrb, ai);
       }
       JUMP;
@@ -1636,7 +2077,19 @@
       if (!m) {
         mrb_value sym = mrb_symbol_value(mid);
-
-        mid = mrb_intern_lit(mrb, "method_missing");
-        m = mrb_method_search_vm(mrb, &c, mid);
+        mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
+        m = mrb_method_search_vm(mrb, &c, missing);
+        if (!m) {
+          mrb_value args;
+
+          if (n == CALL_MAXARGS) {
+            args = regs[a+1];
+          }
+          else {
+            args = mrb_ary_new_from_values(mrb, n, regs+a+1);
+          }
+          ERR_PC_SET(mrb, pc);
+          mrb_method_missing(mrb, mid, recv, args);
+        }
+        mid = missing;
         if (n == CALL_MAXARGS) {
           mrb_ary_unshift(mrb, regs[a+1], sym);
@@ -1663,5 +2116,6 @@
 
       if (MRB_PROC_CFUNC_P(m)) {
-        mrb->c->stack[0] = m->body.func(mrb, recv);
+        mrb_value v = m->body.func(mrb, recv);
+        mrb->c->stack[0] = v;
         mrb_gc_arena_restore(mrb, ai);
         goto L_RETURN;
@@ -1673,10 +2127,9 @@
         syms = irep->syms;
         if (ci->argc < 0) {
-          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs, 3);
+          stack_extend(mrb, (irep->nregs < 3) ? 3 : irep->nregs);
         }
         else {
-          stack_extend(mrb, irep->nregs, ci->argc+2);
-        }
-        regs = mrb->c->stack;
+          stack_extend(mrb, irep->nregs);
+        }
         pc = irep->iseq;
       }
@@ -1697,9 +2150,14 @@
       else {
         struct REnv *e = uvenv(mrb, lv-1);
-        if (!e) {
+        if (!e || e->cioff == 0 ||
+            (!MRB_ENV_STACK_SHARED_P(e) && e->cxt.mid == 0)) {
           localjump_error(mrb, LOCALJUMP_ERROR_YIELD);
           goto L_RAISE;
         }
         stack = e->stack + 1;
+      }
+      if (mrb_nil_p(stack[m1+r+m2])) {
+        localjump_error(mrb, LOCALJUMP_ERROR_YIELD);
+        goto L_RAISE;
       }
       regs[a] = stack[m1+r+m2];
@@ -1833,23 +2291,13 @@
       case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):
         {
-          mrb_value z;
-
-          z = mrb_fixnum_mul(mrb, regs[a], regs[a+1]);
-
-          switch (mrb_type(z)) {
-          case MRB_TT_FIXNUM:
-            {
-              SET_INT_VALUE(regs[a], mrb_fixnum(z));
-            }
+          mrb_int x, y, z;
+
+          x = mrb_fixnum(regs[a]);
+          y = mrb_fixnum(regs[a+1]);
+          if (mrb_int_mul_overflow(x, y, &z)) {
+            SET_FLOAT_VALUE(mrb, regs[a], (mrb_float)x * (mrb_float)y);
             break;
-          case MRB_TT_FLOAT:
-            {
-              SET_FLOAT_VALUE(mrb, regs[a], mrb_float(z));
-            }
-            break;
-          default:
-            /* cannot happen */
-            break;
-          }
+          }
+          SET_INT_VALUE(regs[a], z);
         }
         break;
@@ -1936,5 +2384,6 @@
 #ifdef MRB_NAN_BOXING
       if (isnan(mrb_float(regs[a]))) {
-        regs[a] = mrb_float_value(mrb, mrb_float(regs[a]));
+        mrb_value v = mrb_float_value(mrb, mrb_float(regs[a]));
+        regs[a] = v;
       }
 #endif
@@ -2089,5 +2538,9 @@
     CASE(OP_ARRAY) {
       /* A B C          R(A) := ary_new(R(B),R(B+1)..R(B+C)) */
-      regs[GETARG_A(i)] = mrb_ary_new_from_values(mrb, GETARG_C(i), &regs[GETARG_B(i)]);
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      int c = GETARG_C(i);
+      mrb_value v = mrb_ary_new_from_values(mrb, c, &regs[b]);
+      regs[a] = v;
       ARENA_RESTORE(mrb, ai);
       NEXT;
@@ -2096,6 +2549,8 @@
     CASE(OP_ARYCAT) {
       /* A B            mrb_ary_concat(R(A),R(B)) */
-      mrb_ary_concat(mrb, regs[GETARG_A(i)],
-                     mrb_ary_splat(mrb, regs[GETARG_B(i)]));
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      mrb_value splat = mrb_ary_splat(mrb, regs[b]);
+      mrb_ary_concat(mrb, regs[a], splat);
       ARENA_RESTORE(mrb, ai);
       NEXT;
@@ -2104,5 +2559,7 @@
     CASE(OP_ARYPUSH) {
       /* A B            R(A).push(R(B)) */
-      mrb_ary_push(mrb, regs[GETARG_A(i)], regs[GETARG_B(i)]);
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      mrb_ary_push(mrb, regs[a], regs[b]);
       NEXT;
     }
@@ -2111,10 +2568,11 @@
       /* A B C          R(A) := R(B)[C] */
       int a = GETARG_A(i);
+      int b = GETARG_B(i);
       int c = GETARG_C(i);
-      mrb_value v = regs[GETARG_B(i)];
+      mrb_value v = regs[b];
 
       if (!mrb_array_p(v)) {
         if (c == 0) {
-          regs[GETARG_A(i)] = v;
+          regs[a] = v;
         }
         else {
@@ -2123,5 +2581,6 @@
       }
       else {
-        regs[GETARG_A(i)] = mrb_ary_ref(mrb, v, c);
+        v = mrb_ary_ref(mrb, v, c);
+        regs[a] = v;
       }
       NEXT;
@@ -2130,5 +2589,8 @@
     CASE(OP_ASET) {
       /* A B C          R(B)[C] := R(A) */
-      mrb_ary_set(mrb, regs[GETARG_B(i)], GETARG_C(i), regs[GETARG_A(i)]);
+      int a = GETARG_A(i);
+      int b = GETARG_B(i);
+      int c = GETARG_C(i);
+      mrb_ary_set(mrb, regs[b], c, regs[a]);
       NEXT;
     }
@@ -2140,5 +2602,4 @@
       int pre  = GETARG_B(i);
       int post = GETARG_C(i);
-
       struct RArray *ary;
       int len, idx;
@@ -2150,5 +2611,6 @@
       len = ary->len;
       if (len > pre + post) {
-        regs[a++] = mrb_ary_new_from_values(mrb, len - pre - post, ary->ptr+pre);
+        v = mrb_ary_new_from_values(mrb, len - pre - post, ary->ptr+pre);
+        regs[a++] = v;
         while (post--) {
           regs[a++] = ary->ptr[len-post-1];
@@ -2156,5 +2618,6 @@
       }
       else {
-        regs[a++] = mrb_ary_new_capa(mrb, 0);
+        v = mrb_ary_new_capa(mrb, 0);
+        regs[a++] = v;
         for (idx=0; idx+pre<len; idx++) {
           regs[a+idx] = ary->ptr[pre+idx];
@@ -2171,5 +2634,6 @@
     CASE(OP_STRING) {
       /* A Bx           R(A) := str_new(Lit(Bx)) */
-      regs[GETARG_A(i)] = mrb_str_dup(mrb, pool[GETARG_Bx(i)]);
+      mrb_value str = mrb_str_dup(mrb, pool[GETARG_Bx(i)]);
+      regs[GETARG_A(i)] = str;
       ARENA_RESTORE(mrb, ai);
       NEXT;
@@ -2179,5 +2643,4 @@
       /* A B    R(A).concat(R(B)) */
       mrb_str_concat(mrb, regs[GETARG_A(i)], regs[GETARG_B(i)]);
-      regs = mrb->c->stack;
       NEXT;
     }
@@ -2224,5 +2687,5 @@
     CASE(OP_CLASS) {
       /* A B    R(A) := newclass(R(A),Syms(B),R(A+1)) */
-      struct RClass *c = 0;
+      struct RClass *c = 0, *baseclass;
       int a = GETARG_A(i);
       mrb_value base, super;
@@ -2232,5 +2695,8 @@
       super = regs[a+1];
       if (mrb_nil_p(base)) {
-        base = mrb_obj_value(mrb->c->ci->target_class);
+        baseclass = mrb->c->ci->proc->target_class;
+        if (!baseclass) baseclass = mrb->c->ci->target_class;
+
+        base = mrb_obj_value(baseclass);
       }
       c = mrb_vm_define_class(mrb, base, super, id);
@@ -2242,5 +2708,5 @@
     CASE(OP_MODULE) {
       /* A B            R(A) := newmodule(R(A),Syms(B)) */
-      struct RClass *c = 0;
+      struct RClass *c = 0, *baseclass;
       int a = GETARG_A(i);
       mrb_value base;
@@ -2249,5 +2715,8 @@
       base = regs[a];
       if (mrb_nil_p(base)) {
-        base = mrb_obj_value(mrb->c->ci->target_class);
+        baseclass = mrb->c->ci->proc->target_class;
+        if (!baseclass) baseclass = mrb->c->ci->target_class;
+
+        base = mrb_obj_value(baseclass);
       }
       c = mrb_vm_define_module(mrb, base, id);
@@ -2263,4 +2732,8 @@
       mrb_value recv = regs[a];
       struct RProc *p;
+
+      /* prepare closure */
+      p = mrb_closure_new(mrb, irep->reps[GETARG_Bx(i)]);
+      p->c = NULL;
 
       /* prepare stack */
@@ -2276,28 +2749,16 @@
       mrb->c->stack += a;
 
-      p = mrb_proc_new(mrb, irep->reps[GETARG_Bx(i)]);
+      /* setup closure */
       p->target_class = ci->target_class;
       ci->proc = p;
 
-      if (MRB_PROC_CFUNC_P(p)) {
-        ci->nregs = 0;
-        mrb->c->stack[0] = p->body.func(mrb, recv);
-        mrb_gc_arena_restore(mrb, ai);
-        if (mrb->exc) goto L_RAISE;
-        /* pop stackpos */
-        regs = mrb->c->stack = mrb->c->ci->stackent;
-        cipop(mrb);
-        NEXT;
-      }
-      else {
-        irep = p->body.irep;
-        pool = irep->pool;
-        syms = irep->syms;
-        stack_extend(mrb, irep->nregs, 1);
-        ci->nregs = irep->nregs;
-        regs = mrb->c->stack;
-        pc = irep->iseq;
-        JUMP;
-      }
+      irep = p->body.irep;
+      pool = irep->pool;
+      syms = irep->syms;
+      stack_extend(mrb, irep->nregs);
+      stack_clear(regs+1, irep->nregs-1);
+      ci->nregs = irep->nregs;
+      pc = irep->iseq;
+      JUMP;
     }
 
@@ -2324,5 +2785,5 @@
       if (!mrb->c->ci->target_class) {
         mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR, "no target class or module");
-        mrb->exc = mrb_obj_ptr(exc);
+        mrb_exc_set(mrb, exc);
         goto L_RAISE;
       }
@@ -2334,5 +2795,6 @@
       /* A B C  R(A) := range_new(R(B),R(B+1),C) */
       int b = GETARG_B(i);
-      regs[GETARG_A(i)] = mrb_range_new(mrb, regs[b], regs[b+1], GETARG_C(i));
+      mrb_value val = mrb_range_new(mrb, regs[b], regs[b+1], GETARG_C(i));
+      regs[GETARG_A(i)] = val;
       ARENA_RESTORE(mrb, ai);
       NEXT;
@@ -2357,8 +2819,8 @@
     L_STOP:
       {
-        int eidx_stop = mrb->c->ci == mrb->c->cibase ? 0 : mrb->c->ci[-1].eidx;
-        int eidx = mrb->c->ci->eidx;
-        while (eidx > eidx_stop) {
-          ecall(mrb, --eidx);
+        int epos = mrb->c->ci->epos;
+
+        while (mrb->c->eidx > epos) {
+          ecall(mrb, --mrb->c->eidx);
         }
       }
@@ -2382,9 +2844,10 @@
         exc = mrb_exc_new_str(mrb, E_LOCALJUMP_ERROR, msg);
       }
-      mrb->exc = mrb_obj_ptr(exc);
+      mrb_exc_set(mrb, exc);
       goto L_RAISE;
     }
   }
   END_DISPATCH;
+#undef regs
 
   }
@@ -2399,21 +2862,31 @@
 mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
 {
-  return mrb_context_run(mrb, proc, self, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
+  if (mrb->c->ci->argc < 0) {
+    return mrb_vm_run(mrb, proc, self, 3); /* receiver, args and block) */
+  }
+  else {
+    return mrb_vm_run(mrb, proc, self, mrb->c->ci->argc + 2); /* argc + 2 (receiver and block) */
+  }
 }
 
 MRB_API mrb_value
-mrb_toplevel_run_keep(mrb_state *mrb, struct RProc *proc, unsigned int stack_keep)
+mrb_top_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stack_keep)
 {
   mrb_callinfo *ci;
   mrb_value v;
 
-  if (!mrb->c->cibase || mrb->c->ci == mrb->c->cibase) {
-    return mrb_context_run(mrb, proc, mrb_top_self(mrb), stack_keep);
+  if (!mrb->c->cibase) {
+    return mrb_vm_run(mrb, proc, self, stack_keep);
+  }
+  if (mrb->c->ci == mrb->c->cibase) {
+    mrb->c->ci->env = NULL;
+    return mrb_vm_run(mrb, proc, self, stack_keep);
   }
   ci = cipush(mrb);
+  ci->mid = 0;
   ci->nregs = 1;   /* protect the receiver */
   ci->acc = CI_ACC_SKIP;
   ci->target_class = mrb->object_class;
-  v = mrb_context_run(mrb, proc, mrb_top_self(mrb), stack_keep);
+  v = mrb_vm_run(mrb, proc, self, stack_keep);
   cipop(mrb);
 
@@ -2421,7 +2894,11 @@
 }
 
-MRB_API mrb_value
-mrb_toplevel_run(mrb_state *mrb, struct RProc *proc)
-{
-  return mrb_toplevel_run_keep(mrb, proc, 0);
-}
+#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
+# if !defined(MRB_ENABLE_CXX_ABI)
+} /* end of extern "C" */
+# endif
+mrb_int mrb_jmpbuf::jmpbuf_id = 0;
+# if !defined(MRB_ENABLE_CXX_ABI)
+extern "C" {
+# endif
+#endif
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/gitlab.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/tasks/gitlab.rake	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/gitlab.rake	(revision 331)
@@ -0,0 +1,118 @@
+CI_VERSION = '0.7'.freeze
+CI_BASE = 'ubuntu:16.10'.freeze
+CI_COMPILERS = ['gcc-4.7',
+                'gcc-4.8',
+                'gcc-4.9',
+                'gcc-5',
+                'gcc-6',
+                'clang-3.5',
+                'clang-3.6',
+                'clang-3.7',
+                'clang-3.8',
+                'clang-3.9'].freeze
+
+def ci_image_tag(compiler)
+  compiler.tr('+', 'c').delete('-').delete('.')
+end
+
+def ci_docker_tag(compiler)
+  tag = ci_image_tag(compiler)
+  "registry.gitlab.com/dabroz/mruby:#{tag}_#{CI_VERSION}"
+end
+
+def run_cmd(cmd)
+  puts cmd
+  raise 'error' unless system cmd
+end
+
+desc 'recreate docker images for GitLab builds'
+task :gitlab_dockers do
+  CI_COMPILERS.each do |compiler|
+    tag = ci_image_tag(compiler)
+    filename = "Dockerfile.#{tag}"
+    File.open(filename, 'wb') do |f|
+      f << "# #{compiler} - #{tag}\n"
+      f << "FROM #{CI_BASE}\n"
+      f << "RUN apt-get update && apt-get install -y git ruby2.3 ruby2.3-dev bison\n"
+      f << "RUN apt-get update && apt-get install -y binutils manpages\n"
+      f << "RUN apt-get update && apt-get install -y #{compiler}\n"
+      if compiler['gcc']
+        f << "RUN apt-get update && apt-get install -y libx32#{compiler}-dev\n"
+        f << "RUN apt-get update && apt-get install --no-install-recommends -y #{compiler}-multilib\n"
+      end
+      f << "RUN dpkg --add-architecture i386\n"
+      f << "RUN apt-get update && apt-get install -y linux-libc-dev:i386\n"
+      if compiler['clang']
+        f << "RUN apt-get update && apt-get install --no-install-recommends -y libc6-dev-i386\n"
+        f << "RUN apt-get update && apt-get install -y gcc gcc-multilib\n"
+      end
+    end
+    docker_tag = ci_docker_tag(compiler)
+    cmd1 = "docker build -t #{docker_tag} -f #{filename} ."
+    cmd2 = "docker push #{docker_tag}"
+    run_cmd cmd1
+    run_cmd cmd2
+    File.delete(filename)
+  end
+end
+
+desc 'create build configurations and update .gitlab-ci.yml'
+task :gitlab_config do
+  require 'yaml'
+
+  configs = []
+  [true, false].each do |mode_32|
+    ['', 'MRB_USE_FLOAT'].each do |float_conf|
+      ['', 'MRB_INT16', 'MRB_INT64'].each do |int_conf|
+        ['', 'MRB_NAN_BOXING', 'MRB_WORD_BOXING'].each do |boxing_conf|
+          ['', 'MRB_UTF8_STRING'].each do |utf8_conf|
+            next if (float_conf == 'MRB_USE_FLOAT') && (boxing_conf == 'MRB_NAN_BOXING')
+            next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_NAN_BOXING')
+            next if (int_conf == 'MRB_INT16') && (boxing_conf == 'MRB_WORD_BOXING')
+            next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_WORD_BOXING') && mode_32
+            env = [float_conf, int_conf, boxing_conf, utf8_conf].map do |conf|
+              conf == '' ? nil : "-D#{conf}=1"
+            end.compact.join(' ')
+            bit = mode_32 ? '-m32 ' : ''
+            _info = ''
+            _info += mode_32 ? '32bit ' : '64bit '
+            _info += float_conf['USE'] ? 'float ' : ''
+            _info += int_conf['16'] ? 'int16 ' : ''
+            _info += int_conf['64'] ? 'int64 ' : ''
+            _info += boxing_conf['NAN'] ? 'nan ' : ''
+            _info += boxing_conf['word'] ? 'word ' : ''
+            _info += utf8_conf['UTF8'] ? 'utf8 ' : ''
+            _info = _info.gsub(/ +/, ' ').strip.tr(' ', '_')
+            configs << { '_info' => _info, 'CFLAGS' => "#{bit}#{env}", 'LDFLAGS' => bit.strip.to_s }
+          end
+        end
+      end
+    end
+  end
+  path = './.gitlab-ci.yml'
+  data = YAML.load_file(path)
+  data.keys.select do |key|
+    key.start_with? 'Test'
+  end.each do |key|
+    data.delete(key)
+  end
+  CI_COMPILERS.each do |compiler|
+    configs.each do |config|
+      name = "Test #{compiler} #{config['_info']}"
+      hash = {
+        'CC' => compiler,
+        'CXX' => compiler.gsub('gcc', 'g++').gsub('clang', 'clang++'),
+        'LD' => compiler
+      }
+      hash = hash.merge(config)
+      hash.delete('_info')
+      data[name] = {
+        'stage' => 'test',
+        'image' => ci_docker_tag(compiler),
+        'variables' => hash,
+        'script' => 'env; ./minirake --verbose all test'
+      }
+    end
+  end
+  File.open(path, 'w') { |f| YAML.dump(data, f) }
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/libmruby.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/libmruby.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/libmruby.rake	(revision 331)
@@ -6,15 +6,17 @@
   file "#{build_dir}/lib/libmruby.flags.mak" => [__FILE__, libfile("#{build_dir}/lib/libmruby")] do |t|
     open(t.name, 'w') do |f|
-      f.puts "MRUBY_CFLAGS = #{cc.all_flags.gsub('"', '\\"')}"
+      f.puts "MRUBY_CFLAGS = #{cc.all_flags}"
 
       gem_flags = gems.map { |g| g.linker.flags }
       gem_library_paths = gems.map { |g| g.linker.library_paths }
-      f.puts "MRUBY_LDFLAGS = #{linker.all_flags(gem_library_paths, gem_flags).gsub('"', '\\"')} #{linker.option_library_path % "#{build_dir}/lib"}"
+      f.puts "MRUBY_LDFLAGS = #{linker.all_flags(gem_library_paths, gem_flags)} #{linker.option_library_path % "#{build_dir}/lib"}"
 
       gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
-      f.puts "MRUBY_LDFLAGS_BEFORE_LIBS = #{[linker.flags_before_libraries, gem_flags_before_libraries].flatten.join(' ').gsub('"', '\\"')}"
+      f.puts "MRUBY_LDFLAGS_BEFORE_LIBS = #{[linker.flags_before_libraries, gem_flags_before_libraries].flatten.join(' ')}"
 
       gem_libraries = gems.map { |g| g.linker.libraries }
-      f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries).gsub('"', '\\"')}"
+      f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries)}"
+
+      f.puts "MRUBY_LIBMRUBY_PATH = #{libfile("#{build_dir}/lib/libmruby")}"
     end
   end
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/mrbgem_spec.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/mrbgem_spec.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/mrbgem_spec.rake	(revision 331)
@@ -2,4 +2,5 @@
 require 'forwardable'
 require 'tsort'
+require 'shellwords'
 
 module MRuby
@@ -18,4 +19,5 @@
       alias mruby build
       attr_accessor :build_config_initializer
+      attr_accessor :mrblib_dir, :objs_dir
 
       attr_accessor :version
@@ -45,4 +47,6 @@
         @initializer = block
         @version = "0.0.0"
+        @mrblib_dir = "mrblib"
+        @objs_dir = "src"
         MRuby::Gem.current = self
       end
@@ -55,6 +59,6 @@
         @linker = LinkerConfig.new([], [], [], [], [])
 
-        @rbfiles = Dir.glob("#{dir}/mrblib/**/*.rb").sort
-        @objs = Dir.glob("#{dir}/src/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
+        @rbfiles = Dir.glob("#{@dir}/#{@mrblib_dir}/**/*.rb").sort
+        @objs = Dir.glob("#{@dir}/#{@objs_dir}/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
           objfile(f.relative_path_from(@dir).to_s.pathmap("#{build_dir}/%X"))
         end
@@ -87,5 +91,7 @@
 
         instance_eval(&@build_config_initializer) if @build_config_initializer
-
+      end
+
+      def setup_compilers
         compilers.each do |compiler|
           compiler.define_rules build_dir, "#{dir}"
@@ -122,4 +128,19 @@
       def test_rbireps
         "#{build_dir}/gem_test.c"
+      end
+
+      def search_package(name, version_query=nil)
+        package_query = name
+        package_query += " #{version_query}" if version_query
+        _pp "PKG-CONFIG", package_query
+        escaped_package_query = Shellwords.escape(package_query)
+        if system("pkg-config --exists #{escaped_package_query}")
+          cc.flags += [`pkg-config --cflags #{escaped_package_query}`.strip]
+          cxx.flags += [`pkg-config --cflags #{escaped_package_query}`.strip]
+          linker.flags_before_libraries += [`pkg-config --libs #{escaped_package_query}`.strip]
+          true
+        else
+          false
+        end
       end
 
@@ -182,6 +203,6 @@
         print_gem_comment(f)
         f.puts %Q[#include <stdlib.h>] unless rbfiles.empty?
-        f.puts %Q[#include "mruby.h"]
-        f.puts %Q[#include "mruby/irep.h"] unless rbfiles.empty?
+        f.puts %Q[#include <mruby.h>]
+        f.puts %Q[#include <mruby/irep.h>] unless rbfiles.empty?
       end
 
@@ -190,8 +211,8 @@
         f.puts %Q[#include <stdio.h>]
         f.puts %Q[#include <stdlib.h>]
-        f.puts %Q[#include "mruby.h"]
-        f.puts %Q[#include "mruby/irep.h"]
-        f.puts %Q[#include "mruby/variable.h"]
-        f.puts %Q[#include "mruby/hash.h"] unless test_args.empty?
+        f.puts %Q[#include <mruby.h>]
+        f.puts %Q[#include <mruby/irep.h>]
+        f.puts %Q[#include <mruby/variable.h>]
+        f.puts %Q[#include <mruby/hash.h>] unless test_args.empty?
       end
 
@@ -401,4 +422,6 @@
         @ary = tsort_dependencies gem_table.keys, gem_table, true
 
+        each(&:setup_compilers)
+
         each do |g|
           import_include_paths(g)
@@ -414,7 +437,10 @@
           import_include_paths(dep_g)
 
+          dep_g.export_include_paths.uniq!
           g.compilers.each do |compiler|
             compiler.include_paths += dep_g.export_include_paths
             g.export_include_paths += dep_g.export_include_paths
+            compiler.include_paths.uniq!
+            g.export_include_paths.uniq!
           end
         end
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/mrbgems.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/mrbgems.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/mrbgems.rake	(revision 331)
@@ -32,5 +32,5 @@
         f.puts %Q[ */]
         f.puts %Q[]
-        f.puts %Q[#include "mruby.h"]
+        f.puts %Q[#include <mruby.h>]
         f.puts %Q[]
         f.write gem_func_decls
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/mruby_build.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/mruby_build.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/mruby_build.rake	(revision 331)
@@ -84,6 +84,7 @@
         @gems, @libmruby = MRuby::Gem::List.new, []
         @build_mrbtest_lib_only = false
+        @cxx_exception_enabled = false
+        @cxx_exception_disabled = false
         @cxx_abi_enabled = false
-        @cxx_exception_disabled = false
         @enable_bintest = false
         @enable_test = false
@@ -111,5 +112,26 @@
 
     def disable_cxx_exception
+      if @cxx_exception_enabled or @cxx_abi_enabled
+        raise "cxx_exception already enabled"
+      end
       @cxx_exception_disabled = true
+    end
+
+    def enable_cxx_exception
+      return if @cxx_exception_enabled
+      return if @cxx_abi_enabled
+      if @cxx_exception_disabled
+        raise "cxx_exception disabled"
+      end
+      @cxx_exception_enabled = true
+      compilers.each { |c|
+        c.defines += %w(MRB_ENABLE_CXX_EXCEPTION)
+        c.flags << c.cxx_exception_flag
+      }
+      linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
+    end
+
+    def cxx_exception_enabled?
+      @cxx_exception_enabled
     end
 
@@ -119,6 +141,13 @@
 
     def enable_cxx_abi
-      return if @cxx_exception_disabled or @cxx_abi_enabled
-      compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION) }
+      return if @cxx_abi_enabled
+      if @cxx_exception_enabled
+        raise "cxx_exception already enabled"
+      end
+      compilers.each { |c|
+        c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI)
+        c.flags << c.cxx_compile_flag
+      }
+      compilers.each { |c| c.flags << c.cxx_compile_flag }
       linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
       @cxx_abi_enabled = true
@@ -136,9 +165,11 @@
 #define __STDC_LIMIT_MACROS
 
+#ifndef MRB_ENABLE_CXX_ABI
 extern "C" {
+#endif
 #include "#{src}"
+#ifndef MRB_ENABLE_CXX_ABI
 }
-
-#{src == "#{MRUBY_ROOT}/src/error.c"? 'mrb_int mrb_jmpbuf::jmpbuf_id = 0;' : ''}
+#endif
 EOS
       end
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/mruby_build_commands.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/mruby_build_commands.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/mruby_build_commands.rake	(revision 331)
@@ -43,4 +43,5 @@
     attr_accessor :flags, :include_paths, :defines, :source_exts
     attr_accessor :compile_options, :option_define, :option_include_path, :out_ext
+    attr_accessor :cxx_compile_flag, :cxx_exception_flag
 
     def initialize(build, source_exts=[])
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/mruby_build_gem.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/mruby_build_gem.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/mruby_build_gem.rake	(revision 331)
@@ -39,5 +39,5 @@
         Dir.glob("#{Gem.current.dir}/#{subdir}/*.{cpp,cxx,cc}")
       end.flatten
-      enable_cxx_abi unless cxx_srcs.empty?
+      enable_cxx_exception unless cxx_srcs.empty?
 
       Gem.current
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/android.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/toolchains/android.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/android.rake	(revision 331)
@@ -1,14 +1,23 @@
 class MRuby::Toolchain::Android
-  DEFAULT_ARCH = 'armeabi'
-  DEFAULT_PLATFORM = 'android-14'
-  DEFAULT_TOOLCHAIN = :gcc
+
+  DEFAULT_ARCH = 'armeabi' # TODO : Revise if arch should have a default
+
+  DEFAULT_TOOLCHAIN = :clang
+
   DEFAULT_NDK_HOMES = %w{
+    /usr/local/opt/android-sdk/ndk-bundle
     /usr/local/opt/android-ndk
+    %LOCALAPPDATA%/Android/android-sdk/ndk-bundle
+    %LOCALAPPDATA%/Android/android-ndk
+    ~/Library/Android/sdk/ndk-bundle
+    ~/Library/Android/ndk
   }
-  TOOLCHAINS = [:gcc, :clang]
+
+  TOOLCHAINS = [:clang, :gcc]
+
   ARCHITECTURES = %w{
     armeabi armeabi-v7a arm64-v8a
+    x86 x86_64
     mips mips64
-    x86 x86_64
   }
 
@@ -22,8 +31,37 @@
   end
 
+  class PlatformDirNotFound < StandardError
+    def message
+        <<-EOM
+Couldn't find Android NDK platform directories.
+Set ANDROID_PLATFORM environment variable or set :platform parameter
+        EOM
+    end
+  end
+
   attr_reader :params
 
   def initialize(params)
     @params = params
+  end
+
+  def bin_gcc(command)
+    command = command.to_s
+
+    command = case arch
+      when /armeabi/    then 'arm-linux-androideabi-'
+      when /arm64-v8a/  then 'aarch64-linux-android-'
+      when /x86_64/     then 'x86_64-linux-android-'
+      when /x86/        then 'i686-linux-android-'
+      when /mips64/     then 'mips64el-linux-android-'
+      when /mips/       then 'mipsel-linux-android-'
+      end + command
+
+    gcc_toolchain_path.join('bin', command).to_s
+  end
+
+  def bin(command)
+    command = command.to_s
+    toolchain_path.join('bin', command).to_s
   end
 
@@ -31,99 +69,189 @@
     @home_path ||= Pathname(
       params[:ndk_home] ||
-        ENV['ANDROID_NDK_HOME'] ||
-        DEFAULT_NDK_HOMES.find{ |path| File.directory?(path) } ||
-        raise(AndroidNDKHomeNotFound)
+      ENV['ANDROID_NDK_HOME'] ||
+      DEFAULT_NDK_HOMES.find { |path|
+        path.gsub! '%LOCALAPPDATA%', ENV['LOCALAPPDATA'] || '%LOCALAPPDATA%'
+        path.gsub! '\\', '/'
+        path.gsub! '~', Dir.home || '~'
+        File.directory?(path)
+      } || raise(AndroidNDKHomeNotFound)
     )
   end
 
+  def toolchain
+    @toolchain ||= params.fetch(:toolchain){ DEFAULT_TOOLCHAIN }
+  end
+
+  def toolchain_path
+    @toolchain_path ||= case toolchain
+      when :gcc
+        gcc_toolchain_path
+      when :clang
+        home_path.join('toolchains', 'llvm' , 'prebuilt', host_platform)
+      end
+  end
+
+  def gcc_toolchain_path
+    if @gcc_toolchain_path === nil then
+      prefix = case arch
+        when /armeabi/    then 'arm-linux-androideabi-'
+        when /arm64-v8a/  then 'aarch64-linux-android-'
+        when /x86_64/     then 'x86_64-'
+        when /x86/        then 'x86-'
+        when /mips64/     then 'mips64el-linux-android-'
+        when /mips/       then 'mipsel-linux-android-'
+        end
+
+      test = case arch
+        when /armeabi/    then 'arm-linux-androideabi-*'
+        when /arm64-v8a/  then 'aarch64-linux-android-*'
+        when /x86_64/     then 'x86_64-*'
+        when /x86/        then 'x86-*'
+        when /mips64/     then 'mips64el-linux-android-*'
+        when /mips/       then 'mipsel-linux-android-*'
+        end
+
+      gcc_toolchain_version = Dir[home_path.join('toolchains', test)].map{|t| t.match(/-(\d+\.\d+)$/); $1.to_f }.max
+      @gcc_toolchain_path = home_path.join('toolchains', prefix + gcc_toolchain_version.to_s, 'prebuilt', host_platform)
+    end
+    @gcc_toolchain_path
+  end
+
+  def host_platform
+    @host_platform ||= case RUBY_PLATFORM
+      when /cygwin|mswin|mingw|bccwin|wince|emx/i
+        path = home_path.join('toolchains', 'llvm' , 'prebuilt', 'windows*')
+        Dir.glob(path.to_s){ |item|
+          next if File.file?(item)
+          path = Pathname(item)
+          break
+        }
+        path.basename
+      when /x86_64-darwin/i
+        'darwin-x86_64'
+      when /darwin/i
+        'darwin-x86'
+      when /x86_64-linux/i
+        'linux-x86_64'
+      when /linux/i
+        'linux-x86'
+      else
+        raise NotImplementedError, "Unknown host platform (#{RUBY_PLATFORM})"
+      end
+  end
+
   def arch
-    params.fetch(:arch){ DEFAULT_ARCH }
+    @arch ||= (params[:arch] || ENV['ANDROID_ARCH'] || DEFAULT_ARCH).to_s
+  end
+
+  def sysroot
+    @sysroot ||= home_path.join('platforms', platform,
+        case arch
+        when /armeabi/    then 'arch-arm'
+        when /arm64-v8a/  then 'arch-arm64'
+        when /x86_64/     then 'arch-x86_64'
+        when /x86/        then 'arch-x86'
+        when /mips64/     then 'arch-mips64'
+        when /mips/       then 'arch-mips'
+        end
+      ).to_s
   end
 
   def platform
-    params.fetch(:platform){ DEFAULT_PLATFORM }
-  end
-
-  def toolchain
-    params.fetch(:toolchain){ DEFAULT_TOOLCHAIN }
-  end
-
-  def toolchain_version
-    params.fetch(:toolchain_version) do
-      test = case toolchain
-      when :gcc
-        case arch
-        when /armeabi/
-          'arm-linux-androideabi-*'
-        when /arm64/
-          'aarch64-linux-android-*'
-        when /mips64/
-          'mips64el-linux-android-*'
-        when /mips/
-          'mipsel-linux-android-*'
-        when /x86_64/
-          'x86_64-*'
-        when /x86/
-          'x86-*'
+    if @platform === nil then
+      @platform = params[:platform] || ENV['ANDROID_PLATFORM'] || nil
+      if @platform === nil
+        Dir.glob(home_path.join('platforms/android-*').to_s){ |item|
+          next if File.file?(item)
+          if @platform === nil
+            @platform = Integer(item.rpartition('-')[2])
+          else
+            platform = Integer(item.rpartition('-')[2])
+            @platform = platform > @platform ? platform : @platform
+          end
+        }
+        if @platform === nil
+          raise(PlatformDirNotFound)
+        else
+          @platform = "android-#{@platform}"
         end
-      when :clang
-        'llvm-*'
-      end
-
-      Dir[home_path.join('toolchains',test)].map{|t| t.match(/-(\d+\.\d+)$/); $1.to_f }.max
-    end
-  end
-
-  def toolchain_path
-    prefix = case toolchain
-             when :clang then 'llvm-'
-             when :gcc
-               case arch
-               when /armeabi/ then 'arm-linux-androideabi-'
-               when /arm64/   then 'aarch64-linux-android-'
-               when /x86_64/  then 'x86_64-'
-               when /x86/     then 'x86-'
-               when /mips64/  then 'mips64el-linux-android-'
-               when /mips/    then 'mipsel-linux-android-'
-               end
-             end
-    home_path.join('toolchains', prefix + toolchain_version.to_s, 'prebuilt', host_platform)
-  end
-
-  def sysroot
-    path = case arch
-           when /armeabi/ then 'arch-arm'
-           when /arm64/   then 'arch-arm64'
-           when /x86_64/  then 'arch-x86_64'
-           when /x86/     then 'arch-x86'
-           when /mips64/  then 'arch-mips64'
-           when /mips/    then 'arch-mips'
-           end
-
-    home_path.join('platforms', platform, path).to_s
-  end
-
-  def bin(command)
-    command = command.to_s
-
-    if toolchain == :gcc
-      command = case arch
-                when /armeabi/ then 'arm-linux-androideabi-'
-                when /arm64/   then 'aarch64-linux-android-'
-                when /x86_64/  then 'x86_64-linux-android-'
-                when /x86/     then 'i686-linux-android-'
-                when /mips64/  then 'mips64el-linux-android-'
-                when /mips/    then 'mipsel-linux-android-'
-                end + command
-    end
-
-    toolchain_path.join('bin',command).to_s
+      end
+    end
+    if Integer(@platform.rpartition('-')[2]) < 21
+      case arch
+      when /arm64-v8a/, /x86_64/, /mips64/
+        raise NotImplementedError, "Platform (#{@platform}) has no implementation for architecture (#{arch})"
+      end
+    end
+    @platform
+  end
+
+  def armeabi_v7a_mfpu
+    @armeabi_v7a_mfpu ||= (params[:mfpu] || 'vfpv3-d16').to_s
+  end
+
+  def armeabi_v7a_mfloat_abi
+    @armeabi_v7a_mfloat_abi ||= (params[:mfloat_abi] || 'softfp').to_s
+  end
+
+  def no_warn_mismatch
+    if %W(soft softfp).include? armeabi_v7a_mfloat_abi
+      ''
+    else
+      ',--no-warn-mismatch'
+    end
   end
 
   def cc
     case toolchain
-    when :gcc   then bin(:gcc)
-    when :clang then bin(:clang)
-    end
+    when :gcc then bin_gcc('gcc')
+    when :clang then bin('clang')
+    end
+  end
+
+  def ar
+    case toolchain
+    when :gcc   then bin_gcc('ar')
+    when :clang then bin_gcc('ar')
+    end
+  end
+
+  def ctarget
+    flags = []
+
+    case toolchain
+    when :gcc
+      case arch
+      when /armeabi-v7a/  then flags += %W(-march=armv7-a)
+      when /armeabi/      then flags += %W(-march=armv5te)
+      when /arm64-v8a/    then flags += %W(-march=armv8-a)
+      when /x86_64/       then flags += %W(-march=x86-64)
+      when /x86/          then flags += %W(-march=i686)
+      when /mips64/       then flags += %W(-march=mips64r6)
+      when /mips/         then flags += %W(-march=mips32)
+      end
+    when :clang
+      case arch
+      when /armeabi-v7a/  then flags += %W(-target armv7-none-linux-androideabi)
+      when /armeabi/      then flags += %W(-target armv5te-none-linux-androideabi)
+      when /arm64-v8a/    then flags += %W(-target aarch64-none-linux-android)
+      when /x86_64/       then flags += %W(-target x86_64-none-linux-android)
+      when /x86/          then flags += %W(-target i686-none-linux-android)
+      when /mips64/       then flags += %W(-target mips64el-none-linux-android)
+      when /mips/         then flags += %W(-target mipsel-none-linux-android)
+      end
+    end
+
+    case arch
+    when /armeabi-v7a/  then flags += %W(-mfpu=#{armeabi_v7a_mfpu} -mfloat-abi=#{armeabi_v7a_mfloat_abi})
+    when /armeabi/      then flags += %W(-mtune=xscale -msoft-float)
+    when /arm64-v8a/    then flags += %W()
+    when /x86_64/       then flags += %W()
+    when /x86/          then flags += %W()
+    when /mips64/       then flags += %W(-fmessage-length=0)
+    when /mips/         then flags += %W(-fmessage-length=0)
+    end
+
+    flags
   end
 
@@ -131,86 +259,63 @@
     flags = []
 
+    flags += %W(-MMD -MP -D__android__ -DANDROID --sysroot="#{sysroot}")
+    flags += ctarget
     case toolchain
     when :gcc
-      flags += %W(-ffunction-sections -funwind-tables -no-canonical-prefixes)
-      flags += %W(-D__android__ -mandroid --sysroot="#{sysroot}")
-      case arch
-      when /arm64/
-        flags += %W(-fpic -fstack-protector-strong)
-      when 'armeabi-v7a-hard'
-        flags += %W(-fpic -fstack-protector-strong -march=armv7-a -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -mfpu=vfpv3-d16)
-      when 'armeabi-v7a'
-        flags += %W(-fpic -fstack-protector-strong -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16)
-      when /arm/
-        flags += %W(-fpic -fstack-protector-strong -march=armv5te -mtune=xscale -msoft-float)
-      when /mips/
-        flags += %W(-fpic -fno-strict-aliasing -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers)
-      when /x86/
-        flags += %W(-fstack-protector-strong)
-      end
     when :clang
-    end
+      flags += %W(-gcc-toolchain "#{gcc_toolchain_path.to_s}" -Wno-invalid-command-line-argument -Wno-unused-command-line-argument)
+    end
+    flags += %W(-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes)
 
     flags
-  end
-
-  def ld
-    cc
   end
 
   def ldflags
     flags = []
+
+    flags += %W(--sysroot="#{sysroot}")
+
+    flags
+  end
+
+  def ldflags_before_libraries
+    flags = []
+
     case toolchain
     when :gcc
-      flags += %W(-no-canonical-prefixes)
-      flags += %W(-D__android__ -mandroid --sysroot="#{sysroot}")
-      case arch
-      when 'armeabi-v7a-hard'
-        flags += %W(-march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-warn-mismatch -lm_hard)
-      when 'armeabi-v7a'
-        flags += %W(-march=armv7-a -Wl,--fix-cortex-a8)
-      end
-    end
-    
+      case arch
+      when /armeabi-v7a/  then flags += %W(-Wl#{no_warn_mismatch})
+      end
+    when :clang
+      flags += %W(-gcc-toolchain "#{gcc_toolchain_path.to_s}")
+      case arch
+      when /armeabi-v7a/  then flags += %W(-target armv7-none-linux-androideabi -Wl,--fix-cortex-a8#{no_warn_mismatch})
+      when /armeabi/      then flags += %W(-target armv5te-none-linux-androideabi)
+      when /arm64-v8a/    then flags += %W(-target aarch64-none-linux-android)
+      when /x86_64/       then flags += %W(-target x86_64-none-linux-android)
+      when /x86/          then flags += %W(-target i686-none-linux-android)
+      when /mips64/       then flags += %W(-target mips64el-none-linux-android)
+      when /mips/         then flags += %W(-target mipsel-none-linux-android)
+      end
+    end
+    flags += %W(-no-canonical-prefixes)
+
     flags
   end
-
-  def ar
-    case toolchain
-    when :gcc   then bin(:ar)
-    when :clang then bin('llvm-ar')
-    end
-  end
-
-  def host_platform
-    case RUBY_PLATFORM
-    when /cygwin|mswin|mingw|bccwin|wince|emx/i
-      'windows'
-    when /x86_64-darwin/i
-      'darwin-x86_64'
-    when /darwin/i
-      'darwin-x86'
-    when /x86_64-linux/i
-      'linux-x86_64'
-    when /linux/i
-      'linux-x86'
-    else
-      raise NotImplementedError, "Unknown host platform (#{RUBY_PLATFORM})"
-    end
-  end
 end
 
 MRuby::Toolchain.new(:android) do |conf, params|
-  ndk = MRuby::Toolchain::Android.new(params)
-
-  toolchain ndk.toolchain
+  android = MRuby::Toolchain::Android.new(params)
+
+  toolchain android.toolchain
 
   [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc|
-    cc.command = ndk.cc
-    cc.flags = ndk.cflags
-  end
-  conf.linker.command = ndk.ld
-  conf.linker.flags = ndk.ldflags
-  conf.archiver.command = ndk.ar
+    cc.command = android.cc
+    cc.flags = android.cflags
+  end
+
+  conf.archiver.command = android.ar
+  conf.linker.command = android.cc
+  conf.linker.flags = android.ldflags
+  conf.linker.flags_before_libraries = android.ldflags_before_libraries
 end
-
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/clang.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/toolchains/clang.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/clang.rake	(revision 331)
@@ -1,3 +1,3 @@
-MRuby::Toolchain.new(:clang) do |conf|
+MRuby::Toolchain.new(:clang) do |conf, _params|
   toolchain :gcc
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/gcc.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/toolchains/gcc.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/gcc.rake	(revision 331)
@@ -1,3 +1,3 @@
-MRuby::Toolchain.new(:gcc) do |conf|
+MRuby::Toolchain.new(:gcc) do |conf, _params|
   [conf.cc, conf.objc, conf.asm].each do |cc|
     cc.command = ENV['CC'] || 'gcc'
@@ -7,4 +7,6 @@
     cc.option_define = '-D%s'
     cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
+    cc.cxx_compile_flag = '-x c++ -std=c++03'
+    cc.cxx_exception_flag = '-fexceptions'
   end
 
@@ -16,4 +18,6 @@
     cxx.option_define = '-D%s'
     cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
+    cxx.cxx_compile_flag = '-x c++ -std=c++03'
+    cxx.cxx_exception_flag = '-fexceptions'
   end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/openwrt.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/openwrt.rake	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/openwrt.rake	(revision 331)
@@ -0,0 +1,38 @@
+# usage of environmental variables to set the
+# cross compiling toolchain proper
+MRuby::Toolchain.new(:openwrt) do |conf|
+  [conf.cc, conf.objc, conf.asm].each do |cc|
+    cc.command = ENV['TARGET_CC']
+    cc.flags = ENV['TARGET_CFLAGS']
+    cc.include_paths = ["#{MRUBY_ROOT}/include"]
+    cc.defines = %w(DISABLE_GEMS)
+    cc.option_include_path = '-I%s'
+    cc.option_define = '-D%s'
+    cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
+  end
+
+  [conf.cxx].each do |cxx|
+    cxx.command = ENV['TARGET_CXX']
+    cxx.flags = ENV['TARGET_CXXFLAGS']
+    cxx.include_paths = ["#{MRUBY_ROOT}/include"]
+    cxx.defines = %w(DISABLE_GEMS)
+    cxx.option_include_path = '-I%s'
+    cxx.option_define = '-D%s'
+    cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
+   end
+
+  conf.linker do |linker|
+    linker.command = ENV['TARGET_CC']
+    linker.flags = ENV['TARGET_LDFLAGS']
+    linker.libraries = %w(m)
+    linker.library_paths = []
+    linker.option_library = '-l%s'
+    linker.option_library_path = '-L%s'
+    linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}'
+  end
+
+  conf.archiver do |archiver|
+    archiver.command = ENV['TARGET_AR']
+    archiver.archive_options = 'rs %{outfile} %{objs}'
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/visualcpp.rake
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/tasks/toolchains/visualcpp.rake	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/tasks/toolchains/visualcpp.rake	(revision 331)
@@ -1,27 +1,24 @@
-MRuby::Toolchain.new(:visualcpp) do |conf|
+MRuby::Toolchain.new(:visualcpp) do |conf, _params|
   conf.cc do |cc|
     cc.command = ENV['CC'] || 'cl.exe'
-    cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /utf-8 /W4 /GS /analyze- /Zc:wchar_t /ZI /Gm /Od /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /EHsc /DWIN32 /D_DEBUG /D_CONSOLE /D_CRT_SECURE_NO_WARNINGS)]
-    cc.flags << %w(/we4002 /we4003 /we4005 /we4007 /we4010 /we4013 /we4015 /we4020 /we4022 /we4024 /we4028 /we4029 /we4031 /we4033 /we4034 /we4042 /we4047 /we4048 /we4049 /we4056 /we4067 /we4074 /we4079 /we4083 /we4088 /we4089 /we4090 /we4091 /we4094 /we4096 /we4098 /we4099 /we4113 /we4133 /we4715 /we4716)
-    cc.flags << %w(/wd4214 /wd4100 /wd4996)
-    cc.flags << "/Fd\"#{conf.build_dir}\\vc140.pdb\""
-    cc.flags << "/Fp\"%{outdir}\\%{outfilebase}.pch\""
+    # C4013: implicit function declaration
+    cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /we4013 /Zi /MD /O2 /utf-8 /D_CRT_SECURE_NO_WARNINGS)]
     cc.defines = %w(DISABLE_GEMS MRB_STACK_EXTEND_DOUBLING)
     cc.option_include_path = '/I%s'
     cc.option_define = '/D%s'
     cc.compile_options = "%{flags} /Fo%{outfile} %{infile}"
+    cc.cxx_compile_flag = '/TP'
+    cc.cxx_exception_flag = '/EHs'
   end
 
   conf.cxx do |cxx|
     cxx.command = ENV['CXX'] || 'cl.exe'
-    cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(/c /utf-8 /nologo /W4 /GS /analyze- /Zc:wchar_t /ZI /Gm /Od /Zc:inline /fp:precise /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /EHsc /DWIN32 /D_DEBUG /D_CONSOLE /D_CRT_SECURE_NO_WARNINGS)]
-    cxx.flags << %w(/we4002 /we4003 /we4005 /we4007 /we4010 /we4013 /we4015 /we4020 /we4022 /we4024 /we4028 /we4029 /we4031 /we4033 /we4034 /we4042 /we4047 /we4048 /we4049 /we4056 /we4067 /we4074 /we4079 /we4083 /we4088 /we4089 /we4090 /we4091 /we4094 /we4096 /we4098 /we4099 /we4113 /we4133 /we4715 /we4716)
-    cxx.flags << %w(/wd4214 /wd4100 /wd4996)
-    cxx.flags << "/Fd\"#{conf.build_dir}\\vc140.pdb\""
-    cxx.flags << "/Fp\"%{outdir}\\%{outfilebase}.pch\""
+    cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(/c /nologo /W3 /Zi /MD /O2 /EHs /utf-8 /D_CRT_SECURE_NO_WARNINGS)]
     cxx.defines = %w(DISABLE_GEMS MRB_STACK_EXTEND_DOUBLING)
     cxx.option_include_path = '/I%s'
     cxx.option_define = '/D%s'
     cxx.compile_options = "%{flags} /Fo%{outfile} %{infile}"
+    cxx.cxx_compile_flag = '/TP'
+    cxx.cxx_exception_flag = '/EHs'
   end
 
@@ -61,3 +58,14 @@
 
   conf.file_separator = '\\'
+
+  if require 'open3'
+    Open3.popen3 conf.cc.command do |_, _, e, _|
+      if /Version (\d{2})\.\d{2}\.\d{5}/ =~ e.gets && $1.to_i <= 17
+        m = "# VS2010/2012 support will be dropped after the next release! #"
+        h = "#" * m.length
+        puts h, m, h
+      end
+    end
+  end
+
 end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/assert.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/assert.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/assert.rb	(revision 331)
@@ -11,9 +11,5 @@
   while i < len
     str = args[i].to_s
-    begin
-      __printstr__ str
-    rescue NoMethodError
-      __t_printstr__ str rescue print str
-    end
+    __t_printstr__ str rescue print str
     i += 1
   end
@@ -49,5 +45,6 @@
     $mrbtest_assert = []
     $mrbtest_assert_idx = 0
-    if(!yield || $mrbtest_assert.size > 0)
+    yield
+    if($mrbtest_assert.size > 0)
       $asserts.push(assertion_string('Fail: ', str, iso, nil))
       $ko_test += 1
@@ -218,5 +215,5 @@
 
   $asserts.each do |msg|
-    puts msg
+    t_print "#{msg}\n"
   end
 
@@ -237,5 +234,5 @@
 # Performs fuzzy check for equality on methods returning floats
 def check_float(a, b)
-  tolerance = 1e-12
+  tolerance = Mrbtest::FLOAT_TOLERANCE
   a = a.to_f
   b = b.to_f
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/bintest.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/bintest.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/bintest.rb	(revision 331)
@@ -4,5 +4,5 @@
 def cmd(s)
   case RbConfig::CONFIG['host_os']
-  when /mswin(?!ce)|mingw|cygwin|bccwin/
+  when /mswin(?!ce)|mingw|bccwin/
     "bin\\#{s}.exe"
   else
@@ -13,5 +13,5 @@
 def shellquote(s)
   case RbConfig::CONFIG['host_os']
-  when /mswin(?!ce)|mingw|cygwin|bccwin/
+  when /mswin(?!ce)|mingw|bccwin/
     "\"#{s}\""
   else
@@ -21,4 +21,9 @@
 
 ARGV.each do |gem|
+  case RbConfig::CONFIG['host_os']
+  when /mswin(?!ce)|mingw|bccwin/
+    gem = gem.gsub('\\', '/')
+  end
+
   Dir["#{gem}/bintest/**/*.rb"].each do |file|
     load file
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/array.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/array.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/array.rb	(revision 331)
@@ -12,4 +12,12 @@
 assert('Array.[]', '15.2.12.4.1') do
   assert_equal([1, 2, 3], Array.[](1,2,3))
+end
+
+class SubArray < Array
+end
+
+assert('SubArray.[]') do
+  a = SubArray[1, 2, 3]
+  assert_equal(SubArray, a.class)
 end
 
@@ -83,4 +91,12 @@
   a[2...4] = 6
   assert_equal([1,2,6,5], a)
+
+  # passing self (#3274)
+  a = [1,2,3]
+  a[1,0] = a
+  assert_equal([1,1,2,3,2,3], a)
+  a = [1,2,3]
+  a[-1,0] = a
+  assert_equal([1,2,1,2,3,3], a)
 end
 
@@ -99,4 +115,9 @@
 assert('Array#concat', '15.2.12.5.8') do
   assert_equal([1,2,3,4], [1, 2].concat([3, 4]))
+
+  # passing self (#3302)
+  a = [1,2,3]
+  a.concat(a)
+  assert_equal([1,2,3,1,2,3], a)
 end
 
@@ -319,5 +340,6 @@
   a = [ 1, 2, 3 ]
 
-  assert_true(a.hash.is_a? Integer)
+  #assert_true(a.hash.is_a? Integer)
+  assert_true(a.hash.is_a? Integral)  # mruby special
   assert_equal([1,2].hash, [1,2].hash)
 end
@@ -348,2 +370,21 @@
   assert_equal({Array=>200}, h)
 end
+
+assert("Array#rindex") do
+  class Sneaky
+    def ==(*)
+      $a.clear
+      $a.replace([1])
+      false
+    end
+  end
+  $a = [2, 3, 4, 5, 6, 7, 8, 9, 10, Sneaky.new]
+  assert_equal 0, $a.rindex(1)
+end
+
+assert('Array#freeze') do
+  a = [].freeze
+  assert_raise(RuntimeError) do
+    a[0] = 1
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/class.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/class.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/class.rb	(revision 331)
@@ -385,6 +385,67 @@
 end
 
+assert('class variable definition in singleton_class') do
+  class ClassVariableDefinitionInSingletonTest
+    class << self
+      @@class_variable = "value"
+    end
+    def class_variable
+      @@class_variable
+    end
+  end
+
+  assert_equal("value", ClassVariableDefinitionInSingletonTest.new.class_variable)
+end
+
+assert('class variable in module and class << self style class method') do
+  module ClassVariableInModuleTest
+    @@class_variable = "value"
+    class << self
+      def class_variable
+        @@class_variable
+      end
+    end
+  end
+
+  assert_equal("value", ClassVariableInModuleTest.class_variable)
+end
+
+assert('child class/module defined in singleton class get parent constant') do
+  actual = module GetParentConstantTest
+            EXPECT = "value"
+            class << self
+              class CHILD
+                class << self
+                    EXPECT
+                end
+              end
+            end
+          end
+  assert_equal("value", actual)
+end
+
+assert('overriding class variable with a module (#3235)') do
+  module ModuleWithCVar
+    @@class_variable = 1
+  end
+  class CVarOverrideTest
+    @@class_variable = 2
+    include ModuleWithCVar
+
+    assert_equal(1, @@class_variable)
+  end
+end
+
 assert('class with non-class/module outer raises TypeError') do
   assert_raise(TypeError) { class 0::C1; end }
   assert_raise(TypeError) { class []::C2; end }
 end
+
+assert("remove_method doesn't segfault if the passed in argument isn't a symbol") do
+  klass = Class.new
+  assert_raise(TypeError) { klass.remove_method nil }
+  assert_raise(TypeError) { klass.remove_method 123 }
+  assert_raise(TypeError) { klass.remove_method 1.23 }
+  assert_raise(NameError) { klass.remove_method "hello" }
+  assert_raise(TypeError) { klass.remove_method Class.new }
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/codegen.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/test/t/codegen.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/codegen.rb	(revision 331)
@@ -0,0 +1,75 @@
+##
+# Codegen tests
+
+assert('peephole optimization does not eliminate move whose result is reused') do
+  assert_raise LocalJumpError do
+    def method
+      yield
+    end
+    method(&a &&= 0)
+  end
+end
+
+assert('empty condition in ternary expression parses correctly') do
+  assert_equal(() ? 1 : 2, 2)
+end
+
+assert('method call with exactly 127 arguments') do
+  def args_to_ary(*args)
+    args
+  end
+
+  assert_equal [0]*127, args_to_ary(
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+  )
+end
+
+assert('nested empty heredoc') do
+  _, a = nil, <<B
+#{<<A}
+A
+B
+  assert_equal "\n", a
+end
+
+assert('splat in case splat') do
+  a = *case
+    when 0
+      * = 1
+  end
+
+  assert_equal [1], a
+end
+
+assert('undef with 127 or more arguments') do
+  assert_raise NameError do
+    undef
+      a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,
+      a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,
+      a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a,
+      a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a
+  end
+end
+
+assert('next in normal loop with 127 arguments') do
+  assert_raise NameError do
+    while true
+      next A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A
+    end
+  end
+end
+
+assert('negate literal register alignment') do
+  a = *case
+  when 0
+    -0.0
+    2
+  end
+
+  assert_equal [2], a
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/exception.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/exception.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/exception.rb	(revision 331)
@@ -339,8 +339,11 @@
         1 * "b"
       ensure
-        @e = self.z
-      end
-    end
-
+        @e = self.zz
+      end
+    end
+
+    def zz
+      true
+    end
     def z
       true
@@ -351,5 +354,5 @@
 
 assert('Exception#inspect without message') do
-  assert_equal "Exception: Exception", Exception.new.inspect
+  assert_equal "Exception", Exception.new.inspect
 end
 
@@ -374,11 +377,46 @@
 end
 
-assert('Raise in rescue') do
-  assert_raise(ArgumentError) do
-    begin
-      raise "" # RuntimeError
-    rescue
-      raise ArgumentError
-    end
-  end
-end
+def backtrace_available?
+  begin
+    raise "XXX"
+  rescue => exception
+    not exception.backtrace.empty?
+  end
+end
+
+assert('GC in rescue') do
+  skip "backtrace isn't available" unless backtrace_available?
+
+  line = nil
+  begin
+    [1].each do
+      [2].each do
+        [3].each do
+          line = __LINE__; raise "XXX"
+        end
+      end
+    end
+  rescue => exception
+    GC.start
+    assert_equal("#{__FILE__}:#{line}:in call",
+                 exception.backtrace.first)
+  end
+end
+
+assert('Method call in rescue') do
+  skip "backtrace isn't available" unless backtrace_available?
+
+  line = nil
+  begin
+    [1].each do
+      [2].each do
+        line = __LINE__; raise "XXX"
+      end
+    end
+  rescue => exception
+    [3].each do
+    end
+    assert_equal("#{__FILE__}:#{line}:in call",
+                 exception.backtrace.first)
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/float.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/float.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/float.rb	(revision 331)
@@ -149,4 +149,7 @@
 assert('Float#to_i', '15.2.9.3.14') do
   assert_equal(3, 3.123456789.to_i)
+  assert_raise(FloatDomainError) { Float::INFINITY.to_i }
+  assert_raise(FloatDomainError) { (-Float::INFINITY).to_i }
+  assert_raise(FloatDomainError) { Float::NAN.to_i }
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/hash.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/hash.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/hash.rb	(revision 331)
@@ -17,4 +17,11 @@
 
   assert_equal 'abc', a['abc']
+
+  # Hash#[] should call #default (#3272)
+  hash = {}
+  def hash.default(k); self[k] = 1; end
+  hash[:foo] += 1
+
+  assert_equal 2, hash[:foo]
 end
 
@@ -38,4 +45,8 @@
   a['a'] = 2
   assert_equal({'a' => 1}, b)
+
+  c = Hash.new { |h, k| h[k] = k.upcase }
+  d = c.dup
+  assert_equal("FOO", d["foo"])
 end
 
@@ -240,4 +251,8 @@
   b.replace(a)
   assert_equal(127, b[127])
+
+   assert_raise(TypeError) do
+    { 'abc_key' => 'abc_value' }.replace "a"
+  end
 end
 
@@ -352,2 +367,9 @@
   assert_equal("b", h[[:b]])
 end
+
+assert('Hash#freeze') do
+  h = {}.freeze
+  assert_raise(RuntimeError) do
+    h[:a] = 'b'
+  end
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/integer.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/integer.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/integer.rb	(revision 331)
@@ -148,4 +148,10 @@
   # Left Shift by a negative is Right Shift
   assert_equal 23, 46 << -1
+
+  # Left Shift by 31 is bitShift overflow to SignedInt
+  assert_equal 2147483648, 1 << 31
+
+  # -3 Left Shift by 30 is bitShift overflow to SignedInt
+  assert_equal(-3221225472, -3 << 30)
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/kernel.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/kernel.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/kernel.rb	(revision 331)
@@ -222,4 +222,12 @@
 end
 
+assert('Kernel#dup class') do
+  assert_nothing_raised do
+    Array.dup.new(200)
+    Range.dup.new(2, 3)
+    String.dup.new("a"*50)
+  end
+end
+
 # Kernel#eval is provided by mruby-eval mrbgem '15.3.1.3.12'
 
@@ -248,4 +256,11 @@
 
   assert_true respond_to?(:test_method)
+end
+
+assert('Kernel#freeze') do
+  obj = Object.new
+  assert_equal obj, obj.freeze
+  assert_equal 0, 0.freeze
+  assert_equal :a, :a.freeze
 end
 
@@ -424,4 +439,9 @@
 assert('Kernel#public_methods', '15.3.1.3.38') do
   assert_equal Array, public_methods.class
+  class Foo
+    def foo
+    end
+  end
+  assert_equal [:foo], Foo.new.public_methods(false)
 end
 
@@ -508,4 +528,19 @@
 end
 
+assert('Kernel#to_s on primitives') do
+  begin
+    Fixnum.alias_method :to_s_, :to_s
+    Fixnum.remove_method :to_s
+
+    assert_nothing_raised do
+      # segfaults if mrb_cptr is used
+      1.to_s
+    end
+  ensure
+    Fixnum.alias_method :to_s, :to_s_
+    Fixnum.remove_method :to_s_
+  end
+end
+
 assert('Kernel.local_variables', '15.3.1.2.7') do
   a, b = 0, 1
@@ -515,9 +550,8 @@
   assert_equal [:a, :b, :vars], vars
 
-  Proc.new {
+  assert_equal [:a, :b, :c, :vars], Proc.new { |a, b|
     c = 2
-    vars = Kernel.local_variables.sort
-    assert_equal [:a, :b, :c, :vars], vars
-  }.call
+    Kernel.local_variables.sort
+  }.call(-1, -2)
 end
 
@@ -588,3 +622,2 @@
   assert_equal 6, recurse(0, 5)
 end
-
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/lang.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.3.0/test/t/lang.rb	(revision 331)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/lang.rb	(revision 331)
@@ -0,0 +1,74 @@
+# The aim of these tests is  to detect pitfall for optimized VM.
+
+# Test for or/and
+#
+# You may think instruction fusion(OP_EQ and OP_JMPIF) for avoiding
+# generate intermediate boolean value.
+# But and/or is pitfall for this fusioning.
+#
+# For example, the following mruby code:
+#
+#   if i > 0 and i < 10 then
+#
+# compiles to the following byte code:
+#
+#    1 000 OP_LOADI      R1      0               ; R1:i
+#    2 001 OP_MOVE       R2      R1              ; R1:i
+#    2 002 OP_LOADI      R3      0
+#    2 003 OP_GT R2      :>      1
+#    2 004 OP_JMPNOT     R2      008
+#    2 005 OP_MOVE       R2      R1              ; R1:i
+#    2 006 OP_LOADI      R3      10
+#    2 007 OP_LT R2      :<      1
+#    2 008 OP_JMPNOT     R2      (The address of end of then part)
+#
+# When the instruction fusion the OP_GT and OP_JMPNOT you fell into the pitfalls.
+# The deleted intermediate boolean value is used in OP_JMPNOT (address 008).
+
+assert('and', '11.2.3') do
+  a = 1
+  if a > 0 and a < 10 then
+    b = 1
+  else
+    b = 0
+  end
+  assert_equal 1, b
+
+  if a < 0 and a < 10 then
+    b = 1
+  else
+    b = 0
+  end
+  assert_equal 0, b
+
+  if a < 0 and a > 10 then
+    b = 1
+  else
+    b = 0
+  end
+  assert_equal 0, b
+end
+
+assert('or','11.2.4') do
+  a = 1
+  if a > 0 or a < 10 then
+    b = 1
+  else
+    b = 0
+  end
+  assert_equal 1, b
+
+  if a < 0 or a < 10 then
+    b = 1
+  else
+    b = 0
+  end
+  assert_equal 1, b
+
+  if a < 0 or a > 10 then
+    b = 1
+  else
+    b = 0
+  end
+  assert_equal 0, b
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/literals.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/literals.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/literals.rb	(revision 331)
@@ -27,5 +27,5 @@
   assert_equal       10, 1_0
   # integer with exponent
-  assert_equal 10.0, 1e1,
+  assert_equal 10.0, 1e1
   assert_equal(0.1, 1e-1)
   assert_equal 10.0, 1e+1
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/module.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/module.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/module.rb	(revision 331)
@@ -494,4 +494,16 @@
 
 # Not ISO specified
+
+assert('Module#define_method') do
+  c = Class.new {
+    define_method(:m1) { :ok }
+    define_method(:m2, Proc.new { :ok })
+  }
+  assert_equal c.new.m1, :ok
+  assert_equal c.new.m2, :ok
+  assert_raise(TypeError) do
+    Class.new { define_method(:n1, nil) }
+  end
+end
 
 # @!group prepend
@@ -838,2 +850,13 @@
   assert_raise(TypeError) { module []::M2 end }
 end
+
+assert('get constant of parent module in singleton class; issue #3568') do
+  actual = module GetConstantInSingletonTest
+    EXPECTED = "value"
+    class << self
+      EXPECTED
+    end
+  end
+
+  assert_equal("value", actual)
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/nil.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/nil.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/nil.rb	(revision 331)
@@ -33,2 +33,7 @@
   assert_equal '', nil.to_s
 end
+
+assert('safe navigation') do
+  assert_nil nil&.size
+  assert_equal 0, []&.size
+end
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/proc.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/proc.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/proc.rb	(revision 331)
@@ -137,4 +137,16 @@
 end
 
+assert('call Proc#initialize if defined') do
+  a = []
+  c = Class.new(Proc) do
+    define_method(:initialize) do
+      a << :ok
+    end
+  end
+
+  assert_kind_of c, c.new{}
+  assert_equal [:ok], a
+end
+
 assert('&obj call to_proc if defined') do
   pr = Proc.new{}
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/range.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/range.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/range.rb	(revision 331)
@@ -44,8 +44,9 @@
 
 assert('Range#include?', '15.2.14.4.8') do
-  a = (1..10)
+  assert_true (1..10).include?(10)
+  assert_false (1..10).include?(11)
 
-  assert_true a.include?(5)
-  assert_false a.include?(20)
+  assert_true (1...10).include?(9)
+  assert_false (1...10).include?(10)
 end
 
@@ -58,4 +59,6 @@
   assert_equal (1..10), b
   assert_false b.exclude_end?
+
+  assert_raise(NameError) { (0..1).send(:initialize, 1, 3) }
 end
 
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/string.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/string.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/string.rb	(revision 331)
@@ -252,4 +252,17 @@
 end
 
+assert('String#chomp! uses the correct length') do
+  class A
+    def to_str
+      $s.replace("AA")
+      "A"
+    end
+  end
+
+  $s = "AAA"
+  $s.chomp!(A.new)
+  assert_equal $s, "A"
+end
+
 assert('String#chop', '15.2.10.5.11') do
   a = ''.chop
@@ -329,4 +342,10 @@
 
   assert_equal list, n_list
+
+  n_list.clear
+  a.each_line("li") do |line|
+    n_list << line
+  end
+  assert_equal ["first li", "ne\nsecond li", "ne\nthird li", "ne"], n_list
 end
 
@@ -353,4 +372,11 @@
   assert_equal('A',      'a'.gsub('a', 'A'))
   assert_equal('A',      'a'.gsub('a'){|w| w.capitalize })
+  assert_equal("<a><><>", 'a'.gsub('a', '<\0><\1><\2>'))
+  assert_equal(".h.e.l.l.o.", "hello".gsub("", "."))
+  a = []
+  assert_equal(".h.e.l.l.o.", "hello".gsub("") { |i| a << i; "." })
+  assert_equal(["", "", "", "", "", ""], a)
+  assert_raise(ArgumentError) { "".gsub }
+  assert_raise(ArgumentError) { "".gsub("", "", "") }
 end
 
@@ -382,6 +408,4 @@
 
 assert('String#include?', '15.2.10.5.21') do
-  assert_true 'abc'.include?(97)
-  assert_false 'abc'.include?(100)
   assert_true 'abc'.include?('a')
   assert_false 'abc'.include?('d')
@@ -392,4 +416,6 @@
   assert_nil 'abc'.index('d')
   assert_equal 3, 'abcabc'.index('a', 1)
+  assert_equal 5, "hello".index("", 5)
+  assert_equal nil, "hello".index("", 6)
 end
 
@@ -560,4 +586,14 @@
   assert_equal 'aBcabc', 'abcabc'.sub('b') { |w| w.capitalize }
   assert_equal 'aa$', 'aa#'.sub('#', '$')
+  assert_equal '.abc', "abc".sub("", ".")
+
+  str = "abc"
+  miss = str.sub("X", "Z")
+  assert_equal str, miss
+  assert_not_equal str.object_id, miss.object_id
+
+  a = []
+  assert_equal '.abc', "abc".sub("") { |i| a << i; "." }
+  assert_equal [""], a
 end
 
@@ -586,8 +622,12 @@
   b = '123456789'.to_f
   c = '12345.6789'.to_f
+  d = '1e-2147483648'.to_f
+  e = '1e2147483648'.to_f
 
   assert_float(0.0, a)
   assert_float(123456789.0, b)
   assert_float(12345.6789, c)
+  assert_float(0, d)
+  assert_float(Float::INFINITY, e)
 end
 
@@ -686,3 +726,2 @@
   assert_raise(RuntimeError) { str.upcase! }
 end
-
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/symbol.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/symbol.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/symbol.rb	(revision 331)
@@ -1,4 +1,11 @@
 ##
 # Symbol ISO Test
+
+assert('Symbol') do
+  assert_equal :"a", :a
+  assert_equal :"a#{1}", :a1
+  assert_equal :'a', :a
+  assert_equal :'a#{1}', :"a\#{1}"
+end
 
 assert('Symbol', '15.2.11') do
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/syntax.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/syntax.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/syntax.rb	(revision 331)
@@ -39,4 +39,24 @@
     yield
   end
+  assert_raise LocalJumpError do
+    o = Object.new
+    def o.foo
+      yield
+    end
+    o.foo
+  end
+end
+
+assert('redo in a for loop (#3275)') do
+  sum = 0
+  for i in 1..10
+    sum += i
+    i -= 1
+    if i > 0
+      redo
+    end
+  end
+
+  assert_equal 220, sum
 end
 
@@ -249,4 +269,11 @@
 end
 
+assert('multiple assignment (empty array rhs #3236, #3239)') do
+  a,b,*c = []; assert_equal [nil, nil, []], [a, b, c]
+  a,b,*c = [1]; assert_equal [1, nil, []], [a, b, c]
+  a,b,*c = [nil]; assert_equal [nil,nil, []], [a, b, c]
+  a,b,*c = [[]]; assert_equal [[], nil, []], [a, b, c]
+end
+
 assert('Return values of case statements') do
   a = [] << case 1
@@ -299,4 +326,34 @@
 
   assert_equal 1, when_value
+end
+
+assert('splat object in assignment') do
+  o = Object.new
+  def o.to_a
+    nil
+  end
+  assert_equal [o], (a = *o)
+
+  def o.to_a
+    1
+  end
+  assert_raise(TypeError) { a = *o }
+
+  def o.to_a
+    [2]
+  end
+  assert_equal [2], (a = *o)
+end
+
+assert('splat object in case statement') do
+  o = Object.new
+  def o.to_a
+    nil
+  end
+  a = case o
+  when *o
+    1
+  end
+  assert_equal 1, a
 end
 
@@ -325,5 +382,5 @@
 
 assert('External command execution.') do
-  class << Kernel
+  module Kernel
     sym = '`'.to_sym
     alias_method :old_cmd, sym
Index: EcnlProtoTool/trunk/mruby-1.3.0/test/t/unicode.rb
===================================================================
--- EcnlProtoTool/trunk/mruby-1.2.0/test/t/unicode.rb	(revision 321)
+++ EcnlProtoTool/trunk/mruby-1.3.0/test/t/unicode.rb	(revision 331)
@@ -3,14 +3,14 @@
 assert('bare \u notation test') do
   # Mininum and maximum one byte characters
-  assert_equal("\u0000", "\x00")
-  assert_equal("\u007F", "\x7F")
+  assert_equal("\x00", "\u0000")
+  assert_equal("\x7F", "\u007F")
 
   # Mininum and maximum two byte characters
-  assert_equal("\u0080", "\xC2\x80")
-  assert_equal("\u07FF", "\xDF\xBF")
+  assert_equal("\xC2\x80", "\u0080")
+  assert_equal("\xDF\xBF", "\u07FF")
 
   # Mininum and maximum three byte characters
-  assert_equal("\u0800", "\xE0\xA0\x80")
-  assert_equal("\uFFFF", "\xEF\xBF\xBF")
+  assert_equal("\xE0\xA0\x80", "\u0800")
+  assert_equal("\xEF\xBF\xBF", "\uFFFF")
 
   # Four byte characters require the \U notation
@@ -19,17 +19,21 @@
 assert('braced \u notation test') do
   # Mininum and maximum one byte characters
-  assert_equal("\u{0000}", "\x00")
-  assert_equal("\u{007F}", "\x7F")
+  assert_equal("\x00", "\u{0000}")
+  assert_equal("\x7F", "\u{007F}")
 
   # Mininum and maximum two byte characters
-  assert_equal("\u{0080}", "\xC2\x80")
-  assert_equal("\u{07FF}", "\xDF\xBF")
+  assert_equal("\xC2\x80", "\u{0080}")
+  assert_equal("\xDF\xBF", "\u{07FF}")
 
   # Mininum and maximum three byte characters
-  assert_equal("\u{0800}", "\xE0\xA0\x80")
-  assert_equal("\u{FFFF}", "\xEF\xBF\xBF")
+  assert_equal("\xE0\xA0\x80", "\u{0800}")
+  assert_equal("\xEF\xBF\xBF", "\u{FFFF}")
 
   # Mininum and maximum four byte characters
-  assert_equal("\u{10000}",  "\xF0\x90\x80\x80")
-  assert_equal("\u{10FFFF}", "\xF4\x8F\xBF\xBF")
+  assert_equal("\xF0\x90\x80\x80", "\u{10000}")
+  assert_equal("\xF4\x8F\xBF\xBF", "\u{10FFFF}")
 end
+
+assert('braced multiple \u notation test') do
+  assert_equal("ABC", "\u{41 42 43}")
+end
