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
6ac26e44
Unverified
Commit
6ac26e44
authored
Dec 02, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse.y: support anonymous block argument introduced by Ruby3.1.
parent
bd88870a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1130 additions
and
1094 deletions
+1130
-1094
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+17
-5
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+8
-0
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
+1105
-1089
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
6ac26e44
...
...
@@ -1334,17 +1334,19 @@ lambda_body(codegen_scope *s, node *tree, int blk)
if
(
ma
>
0x1f
||
oa
>
0x1f
||
pa
>
0x1f
||
ka
>
0x1f
)
{
codegen_error
(
s
,
"too many formal arguments"
);
}
/* (23bits = 5:5:1:5:5:1:1) */
a
=
MRB_ARGS_REQ
(
ma
)
|
MRB_ARGS_OPT
(
oa
)
|
(
ra
?
MRB_ARGS_REST
()
:
0
)
|
MRB_ARGS_POST
(
pa
)
|
MRB_ARGS_KEY
(
ka
,
kd
)
|
(
ba
?
MRB_ARGS_BLOCK
()
:
0
);
s
->
ainfo
=
(((
ma
+
oa
)
&
0x3f
)
<<
7
)
/* (12bits = 5:1:5:1) */
genop_W
(
s
,
OP_ENTER
,
a
);
/* (12bits = 5:1:5:1) */
s
->
ainfo
=
(((
ma
+
oa
)
&
0x3f
)
<<
7
)
|
((
ra
&
0x1
)
<<
6
)
|
((
pa
&
0x1f
)
<<
1
)
|
((
ka
|
kd
)
!=
0
?
0x01
:
0x00
);
genop_W
(
s
,
OP_ENTER
,
a
);
|
((
ka
|
kd
)
?
1
:
0
);
/* generate jump table for optional arguments initializer */
pos
=
new_label
(
s
);
for
(
i
=
0
;
i
<
oa
;
i
++
)
{
...
...
@@ -2066,7 +2068,7 @@ false_always(node *tree)
}
static
void
gen_blkmove
(
codegen_scope
*
s
,
in
t
ainfo
,
int
lv
)
gen_blkmove
(
codegen_scope
*
s
,
uint16_
t
ainfo
,
int
lv
)
{
int
m1
=
(
ainfo
>>
7
)
&
0x3f
;
int
r
=
(
ainfo
>>
6
)
&
0x1
;
...
...
@@ -3102,7 +3104,17 @@ codegen(codegen_scope *s, node *tree, int val)
break
;
case
NODE_BLOCK_ARG
:
codegen
(
s
,
tree
,
val
);
if
(
!
tree
)
{
int
idx
=
lv_idx
(
s
,
MRB_OPSYM_2
(
s
->
mrb
,
and
));
if
(
idx
==
0
)
{
codegen_error
(
s
,
"no anonymous block argument"
);
}
gen_move
(
s
,
cursp
(),
idx
,
val
);
}
else
{
codegen
(
s
,
tree
,
val
);
}
break
;
case
NODE_INT
:
...
...
mrbgems/mruby-compiler/core/parse.y
View file @
6ac26e44
...
...
@@ -2603,6 +2603,10 @@ block_arg : tAMPER arg
{
$$ = new_block_arg(p, $2);
}
| tAMPER
{
$$ = new_block_arg(p, 0);
}
;
opt_block_arg : comma block_arg
...
...
@@ -3944,6 +3948,10 @@ f_block_arg : blkarg_mark tIDENTIFIER
{
$$ = $2;
}
| blkarg_mark
{
$$ = intern_op(and);
}
;
opt_f_block_arg : ',' f_block_arg
...
...
mrbgems/mruby-compiler/core/y.tab.c
View file @
6ac26e44
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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