ruby2d 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/README.md +20 -7
- data/assets/include/SDL2/SDL.h +135 -0
- data/assets/include/SDL2/SDL_assert.h +291 -0
- data/assets/include/SDL2/SDL_atomic.h +277 -0
- data/assets/include/SDL2/SDL_audio.h +826 -0
- data/assets/include/SDL2/SDL_bits.h +112 -0
- data/assets/include/SDL2/SDL_blendmode.h +120 -0
- data/assets/include/SDL2/SDL_clipboard.h +71 -0
- data/assets/include/SDL2/SDL_config.h +421 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +188 -0
- data/assets/include/SDL2/SDL_egl.h +1673 -0
- data/assets/include/SDL2/SDL_endian.h +260 -0
- data/assets/include/SDL2/SDL_error.h +76 -0
- data/assets/include/SDL2/SDL_events.h +788 -0
- data/assets/include/SDL2/SDL_filesystem.h +136 -0
- data/assets/include/SDL2/SDL_gamecontroller.h +390 -0
- data/assets/include/SDL2/SDL_gesture.h +87 -0
- data/assets/include/SDL2/SDL_haptic.h +1238 -0
- data/assets/include/SDL2/SDL_hints.h +1135 -0
- data/assets/include/SDL2/SDL_image.h +161 -0
- data/assets/include/SDL2/SDL_joystick.h +408 -0
- data/assets/include/SDL2/SDL_keyboard.h +217 -0
- data/assets/include/SDL2/SDL_keycode.h +349 -0
- data/assets/include/SDL2/SDL_loadso.h +81 -0
- data/assets/include/SDL2/SDL_log.h +211 -0
- data/assets/include/SDL2/SDL_main.h +168 -0
- data/assets/include/SDL2/SDL_messagebox.h +144 -0
- data/assets/include/SDL2/SDL_mixer.h +651 -0
- data/assets/include/SDL2/SDL_mouse.h +302 -0
- data/assets/include/SDL2/SDL_mutex.h +251 -0
- data/assets/include/SDL2/SDL_name.h +33 -0
- data/assets/include/SDL2/SDL_opengl.h +2183 -0
- data/assets/include/SDL2/SDL_opengl_glext.h +11177 -0
- data/assets/include/SDL2/SDL_opengles.h +39 -0
- data/assets/include/SDL2/SDL_opengles2.h +52 -0
- data/assets/include/SDL2/SDL_opengles2_gl2.h +621 -0
- data/assets/include/SDL2/SDL_opengles2_gl2ext.h +2050 -0
- data/assets/include/SDL2/SDL_opengles2_gl2platform.h +30 -0
- data/assets/include/SDL2/SDL_opengles2_khrplatform.h +282 -0
- data/assets/include/SDL2/SDL_pixels.h +470 -0
- data/assets/include/SDL2/SDL_platform.h +198 -0
- data/assets/include/SDL2/SDL_power.h +75 -0
- data/assets/include/SDL2/SDL_quit.h +58 -0
- data/assets/include/SDL2/SDL_rect.h +148 -0
- data/assets/include/SDL2/SDL_render.h +931 -0
- data/assets/include/SDL2/SDL_revision.h +2 -0
- data/assets/include/SDL2/SDL_rwops.h +254 -0
- data/assets/include/SDL2/SDL_scancode.h +413 -0
- data/assets/include/SDL2/SDL_sensor.h +251 -0
- data/assets/include/SDL2/SDL_shape.h +144 -0
- data/assets/include/SDL2/SDL_stdinc.h +607 -0
- data/assets/include/SDL2/SDL_surface.h +553 -0
- data/assets/include/SDL2/SDL_system.h +279 -0
- data/assets/include/SDL2/SDL_syswm.h +324 -0
- data/assets/include/SDL2/SDL_test.h +69 -0
- data/assets/include/SDL2/SDL_test_assert.h +105 -0
- data/assets/include/SDL2/SDL_test_common.h +188 -0
- data/assets/include/SDL2/SDL_test_compare.h +69 -0
- data/assets/include/SDL2/SDL_test_crc32.h +124 -0
- data/assets/include/SDL2/SDL_test_font.h +81 -0
- data/assets/include/SDL2/SDL_test_fuzzer.h +384 -0
- data/assets/include/SDL2/SDL_test_harness.h +134 -0
- data/assets/include/SDL2/SDL_test_images.h +78 -0
- data/assets/include/SDL2/SDL_test_log.h +67 -0
- data/assets/include/SDL2/SDL_test_md5.h +129 -0
- data/assets/include/SDL2/SDL_test_memory.h +63 -0
- data/assets/include/SDL2/SDL_test_random.h +115 -0
- data/assets/include/SDL2/SDL_thread.h +343 -0
- data/assets/include/SDL2/SDL_timer.h +115 -0
- data/assets/include/SDL2/SDL_touch.h +86 -0
- data/assets/include/SDL2/SDL_ttf.h +294 -0
- data/assets/include/SDL2/SDL_types.h +29 -0
- data/assets/include/SDL2/SDL_version.h +162 -0
- data/assets/include/SDL2/SDL_video.h +1276 -0
- data/assets/include/SDL2/SDL_vulkan.h +278 -0
- data/assets/include/SDL2/begin_code.h +167 -0
- data/assets/include/SDL2/close_code.h +37 -0
- data/assets/include/glew.h +23686 -0
- data/assets/include/simple2d.h +735 -0
- data/assets/ios/MRuby.framework/Headers/mrbconf.h +3 -5
- data/assets/ios/MRuby.framework/Headers/mruby.h +35 -32
- data/assets/ios/MRuby.framework/Headers/mruby/array.h +1 -0
- data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
- data/assets/ios/MRuby.framework/Headers/mruby/class.h +14 -11
- data/assets/ios/MRuby.framework/Headers/mruby/common.h +5 -0
- data/assets/ios/MRuby.framework/Headers/mruby/compile.h +4 -3
- data/assets/ios/MRuby.framework/Headers/mruby/debug.h +3 -2
- data/assets/ios/MRuby.framework/Headers/mruby/dump.h +2 -2
- data/assets/ios/MRuby.framework/Headers/mruby/hash.h +38 -5
- data/assets/ios/MRuby.framework/Headers/mruby/irep.h +17 -4
- data/assets/ios/MRuby.framework/Headers/mruby/object.h +4 -5
- data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +47 -139
- data/assets/ios/MRuby.framework/Headers/mruby/ops.h +117 -0
- data/assets/ios/MRuby.framework/Headers/mruby/proc.h +4 -4
- data/assets/ios/MRuby.framework/Headers/mruby/string.h +11 -7
- data/assets/ios/MRuby.framework/Headers/mruby/throw.h +4 -4
- data/assets/ios/MRuby.framework/Headers/mruby/variable.h +2 -4
- data/assets/ios/MRuby.framework/Headers/mruby/version.h +6 -6
- data/assets/ios/MRuby.framework/MRuby +0 -0
- data/assets/ios/MyApp.xcodeproj/project.pbxproj +24 -18
- data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/assets/ios/main.c +1 -1
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libmpg123.a +0 -0
- data/assets/macos/lib/libogg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libsimple2d.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/bin/SDL2_image.dll +0 -0
- data/assets/mingw/bin/SDL2_mixer.dll +0 -0
- data/assets/mingw/bin/SDL2_ttf.dll +0 -0
- data/assets/mingw/bin/glew32.dll +0 -0
- data/assets/mingw/bin/libFLAC-8.dll +0 -0
- data/assets/mingw/bin/libfreetype-6.dll +0 -0
- data/assets/mingw/bin/libjpeg-9.dll +0 -0
- data/assets/mingw/bin/libmodplug-1.dll +0 -0
- data/assets/mingw/bin/libmpg123-0.dll +0 -0
- data/assets/mingw/bin/libogg-0.dll +0 -0
- data/assets/mingw/bin/libopus-0.dll +0 -0
- data/assets/mingw/bin/libopusfile-0.dll +0 -0
- data/assets/mingw/bin/libpng16-16.dll +0 -0
- data/assets/mingw/bin/libtiff-5.dll +0 -0
- data/assets/mingw/bin/libvorbis-0.dll +0 -0
- data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
- data/assets/mingw/bin/libwebp-7.dll +0 -0
- data/assets/mingw/bin/zlib1.dll +0 -0
- data/assets/mingw/lib/libSDL2.a +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_image.a +0 -0
- data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.a +0 -0
- data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.a +0 -0
- data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/assets/mingw/lib/libglew32.a +0 -0
- data/assets/mingw/lib/libglew32.dll.a +0 -0
- data/assets/mingw/lib/libsimple2d.a +0 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +4 -0
- data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +7 -0
- data/assets/tvos/MRuby.framework/Headers/mrbconf.h +3 -5
- data/assets/tvos/MRuby.framework/Headers/mruby.h +35 -32
- data/assets/tvos/MRuby.framework/Headers/mruby/array.h +1 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +9 -1
- data/assets/tvos/MRuby.framework/Headers/mruby/class.h +14 -11
- data/assets/tvos/MRuby.framework/Headers/mruby/common.h +5 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +4 -3
- data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +3 -2
- data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +2 -2
- data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +38 -5
- data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +17 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/object.h +4 -5
- data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +47 -139
- data/assets/tvos/MRuby.framework/Headers/mruby/ops.h +117 -0
- data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +4 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/string.h +11 -7
- data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +4 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +2 -4
- data/assets/tvos/MRuby.framework/Headers/mruby/version.h +6 -6
- data/assets/tvos/MRuby.framework/MRuby +0 -0
- data/assets/tvos/MyApp.xcodeproj/project.pbxproj +25 -19
- data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/assets/tvos/main.c +1 -1
- data/ext/ruby2d/extconf.rb +59 -50
- data/ext/ruby2d/ruby2d.c +0 -1
- data/lib/ruby2d.rb +1 -7
- data/lib/ruby2d/cli/launch.rb +1 -1
- data/lib/ruby2d/font.rb +32 -7
- data/lib/ruby2d/version.rb +1 -1
- metadata +132 -6
- data/assets/opal.js +0 -21637
- data/assets/simple2d.js +0 -1379
- data/assets/template.html +0 -18
@@ -39,23 +39,36 @@ typedef struct mrb_irep {
|
|
39
39
|
|
40
40
|
struct mrb_locals *lv;
|
41
41
|
/* debug info */
|
42
|
-
mrb_bool own_filename;
|
43
|
-
const char *filename;
|
44
|
-
uint16_t *lines;
|
45
42
|
struct mrb_irep_debug_info* debug_info;
|
46
43
|
|
47
|
-
|
44
|
+
uint16_t ilen, plen, slen, rlen;
|
45
|
+
uint32_t refcnt;
|
48
46
|
} mrb_irep;
|
49
47
|
|
50
48
|
#define MRB_ISEQ_NO_FREE 1
|
51
49
|
|
52
50
|
MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
|
51
|
+
|
52
|
+
/* @param [const uint8_t*] irep code, expected as a literal */
|
53
53
|
MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
|
54
|
+
|
55
|
+
/* @param [const uint8_t*] irep code, expected as a literal */
|
54
56
|
MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
|
57
|
+
|
55
58
|
void mrb_irep_free(mrb_state*, struct mrb_irep*);
|
56
59
|
void mrb_irep_incref(mrb_state*, struct mrb_irep*);
|
57
60
|
void mrb_irep_decref(mrb_state*, struct mrb_irep*);
|
58
61
|
void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
|
62
|
+
void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
|
63
|
+
|
64
|
+
struct mrb_insn_data {
|
65
|
+
uint8_t insn;
|
66
|
+
uint16_t a;
|
67
|
+
uint16_t b;
|
68
|
+
uint8_t c;
|
69
|
+
};
|
70
|
+
|
71
|
+
struct mrb_insn_data mrb_decode_insn(mrb_code *pc);
|
59
72
|
|
60
73
|
MRB_END_DECL
|
61
74
|
|
@@ -22,11 +22,10 @@ struct RBasic {
|
|
22
22
|
};
|
23
23
|
#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
|
24
24
|
|
25
|
-
|
26
|
-
#define
|
27
|
-
#define
|
28
|
-
#define
|
29
|
-
#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FLAG_IS_FROZEN)
|
25
|
+
#define MRB_FL_OBJ_IS_FROZEN (1 << 20)
|
26
|
+
#define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
|
27
|
+
#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
|
28
|
+
#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
|
30
29
|
|
31
30
|
struct RObject {
|
32
31
|
MRB_OBJECT_HEADER;
|
@@ -7,145 +7,10 @@
|
|
7
7
|
#ifndef MRUBY_OPCODE_H
|
8
8
|
#define MRUBY_OPCODE_H
|
9
9
|
|
10
|
-
|
11
|
-
#define
|
12
|
-
|
13
|
-
|
14
|
-
/* ------------------------------- */
|
15
|
-
/* A:B:C:OP = 9: 9: 7: 7 */
|
16
|
-
/* A:Bx:OP = 9:16: 7 */
|
17
|
-
/* Ax:OP = 25: 7 */
|
18
|
-
/* A:Bz:Cz:OP = 9:14: 2: 7 */
|
19
|
-
|
20
|
-
#define GET_OPCODE(i) ((int)(((mrb_code)(i)) & 0x7f))
|
21
|
-
#define GETARG_A(i) ((int)((((mrb_code)(i)) >> 23) & 0x1ff))
|
22
|
-
#define GETARG_B(i) ((int)((((mrb_code)(i)) >> 14) & 0x1ff))
|
23
|
-
#define GETARG_C(i) ((int)((((mrb_code)(i)) >> 7) & 0x7f))
|
24
|
-
#define GETARG_Bx(i) ((int)((((mrb_code)(i)) >> 7) & 0xffff))
|
25
|
-
#define GETARG_sBx(i) ((int)(GETARG_Bx(i)-MAXARG_sBx))
|
26
|
-
#define GETARG_Ax(i) ((int32_t)((((mrb_code)(i)) >> 7) & 0x1ffffff))
|
27
|
-
#define GETARG_UNPACK_b(i,n1,n2) ((int)((((mrb_code)(i)) >> (7+(n2))) & (((1<<(n1))-1))))
|
28
|
-
#define GETARG_UNPACK_c(i,n1,n2) ((int)((((mrb_code)(i)) >> 7) & (((1<<(n2))-1))))
|
29
|
-
#define GETARG_b(i) GETARG_UNPACK_b(i,14,2)
|
30
|
-
#define GETARG_c(i) GETARG_UNPACK_c(i,14,2)
|
31
|
-
|
32
|
-
#define MKOPCODE(op) ((op) & 0x7f)
|
33
|
-
#define MKARG_A(c) ((mrb_code)((c) & 0x1ff) << 23)
|
34
|
-
#define MKARG_B(c) ((mrb_code)((c) & 0x1ff) << 14)
|
35
|
-
#define MKARG_C(c) (((c) & 0x7f) << 7)
|
36
|
-
#define MKARG_Bx(v) ((mrb_code)((v) & 0xffff) << 7)
|
37
|
-
#define MKARG_sBx(v) MKARG_Bx((v)+MAXARG_sBx)
|
38
|
-
#define MKARG_Ax(v) ((mrb_code)((v) & 0x1ffffff) << 7)
|
39
|
-
#define MKARG_PACK(b,n1,c,n2) ((((b) & ((1<<n1)-1)) << (7+n2))|(((c) & ((1<<n2)-1)) << 7))
|
40
|
-
#define MKARG_bc(b,c) MKARG_PACK(b,14,c,2)
|
41
|
-
|
42
|
-
#define MKOP_A(op,a) (MKOPCODE(op)|MKARG_A(a))
|
43
|
-
#define MKOP_AB(op,a,b) (MKOP_A(op,a)|MKARG_B(b))
|
44
|
-
#define MKOP_ABC(op,a,b,c) (MKOP_AB(op,a,b)|MKARG_C(c))
|
45
|
-
#define MKOP_ABx(op,a,bx) (MKOP_A(op,a)|MKARG_Bx(bx))
|
46
|
-
#define MKOP_Bx(op,bx) (MKOPCODE(op)|MKARG_Bx(bx))
|
47
|
-
#define MKOP_sBx(op,sbx) (MKOPCODE(op)|MKARG_sBx(sbx))
|
48
|
-
#define MKOP_AsBx(op,a,sbx) (MKOP_A(op,a)|MKARG_sBx(sbx))
|
49
|
-
#define MKOP_Ax(op,ax) (MKOPCODE(op)|MKARG_Ax(ax))
|
50
|
-
#define MKOP_Abc(op,a,b,c) (MKOP_A(op,a)|MKARG_bc(b,c))
|
51
|
-
|
52
|
-
enum {
|
53
|
-
/*-----------------------------------------------------------------------
|
54
|
-
operation code operand description
|
55
|
-
------------------------------------------------------------------------*/
|
56
|
-
OP_NOP=0,/* */
|
57
|
-
OP_MOVE,/* A B R(A) := R(B) */
|
58
|
-
OP_LOADL,/* A Bx R(A) := Pool(Bx) */
|
59
|
-
OP_LOADI,/* A sBx R(A) := sBx */
|
60
|
-
OP_LOADSYM,/* A Bx R(A) := Syms(Bx) */
|
61
|
-
OP_LOADNIL,/* A R(A) := nil */
|
62
|
-
OP_LOADSELF,/* A R(A) := self */
|
63
|
-
OP_LOADT,/* A R(A) := true */
|
64
|
-
OP_LOADF,/* A R(A) := false */
|
65
|
-
|
66
|
-
OP_GETGLOBAL,/* A Bx R(A) := getglobal(Syms(Bx)) */
|
67
|
-
OP_SETGLOBAL,/* A Bx setglobal(Syms(Bx), R(A)) */
|
68
|
-
OP_GETSPECIAL,/*A Bx R(A) := Special[Bx] */
|
69
|
-
OP_SETSPECIAL,/*A Bx Special[Bx] := R(A) */
|
70
|
-
OP_GETIV,/* A Bx R(A) := ivget(Syms(Bx)) */
|
71
|
-
OP_SETIV,/* A Bx ivset(Syms(Bx),R(A)) */
|
72
|
-
OP_GETCV,/* A Bx R(A) := cvget(Syms(Bx)) */
|
73
|
-
OP_SETCV,/* A Bx cvset(Syms(Bx),R(A)) */
|
74
|
-
OP_GETCONST,/* A Bx R(A) := constget(Syms(Bx)) */
|
75
|
-
OP_SETCONST,/* A Bx constset(Syms(Bx),R(A)) */
|
76
|
-
OP_GETMCNST,/* A Bx R(A) := R(A)::Syms(Bx) */
|
77
|
-
OP_SETMCNST,/* A Bx R(A+1)::Syms(Bx) := R(A) */
|
78
|
-
OP_GETUPVAR,/* A B C R(A) := uvget(B,C) */
|
79
|
-
OP_SETUPVAR,/* A B C uvset(B,C,R(A)) */
|
80
|
-
|
81
|
-
OP_JMP,/* sBx pc+=sBx */
|
82
|
-
OP_JMPIF,/* A sBx if R(A) pc+=sBx */
|
83
|
-
OP_JMPNOT,/* A sBx if !R(A) pc+=sBx */
|
84
|
-
OP_ONERR,/* sBx rescue_push(pc+sBx) */
|
85
|
-
OP_RESCUE,/* A B C if A (if C exc=R(A) else R(A) := exc);
|
86
|
-
if B R(B) := exc.isa?(R(B)); clear(exc) */
|
87
|
-
OP_POPERR,/* A A.times{rescue_pop()} */
|
88
|
-
OP_RAISE,/* A raise(R(A)) */
|
89
|
-
OP_EPUSH,/* Bx ensure_push(SEQ[Bx]) */
|
90
|
-
OP_EPOP,/* A A.times{ensure_pop().call} */
|
91
|
-
|
92
|
-
OP_SEND,/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C)) */
|
93
|
-
OP_SENDB,/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C),&R(A+C+1))*/
|
94
|
-
OP_FSEND,/* A B C R(A) := fcall(R(A),Syms(B),R(A+1),...,R(A+C-1)) */
|
95
|
-
OP_CALL,/* A R(A) := self.call(frame.argc, frame.argv) */
|
96
|
-
OP_SUPER,/* A C R(A) := super(R(A+1),... ,R(A+C+1)) */
|
97
|
-
OP_ARGARY,/* A Bx R(A) := argument array (16=6:1:5:4) */
|
98
|
-
OP_ENTER,/* Ax arg setup according to flags (23=5:5:1:5:5:1:1) */
|
99
|
-
OP_KARG,/* A B C R(A) := kdict[Syms(B)]; if C kdict.rm(Syms(B)) */
|
100
|
-
OP_KDICT,/* A C R(A) := kdict */
|
101
|
-
|
102
|
-
OP_RETURN,/* A B return R(A) (B=normal,in-block return/break) */
|
103
|
-
OP_TAILCALL,/* A B C return call(R(A),Syms(B),*R(C)) */
|
104
|
-
OP_BLKPUSH,/* A Bx R(A) := block (16=6:1:5:4) */
|
105
|
-
|
106
|
-
OP_ADD,/* A B C R(A) := R(A)+R(A+1) (Syms[B]=:+,C=1) */
|
107
|
-
OP_ADDI,/* A B C R(A) := R(A)+C (Syms[B]=:+) */
|
108
|
-
OP_SUB,/* A B C R(A) := R(A)-R(A+1) (Syms[B]=:-,C=1) */
|
109
|
-
OP_SUBI,/* A B C R(A) := R(A)-C (Syms[B]=:-) */
|
110
|
-
OP_MUL,/* A B C R(A) := R(A)*R(A+1) (Syms[B]=:*,C=1) */
|
111
|
-
OP_DIV,/* A B C R(A) := R(A)/R(A+1) (Syms[B]=:/,C=1) */
|
112
|
-
OP_EQ,/* A B C R(A) := R(A)==R(A+1) (Syms[B]=:==,C=1) */
|
113
|
-
OP_LT,/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1) */
|
114
|
-
OP_LE,/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1) */
|
115
|
-
OP_GT,/* A B C R(A) := R(A)>R(A+1) (Syms[B]=:>,C=1) */
|
116
|
-
OP_GE,/* A B C R(A) := R(A)>=R(A+1) (Syms[B]=:>=,C=1) */
|
117
|
-
|
118
|
-
OP_ARRAY,/* A B C R(A) := ary_new(R(B),R(B+1)..R(B+C)) */
|
119
|
-
OP_ARYCAT,/* A B ary_cat(R(A),R(B)) */
|
120
|
-
OP_ARYPUSH,/* A B ary_push(R(A),R(B)) */
|
121
|
-
OP_AREF,/* A B C R(A) := R(B)[C] */
|
122
|
-
OP_ASET,/* A B C R(B)[C] := R(A) */
|
123
|
-
OP_APOST,/* A B C *R(A),R(A+1)..R(A+C) := R(A) */
|
124
|
-
|
125
|
-
OP_STRING,/* A Bx R(A) := str_dup(Lit(Bx)) */
|
126
|
-
OP_STRCAT,/* A B str_cat(R(A),R(B)) */
|
127
|
-
|
128
|
-
OP_HASH,/* A B C R(A) := hash_new(R(B),R(B+1)..R(B+C)) */
|
129
|
-
OP_LAMBDA,/* A Bz Cz R(A) := lambda(SEQ[Bz],Cz) */
|
130
|
-
OP_RANGE,/* A B C R(A) := range_new(R(B),R(B+1),C) */
|
131
|
-
|
132
|
-
OP_OCLASS,/* A R(A) := ::Object */
|
133
|
-
OP_CLASS,/* A B R(A) := newclass(R(A),Syms(B),R(A+1)) */
|
134
|
-
OP_MODULE,/* A B R(A) := newmodule(R(A),Syms(B)) */
|
135
|
-
OP_EXEC,/* A Bx R(A) := blockexec(R(A),SEQ[Bx]) */
|
136
|
-
OP_METHOD,/* A B R(A).newmethod(Syms(B),R(A+1)) */
|
137
|
-
OP_SCLASS,/* A B R(A) := R(B).singleton_class */
|
138
|
-
OP_TCLASS,/* A R(A) := target_class */
|
139
|
-
|
140
|
-
OP_DEBUG,/* A B C print R(A),R(B),R(C) */
|
141
|
-
OP_STOP,/* stop VM */
|
142
|
-
OP_ERR,/* Bx raise RuntimeError with message Lit(Bx) */
|
143
|
-
|
144
|
-
OP_RSVD1,/* reserved instruction #1 */
|
145
|
-
OP_RSVD2,/* reserved instruction #2 */
|
146
|
-
OP_RSVD3,/* reserved instruction #3 */
|
147
|
-
OP_RSVD4,/* reserved instruction #4 */
|
148
|
-
OP_RSVD5,/* reserved instruction #5 */
|
10
|
+
enum mrb_insn {
|
11
|
+
#define OPCODE(x,_) OP_ ## x,
|
12
|
+
#include "mruby/ops.h"
|
13
|
+
#undef OPCODE
|
149
14
|
};
|
150
15
|
|
151
16
|
#define OP_L_STRICT 1
|
@@ -158,4 +23,47 @@ enum {
|
|
158
23
|
#define OP_R_BREAK 1
|
159
24
|
#define OP_R_RETURN 2
|
160
25
|
|
26
|
+
#define PEEK_B(pc) (*(pc))
|
27
|
+
#define PEEK_S(pc) ((pc)[0]<<8|(pc)[1])
|
28
|
+
#define PEEK_W(pc) ((pc)[0]<<16|(pc)[1]<<8|(pc)[2])
|
29
|
+
|
30
|
+
#define READ_B() PEEK_B(pc++)
|
31
|
+
#define READ_S() (pc+=2, PEEK_S(pc-2))
|
32
|
+
#define READ_W() (pc+=3, PEEK_W(pc-3))
|
33
|
+
|
34
|
+
#define FETCH_Z() /* nothing */
|
35
|
+
#define FETCH_B() do {a=READ_B();} while (0)
|
36
|
+
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
|
37
|
+
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
|
38
|
+
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
|
39
|
+
#define FETCH_S() do {a=READ_S();} while (0)
|
40
|
+
#define FETCH_W() do {a=READ_W();} while (0)
|
41
|
+
|
42
|
+
/* with OP_EXT1 (1st 16bit) */
|
43
|
+
#define FETCH_Z_1() FETCH_Z()
|
44
|
+
#define FETCH_B_1() FETCH_S()
|
45
|
+
#define FETCH_BB_1() do {a=READ_S(); b=READ_B();} while (0)
|
46
|
+
#define FETCH_BBB_1() do {a=READ_S(); b=READ_B(); c=READ_B();} while (0)
|
47
|
+
#define FETCH_BS_1() do {a=READ_S(); b=READ_S();} while (0)
|
48
|
+
#define FETCH_S_1() FETCH_S()
|
49
|
+
#define FETCH_W_1() FETCH_W()
|
50
|
+
|
51
|
+
/* with OP_EXT2 (2nd 16bit) */
|
52
|
+
#define FETCH_Z_2() FETCH_Z()
|
53
|
+
#define FETCH_B_2() FETCH_B()
|
54
|
+
#define FETCH_BB_2() do {a=READ_B(); b=READ_S();} while (0)
|
55
|
+
#define FETCH_BBB_2() do {a=READ_B(); b=READ_S(); c=READ_B();} while (0)
|
56
|
+
#define FETCH_BS_2() FETCH_BS()
|
57
|
+
#define FETCH_S_2() FETCH_S()
|
58
|
+
#define FETCH_W_2() FETCH_W()
|
59
|
+
|
60
|
+
/* with OP_EXT3 (1st & 2nd 16bit) */
|
61
|
+
#define FETCH_Z_3() FETCH_Z()
|
62
|
+
#define FETCH_B_3() FETCH_B()
|
63
|
+
#define FETCH_BB_3() do {a=READ_S(); b=READ_S();} while (0)
|
64
|
+
#define FETCH_BBB_3() do {a=READ_S(); b=READ_S(); c=READ_B();} while (0)
|
65
|
+
#define FETCH_BS_3() do {a=READ_S(); b=READ_S();} while (0)
|
66
|
+
#define FETCH_S_3() FETCH_S()
|
67
|
+
#define FETCH_W_3() FETCH_W()
|
68
|
+
|
161
69
|
#endif /* MRUBY_OPCODE_H */
|
@@ -0,0 +1,117 @@
|
|
1
|
+
/* operand types:
|
2
|
+
+ Z: no operand (Z,Z,Z,Z)
|
3
|
+
+ B: 8bit (B,S,B,B)
|
4
|
+
+ BB: 8+8bit (BB,SB,BS,SS)
|
5
|
+
+ BBB: 8+8+8bit (BBB,SBB,BSB,SSB)
|
6
|
+
+ BS: 8+16bit (BS,SS,BS,BS)
|
7
|
+
+ S: 16bit (S,S,S,S)
|
8
|
+
+ W: 24bit (W,W,W,W)
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*-----------------------------------------------------------------------
|
12
|
+
operation code operands semantics
|
13
|
+
------------------------------------------------------------------------*/
|
14
|
+
OPCODE(NOP, Z) /* no operation */
|
15
|
+
OPCODE(MOVE, BB) /* R(a) = R(b) */
|
16
|
+
OPCODE(LOADL, BB) /* R(a) = Pool(b) */
|
17
|
+
OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
|
18
|
+
OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
|
19
|
+
OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
|
20
|
+
OPCODE(LOADI_0, B) /* R(a) = mrb_int(0) */
|
21
|
+
OPCODE(LOADI_1, B) /* R(a) = mrb_int(1) */
|
22
|
+
OPCODE(LOADI_2, B) /* R(a) = mrb_int(2) */
|
23
|
+
OPCODE(LOADI_3, B) /* R(a) = mrb_int(3) */
|
24
|
+
OPCODE(LOADI_4, B) /* R(a) = mrb_int(4) */
|
25
|
+
OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
|
26
|
+
OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
|
27
|
+
OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
|
28
|
+
OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
|
29
|
+
OPCODE(LOADNIL, B) /* R(a) = nil */
|
30
|
+
OPCODE(LOADSELF, B) /* R(a) = self */
|
31
|
+
OPCODE(LOADT, B) /* R(a) = true */
|
32
|
+
OPCODE(LOADF, B) /* R(a) = false */
|
33
|
+
OPCODE(GETGV, BB) /* R(a) = getglobal(Syms(b)) */
|
34
|
+
OPCODE(SETGV, BB) /* setglobal(Syms(b), R(a)) */
|
35
|
+
OPCODE(GETSV, BB) /* R(a) = Special[Syms(b)] */
|
36
|
+
OPCODE(SETSV, BB) /* Special[Syms(b)] = R(a) */
|
37
|
+
OPCODE(GETIV, BB) /* R(a) = ivget(Syms(b)) */
|
38
|
+
OPCODE(SETIV, BB) /* ivset(Syms(b),R(a)) */
|
39
|
+
OPCODE(GETCV, BB) /* R(a) = cvget(Syms(b)) */
|
40
|
+
OPCODE(SETCV, BB) /* cvset(Syms(b),R(a)) */
|
41
|
+
OPCODE(GETCONST, BB) /* R(a) = constget(Syms(b)) */
|
42
|
+
OPCODE(SETCONST, BB) /* constset(Syms(b),R(a)) */
|
43
|
+
OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
|
44
|
+
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
|
45
|
+
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
|
46
|
+
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
|
47
|
+
OPCODE(JMP, S) /* pc=a */
|
48
|
+
OPCODE(JMPIF, BS) /* if R(b) pc=a */
|
49
|
+
OPCODE(JMPNOT, BS) /* if !R(b) pc=a */
|
50
|
+
OPCODE(JMPNIL, BS) /* if R(b)==nil pc=a */
|
51
|
+
OPCODE(ONERR, S) /* rescue_push(a) */
|
52
|
+
OPCODE(EXCEPT, B) /* R(a) = exc */
|
53
|
+
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
|
54
|
+
OPCODE(POPERR, B) /* a.times{rescue_pop()} */
|
55
|
+
OPCODE(RAISE, B) /* raise(R(a)) */
|
56
|
+
OPCODE(EPUSH, B) /* ensure_push(SEQ[a]) */
|
57
|
+
OPCODE(EPOP, B) /* A.times{ensure_pop().call} */
|
58
|
+
OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
|
59
|
+
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
|
60
|
+
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
|
61
|
+
OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(Bx),R(a+1),...,R(a+c),&R(a+c+1)) */
|
62
|
+
OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
|
63
|
+
OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
|
64
|
+
OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
|
65
|
+
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
66
|
+
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) # todo */
|
67
|
+
OPCODE(KEYEND, Z) /* raise unless kdict.empty? # todo */
|
68
|
+
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) # todo */
|
69
|
+
OPCODE(RETURN, B) /* return R(a) (normal) */
|
70
|
+
OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
|
71
|
+
OPCODE(BREAK, B) /* break R(a) */
|
72
|
+
OPCODE(BLKPUSH, BS) /* R(a) = block (16=m5:r1:m5:d1:lv4) */
|
73
|
+
OPCODE(ADD, B) /* R(a) = R(a)+R(a+1) */
|
74
|
+
OPCODE(ADDI, BB) /* R(a) = R(a)+mrb_int(c) */
|
75
|
+
OPCODE(SUB, B) /* R(a) = R(a)-R(a+1) */
|
76
|
+
OPCODE(SUBI, BB) /* R(a) = R(a)-C */
|
77
|
+
OPCODE(MUL, B) /* R(a) = R(a)*R(a+1) */
|
78
|
+
OPCODE(DIV, B) /* R(a) = R(a)/R(a+1) */
|
79
|
+
OPCODE(EQ, B) /* R(a) = R(a)==R(a+1) */
|
80
|
+
OPCODE(LT, B) /* R(a) = R(a)<R(a+1) */
|
81
|
+
OPCODE(LE, B) /* R(a) = R(a)<=R(a+1) */
|
82
|
+
OPCODE(GT, B) /* R(a) = R(a)>R(a+1) */
|
83
|
+
OPCODE(GE, B) /* R(a) = R(a)>=R(a+1) */
|
84
|
+
OPCODE(ARRAY, BB) /* R(a) = ary_new(R(a),R(a+1)..R(a+b)) */
|
85
|
+
OPCODE(ARRAY2, BBB) /* R(a) = ary_new(R(b),R(b+1)..R(b+c)) */
|
86
|
+
OPCODE(ARYCAT, B) /* ary_cat(R(a),R(a+1)) */
|
87
|
+
OPCODE(ARYPUSH, B) /* ary_push(R(a),R(a+1)) */
|
88
|
+
OPCODE(ARYDUP, B) /* R(a) = ary_dup(R(a)) */
|
89
|
+
OPCODE(AREF, BBB) /* R(a) = R(b)[c] */
|
90
|
+
OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
|
91
|
+
OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+C) = R(a)[b..] */
|
92
|
+
OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
|
93
|
+
OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
|
94
|
+
OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
|
95
|
+
OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b)) */
|
96
|
+
OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b)) */
|
97
|
+
OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
|
98
|
+
OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
|
99
|
+
OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
|
100
|
+
OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
|
101
|
+
OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
|
102
|
+
OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
|
103
|
+
OPCODE(OCLASS, B) /* R(a) = ::Object */
|
104
|
+
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
|
105
|
+
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
|
106
|
+
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
|
107
|
+
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
|
108
|
+
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
|
109
|
+
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
|
110
|
+
OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
|
111
|
+
OPCODE(TCLASS, B) /* R(a) = target_class */
|
112
|
+
OPCODE(DEBUG, BBB) /* print a,b,c */
|
113
|
+
OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
|
114
|
+
OPCODE(EXT1, Z) /* make 1st operand 16bit */
|
115
|
+
OPCODE(EXT2, Z) /* make 2nd operand 16bit */
|
116
|
+
OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
|
117
|
+
OPCODE(STOP, Z) /* stop VM */
|
@@ -88,7 +88,7 @@ MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int
|
|
88
88
|
void mrb_proc_copy(struct RProc *a, struct RProc *b);
|
89
89
|
|
90
90
|
/* implementation of #send method */
|
91
|
-
|
91
|
+
mrb_value mrb_f_send(mrb_state *mrb, mrb_value self);
|
92
92
|
|
93
93
|
/* following functions are defined in mruby-proc-ext so please include it when using */
|
94
94
|
MRB_API struct RProc *mrb_proc_new_cfunc_with_env(mrb_state*, mrb_func_t, mrb_int, const mrb_value*);
|
@@ -98,8 +98,8 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state*, mrb_int);
|
|
98
98
|
|
99
99
|
#ifdef MRB_METHOD_TABLE_INLINE
|
100
100
|
|
101
|
-
#define MRB_METHOD_FUNC_FL ((uintptr_t)
|
102
|
-
#define MRB_METHOD_FUNC_P(m) ((uintptr_t)(m)&MRB_METHOD_FUNC_FL)
|
101
|
+
#define MRB_METHOD_FUNC_FL ((uintptr_t)1)
|
102
|
+
#define MRB_METHOD_FUNC_P(m) (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)
|
103
103
|
#define MRB_METHOD_FUNC(m) ((mrb_func_t)((uintptr_t)(m)&(~MRB_METHOD_FUNC_FL)))
|
104
104
|
#define MRB_METHOD_FROM_FUNC(m,fn) m=(mrb_method_t)((struct RProc*)((uintptr_t)(fn)|MRB_METHOD_FUNC_FL))
|
105
105
|
#define MRB_METHOD_FROM_PROC(m,pr) m=(mrb_method_t)(struct RProc*)(pr)
|
@@ -114,7 +114,7 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state*, mrb_int);
|
|
114
114
|
#define MRB_METHOD_FROM_FUNC(m,fn) do{(m).func_p=TRUE;(m).func=(fn);}while(0)
|
115
115
|
#define MRB_METHOD_FROM_PROC(m,pr) do{(m).func_p=FALSE;(m).proc=(pr);}while(0)
|
116
116
|
#define MRB_METHOD_PROC_P(m) (!MRB_METHOD_FUNC_P(m))
|
117
|
-
#define MRB_METHOD_PROC(
|
117
|
+
#define MRB_METHOD_PROC(m) ((m).proc)
|
118
118
|
#define MRB_METHOD_UNDEF_P(m) ((m).proc==NULL)
|
119
119
|
|
120
120
|
#endif /* MRB_METHOD_TABLE_INLINE */
|
@@ -102,7 +102,7 @@ MRB_API mrb_int mrb_str_index(mrb_state*, mrb_value, const char*, mrb_int, mrb_i
|
|
102
102
|
#define mrb_str_index_lit(mrb, str, lit, off) mrb_str_index(mrb, str, lit, mrb_strlen_lit(lit), off);
|
103
103
|
|
104
104
|
/*
|
105
|
-
* Appends self to other. Returns self as a
|
105
|
+
* Appends self to other. Returns self as a concatenated string.
|
106
106
|
*
|
107
107
|
*
|
108
108
|
* Example:
|
@@ -126,10 +126,10 @@ MRB_API mrb_int mrb_str_index(mrb_state*, mrb_value, const char*, mrb_int, mrb_i
|
|
126
126
|
* str1 = mrb_str_new_lit(mrb, "abc");
|
127
127
|
* str2 = mrb_str_new_lit(mrb, "def");
|
128
128
|
*
|
129
|
-
* //
|
129
|
+
* // Concatenates str2 to str1.
|
130
130
|
* mrb_str_concat(mrb, str1, str2);
|
131
131
|
*
|
132
|
-
* // Prints new
|
132
|
+
* // Prints new Concatenated Ruby string.
|
133
133
|
* mrb_p(mrb, str1);
|
134
134
|
*
|
135
135
|
* mrb_close(mrb);
|
@@ -178,10 +178,10 @@ MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
|
|
178
178
|
* mrb_p(mrb, a);
|
179
179
|
* mrb_p(mrb, b);
|
180
180
|
*
|
181
|
-
* //
|
181
|
+
* // Concatenates both Ruby strings.
|
182
182
|
* c = mrb_str_plus(mrb, a, b);
|
183
183
|
*
|
184
|
-
* // Prints new
|
184
|
+
* // Prints new Concatenated Ruby string.
|
185
185
|
* mrb_p(mrb, c);
|
186
186
|
*
|
187
187
|
* mrb_close(mrb);
|
@@ -193,7 +193,7 @@ MRB_API void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
|
|
193
193
|
*
|
194
194
|
* => "abc" # First string
|
195
195
|
* => "def" # Second string
|
196
|
-
* => "abcdef" # First & Second
|
196
|
+
* => "abcdef" # First & Second concatenated.
|
197
197
|
*
|
198
198
|
* @param [mrb_state] mrb The current mruby state.
|
199
199
|
* @param [mrb_value] a First string to concatenate.
|
@@ -311,9 +311,12 @@ MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb
|
|
311
311
|
* @param [mrb_value] str Ruby string.
|
312
312
|
* @return [mrb_value] A Ruby string.
|
313
313
|
*/
|
314
|
+
MRB_API mrb_value mrb_ensure_string_type(mrb_state *mrb, mrb_value str);
|
315
|
+
MRB_API mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
|
316
|
+
/* obsolete: use mrb_ensure_string_type() instead */
|
314
317
|
MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
|
315
318
|
|
316
|
-
|
319
|
+
|
317
320
|
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
|
318
321
|
MRB_API mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa);
|
319
322
|
|
@@ -353,6 +356,7 @@ MRB_API double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, mrb_bool badcheck);
|
|
353
356
|
|
354
357
|
/*
|
355
358
|
* Returns a converted string type.
|
359
|
+
* For type checking, non converting `mrb_to_str` is recommended.
|
356
360
|
*/
|
357
361
|
MRB_API mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str);
|
358
362
|
|