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
5a4beeed
Commit
5a4beeed
authored
Jul 29, 2012
by
Max Anselm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make all(?) void casts explicit for C++
parent
ee899778
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
114 additions
and
113 deletions
+114
-113
src/array.c
src/array.c
+6
-6
src/cdump.c
src/cdump.c
+2
-2
src/codegen.c
src/codegen.c
+13
-13
src/dump.c
src/dump.c
+7
-7
src/gc.c
src/gc.c
+1
-1
src/kernel.c
src/kernel.c
+1
-1
src/load.c
src/load.c
+11
-11
src/math.c
src/math.c
+1
-0
src/pool.c
src/pool.c
+2
-2
src/proc.c
src/proc.c
+2
-2
src/range.c
src/range.c
+1
-1
src/st.c
src/st.c
+6
-6
src/state.c
src/state.c
+3
-3
src/string.c
src/string.c
+15
-15
src/struct.c
src/struct.c
+2
-2
src/symbol.c
src/symbol.c
+1
-1
src/time.c
src/time.c
+32
-32
src/vm.c
src/vm.c
+8
-8
No files found.
src/array.c
View file @
5a4beeed
...
...
@@ -46,7 +46,7 @@ ary_new_capa(mrb_state *mrb, int capa)
}
a
=
(
struct
RArray
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_ARRAY
,
mrb
->
array_class
);
a
->
ptr
=
mrb_calloc
(
mrb
,
blen
,
1
);
a
->
ptr
=
(
mrb_value
*
)
mrb_calloc
(
mrb
,
blen
,
1
);
a
->
aux
.
capa
=
capa
;
a
->
len
=
0
;
...
...
@@ -116,7 +116,7 @@ ary_modify(mrb_state *mrb, struct RArray *a)
p
=
a
->
ptr
;
len
=
a
->
len
*
sizeof
(
mrb_value
);
ptr
=
mrb_malloc
(
mrb
,
len
);
ptr
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
len
);
if
(
p
)
{
memcpy
(
ptr
,
p
,
len
);
}
...
...
@@ -132,11 +132,11 @@ static void
ary_make_shared
(
mrb_state
*
mrb
,
struct
RArray
*
a
)
{
if
(
!
(
a
->
flags
&
MRB_ARY_SHARED
))
{
struct
mrb_shared_array
*
shared
=
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_shared_array
));
struct
mrb_shared_array
*
shared
=
(
struct
mrb_shared_array
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_shared_array
));
shared
->
refcnt
=
1
;
if
(
a
->
aux
.
capa
>
a
->
len
)
{
a
->
ptr
=
shared
->
ptr
=
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
a
->
len
+
1
);
a
->
ptr
=
shared
->
ptr
=
(
mrb_value
*
)
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
a
->
len
+
1
);
}
else
{
shared
->
ptr
=
a
->
ptr
;
...
...
@@ -173,7 +173,7 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, int len)
if
(
capa
>
a
->
aux
.
capa
)
{
a
->
aux
.
capa
=
capa
;
a
->
ptr
=
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
capa
);
a
->
ptr
=
(
mrb_value
*
)
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
capa
);
}
}
...
...
@@ -195,7 +195,7 @@ ary_shrink_capa(mrb_state *mrb, struct RArray *a)
if
(
capa
>
a
->
len
&&
capa
<
a
->
aux
.
capa
)
{
a
->
aux
.
capa
=
capa
;
a
->
ptr
=
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
capa
);
a
->
ptr
=
(
mrb_value
*
)
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
capa
);
}
}
...
...
src/cdump.c
View file @
5a4beeed
...
...
@@ -107,7 +107,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
return
-
1
;
buf_len
=
MRB_CDUMP_LINE_LEN
;
if
((
buf
=
mrb_malloc
(
mrb
,
buf_len
))
==
0
)
{
if
((
buf
=
(
char
*
)
mrb_malloc
(
mrb
,
buf_len
))
==
0
)
{
return
MRB_CDUMP_GENERAL_FAILURE
;
}
...
...
@@ -144,7 +144,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
str_len
=
str_format_len
(
irep
->
pool
[
n
])
+
1
;
if
(
str_len
>
buf_len
)
{
buf_len
=
str_len
;
if
((
buf
=
mrb_realloc
(
mrb
,
buf
,
buf_len
))
==
0
)
{
if
((
buf
=
(
char
*
)
mrb_realloc
(
mrb
,
buf
,
buf_len
))
==
0
)
{
return
MRB_CDUMP_GENERAL_FAILURE
;
}
}
...
...
src/codegen.c
View file @
5a4beeed
...
...
@@ -136,7 +136,7 @@ genop(codegen_scope *s, mrb_code i)
{
if
(
s
->
pc
==
s
->
icapa
)
{
s
->
icapa
*=
2
;
s
->
iseq
=
codegen_realloc
(
s
,
s
->
iseq
,
sizeof
(
mrb_code
)
*
s
->
icapa
);
s
->
iseq
=
(
mrb_code
*
)
codegen_realloc
(
s
,
s
->
iseq
,
sizeof
(
mrb_code
)
*
s
->
icapa
);
}
s
->
iseq
[
s
->
pc
]
=
i
;
s
->
pc
++
;
...
...
@@ -323,7 +323,7 @@ new_lit(codegen_scope *s, mrb_value val)
}
if
(
s
->
plen
==
s
->
pcapa
)
{
s
->
pcapa
*=
2
;
s
->
pool
=
codegen_realloc
(
s
,
s
->
pool
,
sizeof
(
mrb_value
)
*
s
->
pcapa
);
s
->
pool
=
(
mrb_value
*
)
codegen_realloc
(
s
,
s
->
pool
,
sizeof
(
mrb_value
)
*
s
->
pcapa
);
}
s
->
pool
[
s
->
plen
]
=
val
;
return
s
->
plen
++
;
...
...
@@ -357,7 +357,7 @@ new_sym(codegen_scope *s, mrb_sym sym)
if
(
s
->
syms
[
i
]
==
sym
)
return
i
;
}
if
(
s
->
slen
>
125
&&
s
->
slen
<
256
)
{
s
->
syms
=
codegen_realloc
(
s
,
s
->
syms
,
sizeof
(
mrb_sym
)
*
65536
);
s
->
syms
=
(
mrb_sym
*
)
codegen_realloc
(
s
,
s
->
syms
,
sizeof
(
mrb_sym
)
*
65536
);
memset
(
s
->
syms
+
s
->
slen
,
0
,
sizeof
(
mrb_sym
)
*
(
256
-
s
->
slen
));
s
->
slen
=
256
;
}
...
...
@@ -556,7 +556,7 @@ attrsym(codegen_scope *s, mrb_sym a)
char
*
name2
;
name
=
mrb_sym2name_len
(
s
->
mrb
,
a
,
&
len
);
name2
=
codegen_palloc
(
s
,
len
+
1
);
name2
=
(
char
*
)
codegen_palloc
(
s
,
len
+
1
);
memcpy
(
name2
,
name
,
len
);
name2
[
len
]
=
'='
;
name2
[
len
+
1
]
=
'\0'
;
...
...
@@ -1927,7 +1927,7 @@ static codegen_scope*
scope_new
(
mrb_state
*
mrb
,
codegen_scope
*
prev
,
node
*
lv
)
{
mrb_pool
*
pool
=
mrb_pool_open
(
mrb
);
codegen_scope
*
p
=
mrb_pool_alloc
(
pool
,
sizeof
(
codegen_scope
));
codegen_scope
*
p
=
(
codegen_scope
*
)
mrb_pool_alloc
(
pool
,
sizeof
(
codegen_scope
));
if
(
!
p
)
return
0
;
memset
(
p
,
0
,
sizeof
(
codegen_scope
));
...
...
@@ -1940,12 +1940,12 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
p
->
mrb
=
prev
->
mrb
;
p
->
icapa
=
1024
;
p
->
iseq
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
)
*
p
->
icapa
);
p
->
iseq
=
(
mrb_code
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
)
*
p
->
icapa
);
p
->
pcapa
=
32
;
p
->
pool
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
p
->
pcapa
);
p
->
pool
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
p
->
pcapa
);
p
->
syms
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
256
);
p
->
syms
=
(
mrb_sym
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
256
);
p
->
lv
=
lv
;
p
->
sp
+=
node_len
(
lv
)
+
2
;
...
...
@@ -1964,20 +1964,20 @@ scope_finish(codegen_scope *s, int idx)
mrb_irep
*
irep
;
mrb_add_irep
(
mrb
,
idx
);
irep
=
mrb
->
irep
[
idx
]
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
));
irep
=
mrb
->
irep
[
idx
]
=
(
mrb_irep
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
));
irep
->
idx
=
idx
;
irep
->
flags
=
0
;
if
(
s
->
iseq
)
{
irep
->
iseq
=
codegen_realloc
(
s
,
s
->
iseq
,
sizeof
(
mrb_code
)
*
s
->
pc
);
irep
->
iseq
=
(
mrb_code
*
)
codegen_realloc
(
s
,
s
->
iseq
,
sizeof
(
mrb_code
)
*
s
->
pc
);
irep
->
ilen
=
s
->
pc
;
}
if
(
s
->
pool
)
{
irep
->
pool
=
codegen_realloc
(
s
,
s
->
pool
,
sizeof
(
mrb_value
)
*
s
->
plen
);
irep
->
pool
=
(
mrb_value
*
)
codegen_realloc
(
s
,
s
->
pool
,
sizeof
(
mrb_value
)
*
s
->
plen
);
irep
->
plen
=
s
->
plen
;
}
if
(
s
->
syms
)
{
irep
->
syms
=
codegen_realloc
(
s
,
s
->
syms
,
sizeof
(
mrb_sym
)
*
s
->
slen
);
irep
->
syms
=
(
mrb_sym
*
)
codegen_realloc
(
s
,
s
->
syms
,
sizeof
(
mrb_sym
)
*
s
->
slen
);
irep
->
slen
=
s
->
slen
;
}
...
...
@@ -1991,7 +1991,7 @@ scope_finish(codegen_scope *s, int idx)
static
struct
loopinfo
*
loop_push
(
codegen_scope
*
s
,
enum
looptype
t
)
{
struct
loopinfo
*
p
=
codegen_palloc
(
s
,
sizeof
(
struct
loopinfo
));
struct
loopinfo
*
p
=
(
struct
loopinfo
*
)
codegen_palloc
(
s
,
sizeof
(
struct
loopinfo
));
p
->
type
=
t
;
p
->
pc1
=
p
->
pc2
=
p
->
pc3
=
0
;
...
...
src/dump.c
View file @
5a4beeed
...
...
@@ -335,7 +335,7 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
int
len
;
buf_size
=
MRB_DUMP_DEFAULT_STR_LEN
;
if
((
char_buf
=
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
goto
error_exit
;
buf
+=
uint32_dump
((
uint32_t
)
irep
->
plen
,
buf
,
type
);
/* number of pool */
...
...
@@ -360,7 +360,7 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
nlen
=
str_dump_len
(
RSTRING_PTR
(
str
),
RSTRING_LEN
(
str
),
type
);
if
(
nlen
>
buf_size
-
1
)
{
buf_size
=
nlen
+
1
;
if
((
char_buf
=
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
goto
error_exit
;
memset
(
char_buf
,
0
,
buf_size
);
}
...
...
@@ -409,7 +409,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
uint16_t
buf_size
=
0
;
buf_size
=
MRB_DUMP_DEFAULT_STR_LEN
;
if
((
char_buf
=
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
goto
error_exit
;
buf
+=
uint32_dump
((
uint32_t
)
irep
->
slen
,
buf
,
type
);
/* number of symbol */
...
...
@@ -425,7 +425,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
nlen
=
str_dump_len
((
char
*
)
name
,
len
,
type
);
if
(
nlen
>
buf_size
-
1
)
{
buf_size
=
nlen
+
1
;
if
((
char_buf
=
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
goto
error_exit
;
}
memset
(
char_buf
,
0
,
buf_size
);
...
...
@@ -461,7 +461,7 @@ calc_crc_section(mrb_state *mrb, mrb_irep *irep, uint16_t *crc, int section)
default:
return
MRB_DUMP_GENERAL_FAILURE
;
}
if
((
buf
=
mrb_calloc
(
mrb
,
1
,
buf_size
))
==
0
)
if
((
buf
=
(
char
*
)
mrb_calloc
(
mrb
,
1
,
buf_size
))
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
buf_top
=
buf
;
...
...
@@ -598,7 +598,7 @@ dump_irep_record(mrb_state *mrb, int irep_no, FILE* fp, uint32_t *rlen)
if
(
irep_record_size
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
if
((
buf
=
mrb_calloc
(
mrb
,
1
,
irep_record_size
))
==
0
)
if
((
buf
=
(
char
*
)
mrb_calloc
(
mrb
,
1
,
irep_record_size
))
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
if
((
rc
=
write_irep_record
(
mrb
,
irep_no
,
buf
,
rlen
,
DUMP_TYPE_HEX
))
!=
MRB_DUMP_OK
)
{
...
...
@@ -690,7 +690,7 @@ mrb_bdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
buf_size
+=
get_irep_record_size
(
mrb
,
irep_no
,
DUMP_TYPE_BIN
);
buf_size
+=
MRB_DUMP_SIZE_OF_LONG
;
/* end of file */
if
((
buf
=
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
if
((
buf
=
(
char
*
)
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
rc
=
mrb_write_irep
(
mrb
,
n
,
buf
);
...
...
src/gc.c
View file @
5a4beeed
...
...
@@ -248,7 +248,7 @@ unlink_free_heap_page(mrb_state *mrb, struct heap_page *page)
static
void
add_heap
(
mrb_state
*
mrb
)
{
struct
heap_page
*
page
=
mrb_calloc
(
mrb
,
1
,
sizeof
(
struct
heap_page
));
struct
heap_page
*
page
=
(
struct
heap_page
*
)
mrb_calloc
(
mrb
,
1
,
sizeof
(
struct
heap_page
));
RVALUE
*
p
,
*
e
;
struct
RBasic
*
prev
=
NULL
;
...
...
src/kernel.c
View file @
5a4beeed
...
...
@@ -853,7 +853,7 @@ mrb_obj_methods_m(mrb_state *mrb, mrb_value self)
int
argc
;
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
return
mrb_obj_methods
(
mrb
,
argc
,
argv
,
self
,
0
);
/* everything but private */
return
mrb_obj_methods
(
mrb
,
argc
,
argv
,
self
,
(
mrb_method_flag_t
)
0
);
/* everything but private */
}
/* 15.3.1.3.32 */
...
...
src/load.c
View file @
5a4beeed
...
...
@@ -143,7 +143,7 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
uint16_t
buf_size
=
0
;
buf_size
=
MRB_DUMP_DEFAULT_STR_LEN
;
if
((
char_buf
=
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_malloc
(
mrb
,
buf_size
))
==
0
)
goto
error_exit
;
pStart
=
dst
;
...
...
@@ -192,7 +192,7 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
if
(
pdl
>
buf_size
-
1
)
{
buf_size
=
pdl
+
1
;
if
((
char_buf
=
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
goto
error_exit
;
}
memset
(
char_buf
,
'\0'
,
buf_size
);
...
...
@@ -219,7 +219,7 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
if
(
snl
>
buf_size
-
1
)
{
buf_size
=
snl
+
1
;
if
((
char_buf
=
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
if
((
char_buf
=
(
char
*
)
mrb_realloc
(
mrb
,
char_buf
,
buf_size
))
==
0
)
goto
error_exit
;
}
memset
(
char_buf
,
'\0'
,
buf_size
);
...
...
@@ -262,7 +262,7 @@ mrb_load_irep(mrb_state *mrb, FILE* fp)
return
ret
;
len
=
sizeof
(
rite_binary_header
)
+
bin_to_uint32
(
bin_header
.
rbds
);
if
((
rite_dst
=
mrb_malloc
(
mrb
,
len
))
==
NULL
)
if
((
rite_dst
=
(
unsigned
char
*
)
mrb_malloc
(
mrb
,
len
))
==
NULL
)
return
MRB_DUMP_GENERAL_FAILURE
;
dst
=
rite_dst
;
...
...
@@ -331,7 +331,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
int
ai
=
mrb_gc_arena_save
(
mrb
);
recordStart
=
src
;
buf
=
mrb_malloc
(
mrb
,
bufsize
);
buf
=
(
char
*
)
mrb_malloc
(
mrb
,
bufsize
);
if
(
buf
==
NULL
)
{
ret
=
MRB_DUMP_INVALID_IREP
;
goto
error_exit
;
...
...
@@ -359,7 +359,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep
->
ilen
=
bin_to_uint32
(
src
);
//iseq length
src
+=
MRB_DUMP_SIZE_OF_LONG
;
if
(
irep
->
ilen
>
0
)
{
if
((
irep
->
iseq
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
)
*
irep
->
ilen
))
==
NULL
)
{
if
((
irep
->
iseq
=
(
mrb_code
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
)
*
irep
->
ilen
))
==
NULL
)
{
ret
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
}
...
...
@@ -380,7 +380,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep
->
plen
=
bin_to_uint32
(
src
);
//pool length
src
+=
MRB_DUMP_SIZE_OF_LONG
;
if
(
irep
->
plen
>
0
)
{
irep
->
pool
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
irep
->
plen
);
irep
->
pool
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
irep
->
plen
);
if
(
irep
->
pool
==
NULL
)
{
ret
=
MRB_DUMP_INVALID_IREP
;
goto
error_exit
;
...
...
@@ -394,7 +394,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
if
(
pdl
>
bufsize
-
1
)
{
mrb_free
(
mrb
,
buf
);
bufsize
=
pdl
+
1
;
if
((
buf
=
mrb_malloc
(
mrb
,
bufsize
))
==
NULL
)
{
if
((
buf
=
(
char
*
)
mrb_malloc
(
mrb
,
bufsize
))
==
NULL
)
{
ret
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
}
...
...
@@ -443,7 +443,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep
->
slen
=
bin_to_uint32
(
src
);
//syms length
src
+=
MRB_DUMP_SIZE_OF_LONG
;
if
(
irep
->
slen
>
0
)
{
if
((
irep
->
syms
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
irep
->
slen
))
==
NULL
)
{
if
((
irep
->
syms
=
(
mrb_sym
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
irep
->
slen
))
==
NULL
)
{
ret
=
MRB_DUMP_INVALID_IREP
;
goto
error_exit
;
}
...
...
@@ -461,7 +461,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
if
(
snl
>
bufsize
-
1
)
{
mrb_free
(
mrb
,
buf
);
bufsize
=
snl
+
1
;
if
((
buf
=
mrb_malloc
(
mrb
,
bufsize
))
==
NULL
)
{
if
((
buf
=
(
char
*
)
mrb_malloc
(
mrb
,
bufsize
))
==
NULL
)
{
ret
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
}
...
...
@@ -509,7 +509,7 @@ mrb_read_irep(mrb_state *mrb, const char *bin)
mrb_add_irep
(
mrb
,
sirep
+
nirep
);
for
(
n
=
0
,
i
=
sirep
;
n
<
nirep
;
n
++
,
i
++
)
{
if
((
mrb
->
irep
[
i
]
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
)))
==
NULL
)
{
if
((
mrb
->
irep
[
i
]
=
(
mrb_irep
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
)))
==
NULL
)
{
ret
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
}
...
...
src/math.c
View file @
5a4beeed
...
...
@@ -5,6 +5,7 @@
*/
#include "mruby.h"
#include "mruby/array.h"
#ifdef ENABLE_MATH
#include <math.h>
...
...
src/pool.c
View file @
5a4beeed
...
...
@@ -49,7 +49,7 @@ struct mrb_pool {
mrb_pool
*
mrb_pool_open
(
mrb_state
*
mrb
)
{
mrb_pool
*
pool
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_pool
));
mrb_pool
*
pool
=
(
mrb_pool
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_pool
));
if
(
pool
)
{
pool
->
mrb
=
mrb
;
...
...
@@ -81,7 +81,7 @@ page_alloc(mrb_pool *pool, size_t len)
if
(
len
<
POOL_PAGE_SIZE
)
len
=
POOL_PAGE_SIZE
;
page
=
mrb_malloc
(
pool
->
mrb
,
sizeof
(
struct
mrb_pool_page
)
+
len
-
1
);
page
=
(
struct
mrb_pool_page
*
)
mrb_malloc
(
pool
->
mrb
,
sizeof
(
struct
mrb_pool_page
)
+
len
-
1
);
if
(
page
)
{
page
->
offset
=
0
;
page
->
len
=
len
;
...
...
src/proc.c
View file @
5a4beeed
...
...
@@ -144,8 +144,8 @@ void
mrb_init_proc
(
mrb_state
*
mrb
)
{
struct
RProc
*
m
;
mrb_code
*
call_iseq
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
));
mrb_irep
*
call_irep
=
mrb_calloc
(
mrb
,
sizeof
(
mrb_irep
),
1
);
mrb_code
*
call_iseq
=
(
mrb_code
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
));
mrb_irep
*
call_irep
=
(
mrb_irep
*
)
mrb_calloc
(
mrb
,
sizeof
(
mrb_irep
),
1
);
if
(
call_iseq
==
NULL
||
call_irep
==
NULL
)
return
;
...
...
src/range.c
View file @
5a4beeed
...
...
@@ -43,7 +43,7 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, int excl)
struct
RRange
*
r
;
r
=
(
struct
RRange
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_RANGE
,
RANGE_CLASS
);
r
->
edges
=
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_range_edges
));
r
->
edges
=
(
struct
mrb_range_edges
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_range_edges
));
range_check
(
mrb
,
beg
,
end
);
r
->
edges
->
beg
=
beg
;
r
->
edges
->
end
=
end
;
...
...
src/st.c
View file @
5a4beeed
...
...
@@ -24,21 +24,21 @@
static
int
numcmp
(
long
,
long
);
static
st_index_t
numhash
(
long
);
static
struct
st_hash_type
type_numhash
=
{
numcmp
,
numhash
,
(
int
(
*
)(
ANYARGS
))
numcmp
,
(
st_index_t
(
*
)(
ANYARGS
))
numhash
,
};
/* extern int strcmp(const char *, const char *); */
static
st_index_t
strhash
(
const
char
*
);
static
struct
st_hash_type
type_strhash
=
{
strcmp
,
strhash
,
(
int
(
*
)(
ANYARGS
))
strcmp
,
(
st_index_t
(
*
)(
ANYARGS
))
strhash
,
};
static
st_index_t
strcasehash
(
st_data_t
);
static
const
struct
st_hash_type
type_strcasehash
=
{
st_strcasecmp
,
strcasehash
,
(
int
(
*
)(
ANYARGS
))
st_strcasecmp
,
(
st_index_t
(
*
)(
ANYARGS
))
strcasehash
,
};
static
void
rehash
(
st_table
*
);
...
...
src/state.c
View file @
5a4beeed
...
...
@@ -15,7 +15,7 @@ void mrb_init_ext(mrb_state*);
mrb_state
*
mrb_open_allocf
(
mrb_allocf
f
)
{
mrb_state
*
mrb
=
(
f
)(
NULL
,
NULL
,
sizeof
(
mrb_state
));
mrb_state
*
mrb
=
(
mrb_state
*
)(
f
)(
NULL
,
NULL
,
sizeof
(
mrb_state
));
if
(
mrb
==
NULL
)
return
NULL
;
memset
(
mrb
,
0
,
sizeof
(
mrb_state
));
...
...
@@ -76,14 +76,14 @@ mrb_add_irep(mrb_state *mrb, int idx)
int
max
=
256
;
if
(
idx
>
max
)
max
=
idx
+
1
;
mrb
->
irep
=
mrb_calloc
(
mrb
,
max
,
sizeof
(
mrb_irep
*
));
mrb
->
irep
=
(
mrb_irep
**
)
mrb_calloc
(
mrb
,
max
,
sizeof
(
mrb_irep
*
));
mrb
->
irep_capa
=
max
;
}
else
if
(
mrb
->
irep_capa
<=
idx
)
{
while
(
mrb
->
irep_capa
<=
idx
)
{
mrb
->
irep_capa
*=
2
;
}
mrb
->
irep
=
mrb_realloc
(
mrb
,
mrb
->
irep
,
sizeof
(
mrb_irep
*
)
*
mrb
->
irep_capa
);
mrb
->
irep
=
(
mrb_irep
**
)
mrb_realloc
(
mrb
,
mrb
->
irep
,
sizeof
(
mrb_irep
*
)
*
mrb
->
irep_capa
);
}
}
...
...
src/string.c
View file @
5a4beeed
...
...
@@ -29,7 +29,7 @@ static mrb_value str_replace(mrb_state *mrb, struct RString *s1, struct RString
static
mrb_value
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
int
beg
,
int
len
);
#define RESIZE_CAPA(s,capacity) do {\
s->ptr = mrb_realloc(mrb, s->ptr, (capacity)+1);\
s->ptr =
(char *)
mrb_realloc(mrb, s->ptr, (capacity)+1);\
s->aux.capa = capacity;\
} while (0)
...
...
@@ -60,7 +60,7 @@ str_modify(mrb_state *mrb, struct RString *s)
p
=
s
->
ptr
;
len
=
s
->
len
;
ptr
=
mrb_malloc
(
mrb
,
len
+
1
);
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
if
(
p
)
{
memcpy
(
ptr
,
p
,
len
);
}
...
...
@@ -83,7 +83,7 @@ mrb_str_resize(mrb_state *mrb, mrb_value str, int len)
slen
=
s
->
len
;
if
(
len
!=
slen
)
{
if
(
slen
<
len
||
slen
-
len
>
1024
)
{
s
->
ptr
=
mrb_realloc
(
mrb
,
s
->
ptr
,
len
+
1
);
s
->
ptr
=
(
char
*
)
mrb_realloc
(
mrb
,
s
->
ptr
,
len
+
1
);
}
s
->
aux
.
capa
=
len
;
s
->
len
=
len
;
...
...
@@ -133,7 +133,7 @@ str_new(mrb_state *mrb, const char *p, int len)
s
->
len
=
len
;
s
->
aux
.
capa
=
len
;
s
->
ptr
=
mrb_malloc
(
mrb
,
len
+
1
);
s
->
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
if
(
p
)
{
memcpy
(
s
->
ptr
,
p
,
len
);
}
...
...
@@ -168,7 +168,7 @@ mrb_str_buf_new(mrb_state *mrb, int capa)
}
s
->
len
=
0
;
s
->
aux
.
capa
=
capa
;
s
->
ptr
=
mrb_malloc
(
mrb
,
capa
+
1
);
s
->
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
capa
+
1
);
s
->
ptr
[
0
]
=
'\0'
;
return
mrb_obj_value
(
s
);
...
...
@@ -249,7 +249,7 @@ mrb_str_new_cstr(mrb_state *mrb, const char *p)
int
len
=
strlen
(
p
);
s
=
mrb_obj_alloc_string
(
mrb
);
s
->
ptr
=
mrb_malloc
(
mrb
,
len
+
1
);
s
->
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
memcpy
(
s
->
ptr
,
p
,
len
);
s
->
ptr
[
len
]
=
0
;
s
->
len
=
len
;
...
...
@@ -262,11 +262,11 @@ static void
str_make_shared
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
if
(
!
(
s
->
flags
&
MRB_STR_SHARED
))
{
struct
mrb_shared_string
*
shared
=
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_shared_string
));
struct
mrb_shared_string
*
shared
=
(
struct
mrb_shared_string
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_shared_string
));
shared
->
refcnt
=
1
;
if
(
s
->
aux
.
capa
>
s
->
len
)
{
s
->
ptr
=
shared
->
ptr
=
mrb_realloc
(
mrb
,
s
->
ptr
,
s
->
len
+
1
);
s
->
ptr
=
shared
->
ptr
=
(
char
*
)
mrb_realloc
(
mrb
,
s
->
ptr
,
s
->
len
+
1
);
}
else
{
shared
->
ptr
=
s
->
ptr
;
...
...
@@ -341,7 +341,7 @@ mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
if
(
s1
->
aux
.
capa
<
len
)
{
s1
->
aux
.
capa
=
len
;
s1
->
ptr
=
mrb_realloc
(
mrb
,
s1
->
ptr
,
len
+
1
);
s1
->
ptr
=
(
char
*
)
mrb_realloc
(
mrb
,
s1
->
ptr
,
len
+
1
);
}
memcpy
(
s1
->
ptr
+
s1
->
len
,
s2
->
ptr
,
s2
->
len
);
s1
->
len
=
len
;
...
...
@@ -664,7 +664,7 @@ mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long
static
int
mrb_memsearch
(
const
void
*
x0
,
int
m
,
const
void
*
y0
,
int
n
)
{
const
unsigned
char
*
x
=
x0
,
*
y
=
y0
;
const
unsigned
char
*
x
=
(
const
unsigned
char
*
)
x0
,
*
y
=
(
const
unsigned
char
*
)
y0
;
if
(
m
>
n
)
return
-
1
;
else
if
(
m
==
n
)
{
...
...
@@ -681,7 +681,7 @@ mrb_memsearch(const void *x0, int m, const void *y0, int n)
}
return
-
1
;
}
return
mrb_memsearch_qs
(
x0
,
m
,
y0
,
n
);
return
mrb_memsearch_qs
(
(
const
unsigned
char
*
)
x0
,
m
,
(
const
unsigned
char
*
)
y0
,
n
);
}
static
mrb_int
...
...
@@ -1564,10 +1564,10 @@ str_replace(mrb_state *mrb, struct RString *s1, struct RString *s2)
if
(
s1
->
flags
&
MRB_STR_SHARED
)
{
mrb_str_decref
(
mrb
,
s1
->
aux
.
shared
);
s1
->
flags
&=
~
MRB_STR_SHARED
;
s1
->
ptr
=
mrb_malloc
(
mrb
,
s2
->
len
+
1
);
s1
->
ptr
=
(
char
*
)
mrb_malloc
(
mrb
,
s2
->
len
+
1
);
}
else
{
s1
->
ptr
=
mrb_realloc
(
mrb
,
s1
->
ptr
,
s2
->
len
+
1
);
s1
->
ptr
=
(
char
*
)
mrb_realloc
(
mrb
,
s1
->
ptr
,
s2
->
len
+
1
);
}
memcpy
(
s1
->
ptr
,
s2
->
ptr
,
s2
->
len
);
s1
->
ptr
[
s2
->
len
]
=
0
;
...
...
@@ -2541,7 +2541,7 @@ mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck)
if
(
s
)
{
len
=
RSTRING_LEN
(
str
);
if
(
s
[
len
])
{
/* no sentinel somehow */
char
*
p
=
mrb_malloc
(
mrb
,
len
+
1
);
char
*
p
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
//MEMCPY(p, s, char, len);
memcpy
(
p
,
s
,
sizeof
(
char
)
*
len
);
...
...
@@ -2675,7 +2675,7 @@ mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck)
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"string for Float contains null byte"
);
}
if
(
s
[
len
])
{
/* no sentinel somehow */
char
*
p
=
mrb_malloc
(
mrb
,
len
+
1
);
char
*
p
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
memcpy
(
p
,
s
,
sizeof
(
char
)
*
len
);
p
[
len
]
=
'\0'
;
...
...
src/struct.c
View file @
5a4beeed
...
...
@@ -184,7 +184,7 @@ mrb_id_attrset(mrb_state *mrb, mrb_sym id)
mrb_sym
mid
;
name
=
mrb_sym2name_len
(
mrb
,
id
,
&
len
);
buf
=
mrb_malloc
(
mrb
,
len
+
2
);
buf
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
2
);
memcpy
(
buf
,
name
,
len
);
buf
[
len
]
=
'='
;
buf
[
len
+
1
]
=
'\0'
;
...
...
@@ -427,7 +427,7 @@ mrb_struct_initialize_withArg(mrb_state *mrb, int argc, mrb_value *argv, mrb_val
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"struct size differs"
);
}
st
=
RSTRUCT
(
self
);
st
->
ptr
=
mrb_calloc
(
mrb
,
sizeof
(
mrb_value
),
n
);
st
->
ptr
=
(
mrb_value
*
)
mrb_calloc
(
mrb
,
sizeof
(
mrb_value
),
n
);
st
->
len
=
n
;
memcpy
(
st
->
ptr
,
argv
,
sizeof
(
mrb_value
)
*
argc
);
...
...
src/symbol.c
View file @
5a4beeed
...
...
@@ -50,7 +50,7 @@ mrb_intern2(mrb_state *mrb, const char *name, int len)
return
kh_value
(
h
,
k
);
sym
=
++
mrb
->
symidx
;
p
=
mrb_malloc
(
mrb
,
len
+
1
);
p
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
memcpy
(
p
,
name
,
len
);
p
[
len
]
=
0
;
sname
.
name
=
(
const
char
*
)
p
;
...
...
src/time.c
View file @
5a4beeed
...
...
@@ -164,7 +164,7 @@ mrb_time_alloc(mrb_state *mrb, mrb_float sec, mrb_float usec, enum mrb_timezone
{
struct
mrb_time
*
tm
;
tm
=
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_time
));
tm
=
(
struct
mrb_time
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_time
));
tm
->
sec
=
(
time_t
)
sec
;
tm
->
usec
=
(
sec
-
tm
->
sec
)
*
1.0e6
+
usec
;
while
(
tm
->
usec
<
0
)
{
...
...
@@ -192,7 +192,7 @@ current_mrb_time(mrb_state *mrb)
{
struct
mrb_time
*
tm
;
tm
=
mrb_malloc
(
mrb
,
sizeof
(
*
tm
));
tm
=
(
struct
mrb_time
*
)
mrb_malloc
(
mrb
,
sizeof
(
*
tm
));
#ifdef NO_GETTIMEOFDAY
{
static
time_t
last_sec
=
0
,
last_usec
=
0
;
...
...
@@ -304,8 +304,8 @@ mrb_time_eq(mrb_state *mrb, mrb_value self)
struct
mrb_time
*
tm1
,
*
tm2
;
mrb_get_args
(
mrb
,
"o"
,
&
other
);
tm1
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm2
=
mrb_get_datatype
(
mrb
,
other
,
&
mrb_time_type
);
tm1
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm2
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
other
,
&
mrb_time_type
);
if
(
!
tm1
||
!
tm2
)
return
mrb_false_value
();
if
(
tm1
->
sec
==
tm2
->
sec
&&
tm1
->
usec
==
tm2
->
usec
)
{
return
mrb_true_value
();
...
...
@@ -320,8 +320,8 @@ mrb_time_cmp(mrb_state *mrb, mrb_value self)
struct
mrb_time
*
tm1
,
*
tm2
;
mrb_get_args
(
mrb
,
"o"
,
&
other
);
tm1
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm2
=
mrb_get_datatype
(
mrb
,
other
,
&
mrb_time_type
);
tm1
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm2
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
other
,
&
mrb_time_type
);
if
(
!
tm1
||
!
tm2
)
return
mrb_nil_value
();
if
(
tm1
->
sec
>
tm2
->
sec
)
{
return
mrb_fixnum_value
(
1
);
...
...
@@ -346,7 +346,7 @@ mrb_time_plus(mrb_state *mrb, mrb_value self)
struct
mrb_time
*
tm
;
mrb_get_args
(
mrb
,
"f"
,
&
f
);
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_time_make
(
mrb
,
mrb_obj_class
(
mrb
,
self
),
tm
->
sec
+
f
,
tm
->
usec
,
tm
->
timezone
);
}
...
...
@@ -359,10 +359,10 @@ mrb_time_minus(mrb_state *mrb, mrb_value self)
struct
mrb_time
*
tm
,
*
tm2
;
mrb_get_args
(
mrb
,
"o"
,
&
other
);
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
tm2
=
mrb_get_datatype
(
mrb
,
other
,
&
mrb_time_type
);
tm2
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
other
,
&
mrb_time_type
);
if
(
tm2
)
{
f
=
(
mrb_float
)(
tm
->
sec
-
tm2
->
sec
)
+
(
mrb_float
)(
tm
->
usec
-
tm2
->
usec
)
/
1.0e6
;
...
...
@@ -381,7 +381,7 @@ mrb_time_wday(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_wday
);
}
...
...
@@ -393,7 +393,7 @@ mrb_time_yday(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_check_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_check_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_yday
);
}
...
...
@@ -405,7 +405,7 @@ mrb_time_year(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_year
+
1900
);
}
...
...
@@ -417,7 +417,7 @@ mrb_time_zone(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
if
(
tm
->
timezone
<=
MRB_TIMEZONE_NONE
)
return
mrb_nil_value
();
if
(
tm
->
timezone
>=
MRB_TIMEZONE_LAST
)
return
mrb_nil_value
();
...
...
@@ -434,7 +434,7 @@ mrb_time_asctime(mrb_state *mrb, mrb_value self)
char
buf
[
256
];
int
len
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
d
=
&
tm
->
datetime
;
len
=
snprintf
(
buf
,
sizeof
(
buf
),
"%s %s %02d %02d:%02d:%02d %s%d"
,
...
...
@@ -452,7 +452,7 @@ mrb_time_day(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_mday
);
}
...
...
@@ -465,7 +465,7 @@ mrb_time_dstp(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_bool_value
(
tm
->
datetime
.
tm_isdst
);
}
...
...
@@ -478,9 +478,9 @@ mrb_time_getutc(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
,
*
tm2
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
self
;
tm2
=
mrb_malloc
(
mrb
,
sizeof
(
*
tm
));
tm2
=
(
struct
mrb_time
*
)
mrb_malloc
(
mrb
,
sizeof
(
*
tm
));
*
tm2
=
*
tm
;
tm2
->
timezone
=
MRB_TIMEZONE_UTC
;
mrb_time_update_datetime
(
tm2
);
...
...
@@ -494,9 +494,9 @@ mrb_time_getlocal(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
,
*
tm2
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
self
;
tm2
=
mrb_malloc
(
mrb
,
sizeof
(
*
tm
));
tm2
=
(
struct
mrb_time
*
)
mrb_malloc
(
mrb
,
sizeof
(
*
tm
));
*
tm2
=
*
tm
;
tm2
->
timezone
=
MRB_TIMEZONE_LOCAL
;
mrb_time_update_datetime
(
tm2
);
...
...
@@ -510,7 +510,7 @@ mrb_time_hour(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_hour
);
}
...
...
@@ -524,7 +524,7 @@ mrb_time_initialize(mrb_state *mrb, mrb_value self)
amin
=
0
,
asec
=
0
,
ausec
=
0
;
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
tm
)
{
mrb_time_free
(
mrb
,
tm
);
}
...
...
@@ -568,7 +568,7 @@ mrb_time_localtime(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
self
;
tm
->
timezone
=
MRB_TIMEZONE_LOCAL
;
mrb_time_update_datetime
(
tm
);
...
...
@@ -582,7 +582,7 @@ mrb_time_mday(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_mday
);
}
...
...
@@ -594,7 +594,7 @@ mrb_time_min(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_min
);
}
...
...
@@ -606,7 +606,7 @@ mrb_time_mon(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_mon
+
1
);
}
...
...
@@ -618,7 +618,7 @@ mrb_time_sec(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
datetime
.
tm_sec
);
}
...
...
@@ -631,7 +631,7 @@ mrb_time_to_f(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_float_value
((
mrb_float
)
tm
->
sec
+
(
mrb_float
)
tm
->
usec
/
1.0e6
);
}
...
...
@@ -643,7 +643,7 @@ mrb_time_to_i(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
sec
);
}
...
...
@@ -655,7 +655,7 @@ mrb_time_usec(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_fixnum_value
(
tm
->
usec
);
}
...
...
@@ -667,7 +667,7 @@ mrb_time_utc(mrb_state *mrb, mrb_value self)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
tm
)
{
tm
->
timezone
=
MRB_TIMEZONE_UTC
;
mrb_time_update_datetime
(
tm
);
...
...
@@ -681,7 +681,7 @@ static mrb_value
mrb_time_utcp
(
mrb_state
*
mrb
,
mrb_value
self
)
{
struct
mrb_time
*
tm
;
tm
=
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
tm
=
(
struct
mrb_time
*
)
mrb_get_datatype
(
mrb
,
self
,
&
mrb_time_type
);
if
(
!
tm
)
return
mrb_nil_value
();
return
mrb_bool_value
(
tm
->
timezone
==
MRB_TIMEZONE_UTC
);
}
...
...
src/vm.c
View file @
5a4beeed
...
...
@@ -28,12 +28,12 @@ static void
stack_init
(
mrb_state
*
mrb
)
{
/* assert(mrb->stack == NULL); */
mrb
->
stbase
=
mrb_calloc
(
mrb
,
STACK_INIT_SIZE
,
sizeof
(
mrb_value
));
mrb
->
stbase
=
(
mrb_value
*
)
mrb_calloc
(
mrb
,
STACK_INIT_SIZE
,
sizeof
(
mrb_value
));
mrb
->
stend
=
mrb
->
stbase
+
STACK_INIT_SIZE
;
mrb
->
stack
=
mrb
->
stbase
;
/* assert(mrb->ci == NULL); */
mrb
->
cibase
=
mrb_calloc
(
mrb
,
CALLINFO_INIT_SIZE
,
sizeof
(
mrb_callinfo
));
mrb
->
cibase
=
(
mrb_callinfo
*
)
mrb_calloc
(
mrb
,
CALLINFO_INIT_SIZE
,
sizeof
(
mrb_callinfo
));
mrb
->
ciend
=
mrb
->
cibase
+
CALLINFO_INIT_SIZE
;
mrb
->
ci
=
mrb
->
cibase
;
mrb
->
ci
->
target_class
=
mrb
->
object_class
;
...
...
@@ -70,7 +70,7 @@ stack_extend(mrb_state *mrb, int room, int keep)
size
*=
2
;
else
size
+=
room
;
mrb
->
stbase
=
mrb_realloc
(
mrb
,
mrb
->
stbase
,
sizeof
(
mrb_value
)
*
size
);
mrb
->
stbase
=
(
mrb_value
*
)
mrb_realloc
(
mrb
,
mrb
->
stbase
,
sizeof
(
mrb_value
)
*
size
);
mrb
->
stack
=
mrb
->
stbase
+
off
;
mrb
->
stend
=
mrb
->
stbase
+
size
;
envadjust
(
mrb
,
oldbase
,
mrb
->
stbase
);
...
...
@@ -127,7 +127,7 @@ cipush(mrb_state *mrb)
if
(
mrb
->
ci
+
1
==
mrb
->
ciend
)
{
size_t
size
=
mrb
->
ci
-
mrb
->
cibase
;
mrb
->
cibase
=
mrb_realloc
(
mrb
,
mrb
->
cibase
,
sizeof
(
mrb_callinfo
)
*
size
*
2
);
mrb
->
cibase
=
(
mrb_callinfo
*
)
mrb_realloc
(
mrb
,
mrb
->
cibase
,
sizeof
(
mrb_callinfo
)
*
size
*
2
);
mrb
->
ci
=
mrb
->
cibase
+
size
;
mrb
->
ciend
=
mrb
->
cibase
+
size
*
2
;
}
...
...
@@ -145,7 +145,7 @@ cipop(mrb_state *mrb)
if
(
mrb
->
ci
->
env
)
{
struct
REnv
*
e
=
mrb
->
ci
->
env
;
int
len
=
(
int
)
e
->
flags
;
mrb_value
*
p
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
len
);
mrb_value
*
p
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
len
);
e
->
cioff
=
-
1
;
memcpy
(
p
,
e
->
stack
,
sizeof
(
mrb_value
)
*
len
);
...
...
@@ -395,7 +395,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
mrb_value
*
regs
=
NULL
;
mrb_code
i
;
int
ai
=
mrb
->
arena_idx
;
jmp_buf
*
prev_jmp
=
mrb
->
jmp
;
jmp_buf
*
prev_jmp
=
(
jmp_buf
*
)
mrb
->
jmp
;
jmp_buf
c_jmp
;
#ifdef DIRECT_THREADED
...
...
@@ -620,7 +620,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
if
(
mrb
->
rsize
<=
mrb
->
ci
->
ridx
)
{
if
(
mrb
->
rsize
==
0
)
mrb
->
rsize
=
16
;
else
mrb
->
rsize
*=
2
;
mrb
->
rescue
=
mrb_realloc
(
mrb
,
mrb
->
rescue
,
sizeof
(
mrb_code
*
)
*
mrb
->
rsize
);
mrb
->
rescue
=
(
mrb_code
**
)
mrb_realloc
(
mrb
,
mrb
->
rescue
,
sizeof
(
mrb_code
*
)
*
mrb
->
rsize
);
}
mrb
->
rescue
[
mrb
->
ci
->
ridx
++
]
=
pc
+
GETARG_sBx
(
i
);
NEXT
;
...
...
@@ -657,7 +657,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
if
(
mrb
->
esize
<=
mrb
->
ci
->
eidx
)
{
if
(
mrb
->
esize
==
0
)
mrb
->
esize
=
16
;
else
mrb
->
esize
*=
2
;
mrb
->
ensure
=
mrb_realloc
(
mrb
,
mrb
->
ensure
,
sizeof
(
struct
RProc
*
)
*
mrb
->
esize
);
mrb
->
ensure
=
(
struct
RProc
**
)
mrb_realloc
(
mrb
,
mrb
->
ensure
,
sizeof
(
struct
RProc
*
)
*
mrb
->
esize
);
}
mrb
->
ensure
[
mrb
->
ci
->
eidx
++
]
=
p
;
NEXT
;
...
...
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