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
5d5e4f52
Unverified
Commit
5d5e4f52
authored
Oct 19, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ops.h: add new instructions `OP_SSEND` and `OP_SSENDB`.
These instructions call methods of the receiver.
parent
45491cdd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
include/mruby/ops.h
include/mruby/ops.h
+2
-0
src/codedump.c
src/codedump.c
+8
-0
src/vm.c
src/vm.c
+15
-3
No files found.
include/mruby/ops.h
View file @
5d5e4f52
...
...
@@ -57,6 +57,8 @@ OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
OPCODE
(
EXCEPT
,
B
)
/* R[a] = exc */
OPCODE
(
RESCUE
,
BB
)
/* R[b] = R[a].isa?(R[b]) */
OPCODE
(
RAISEIF
,
B
)
/* raise(R[a]) if R[a] */
OPCODE
(
SSEND
,
BBB
)
/* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
OPCODE
(
SSENDB
,
BBB
)
/* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
OPCODE
(
SEND
,
BBB
)
/* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
OPCODE
(
SENDB
,
BBB
)
/* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
OPCODE
(
CALL
,
Z
)
/* R[0] = self.call(frame.argc, frame.argv) */
...
...
src/codedump.c
View file @
5d5e4f52
...
...
@@ -318,6 +318,14 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
printf
(
"OP_JMPNIL
\t
R%d
\t
%03d
\t
"
,
a
,
(
int
)
i
+
(
int16_t
)
b
);
print_lv_a
(
mrb
,
irep
,
a
);
break
;
CASE
(
OP_SSEND
,
BBB
)
:
printf
(
"OP_SSEND
\t
R%d
\t
:%s
\t
"
,
a
,
mrb_sym_dump
(
mrb
,
irep
->
syms
[
b
]));
print_args
(
c
);
break
;
CASE
(
OP_SSENDB
,
BBB
)
:
printf
(
"OP_SSENDB
\t
R%d
\t
:%s
\t
"
,
a
,
mrb_sym_dump
(
mrb
,
irep
->
syms
[
b
]));
print_args
(
c
);
break
;
CASE
(
OP_SEND
,
BBB
)
:
printf
(
"OP_SEND
\t
R%d
\t
:%s
\t
"
,
a
,
mrb_sym_dump
(
mrb
,
irep
->
syms
[
b
]));
print_args
(
c
);
...
...
src/vm.c
View file @
5d5e4f52
...
...
@@ -1539,6 +1539,17 @@ RETRY_TRY_BLOCK:
NEXT
;
}
CASE
(
OP_SSEND
,
BBB
)
{
regs
[
a
]
=
regs
[
0
];
insn
=
OP_SEND
;
}
goto
L_SENDB
;
CASE
(
OP_SSENDB
,
BBB
)
{
regs
[
a
]
=
regs
[
0
];
}
goto
L_SENDB
;
CASE
(
OP_SEND
,
BBB
)
goto
L_SENDB
;
...
...
@@ -1556,7 +1567,7 @@ RETRY_TRY_BLOCK:
int
n
=
c
&
0xf
;
int
nk
=
(
c
>>
4
)
&
0xf
;
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
mrb_int
bidx
=
a
+
((
n
==
15
)
?
1
:
n
)
+
((
nk
==
15
)
?
1
:
2
*
nk
)
+
1
;
mrb_int
bidx
=
a
+
mrb_bidx
(
c
)
;
mrb_method_t
m
;
struct
RClass
*
cls
;
mrb_value
recv
;
...
...
@@ -1570,11 +1581,12 @@ RETRY_TRY_BLOCK:
}
mrb_assert
(
bidx
<
irep
->
nregs
+
a
);
mrb_value
blk
=
mrb_nil_value
()
;
mrb_int
new_bidx
=
a
+
((
n
==
15
)
?
1
:
n
)
+
1
+
(
nk
==
15
);
mrb_value
blk
;
mrb_int
new_bidx
=
a
+
mrb_bidx
(
c
);
if
(
insn
==
OP_SEND
)
{
/* clear block argument */
SET_NIL_VALUE
(
regs
[
new_bidx
]);
SET_NIL_VALUE
(
blk
);
}
else
{
blk
=
regs
[
bidx
];
...
...
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