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
ced8fea3
Commit
ced8fea3
authored
Feb 26, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #898 from masamitsu-murase/modify_return_value
Modify handling of NODE_RETURN and NODE_NEXT.
parents
2a932441
f413e688
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
src/codegen.c
src/codegen.c
+11
-3
test/t/exception.rb
test/t/exception.rb
+5
-5
No files found.
src/codegen.c
View file @
ced8fea3
...
@@ -1570,15 +1570,20 @@ codegen(codegen_scope *s, node *tree, int val)
...
@@ -1570,15 +1570,20 @@ codegen(codegen_scope *s, node *tree, int val)
break
;
break
;
case
NODE_RETURN
:
case
NODE_RETURN
:
codegen
(
s
,
tree
,
VAL
);
if
(
tree
)
{
pop
();
codegen
(
s
,
tree
,
VAL
);
pop
();
}
else
{
genop
(
s
,
MKOP_A
(
OP_LOADNIL
,
cursp
()));
}
if
(
s
->
loop
)
{
if
(
s
->
loop
)
{
genop
(
s
,
MKOP_AB
(
OP_RETURN
,
cursp
(),
OP_R_RETURN
));
genop
(
s
,
MKOP_AB
(
OP_RETURN
,
cursp
(),
OP_R_RETURN
));
}
}
else
{
else
{
genop_peep
(
s
,
MKOP_AB
(
OP_RETURN
,
cursp
(),
OP_R_NORMAL
),
NOVAL
);
genop_peep
(
s
,
MKOP_AB
(
OP_RETURN
,
cursp
(),
OP_R_NORMAL
),
NOVAL
);
}
}
push
();
if
(
val
)
push
();
break
;
break
;
case
NODE_YIELD
:
case
NODE_YIELD
:
...
@@ -1630,6 +1635,9 @@ codegen(codegen_scope *s, node *tree, int val)
...
@@ -1630,6 +1635,9 @@ codegen(codegen_scope *s, node *tree, int val)
codegen
(
s
,
tree
,
VAL
);
codegen
(
s
,
tree
,
VAL
);
pop
();
pop
();
}
}
else
{
genop
(
s
,
MKOP_A
(
OP_LOADNIL
,
cursp
()));
}
genop_peep
(
s
,
MKOP_AB
(
OP_RETURN
,
cursp
(),
OP_R_NORMAL
),
NOVAL
);
genop_peep
(
s
,
MKOP_AB
(
OP_RETURN
,
cursp
(),
OP_R_NORMAL
),
NOVAL
);
}
}
if
(
val
)
push
();
if
(
val
)
push
();
...
...
test/t/exception.rb
View file @
ced8fea3
...
@@ -321,19 +321,19 @@ end
...
@@ -321,19 +321,19 @@ end
# very deeply recursive function that stil returns albeit very deeply so
# very deeply recursive function that stil returns albeit very deeply so
$test_infinite_recursion
=
0
$test_infinite_recursion
=
0
TEST_INFINITE_RECURSION_MAX
=
100000
TEST_INFINITE_RECURSION_MAX
=
100000
0
def
test_infinite_recursion
def
test_infinite_recursion
$test_infinite_recursion
+=
1
$test_infinite_recursion
+=
1
if
$test_infinite_recursion
>
TEST_INFINITE_RECURSION_MAX
if
$test_infinite_recursion
>
TEST_INFINITE_RECURSION_MAX
return
$test_infinite_recursion
return
$test_infinite_recursion
end
end
test_infinite_recursion
test_infinite_recursion
end
end
assert
(
'Infinite recursion should result in an exception being raised'
)
do
assert
(
'Infinite recursion should result in an exception being raised'
)
do
a
=
begin
a
=
begin
test_infinite_recursion
test_infinite_recursion
rescue
rescue
:ok
:ok
end
end
# OK if an exception was caught, otherwise a number will be stored in a
# OK if an exception was caught, otherwise a number will be stored in a
...
...
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