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
779251de
Commit
779251de
authored
May 26, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `mrb_mod_s_nesting()` to `mruby-metaprog` gem from the core
parent
4261ba94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
27 deletions
+24
-27
mrbgems/mruby-metaprog/src/metaprog.c
mrbgems/mruby-metaprog/src/metaprog.c
+24
-2
src/vm.c
src/vm.c
+0
-25
No files found.
mrbgems/mruby-metaprog/src/metaprog.c
View file @
779251de
...
...
@@ -657,8 +657,30 @@ mrb_mod_s_constants(mrb_state *mrb, mrb_value mod)
return
mrb_nil_value
();
/* not reached */
}
/* implementation of Module.nesting */
mrb_value
mrb_mod_s_nesting
(
mrb_state
*
,
mrb_value
);
mrb_value
mrb_mod_s_nesting
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
struct
RProc
*
proc
;
mrb_value
ary
;
struct
RClass
*
c
=
NULL
;
mrb_get_args
(
mrb
,
""
);
ary
=
mrb_ary_new
(
mrb
);
proc
=
mrb
->
c
->
ci
[
-
1
].
proc
;
/* callee proc */
mrb_assert
(
!
MRB_PROC_CFUNC_P
(
proc
));
while
(
proc
)
{
if
(
MRB_PROC_SCOPE_P
(
proc
))
{
struct
RClass
*
c2
=
MRB_PROC_TARGET_CLASS
(
proc
);
if
(
c2
!=
c
)
{
c
=
c2
;
mrb_ary_push
(
mrb
,
ary
,
mrb_obj_value
(
c
));
}
}
proc
=
proc
->
upper
;
}
return
ary
;
}
void
mrb_mruby_metaprog_gem_init
(
mrb_state
*
mrb
)
...
...
src/vm.c
View file @
779251de
...
...
@@ -830,31 +830,6 @@ mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const
return
mrb_exec_irep
(
mrb
,
self
,
p
);
}
mrb_value
mrb_mod_s_nesting
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
struct
RProc
*
proc
;
mrb_value
ary
;
struct
RClass
*
c
=
NULL
;
mrb_get_args
(
mrb
,
""
);
ary
=
mrb_ary_new
(
mrb
);
proc
=
mrb
->
c
->
ci
[
-
1
].
proc
;
/* callee proc */
mrb_assert
(
!
MRB_PROC_CFUNC_P
(
proc
));
while
(
proc
)
{
if
(
MRB_PROC_SCOPE_P
(
proc
))
{
struct
RClass
*
c2
=
MRB_PROC_TARGET_CLASS
(
proc
);
if
(
c2
!=
c
)
{
c
=
c2
;
mrb_ary_push
(
mrb
,
ary
,
mrb_obj_value
(
c
));
}
}
proc
=
proc
->
upper
;
}
return
ary
;
}
static
struct
RBreak
*
break_new
(
mrb_state
*
mrb
,
struct
RProc
*
p
,
mrb_value
val
)
{
...
...
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