Ruby: include/ruby/internal/intern/eval.h File Reference

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

Functions
eval.h File Reference

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"`

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.
void | rb_exc_fatal (VALUE exc)
| Identical to rb_fatal(), except it raises the passed exception instance as- is instead of creating new one.
VALUE | rb_f_exit (int argc, const VALUE *argv)
| Identical to rb_exit(), except how arguments are passed.
VALUE | rb_f_abort (int argc, const VALUE *argv)
| This is similar to rb_f_exit().
void | rb_interrupt (void)
| Raises an instance of rb_eInterrupt.
ID | rb_frame_this_func (void)
| Queries the name of the Ruby level method that is calling this function.
void | rb_jump_tag (int state)
| This function is to re-throw global escapes.
void | rb_obj_call_init (VALUE obj, int argc, const VALUE *argv)
| Calls `initialize` method of the passed object with the passed arguments.
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.
ID | rb_frame_callee (void)
| Identical to rb_frame_this_func(), except it returns the named used to call the method.
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`.
void | rb_set_end_proc (void(*func)(VALUE arg), VALUE arg)
| Registers a function that shall run on process exit.

## 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

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

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] | argc | Number of objects of `argv`.
  [in] | argv | Contains at most one string-ish object.

Exceptions

  rb_eArgError | Wrong `argc`.
  rb_eTypeError | No conversion from `argv[0]` to String.
  rb_eSystemExit | Exception representing `EXIT_FAILURE`.

Note
  It never returns.

Definition at line 4597 of file process.c.

Referenced by rb_f_abort().

## ◆ rb_f_exit()

VALUE rb_f_exit | ( | int | argc,
|  | const VALUE * | argv )

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

Parameters

  [in] | argc | Number of objects of `argv`.
  [in] | argv | Contains at most one of the following: RUBY_Qtrue - means `EXIT_SUCCESS`. RUBY_Qfalse - means `EXIT_FAILURE`. Numerical value - takes that value.

Exceptions

  rb_eArgError | Wrong `argc`.
  rb_eSystemExit | Exception representing the exit status.

Note
  It never returns.

Definition at line 4532 of file process.c.

Referenced by rb_f_exit().

## ◆ 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

  0 | There is no method (e.g. toplevel context).
  otherwise | The name of the current method.

Definition at line 1059 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

  0 | There is no method (e.g. toplevel context).
  otherwise | The name of the current method.

Definition at line 1053 of file eval.c.

## ◆ rb_interrupt()

void rb_interrupt | ( | void |  | ) |

Raises an instance of rb_eInterrupt.

Exceptions

  rb_eInterrupt | Always raises this exception.

Note
  It never returns.

Definition at line 707 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] | state | Opaque state of execution.

Note
  It never returns.

Definition at line 859 of file eval.c.

## ◆ 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] | argc | Number of objects of `argv`.
  [in] | argv | 0 up to 3 objects.

Exceptions

  rb_eArgError | Wrong `argc`.
  rb_eTypeError | `argv[0].exception` returned non-exception.

Returns
  An instance of a subclass of rb_eException.

Definition at line 835 of file eval.c.

## ◆ 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] | obj | Receiver object.
  [in] | argc | Number of objects of `argv`.
  [in] | argv | Passed as-is to `obj.initialize`.

Exceptions

  rb_eException | Any exceptions happen inside.

Definition at line 1680 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] | obj | Receiver object.
  [in] | argc | Number of objects of `argv`.
  [in] | argv | Passed as-is to `obj.initialize`.
  [in] | kw_splat | Handling 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_eNoMethodError | No such method.
  rb_eException | Any exceptions happen inside.

Definition at line 1686 of file eval.c.

## ◆ rb_set_end_proc()

void rb_set_end_proc | ( | void(* | func )(VALUE arg),
|  | 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] | func | Function to run at process exit.
  [in] | arg | Passed as-is to `func`.

Definition at line 59 of file eval_jump.c.