Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
fd9cc993
Commit
fd9cc993
authored
Jul 21, 2013
by
Ryan Scott
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into attr-perf-fix
parents
43c0f43f
bc843ed9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
6 deletions
+35
-6
include/mruby/irep.h
include/mruby/irep.h
+3
-2
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+28
-0
src/array.c
src/array.c
+2
-2
test/t/string.rb
test/t/string.rb
+2
-2
No files found.
include/mruby/irep.h
View file @
fd9cc993
...
@@ -11,10 +11,11 @@
...
@@ -11,10 +11,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
/* Program data array struct */
typedef
struct
mrb_irep
{
typedef
struct
mrb_irep
{
uint32_t
idx
;
uint32_t
idx
;
uint16_t
nlocals
;
uint16_t
nlocals
;
/* Number of local variables */
uint16_t
nregs
;
uint16_t
nregs
;
/* Number of register variables */
uint8_t
flags
;
uint8_t
flags
;
mrb_code
*
iseq
;
mrb_code
*
iseq
;
...
...
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
fd9cc993
...
@@ -15,11 +15,19 @@
...
@@ -15,11 +15,19 @@
#include <mruby/data.h>
#include <mruby/data.h>
#include <mruby/compile.h>
#include <mruby/compile.h>
#ifdef ENABLE_READLINE
#ifdef ENABLE_READLINE
#include <limits.h>
#include <readline/readline.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <readline/history.h>
#endif
#endif
#include <mruby/string.h>
#include <mruby/string.h>
#ifdef ENABLE_READLINE
static
const
char
*
history_file_name
=
".mirb_history"
;
char
history_path
[
PATH_MAX
];
#endif
static
void
static
void
p
(
mrb_state
*
mrb
,
mrb_value
obj
,
int
prompt
)
p
(
mrb_state
*
mrb
,
mrb_value
obj
,
int
prompt
)
{
{
...
@@ -245,6 +253,7 @@ main(int argc, char **argv)
...
@@ -245,6 +253,7 @@ main(int argc, char **argv)
int
n
;
int
n
;
int
code_block_open
=
FALSE
;
int
code_block_open
=
FALSE
;
int
ai
;
int
ai
;
char
*
home
=
NULL
;
/* new interpreter instance */
/* new interpreter instance */
mrb
=
mrb_open
();
mrb
=
mrb_open
();
...
@@ -268,6 +277,21 @@ main(int argc, char **argv)
...
@@ -268,6 +277,21 @@ main(int argc, char **argv)
if
(
args
.
verbose
)
cxt
->
dump_result
=
1
;
if
(
args
.
verbose
)
cxt
->
dump_result
=
1
;
ai
=
mrb_gc_arena_save
(
mrb
);
ai
=
mrb_gc_arena_save
(
mrb
);
#ifdef ENABLE_READLINE
using_history
();
home
=
getenv
(
"HOME"
);
#ifdef _WIN32
if
(
!
home
)
home
=
getenv
(
"USERPROFILE"
);
#endif
strcpy
(
history_path
,
home
);
strcat
(
history_path
,
"/"
);
strcat
(
history_path
,
history_file_name
);
read_history
(
history_path
);
#endif
while
(
TRUE
)
{
while
(
TRUE
)
{
#ifndef ENABLE_READLINE
#ifndef ENABLE_READLINE
print_cmdline
(
code_block_open
);
print_cmdline
(
code_block_open
);
...
@@ -361,5 +385,9 @@ main(int argc, char **argv)
...
@@ -361,5 +385,9 @@ main(int argc, char **argv)
mrbc_context_free
(
mrb
,
cxt
);
mrbc_context_free
(
mrb
,
cxt
);
mrb_close
(
mrb
);
mrb_close
(
mrb
);
#ifdef ENABLE_READLINE
write_history
(
history_path
);
#endif
return
0
;
return
0
;
}
}
src/array.c
View file @
fd9cc993
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#define ARY_DEFAULT_LEN 4
#define ARY_DEFAULT_LEN 4
#define ARY_SHRINK_RATIO 5
/* must be larger than 2 */
#define ARY_SHRINK_RATIO 5
/* must be larger than 2 */
#define ARY_C_MAX_SIZE (SIZE_MAX / sizeof(mrb_value))
#define ARY_C_MAX_SIZE (SIZE_MAX / sizeof(mrb_value))
#define ARY_MAX_SIZE ((ARY_C_MAX_SIZE < (size_t)MRB_INT_MAX) ? (mrb_int)ARY_C_MAX_SIZE : MRB_INT_MAX)
#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
static
inline
mrb_value
ary_elt
(
mrb_value
ary
,
mrb_int
offset
)
ary_elt
(
mrb_value
ary
,
mrb_int
offset
)
...
@@ -40,7 +40,7 @@ ary_new_capa(mrb_state *mrb, mrb_int capa)
...
@@ -40,7 +40,7 @@ ary_new_capa(mrb_state *mrb, mrb_int capa)
if
(
capa
>
ARY_MAX_SIZE
)
{
if
(
capa
>
ARY_MAX_SIZE
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
}
}
blen
=
capa
*
sizeof
(
mrb_value
)
;
blen
=
capa
*
sizeof
(
mrb_value
);
if
(
blen
<
capa
)
{
if
(
blen
<
capa
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
}
}
...
...
test/t/string.rb
View file @
fd9cc993
...
@@ -399,12 +399,12 @@ end
...
@@ -399,12 +399,12 @@ end
assert
(
'String#to_i'
,
'15.2.10.5.38'
)
do
assert
(
'String#to_i'
,
'15.2.10.5.38'
)
do
a
=
''
.
to_i
a
=
''
.
to_i
b
=
'
123456789
'
.
to_i
b
=
'
32143
'
.
to_i
c
=
'a'
.
to_i
(
16
)
c
=
'a'
.
to_i
(
16
)
d
=
'100'
.
to_i
(
2
)
d
=
'100'
.
to_i
(
2
)
assert_equal
a
,
0
assert_equal
a
,
0
assert_equal
b
,
123456789
assert_equal
b
,
32143
assert_equal
c
,
10
assert_equal
c
,
10
assert_equal
d
,
4
assert_equal
d
,
4
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment