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

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
eval.h File Reference

Declares rb_eval_string(). More...

`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`

Go to the source code of this file.

## Macros
#define | rb_funcall2 rb_funcallv
#define | rb_funcall3 rb_funcallv_public

## Functions
VALUE | rb_eval_string (const char *)
| Evaluates the given string in an isolated binding. More...
VALUE | rb_eval_string_protect (const char *, int *)
| Evaluates the given string in an isolated binding. More...
VALUE | rb_eval_string_wrap (const char *, int *)
| Evaluates the given string under a module binding in an isolated binding. More...
VALUE | rb_funcall (VALUE, ID, int,...)
| Calls a method. More...
VALUE | rb_funcallv (VALUE, ID, int, const VALUE *)
| Calls a method. More...
VALUE | rb_funcallv_kw (VALUE, ID, int, const VALUE *, int)
VALUE | rb_funcallv_public (VALUE, ID, int, const VALUE *)
| Calls a method. More...
VALUE | rb_funcallv_public_kw (VALUE, ID, int, const VALUE *, int)
VALUE | rb_funcall_passing_block (VALUE, ID, int, const VALUE *)
VALUE | rb_funcall_passing_block_kw (VALUE, ID, int, const VALUE *, int)
VALUE | rb_funcall_with_block (VALUE, ID, int, const VALUE *, VALUE)
VALUE | rb_funcall_with_block_kw (VALUE, ID, int, const VALUE *, VALUE, int)
VALUE | rb_call_super (int, const VALUE *)
VALUE | rb_call_super_kw (int, const VALUE *, int)
VALUE | rb_current_receiver (void)
int | rb_get_kwargs (VALUE keyword_hash, const ID *table, int required, int optional, VALUE *)
VALUE | rb_extract_keywords (VALUE *orighash)

## Detailed Description

Declares rb_eval_string().

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.

## Macro Definition Documentation

## ◆ rb_funcall2

#define rb_funcall2 rb_funcallv

Definition at line 36 of file eval.h.

## ◆ rb_funcall3

#define rb_funcall3 rb_funcallv_public

Definition at line 37 of file eval.h.

## Function Documentation

## ◆ rb_call_super()

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

Definition at line 298 of file vm_eval.c.

References argc, argv, PASS_PASSED_BLOCK_HANDLER_EC, and RB_NO_KEYWORDS.

## ◆ rb_call_super_kw()

VALUE rb_call_super_kw | ( | int | argc,
|  | const VALUE * | argv,
|  | int | kw_splat
| ) |  |

Definition at line 290 of file vm_eval.c.

References argc, argv, and PASS_PASSED_BLOCK_HANDLER_EC.

## ◆ rb_current_receiver()

VALUE rb_current_receiver | ( | void |  | ) |

Definition at line 306 of file vm_eval.c.

References rb_execution_context_struct::cfp, rb_eRuntimeError, rb_raise(), and rb_control_frame_struct::self.

## ◆ rb_eval_string()

VALUE rb_eval_string | ( | const char * | str | ) |

Evaluates the given string in an isolated binding.

Here "isolated" means the binding does not inherit any other binding. This behaves same as the binding for required libraries.

FILE will be "(eval)", and LINE starts from 1 in the evaluation.

Parameters

  str | Ruby code to evaluate.

Returns
  The evaluated result.

Exceptions

  Exception | Raises an exception on error.

Definition at line 1823 of file vm_eval.c.

References ruby_eval_string_from_file(), and str.

## ◆ rb_eval_string_protect()

VALUE rb_eval_string_protect | ( | const char * | str,
|  | int * | pstate
| ) |  |

Evaluates the given string in an isolated binding.

FILE will be "(eval)", and LINE starts from 1 in the evaluation.

See also
  rb_eval_string

Parameters

  str | Ruby code to evaluate.
  state | Being set to zero if succeeded. Nonzero if an error occurred.

Returns
  The evaluated result if succeeded, an undefined value if otherwise.

Definition at line 1845 of file vm_eval.c.

References rb_protect(), and str.

## ◆ rb_eval_string_wrap()

VALUE rb_eval_string_wrap | ( | const char * | str,
|  | int * | pstate
| ) |  |

Evaluates the given string under a module binding in an isolated binding.

This is same as the binding for loaded libraries on "load('foo', true)".

FILE will be "(eval)", and LINE starts from 1 in the evaluation.

See also
  rb_eval_string

Parameters

  str | Ruby code to evaluate.
  state | Being set to zero if succeeded. Nonzero if an error occurred.

Returns
  The evaluated result if succeeded, an undefined value if otherwise.

Definition at line 1877 of file vm_eval.c.

References rb_thread_struct::ec, EC_JUMP_TAG, eval_string_wrap_arg::klass, rb_extend_object(), rb_module_new(), rb_obj_clone(), rb_protect(), rb_vm_top_self(), str, eval_string_wrap_arg::str, TAG_NONE, rb_thread_struct::top_self, eval_string_wrap_arg::top_self, and rb_thread_struct::top_wrapper.

## ◆ rb_funcall()

VALUE rb_funcall | ( | VALUE | recv,
|  | ID | mid,
|  | int | n,
|  |  | ...
| ) |  |

Calls a method.

Parameters

  recv | receiver of the method
  mid | an ID that represents the name of the method
  n | the number of arguments
  ... | arbitrary number of method arguments

Precondition
  each of arguments after n must be a VALUE.

Definition at line 1077 of file vm_eval.c.

References ALLOCA_N, argv, and rb_funcallv.

Referenced by default_inspect(), DupConfigPtr(), Init_generator(), Init_ossl_digest(), Init_syslog(), Init_win32ole_variant(), InitVM_Enumerator(), ossl_time_split(), ossl_to_der(), rb_callable_receiver(), rb_class_inherited(), rb_cmpint(), rb_eql(), rb_equal(), rb_fiddle_generic_to_value(), rb_hash_default_value(), rb_io_flush_raw(), rb_iseq_add_local_tracepoint_recursively(), rb_num_coerce_bin(), rb_num_coerce_cmp(), rb_num_coerce_relop(), rb_obj_as_string(), rb_obj_dup(), rb_obj_init_dup_clone(), rb_obj_not_equal(), rb_scheduler_block(), rb_scheduler_close(), rb_scheduler_io_read(), rb_scheduler_io_wait(), rb_scheduler_io_write(), rb_scheduler_kernel_sleep(), rb_scheduler_process_wait(), rb_scheduler_unblock(), rb_str_upto_each(), and ruby_num_interval_step_size().

## ◆ rb_funcall_passing_block()

VALUE rb_funcall_passing_block | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv
| ) |  |

Definition at line 1149 of file vm_eval.c.

References argc, argv, PASS_PASSED_BLOCK_HANDLER, and rb_funcallv_public().

## ◆ rb_funcall_passing_block_kw()

VALUE rb_funcall_passing_block_kw | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | int | kw_splat
| ) |  |

Definition at line 1156 of file vm_eval.c.

References argc, argv, CALL_PUBLIC, CALL_PUBLIC_KW, and PASS_PASSED_BLOCK_HANDLER.

## ◆ rb_funcall_with_block()

VALUE rb_funcall_with_block | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | VALUE | passed_procval
| ) |  |

Definition at line 1163 of file vm_eval.c.

References argc, argv, NIL_P, and rb_funcallv_public().

## ◆ rb_funcall_with_block_kw()

VALUE rb_funcall_with_block_kw | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | VALUE | passed_procval,
|  | int | kw_splat
| ) |  |

Definition at line 1173 of file vm_eval.c.

References argc, argv, CALL_PUBLIC, CALL_PUBLIC_KW, and NIL_P.

Referenced by rb_sym_proc_call().

## ◆ rb_funcallv()

VALUE rb_funcallv | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv
| ) |  |

Calls a method.

Parameters

  recv | receiver of the method
  mid | an ID that represents the name of the method
  argc | the number of arguments
  argv | pointer to an array of method arguments

Definition at line 1024 of file vm_eval.c.

References argc, argv, and CALL_FCALL.

## ◆ rb_funcallv_kw()

VALUE rb_funcallv_kw | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | int | kw_splat
| ) |  |

Definition at line 1030 of file vm_eval.c.

References argc, argv, CALL_FCALL, and CALL_FCALL_KW.

Referenced by rb_eval_cmd_kw(), rb_obj_call_init(), and rb_obj_call_init_kw().

## ◆ rb_funcallv_public()

VALUE rb_funcallv_public | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv
| ) |  |

Calls a method.

Same as rb_funcallv but this function can call only public methods.

Parameters

  recv | receiver of the method
  mid | an ID that represents the name of the method
  argc | the number of arguments
  argv | pointer to an array of method arguments

Definition at line 1137 of file vm_eval.c.

References argc, argv, and CALL_PUBLIC.

Referenced by rb_funcall_passing_block(), rb_funcall_with_block(), and rb_random_ulong_limited().

## ◆ rb_funcallv_public_kw()

VALUE rb_funcallv_public_kw | ( | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | int | kw_splat
| ) |  |

Definition at line 1143 of file vm_eval.c.

References argc, argv, CALL_PUBLIC, and CALL_PUBLIC_KW.