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

◆ 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
strRuby code to evaluate.
Returns
The evaluated result.
Exceptions
ExceptionRaises 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
strRuby code to evaluate.
stateBeing 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
strRuby code to evaluate.
stateBeing 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,
  ... 
)

◆ 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
recvreceiver of the method
midan ID that represents the name of the method
argcthe number of arguments
argvpointer 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
recvreceiver of the method
midan ID that represents the name of the method
argcthe number of arguments
argvpointer 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.