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
080f7bae
Unverified
Commit
080f7bae
authored
5 years ago
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4699 from takkaw/mirb_lv_under_score
add special local variable _ in mirb
parents
9d9cb0ab
3f70e3a8
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+27
-0
No files found.
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
080f7bae
...
...
@@ -406,6 +406,26 @@ ctrl_c_handler(int signo)
}
#endif
#ifndef DISABLE_MIRB_UNDERSCORE
void
decl_lv_underscore
(
mrb_state
*
mrb
,
mrbc_context
*
cxt
)
{
struct
RProc
*
proc
;
struct
mrb_parser_state
*
parser
;
parser
=
mrb_parse_string
(
mrb
,
"_=nil"
,
cxt
);
if
(
parser
==
NULL
)
{
fputs
(
"create parser state error
\n
"
,
stderr
);
mrb_close
(
mrb
);
exit
(
EXIT_FAILURE
);
}
proc
=
mrb_generate_code
(
mrb
,
parser
);
mrb_vm_run
(
mrb
,
proc
,
mrb_top_self
(
mrb
),
0
);
mrb_parser_free
(
parser
);
}
#endif
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -471,6 +491,10 @@ main(int argc, char **argv)
cxt
=
mrbc_context_new
(
mrb
);
#ifndef DISABLE_MIRB_UNDERSCORE
decl_lv_underscore
(
mrb
,
cxt
);
#endif
/* Load libraries */
for
(
i
=
0
;
i
<
args
.
libc
;
i
++
)
{
FILE
*
lfp
=
fopen
(
args
.
libv
[
i
],
"r"
);
...
...
@@ -643,6 +667,9 @@ main(int argc, char **argv)
result
=
mrb_any_to_s
(
mrb
,
result
);
}
p
(
mrb
,
result
,
1
);
#ifndef DISABLE_MIRB_UNDERSCORE
*
(
mrb
->
c
->
stack
+
1
)
=
result
;
#endif
}
}
ruby_code
[
0
]
=
'\0'
;
...
...
This diff is collapsed.
Click to expand it.
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