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
71354b91
Commit
71354b91
authored
Nov 15, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enum mrb_vtype varies on compile time configuration, namely MRB_NAN_BOXING
parent
16b34d18
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
18 deletions
+27
-18
include/mruby/irep.h
include/mruby/irep.h
+7
-1
src/codegen.c
src/codegen.c
+8
-6
src/dump.c
src/dump.c
+6
-6
src/load.c
src/load.c
+4
-3
src/state.c
src/state.c
+1
-1
src/vm.c
src/vm.c
+1
-1
No files found.
include/mruby/irep.h
View file @
71354b91
...
...
@@ -11,6 +11,12 @@
extern
"C"
{
#endif
enum
irep_pool_type
{
IREP_TT_STRING
,
IREP_TT_FIXNUM
,
IREP_TT_FLOAT
,
};
/* Program data array struct */
typedef
struct
mrb_irep
{
uint16_t
nlocals
;
/* Number of local variables */
...
...
@@ -27,7 +33,7 @@ typedef struct mrb_irep {
}
*
s
;
mrb_int
i
;
}
value
;
enum
mrb_v
type
type
;
enum
irep_pool_
type
type
;
}
*
pool
;
mrb_sym
*
syms
;
struct
mrb_irep
**
reps
;
...
...
src/codegen.c
View file @
71354b91
...
...
@@ -316,7 +316,7 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
if
(
c0
==
OP_STRING
)
{
int
i
=
GETARG_Bx
(
i0
);
if
(
s
->
irep
->
pool
[
i
].
type
==
MRB
_TT_STRING
&&
if
(
s
->
irep
->
pool
[
i
].
type
==
IREP
_TT_STRING
&&
s
->
irep
->
pool
[
i
].
value
.
s
->
len
==
0
)
{
s
->
pc
--
;
return
;
...
...
@@ -405,7 +405,7 @@ new_lit(codegen_scope *s, mrb_value val)
mrb_int
len
;
pv
=
&
s
->
irep
->
pool
[
i
];
if
(
pv
->
type
!=
MRB
_TT_STRING
)
continue
;
if
(
pv
->
type
!=
IREP
_TT_STRING
)
continue
;
if
((
len
=
pv
->
value
.
s
->
len
)
!=
RSTRING_LEN
(
val
))
continue
;
if
(
memcmp
(
pv
->
value
.
s
->
buf
,
RSTRING_PTR
(
val
),
len
)
==
0
)
return
i
;
...
...
@@ -414,14 +414,14 @@ new_lit(codegen_scope *s, mrb_value val)
case
MRB_TT_FLOAT
:
for
(
i
=
0
;
i
<
s
->
irep
->
plen
;
i
++
)
{
pv
=
&
s
->
irep
->
pool
[
i
];
if
(
pv
->
type
!=
MRB
_TT_FLOAT
)
continue
;
if
(
pv
->
type
!=
IREP
_TT_FLOAT
)
continue
;
if
(
pv
->
value
.
f
==
mrb_float
(
val
))
return
i
;
}
break
;
case
MRB_TT_FIXNUM
:
for
(
i
=
0
;
i
<
s
->
irep
->
plen
;
i
++
)
{
pv
=
&
s
->
irep
->
pool
[
i
];
if
(
pv
->
type
!=
MRB
_TT_FIXNUM
)
continue
;
if
(
pv
->
type
!=
IREP
_TT_FIXNUM
)
continue
;
if
(
pv
->
value
.
i
==
mrb_fixnum
(
val
))
return
i
;
}
break
;
...
...
@@ -437,18 +437,20 @@ new_lit(codegen_scope *s, mrb_value val)
pv
=
&
s
->
irep
->
pool
[
s
->
irep
->
plen
];
i
=
s
->
irep
->
plen
++
;
pv
->
type
=
mrb_type
(
val
);
switch
(
pv
->
type
)
{
switch
(
mrb_type
(
val
)
)
{
case
MRB_TT_STRING
:
pv
->
type
=
IREP_TT_STRING
;
pv
->
value
.
s
=
(
struct
irep_pool_string
*
)
codegen_malloc
(
s
,
sizeof
(
struct
irep_pool_string
)
+
RSTRING_LEN
(
val
));
pv
->
value
.
s
->
len
=
RSTRING_LEN
(
val
);
memcpy
(
pv
->
value
.
s
->
buf
,
RSTRING_PTR
(
val
),
RSTRING_LEN
(
val
));
break
;
case
MRB_TT_FLOAT
:
pv
->
type
=
IREP_TT_FLOAT
;
pv
->
value
.
f
=
mrb_float
(
val
);
break
;
case
MRB_TT_FIXNUM
:
pv
->
type
=
IREP_TT_FIXNUM
;
pv
->
value
.
i
=
mrb_fixnum
(
val
);
break
;
default:
...
...
src/dump.c
View file @
71354b91
...
...
@@ -80,17 +80,17 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep)
int
ai
=
mrb_gc_arena_save
(
mrb
);
switch
(
irep
->
pool
[
pool_no
].
type
)
{
case
MRB
_TT_FIXNUM
:
case
IREP
_TT_FIXNUM
:
str
=
mrb_fixnum_to_str
(
mrb
,
mrb_fixnum_value
(
irep
->
pool
[
pool_no
].
value
.
i
),
10
);
size
+=
RSTRING_LEN
(
str
);
break
;
case
MRB
_TT_FLOAT
:
case
IREP
_TT_FLOAT
:
len
=
mrb_float_to_str
(
buf
,
irep
->
pool
[
pool_no
].
value
.
f
);
size
+=
len
;
break
;
case
MRB
_TT_STRING
:
case
IREP
_TT_STRING
:
size
+=
irep
->
pool
[
pool_no
].
value
.
s
->
len
;
break
;
...
...
@@ -121,18 +121,18 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
cur
+=
uint8_to_bin
(
irep
->
pool
[
pool_no
].
type
,
cur
);
/* data type */
switch
(
irep
->
pool
[
pool_no
].
type
)
{
case
MRB
_TT_FIXNUM
:
case
IREP
_TT_FIXNUM
:
str
=
mrb_fixnum_to_str
(
mrb
,
mrb_fixnum_value
(
irep
->
pool
[
pool_no
].
value
.
i
),
10
);
char_ptr
=
RSTRING_PTR
(
str
);
len
=
RSTRING_LEN
(
str
);
break
;
case
MRB
_TT_FLOAT
:
case
IREP
_TT_FLOAT
:
len
=
mrb_float_to_str
(
char_buf
,
irep
->
pool
[
pool_no
].
value
.
f
);
char_ptr
=
&
char_buf
[
0
];
break
;
case
MRB
_TT_STRING
:
case
IREP
_TT_STRING
:
char_ptr
=
irep
->
pool
[
pool_no
].
value
.
s
->
buf
;
len
=
irep
->
pool
[
pool_no
].
value
.
s
->
len
;
break
;
...
...
src/load.c
View file @
71354b91
...
...
@@ -94,6 +94,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len)
for
(
i
=
0
;
i
<
plen
;
i
++
)
{
mrb_value
s
;
tt
=
*
src
++
;
//pool TT
pool_data_len
=
bin_to_uint16
(
src
);
//pool data length
src
+=
sizeof
(
uint16_t
);
...
...
@@ -101,7 +102,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len)
src
+=
pool_data_len
;
irep
->
pool
[
i
].
type
=
tt
;
switch
(
tt
)
{
//pool data
case
MRB
_TT_FIXNUM
:
case
IREP
_TT_FIXNUM
:
{
mrb_value
v
=
mrb_str_to_inum
(
mrb
,
s
,
10
,
FALSE
);
...
...
@@ -119,11 +120,11 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len)
}
break
;
case
MRB
_TT_FLOAT
:
case
IREP
_TT_FLOAT
:
irep
->
pool
[
i
].
value
.
f
=
mrb_str_to_dbl
(
mrb
,
s
,
FALSE
);
break
;
case
MRB
_TT_STRING
:
case
IREP
_TT_STRING
:
irep
->
pool
[
i
].
value
.
s
=
(
struct
irep_pool_string
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
irep_pool_string
)
+
pool_data_len
);
irep
->
pool
[
i
].
value
.
s
->
len
=
pool_data_len
;
memcpy
(
irep
->
pool
[
i
].
value
.
s
->
buf
,
src
-
pool_data_len
,
pool_data_len
);
...
...
src/state.c
View file @
71354b91
...
...
@@ -129,7 +129,7 @@ mrb_irep_free(mrb_state *mrb, mrb_irep *irep)
if
(
!
(
irep
->
flags
&
MRB_ISEQ_NO_FREE
))
mrb_free
(
mrb
,
irep
->
iseq
);
for
(
i
=
0
;
i
<
irep
->
plen
;
i
++
)
{
if
(
irep
->
pool
[
i
].
type
==
MRB
_TT_STRING
)
if
(
irep
->
pool
[
i
].
type
==
IREP
_TT_STRING
)
mrb_free
(
mrb
,
irep
->
pool
[
i
].
value
.
s
);
}
mrb_free
(
mrb
,
irep
->
pool
);
...
...
src/vm.c
View file @
71354b91
...
...
@@ -618,7 +618,7 @@ mrb_context_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int
CASE
(
OP_LOADL
)
{
/* A Bx R(A) := Pool(Bx) */
if
(
pool
[
GETARG_Bx
(
i
)].
type
==
MRB
_TT_FLOAT
)
if
(
pool
[
GETARG_Bx
(
i
)].
type
==
IREP
_TT_FLOAT
)
SET_FLT_VALUE
(
mrb
,
regs
[
GETARG_A
(
i
)],
pool
[
GETARG_Bx
(
i
)].
value
.
f
);
else
SET_INT_VALUE
(
regs
[
GETARG_A
(
i
)],
pool
[
GETARG_Bx
(
i
)].
value
.
i
);
...
...
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