mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
iseq.c: kwarg to compile
* iseq.c (iseqw_s_compile, iseqw_s_compile_file): allow keyword arguments as the options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
802e5677a4
commit
b15f76556f
1 changed files with 16 additions and 2 deletions
18
iseq.c
18
iseq.c
|
@ -781,9 +781,18 @@ static VALUE
|
|||
iseqw_s_compile(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil;
|
||||
int i;
|
||||
|
||||
rb_secure(1);
|
||||
|
||||
rb_scan_args(argc, argv, "14", &src, &file, &path, &line, &opt);
|
||||
i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
|
||||
if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
|
||||
switch (i) {
|
||||
case 5: opt = argv[--i];
|
||||
case 4: line = argv[--i];
|
||||
case 3: path = argv[--i];
|
||||
case 2: file = argv[--i];
|
||||
}
|
||||
if (NIL_P(file)) file = rb_fstring_cstr("<compiled>");
|
||||
if (NIL_P(line)) line = INT2FIX(1);
|
||||
|
||||
|
@ -818,9 +827,14 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||
VALUE f;
|
||||
NODE *node;
|
||||
rb_compile_option_t option;
|
||||
int i;
|
||||
|
||||
rb_secure(1);
|
||||
rb_scan_args(argc, argv, "11", &file, &opt);
|
||||
i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt);
|
||||
if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 2);
|
||||
switch (i) {
|
||||
case 2: opt = argv[--i];
|
||||
}
|
||||
FilePathValue(file);
|
||||
file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue