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
27df1a84
Commit
27df1a84
authored
May 14, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kernel.local_variables to list UPVAR as well
parent
232ec102
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
+19
-1
mrbgems/mruby-proc-ext/test/proc.rb
mrbgems/mruby-proc-ext/test/proc.rb
+6
-0
No files found.
mrbgems/mruby-proc-ext/src/proc.c
View file @
27df1a84
...
...
@@ -137,10 +137,28 @@ mrb_local_variables(mrb_state *mrb, mrb_value self)
}
irep
=
proc
->
body
.
irep
;
if
(
!
irep
->
lv
)
{
return
mrb_ary_new
(
mrb
);
}
ret
=
mrb_ary_new_capa
(
mrb
,
irep
->
nlocals
-
1
);
for
(
i
=
0
;
i
<
(
irep
->
nlocals
-
1
)
;
++
i
)
{
for
(
i
=
0
;
i
+
1
<
irep
->
nlocals
;
++
i
)
{
mrb_ary_push
(
mrb
,
ret
,
mrb_symbol_value
(
irep
->
lv
[
i
].
name
));
}
if
(
proc
->
env
)
{
struct
REnv
*
e
=
proc
->
env
;
while
(
e
)
{
if
(
!
MRB_PROC_CFUNC_P
(
mrb
->
c
->
cibase
[
e
->
cioff
].
proc
))
{
irep
=
mrb
->
c
->
cibase
[
e
->
cioff
].
proc
->
body
.
irep
;
if
(
irep
->
lv
)
{
for
(
i
=
0
;
i
+
1
<
irep
->
nlocals
;
++
i
)
{
mrb_ary_push
(
mrb
,
ret
,
mrb_symbol_value
(
irep
->
lv
[
i
].
name
));
}
}
}
e
=
(
struct
REnv
*
)
e
->
c
;
}
}
return
ret
;
}
...
...
mrbgems/mruby-proc-ext/test/proc.rb
View file @
27df1a84
...
...
@@ -81,4 +81,10 @@ assert('Kernel.local_variables') do
vars
=
Kernel
.
local_variables
.
sort
assert_equal
[
:a
,
:b
,
:vars
],
vars
proc
{
c
=
2
vars
=
Kernel
.
local_variables
.
sort
assert_equal
[
:a
,
:b
,
:c
,
:vars
],
vars
}.
call
end
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