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
cda4d9bc
Unverified
Commit
cda4d9bc
authored
3 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codegen.c: refactor `gen_call` and `gen_values`.
Remove no longer used arguments from the functions.
parent
b611c43a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
38 deletions
+12
-38
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+12
-38
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
cda4d9bc
...
...
@@ -1530,7 +1530,7 @@ attrsym(codegen_scope *s, mrb_sym a)
#define GEN_VAL_STACK_MAX 99
static
int
gen_values
(
codegen_scope
*
s
,
node
*
t
,
int
val
,
int
extra
,
int
limit
)
gen_values
(
codegen_scope
*
s
,
node
*
t
,
int
val
,
int
limit
)
{
int
n
=
0
;
int
first
=
1
;
...
...
@@ -1551,7 +1551,7 @@ gen_values(codegen_scope *s, node *t, int val, int extra, int limit)
while
(
t
)
{
int
is_splat
=
nint
(
t
->
car
->
car
)
==
NODE_SPLAT
;
if
(
is_splat
||
n
+
extra
>=
limit
-
1
||
cursp
()
>=
slimit
)
{
/* flush stack */
if
(
is_splat
||
n
>=
limit
-
1
||
cursp
()
>=
slimit
)
{
/* flush stack */
pop_n
(
n
);
if
(
first
)
{
if
(
n
==
0
)
{
...
...
@@ -1655,9 +1655,9 @@ gen_hash(codegen_scope *s, node *tree, int val, int limit)
}
static
void
gen_call
(
codegen_scope
*
s
,
node
*
tree
,
mrb_sym
name
,
int
sp
,
int
val
,
int
safe
)
gen_call
(
codegen_scope
*
s
,
node
*
tree
,
int
val
,
int
safe
)
{
mrb_sym
sym
=
n
ame
?
name
:
n
sym
(
tree
->
cdr
->
car
);
mrb_sym
sym
=
nsym
(
tree
->
cdr
->
car
);
int
skip
=
0
,
n
=
0
,
nk
=
0
,
noop
=
0
,
noself
=
0
,
blk
=
0
,
sp_save
=
cursp
();
if
(
!
tree
->
car
)
{
...
...
@@ -1675,7 +1675,7 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe)
tree
=
tree
->
cdr
->
cdr
->
car
;
if
(
tree
)
{
if
(
tree
->
car
)
{
/* positional arguments */
n
=
gen_values
(
s
,
tree
->
car
,
VAL
,
sp
?
1
:
0
,
14
);
n
=
gen_values
(
s
,
tree
->
car
,
VAL
,
14
);
if
(
n
<
0
)
{
/* variable length */
noop
=
1
;
/* not operator */
n
=
15
;
...
...
@@ -1688,32 +1688,6 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe)
if
(
nk
<
0
)
nk
=
15
;
}
}
if
(
sp
)
{
/* last argument pushed (attr=, []=) */
/* pack keyword arguments */
if
(
nk
>
0
&&
nk
<
15
)
{
pop_n
(
nk
*
2
);
genop_2
(
s
,
OP_HASH
,
cursp
(),
nk
);
push
();
}
if
(
n
==
CALL_MAXARGS
)
{
if
(
nk
>
0
)
{
pop
();
pop
();
genop_2
(
s
,
OP_ARYPUSH
,
cursp
(),
1
);
push
();
}
gen_move
(
s
,
cursp
(),
sp
,
0
);
pop
();
genop_2
(
s
,
OP_ARYPUSH
,
cursp
(),
1
);
push
();
}
else
{
gen_move
(
s
,
cursp
(),
sp
,
0
);
push
();
if
(
nk
>
0
)
n
++
;
n
++
;
}
nk
=
0
;
}
if
(
tree
&&
tree
->
cdr
&&
tree
->
cdr
->
cdr
)
{
codegen
(
s
,
tree
->
cdr
->
cdr
,
VAL
);
pop
();
...
...
@@ -1878,7 +1852,7 @@ gen_assignment(codegen_scope *s, node *tree, node *rhs, int sp, int val)
tree
=
tree
->
cdr
->
cdr
->
car
;
if
(
tree
)
{
if
(
tree
->
car
)
{
/* positional arguments */
n
=
gen_values
(
s
,
tree
->
car
,
VAL
,
0
,
(
tree
->
cdr
->
car
)
?
13
:
14
);
n
=
gen_values
(
s
,
tree
->
car
,
VAL
,
(
tree
->
cdr
->
car
)
?
13
:
14
);
if
(
n
<
0
)
{
/* variable length */
n
=
15
;
push
();
...
...
@@ -2602,10 +2576,10 @@ codegen(codegen_scope *s, node *tree, int val)
case
NODE_FCALL
:
case
NODE_CALL
:
gen_call
(
s
,
tree
,
0
,
0
,
val
,
0
);
gen_call
(
s
,
tree
,
val
,
0
);
break
;
case
NODE_SCALL
:
gen_call
(
s
,
tree
,
0
,
0
,
val
,
1
);
gen_call
(
s
,
tree
,
val
,
1
);
break
;
case
NODE_DOT2
:
...
...
@@ -2653,7 +2627,7 @@ codegen(codegen_scope *s, node *tree, int val)
{
int
n
;
n
=
gen_values
(
s
,
tree
,
val
,
0
,
0
);
n
=
gen_values
(
s
,
tree
,
val
,
0
);
if
(
val
)
{
if
(
n
>=
0
)
{
pop_n
(
n
);
...
...
@@ -2804,7 +2778,7 @@ codegen(codegen_scope *s, node *tree, int val)
idx
=
new_sym
(
s
,
nsym
(
n
->
cdr
->
car
));
base
=
cursp
()
-
1
;
if
(
n
->
cdr
->
cdr
->
car
)
{
nargs
=
gen_values
(
s
,
n
->
cdr
->
cdr
->
car
->
car
,
VAL
,
1
,
14
);
nargs
=
gen_values
(
s
,
n
->
cdr
->
cdr
->
car
->
car
,
VAL
,
1
3
);
if
(
nargs
>=
0
)
{
callargs
=
nargs
;
}
...
...
@@ -2934,7 +2908,7 @@ codegen(codegen_scope *s, node *tree, int val)
if
(
tree
)
{
node
*
args
=
tree
->
car
;
if
(
args
)
{
st
=
n
=
gen_values
(
s
,
args
,
VAL
,
0
,
14
);
st
=
n
=
gen_values
(
s
,
args
,
VAL
,
14
);
if
(
n
<
0
)
{
st
=
1
;
n
=
15
;
push
();
...
...
@@ -3051,7 +3025,7 @@ codegen(codegen_scope *s, node *tree, int val)
if
(
ainfo
<
0
)
codegen_error
(
s
,
"invalid yield (SyntaxError)"
);
push
();
if
(
tree
)
{
n
=
gen_values
(
s
,
tree
,
VAL
,
0
,
14
);
n
=
gen_values
(
s
,
tree
,
VAL
,
14
);
if
(
n
<
0
)
{
n
=
sendv
=
1
;
push
();
...
...
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