예제 #1
0
파일: safe.c 프로젝트: GunioRobot/ruby
void
rb_insecure_operation(void)
{
    if (rb_frame_callee()) {
	rb_raise(rb_eSecurityError, "Insecure operation - %s",
		 rb_id2name(rb_frame_callee()));
    }
    else {
	rb_raise(rb_eSecurityError, "Insecure operation: -r");
    }
}
예제 #2
0
파일: safe.c 프로젝트: GunioRobot/ruby
void
rb_secure(int level)
{
    if (level <= rb_safe_level()) {
	if (rb_frame_callee()) {
	    rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d",
		     rb_id2name(rb_frame_callee()), rb_safe_level());
	}
	else {
	    rb_raise(rb_eSecurityError, "Insecure operation at level %d",
		     rb_safe_level());
	}
    }
}
예제 #3
0
void
rb_notimplement(void)
{
  rb_raise(rb_eNotImpError,
           "The %s() function is unimplemented on this machine",
	     rb_id2name(rb_frame_callee()));
}
예제 #4
0
static void
error_pos(void)
{
    const char *sourcefile = rb_sourcefile();
    int sourceline = rb_sourceline();

    if (sourcefile) {
	if (sourceline == 0) {
	    warn_printf("%s", sourcefile);
	}
	else if (rb_frame_callee()) {
	    warn_printf("%s:%d:in `%s'", sourcefile, sourceline,
			rb_id2name(rb_frame_callee()));
	}
	else {
	    warn_printf("%s:%d", sourcefile, sourceline);
	}
    }
}
예제 #5
0
static VALUE
specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
{
    VALUE retval;

    // XXX: not exception-safe
    const long old_version = RCLASS_VERSION(klass);

    if (rb_block_given_p()) {
        if (argc > 0) {
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)",
		    argc);
        }
	rb_vm_set_current_scope(klass, SCOPE_PUBLIC);
        retval = rb_vm_yield_under(klass, self, 1, &self);
    }
    else {
	const char *file = "(eval)";
	int line = 1;

        if (argc == 0) {
            rb_raise(rb_eArgError, "block not supplied");
        }
	if (rb_safe_level() >= 4) {
	    StringValue(argv[0]);
	}
	else {
	    SafeStringValue(argv[0]);
	}
	if (argc > 3) {
	    const char *name = rb_id2name(rb_frame_callee());
	    rb_raise(rb_eArgError,
		    "wrong number of arguments: %s(src) or %s{..}",
		    name, name);
	}
	if (argc > 2) {
	    line = NUM2INT(argv[2]);
	}
	if (argc > 1) {
	    file = StringValuePtr(argv[1]);
	}
	rb_vm_set_current_scope(klass, SCOPE_PUBLIC);
	retval = eval_under(self, klass, argv[0], Qnil, file, line);
    }

    RCLASS_SET_VERSION(klass, old_version);

    return retval;
}
예제 #6
0
파일: vm_eval.c 프로젝트: 3runo5ouza/rhodes
static VALUE
specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
{
    if (rb_block_given_p()) {
	if (argc > 0) {
	    rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
	}
	return yield_under(klass, self, Qundef);
    }
    else {
	const char *file = "(eval)";
	int line = 1;

//RHO
    rb_raise(rb_eNotImpError, "Not implemented: only eval of block is supported.");
//RHO

	if (argc == 0) {
	    rb_raise(rb_eArgError, "block not supplied");
	}
	else {
	    if (rb_safe_level() >= 4) {
		StringValue(argv[0]);
	    }
	    else {
		SafeStringValue(argv[0]);
	    }
	    if (argc > 3) {
		const char *name = rb_id2name(rb_frame_callee());
		rb_raise(rb_eArgError,
			 "wrong number of arguments: %s(src) or %s{..}",
			 name, name);
	    }
	    if (argc > 2)
		line = NUM2INT(argv[2]);
	    if (argc > 1) {
		file = StringValuePtr(argv[1]);
	    }
	}
	return eval_under(klass, self, argv[0], file, line);
    }
}
예제 #7
0
static void
error_pos(void)
{
    int sourceline;
    VALUE sourcefile = rb_source_location(&sourceline);

    if (sourcefile) {
	ID caller_name;
	if (sourceline == 0) {
	    warn_printf("%"PRIsVALUE, sourcefile);
	}
	else if ((caller_name = rb_frame_callee()) != 0) {
	    warn_printf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'", sourcefile, sourceline,
			rb_id2str(caller_name));
	}
	else {
	    warn_printf("%"PRIsVALUE":%d", sourcefile, sourceline);
	}
    }
}
예제 #8
0
static void
set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_flag_t ex)
{
    int i;

    if (argc == 0) {
	rb_warning("%"PRIsVALUE" with no argument is just ignored",
		   QUOTE_ID(rb_frame_callee()));
	return;
    }

    for (i = 0; i < argc; i++) {
	VALUE v = argv[i];
	ID id = rb_check_id(&v);
	if (!id) {
	    rb_print_undef_str(self, v);
	}
	rb_export_method(self, id, ex);
    }
}
예제 #9
0
파일: eval_error.c 프로젝트: rhenium/ruby
static VALUE
error_pos_str(void)
{
    int sourceline;
    VALUE sourcefile = rb_source_location(&sourceline);

    if (sourcefile) {
	ID caller_name;
	if (sourceline == 0) {
	    return rb_sprintf("%"PRIsVALUE": ", sourcefile);
	}
	else if ((caller_name = rb_frame_callee()) != 0) {
	    return rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"': ",
			      sourcefile, sourceline,
			      rb_id2str(caller_name));
	}
	else {
	    return rb_sprintf("%"PRIsVALUE":%d: ", sourcefile, sourceline);
	}
    }
    return Qnil;
}
예제 #10
0
static VALUE
specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
{
    if (rb_block_given_p()) {
        if (argc > 0) {
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
        }
        return rb_vm_yield_under(klass, self, 0, NULL);
    }
    else {
	const char *file = "(eval)";
	int line = 1;

        if (argc == 0) {
            rb_raise(rb_eArgError, "block not supplied");
        }
	if (rb_safe_level() >= 4) {
	    StringValue(argv[0]);
	}
	else {
	    SafeStringValue(argv[0]);
	}
	if (argc > 3) {
	    const char *name = rb_id2name(rb_frame_callee());
	    rb_raise(rb_eArgError,
		    "wrong number of arguments: %s(src) or %s{..}",
		    name, name);
	}
	if (argc > 2) {
	    line = NUM2INT(argv[2]);
	}
	if (argc > 1) {
	    file = StringValuePtr(argv[1]);
	}
	return eval_string(self, klass, argv[0], Qnil, file, line);
    }
}