Ruby  3.4.0dev (2024-11-22 revision 37a72b0150ec36b4ea27175039afc28c62207b0c)
Functions
eval.h File Reference

(37a72b0150ec36b4ea27175039afc28c62207b0c)

Pre-1.9 era evaluator APIs (now considered miscellaneous). More...

#include "ruby/internal/attr/noreturn.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Include dependency graph for eval.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void rb_exc_raise (VALUE exc)
 Identical to rb_raise(), except it raises the passed exception instance as- is instead of creating new one. More...
 
void rb_exc_fatal (VALUE exc)
 Identical to rb_fatal(), except it raises the passed exception instance as- is instead of creating new one. More...
 
VALUE rb_f_exit (int argc, const VALUE *argv)
 Identical to rb_exit(), except how arguments are passed. More...
 
VALUE rb_f_abort (int argc, const VALUE *argv)
 This is similar to rb_f_exit(). More...
 
void rb_interrupt (void)
 Raises an instance of rb_eInterrupt. More...
 
ID rb_frame_this_func (void)
 Queries the name of the Ruby level method that is calling this function. More...
 
void rb_jump_tag (int state)
 This function is to re-throw global escapes. More...
 
void rb_obj_call_init (VALUE obj, int argc, const VALUE *argv)
 Calls initialize method of the passed object with the passed arguments. More...
 
void rb_obj_call_init_kw (VALUE, int, const VALUE *, int)
 Identical to rb_obj_call_init(), except you can specify how to handle the last element of the given array. More...
 
ID rb_frame_callee (void)
 Identical to rb_frame_this_func(), except it returns the named used to call the method. More...
 
VALUE rb_make_exception (int argc, const VALUE *argv)
 Constructs an exception object from the list of arguments, in a manner similar to Ruby's raise. More...
 
void rb_set_end_proc (void(*func)(VALUE arg), VALUE arg)
 Registers a function that shall run on process exit. More...
 

Detailed Description

Pre-1.9 era evaluator APIs (now considered miscellaneous).

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file eval.h.

Function Documentation

◆ rb_f_abort()

VALUE rb_f_abort ( int  argc,
const VALUE argv 
)

This is similar to rb_f_exit().

In fact on some situation it internally calls rb_exit(). But can be very esoteric on occasions.

It takes up to one argument. If an argument is passed, it tries to display that. Otherwise if there is $!, displays that exception instead. It finally raise rb_eSystemExit in both cases.

Parameters
[in]argcNumber of objects of argv.
[in]argvContains at most one string-ish object.
Exceptions
rb_eArgErrorWrong argc.
rb_eTypeErrorNo conversion from argv[0] to String.
rb_eSystemExitException representing EXIT_FAILURE.
Note
It never returns.

Definition at line 4533 of file process.c.

◆ rb_f_exit()

VALUE rb_f_exit ( int  argc,
const VALUE argv 
)

Identical to rb_exit(), except how arguments are passed.

Parameters
[in]argcNumber of objects of argv.
[in]argvContains at most one of the following:
Exceptions
rb_eArgErrorWrong argc.
rb_eSystemExitException representing the exit status.
Note
It never returns.

Definition at line 4464 of file process.c.

◆ rb_frame_callee()

ID rb_frame_callee ( void  )

Identical to rb_frame_this_func(), except it returns the named used to call the method.

Return values
0There is no method (e.g. toplevel context).
otherwiseThe name of the current method.

Definition at line 1100 of file eval.c.

◆ rb_frame_this_func()

ID rb_frame_this_func ( void  )

Queries the name of the Ruby level method that is calling this function.

The "name" in this context is the one assigned to the function for the first time (note that methods can have multiple names via aliases).

Return values
0There is no method (e.g. toplevel context).
otherwiseThe name of the current method.

Definition at line 1094 of file eval.c.

Referenced by rb_notimplement().

◆ rb_interrupt()

void rb_interrupt ( void  )

Raises an instance of rb_eInterrupt.

Exceptions
rb_eInterruptAlways raises this exception.
Note
It never returns.

Definition at line 695 of file eval.c.

◆ rb_jump_tag()

void rb_jump_tag ( int  state)

This function is to re-throw global escapes.

Such global escapes include exceptions, throw, break, for example.

It makes sense only when used in conjunction with "protect" series APIs e.g. rb_protect(), rb_load_protect(), rb_eval_string_protect(), etc. In case these functions experience global escapes, they fill their opaque state return buffer. You can ignore such escapes. But if you decide otherwise, you have to somehow escape globally again. This function is used for that purpose.

Parameters
[in]stateOpaque state of execution.
Note
It never returns.

Definition at line 907 of file eval.c.

Referenced by rb_f_exec(), and rb_io_open_descriptor().

◆ rb_make_exception()

VALUE rb_make_exception ( int  argc,
const VALUE argv 
)

Constructs an exception object from the list of arguments, in a manner similar to Ruby's raise.

This function can take:

  • No arguments at all, i.e. argc == 0. This is not a failure. It returns RUBY_Qnil then.
  • An object, which is an instance of rb_cString. In this case an instance of rb_eRuntimeError whose message is the passed string is created then returned.
  • An object, which responds to exception method, and optionally its argument, and optionally its backtrace. For example instances of subclasses of rb_eException have this method. What is returned from the method is returned.
Parameters
[in]argcNumber of objects of argv.
[in]argv0 up to 3 objects.
Exceptions
rb_eArgErrorWrong argc.
rb_eTypeErrorargv[0].exception returned non-exception.
Returns
An instance of a subclass of rb_eException.

Definition at line 883 of file eval.c.

Referenced by rb_fiber_raise().

◆ rb_obj_call_init()

void rb_obj_call_init ( VALUE  obj,
int  argc,
const VALUE argv 
)

Calls initialize method of the passed object with the passed arguments.

It also forwards the implicitly passed block to the method.

Parameters
[in]objReceiver object.
[in]argcNumber of objects of argv.
[in]argvPassed as-is to obj.initialize.
Exceptions
rb_eExceptionAny exceptions happen inside.

Definition at line 1722 of file eval.c.

◆ rb_obj_call_init_kw()

void rb_obj_call_init_kw ( VALUE  obj,
int  argc,
const VALUE argv,
int  kw_splat 
)

Identical to rb_obj_call_init(), except you can specify how to handle the last element of the given array.

Parameters
[in]objReceiver object.
[in]argcNumber of objects of argv.
[in]argvPassed as-is to obj.initialize.
[in]kw_splatHandling of keyword parameters:
  • RB_NO_KEYWORDS argv's last is not a keyword argument.
  • RB_PASS_KEYWORDS argv's last is a keyword argument.
  • RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.
Exceptions
rb_eNoMethodErrorNo such method.
rb_eExceptionAny exceptions happen inside.

Definition at line 1728 of file eval.c.

Referenced by rb_obj_call_init().

◆ rb_set_end_proc()

void rb_set_end_proc ( void(*)(VALUE arg)  func,
VALUE  arg 
)

Registers a function that shall run on process exit.

Registered functions run in reverse-chronological order, mixed with syntactic END block and Kernel#at_exit.

Parameters
[in]funcFunction to run at process exit.
[in]argPassed as-is to func.