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
e81d4971
Unverified
Commit
e81d4971
authored
Jul 23, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codegen.c: removed bytecode when the value of `while` is not used.
parent
2910af00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+8
-6
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
e81d4971
...
...
@@ -39,7 +39,7 @@ enum looptype {
struct
loopinfo
{
enum
looptype
type
;
uint32_t
pc0
,
pc
1
,
pc
2
,
pc3
;
uint32_t
pc0
,
pc2
,
pc3
;
int
acc
;
struct
loopinfo
*
prev
;
};
...
...
@@ -1931,13 +1931,14 @@ codegen(codegen_scope *s, node *tree, int val)
case
NODE_WHILE
:
{
struct
loopinfo
*
lp
=
loop_push
(
s
,
LOOP_NORMAL
);
uint32_t
pc1
;
if
(
!
val
)
lp
->
acc
=
-
1
;
lp
->
pc0
=
new_label
(
s
);
lp
->
pc1
=
genjmp_0
(
s
,
OP_JMP
);
pc1
=
genjmp_0
(
s
,
OP_JMP
);
lp
->
pc2
=
new_label
(
s
);
codegen
(
s
,
tree
->
cdr
,
NOVAL
);
dispatch
(
s
,
lp
->
pc1
);
dispatch
(
s
,
pc1
);
codegen
(
s
,
tree
->
car
,
VAL
);
pop
();
genjmp2
(
s
,
OP_JMPIF
,
cursp
(),
lp
->
pc2
,
NOVAL
);
...
...
@@ -1949,13 +1950,14 @@ codegen(codegen_scope *s, node *tree, int val)
case
NODE_UNTIL
:
{
struct
loopinfo
*
lp
=
loop_push
(
s
,
LOOP_NORMAL
);
uint32_t
pc1
;
if
(
!
val
)
lp
->
acc
=
-
1
;
lp
->
pc0
=
new_label
(
s
);
lp
->
pc1
=
genjmp_0
(
s
,
OP_JMP
);
pc1
=
genjmp_0
(
s
,
OP_JMP
);
lp
->
pc2
=
new_label
(
s
);
codegen
(
s
,
tree
->
cdr
,
NOVAL
);
dispatch
(
s
,
lp
->
pc1
);
dispatch
(
s
,
pc1
);
codegen
(
s
,
tree
->
car
,
VAL
);
pop
();
genjmp2
(
s
,
OP_JMPNOT
,
cursp
(),
lp
->
pc2
,
NOVAL
);
...
...
@@ -3322,7 +3324,7 @@ loop_push(codegen_scope *s, enum looptype t)
struct
loopinfo
*
p
=
(
struct
loopinfo
*
)
codegen_palloc
(
s
,
sizeof
(
struct
loopinfo
));
p
->
type
=
t
;
p
->
pc0
=
p
->
pc
1
=
p
->
pc
2
=
p
->
pc3
=
JMPLINK_START
;
p
->
pc0
=
p
->
pc2
=
p
->
pc3
=
JMPLINK_START
;
p
->
prev
=
s
->
loop
;
p
->
acc
=
cursp
();
s
->
loop
=
p
;
...
...
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