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
598c97ef
Unverified
Commit
598c97ef
authored
3 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codegen.c: `get_int_operand()` to support `OP_LOADL` (int in pool).
parent
d0fed634
master
removing-y-tab-c
stable
3.1.0-rc
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+21
-3
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
598c97ef
...
...
@@ -549,7 +549,7 @@ gen_return(codegen_scope *s, uint8_t op, uint16_t src)
}
static
mrb_bool
get_int_operand
(
struct
mrb_insn_data
*
data
,
mrb_int
*
n
)
get_int_operand
(
codegen_scope
*
s
,
struct
mrb_insn_data
*
data
,
mrb_int
*
n
)
{
switch
(
data
->
insn
)
{
case
OP_LOADI__1
:
...
...
@@ -574,6 +574,24 @@ get_int_operand(struct mrb_insn_data *data, mrb_int *n)
*
n
=
(
mrb_int
)((
uint32_t
)
data
->
b
<<
16
)
+
data
->
c
;
return
TRUE
;
case
OP_LOADL
:
{
mrb_pool_value
*
pv
=
&
s
->
pool
[
data
->
b
];
if
(
pv
->
tt
==
IREP_TT_INT32
)
{
*
n
=
(
mrb_int
)
pv
->
u
.
i32
;
}
#ifdef MRB_INT64
else
if
(
pv
->
tt
==
IREP_TT_INT64
)
{
*
n
=
(
mrb_int
)
pv
->
u
.
i64
;
}
#endif
else
{
return
FALSE
;
}
}
return
TRUE
;
default:
return
FALSE
;
}
...
...
@@ -591,7 +609,7 @@ gen_addsub(codegen_scope *s, uint8_t op, uint16_t dst)
struct
mrb_insn_data
data
=
mrb_last_insn
(
s
);
mrb_int
n
;
if
(
!
get_int_operand
(
&
data
,
&
n
))
{
if
(
!
get_int_operand
(
s
,
&
data
,
&
n
))
{
/* not integer immediate */
goto
normal
;
}
...
...
@@ -864,7 +882,7 @@ gen_uniop(codegen_scope *s, mrb_sym sym, uint16_t dst)
struct
mrb_insn_data
data
=
mrb_last_insn
(
s
);
mrb_int
n
;
if
(
get_int_operand
(
&
data
,
&
n
))
{
if
(
get_int_operand
(
s
,
&
data
,
&
n
))
{
s
->
pc
=
s
->
lastpc
;
if
(
sym
==
MRB_OPSYM_2
(
s
->
mrb
,
minus
))
{
n
=
-
n
;
...
...
This diff is collapsed.
Click to expand it.
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