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
7ea82fed
Commit
7ea82fed
authored
Apr 29, 2014
by
take_cheeze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Kernel.local_variables for testing dumped local variables information.
parent
4c7f9897
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
+24
-0
mrbgems/mruby-proc-ext/test/proc.rb
mrbgems/mruby-proc-ext/test/proc.rb
+8
-0
No files found.
mrbgems/mruby-proc-ext/src/proc.c
View file @
7ea82fed
...
...
@@ -122,6 +122,29 @@ mrb_kernel_proc(mrb_state *mrb, mrb_value self)
return
blk
;
}
static
mrb_value
mrb_local_variables
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_value
ret
;
struct
RProc
*
proc
;
struct
mrb_irep
*
irep
;
size_t
i
;
proc
=
mrb
->
c
->
ci
[
-
1
].
proc
;
if
(
MRB_PROC_CFUNC_P
(
proc
))
{
return
mrb_ary_new
(
mrb
);
}
irep
=
proc
->
body
.
irep
;
ret
=
mrb_ary_new_capa
(
mrb
,
irep
->
lv_len
);
for
(
i
=
0
;
i
<
irep
->
lv_len
;
++
i
)
{
mrb_ary_push
(
mrb
,
ret
,
mrb_symbol_value
(
irep
->
lv
[
i
].
name
));
}
return
ret
;
}
void
mrb_mruby_proc_ext_gem_init
(
mrb_state
*
mrb
)
{
...
...
@@ -133,6 +156,7 @@ mrb_mruby_proc_ext_gem_init(mrb_state* mrb)
mrb_define_class_method
(
mrb
,
mrb
->
kernel_module
,
"proc"
,
mrb_kernel_proc
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
mrb
->
kernel_module
,
"proc"
,
mrb_kernel_proc
,
MRB_ARGS_NONE
());
mrb_define_module_function
(
mrb
,
mrb
->
kernel_module
,
"local_variables"
,
mrb_local_variables
,
MRB_ARGS_NONE
());
}
void
...
...
mrbgems/mruby-proc-ext/test/proc.rb
View file @
7ea82fed
...
...
@@ -74,3 +74,11 @@ assert('mrb_cfunc_env_get') do
assert_equal
1
,
t
.
get_int
(
1
)
end
assert
(
'Kernel.local_variables'
)
do
a
,
b
=
0
,
1
a
+=
b
vars
=
Kernel
.
local_variables
.
sort
assert_equal
[
:a
,
:b
,
:vars
],
vars
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