Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Functions | Variables
iseq.c File Reference
#include "internal.h"
#include "ruby/util.h"
#include "eval_intern.h"
#include "gc.h"
#include "vm_core.h"
#include "iseq.h"
#include "id_table.h"
#include "insns.inc"
#include "insns_info.inc"
#include "node_name.inc"

Go to the source code of this file.

Data Structures

struct  set_specifc_data
 

Macros

#define hidden_obj_p(obj)   (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass)
 
#define SET_COMPILE_OPTION(o, h, mem)
 
#define SET_COMPILE_OPTION_NUM(o, h, mem)
 
#define SET_COMPILE_OPTION(o, h, mem)   rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse)
 
#define SET_COMPILE_OPTION_NUM(o, h, mem)   rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem))
 
#define CHECK_ARRAY(v)   rb_convert_type_with_id((v), T_ARRAY, "Array", idTo_ary)
 
#define CHECK_HASH(v)   rb_convert_type_with_id((v), T_HASH, "Hash", idTo_hash)
 
#define CHECK_STRING(v)   rb_convert_type_with_id((v), T_STRING, "String", idTo_str)
 
#define CHECK_SYMBOL(v)   rb_convert_type_with_id((v), T_SYMBOL, "Symbol", idTo_sym)
 
#define INITIALIZED   volatile /* suppress warnings by gcc 4.8 */
 
#define DECL_SYMBOL(name)   static VALUE sym_##name
 
#define INIT_SYMBOL(name)   sym_##name = ID2SYM(rb_intern(#name))
 
#define PARAM_TYPE(type)   rb_ary_push(a = rb_ary_new2(2), ID2SYM(type))
 
#define PARAM_ID(i)   iseq->body->local_table[(i)]
 
#define PARAM(i, type)
 

Functions

void rb_iseq_free (const rb_iseq_t *iseq)
 
void rb_iseq_mark (const rb_iseq_t *iseq)
 
VALUE rb_iseq_pathobj_new (VALUE path, VALUE realpath)
 
void rb_iseq_pathobj_set (const rb_iseq_t *iseq, VALUE path, VALUE realpath)
 
void rb_iseq_add_mark_object (const rb_iseq_t *iseq, VALUE obj)
 
void rb_iseq_make_compile_option (rb_compile_option_t *option, VALUE opt)
 
rb_iseq_trb_iseq_new (NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum iseq_type type)
 
rb_iseq_trb_iseq_new_top (NODE *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
 
rb_iseq_trb_iseq_new_main (NODE *node, VALUE path, VALUE realpath, const rb_iseq_t *parent)
 
rb_iseq_trb_iseq_new_with_opt (NODE *node, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, enum iseq_type type, const rb_compile_option_t *option)
 
const rb_iseq_trb_iseq_load_iseq (VALUE fname)
 
VALUE rb_iseq_load (VALUE data, VALUE parent, VALUE opt)
 
rb_iseq_trb_iseq_compile_with_option (VALUE src, VALUE file, VALUE realpath, VALUE line, const struct rb_block *base_block, VALUE opt)
 
rb_iseq_trb_iseq_compile (VALUE src, VALUE file, VALUE line)
 
rb_iseq_trb_iseq_compile_on_base (VALUE src, VALUE file, VALUE line, const struct rb_block *base_block)
 
VALUE rb_iseq_path (const rb_iseq_t *iseq)
 
VALUE rb_iseq_realpath (const rb_iseq_t *iseq)
 
VALUE rb_iseq_absolute_path (const rb_iseq_t *iseq)
 
VALUE rb_iseq_label (const rb_iseq_t *iseq)
 
VALUE rb_iseq_base_label (const rb_iseq_t *iseq)
 
VALUE rb_iseq_first_lineno (const rb_iseq_t *iseq)
 
VALUE rb_iseq_method_name (const rb_iseq_t *iseq)
 
VALUE rb_iseq_coverage (const rb_iseq_t *iseq)
 
VALUE rb_iseqw_new (const rb_iseq_t *iseq)
 
const rb_iseq_trb_iseqw_to_iseq (VALUE iseqw)
 
unsigned int rb_iseq_line_no (const rb_iseq_t *iseq, size_t pos)
 
VALUE rb_insn_operand_intern (const rb_iseq_t *iseq, VALUE insn, int op_no, VALUE op, int len, size_t pos, const VALUE *pnop, VALUE child)
 
int rb_iseq_disasm_insn (VALUE ret, const VALUE *code, size_t pos, const rb_iseq_t *iseq, VALUE child)
 Disassemble a instruction Iseq -> Iseq inspect object. More...
 
VALUE rb_iseq_disasm (const rb_iseq_t *iseq)
 
const char * ruby_node_name (int node)
 
VALUE rb_iseq_parameters (const rb_iseq_t *iseq, int is_proc)
 
VALUE rb_iseq_defined_string (enum defined_type type)
 
int rb_iseqw_line_trace_each (VALUE iseqw, int(*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data)
 
VALUE rb_iseqw_line_trace_all (VALUE iseqw)
 
VALUE rb_iseqw_line_trace_specify (VALUE iseqval, VALUE pos, VALUE set)
 
VALUE rb_iseqw_local_variables (VALUE iseqval)
 
void Init_ISeq (void)
 

Variables

VALUE rb_cISeq
 

Macro Definition Documentation

◆ CHECK_ARRAY

#define CHECK_ARRAY (   v)    rb_convert_type_with_id((v), T_ARRAY, "Array", idTo_ary)

Definition at line 523 of file iseq.c.

◆ CHECK_HASH

#define CHECK_HASH (   v)    rb_convert_type_with_id((v), T_HASH, "Hash", idTo_hash)

Definition at line 524 of file iseq.c.

◆ CHECK_STRING

#define CHECK_STRING (   v)    rb_convert_type_with_id((v), T_STRING, "String", idTo_str)

Definition at line 525 of file iseq.c.

◆ CHECK_SYMBOL

#define CHECK_SYMBOL (   v)    rb_convert_type_with_id((v), T_SYMBOL, "Symbol", idTo_sym)

Definition at line 526 of file iseq.c.

◆ DECL_SYMBOL

#define DECL_SYMBOL (   name)    static VALUE sym_##name

Definition at line 1777 of file iseq.c.

◆ hidden_obj_p

#define hidden_obj_p (   obj)    (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass)

Definition at line 33 of file iseq.c.

◆ INIT_SYMBOL

#define INIT_SYMBOL (   name)    sym_##name = ID2SYM(rb_intern(#name))

Definition at line 1780 of file iseq.c.

◆ INITIALIZED

#define INITIALIZED   volatile /* suppress warnings by gcc 4.8 */

◆ PARAM

#define PARAM (   i,
  type 
)
Value:
( \
PARAM_TYPE(type), \
rb_id2str(PARAM_ID(i)) ? \
rb_ary_push(a, ID2SYM(PARAM_ID(i))) : \
a)
#define PARAM_ID(i)
#define ID2SYM(x)
Definition: ruby.h:383

Referenced by rb_iseq_parameters().

◆ PARAM_ID

#define PARAM_ID (   i)    iseq->body->local_table[(i)]

Referenced by rb_iseq_parameters().

◆ PARAM_TYPE

#define PARAM_TYPE (   type)    rb_ary_push(a = rb_ary_new2(2), ID2SYM(type))

Referenced by rb_iseq_parameters().

◆ SET_COMPILE_OPTION [1/2]

#define SET_COMPILE_OPTION (   o,
  h,
  mem 
)
Value:
{ VALUE flag = rb_hash_aref((h), ID2SYM(rb_intern(#mem))); \
if (flag == Qtrue) { (o)->mem = 1; } \
else if (flag == Qfalse) { (o)->mem = 0; } \
}
#define Qtrue
Definition: ruby.h:437
#define Qfalse
Definition: ruby.h:436
unsigned long VALUE
Definition: ruby.h:85
VALUE rb_hash_aref(VALUE hash, VALUE key)
Definition: hash.c:831
#define ID2SYM(x)
Definition: ruby.h:383
#define rb_intern(str)

◆ SET_COMPILE_OPTION [2/2]

#define SET_COMPILE_OPTION (   o,
  h,
  mem 
)    rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse)

◆ SET_COMPILE_OPTION_NUM [1/2]

#define SET_COMPILE_OPTION_NUM (   o,
  h,
  mem 
)
Value:
{ VALUE num = rb_hash_aref(opt, ID2SYM(rb_intern(#mem))); \
if (!NIL_P(num)) (o)->mem = NUM2INT(num); \
}
#define NUM2INT(x)
Definition: ruby.h:684
#define NIL_P(v)
Definition: ruby.h:451
unsigned long VALUE
Definition: ruby.h:85
VALUE rb_hash_aref(VALUE hash, VALUE key)
Definition: hash.c:831
#define ID2SYM(x)
Definition: ruby.h:383
#define rb_intern(str)

◆ SET_COMPILE_OPTION_NUM [2/2]

#define SET_COMPILE_OPTION_NUM (   o,
  h,
  mem 
)    rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem))

Function Documentation

◆ Init_ISeq()

void Init_ISeq ( void  )

◆ rb_insn_operand_intern()

VALUE rb_insn_operand_intern ( const rb_iseq_t iseq,
VALUE  insn,
int  op_no,
VALUE  op,
int  len,
size_t  pos,
const VALUE pnop,
VALUE  child 
)

◆ rb_iseq_absolute_path()

VALUE rb_iseq_absolute_path ( const rb_iseq_t iseq)

Definition at line 704 of file iseq.c.

References rb_iseq_realpath().

◆ rb_iseq_add_mark_object()

void rb_iseq_add_mark_object ( const rb_iseq_t iseq,
VALUE  obj 
)

Definition at line 280 of file iseq.c.

References ISEQ_MARK_ARY, and rb_ary_push().

◆ rb_iseq_base_label()

VALUE rb_iseq_base_label ( const rb_iseq_t iseq)

◆ rb_iseq_compile()

rb_iseq_t* rb_iseq_compile ( VALUE  src,
VALUE  file,
VALUE  line 
)

Definition at line 680 of file iseq.c.

References Qnil, and rb_iseq_compile_with_option().

◆ rb_iseq_compile_on_base()

rb_iseq_t* rb_iseq_compile_on_base ( VALUE  src,
VALUE  file,
VALUE  line,
const struct rb_block base_block 
)

Definition at line 686 of file iseq.c.

References Qnil, and rb_iseq_compile_with_option().

◆ rb_iseq_compile_with_option()

rb_iseq_t* rb_iseq_compile_with_option ( VALUE  src,
VALUE  file,
VALUE  realpath,
VALUE  line,
const struct rb_block base_block,
VALUE  opt 
)

Definition at line 632 of file iseq.c.

References GET_THREAD, and NULL.

Referenced by rb_iseq_compile(), and rb_iseq_compile_on_base().

◆ rb_iseq_coverage()

VALUE rb_iseq_coverage ( const rb_iseq_t iseq)

Definition at line 743 of file iseq.c.

References ISEQ_COVERAGE.

◆ rb_iseq_defined_string()

VALUE rb_iseq_defined_string ( enum defined_type  type)

◆ rb_iseq_disasm()

VALUE rb_iseq_disasm ( const rb_iseq_t iseq)

◆ rb_iseq_disasm_insn()

int rb_iseq_disasm_insn ( VALUE  ret,
const VALUE code,
size_t  pos,
const rb_iseq_t iseq,
VALUE  child 
)

Disassemble a instruction Iseq -> Iseq inspect object.

Definition at line 1431 of file iseq.c.

References len, PRIuSIZE, rb_insn_operand_intern(), rb_str_cat2(), rb_str_catf(), rb_str_concat(), and rb_str_new().

Referenced by rb_vmdebug_debug_print_pre().

◆ rb_iseq_first_lineno()

VALUE rb_iseq_first_lineno ( const rb_iseq_t iseq)

◆ rb_iseq_free()

void rb_iseq_free ( const rb_iseq_t iseq)

◆ rb_iseq_label()

VALUE rb_iseq_label ( const rb_iseq_t iseq)

◆ rb_iseq_line_no()

unsigned int rb_iseq_line_no ( const rb_iseq_t iseq,
size_t  pos 
)

Definition at line 1263 of file iseq.c.

◆ rb_iseq_load()

VALUE rb_iseq_load ( VALUE  data,
VALUE  parent,
VALUE  opt 
)

Definition at line 626 of file iseq.c.

◆ rb_iseq_load_iseq()

const rb_iseq_t* rb_iseq_load_iseq ( VALUE  fname)

Definition at line 512 of file iseq.c.

References rb_check_funcall(), rb_cISeq, rb_intern, RBASIC_CLASS, and SPECIAL_CONST_P.

◆ rb_iseq_make_compile_option()

void rb_iseq_make_compile_option ( rb_compile_option_t option,
VALUE  opt 
)

Definition at line 401 of file iseq.c.

References Check_Type, and T_HASH.

◆ rb_iseq_mark()

void rb_iseq_mark ( const rb_iseq_t iseq)

◆ rb_iseq_method_name()

VALUE rb_iseq_method_name ( const rb_iseq_t iseq)

◆ rb_iseq_new()

rb_iseq_t* rb_iseq_new ( NODE node,
VALUE  name,
VALUE  path,
VALUE  realpath,
const rb_iseq_t parent,
enum iseq_type  type 
)

Definition at line 458 of file iseq.c.

References INT2FIX, and rb_iseq_new_with_opt().

Referenced by rb_vm_call_cfunc().

◆ rb_iseq_new_main()

rb_iseq_t* rb_iseq_new_main ( NODE node,
VALUE  path,
VALUE  realpath,
const rb_iseq_t parent 
)

Definition at line 473 of file iseq.c.

References INT2FIX, rb_fstring_cstr(), and rb_iseq_new_with_opt().

◆ rb_iseq_new_top()

rb_iseq_t* rb_iseq_new_top ( NODE node,
VALUE  name,
VALUE  path,
VALUE  realpath,
const rb_iseq_t parent 
)

Definition at line 466 of file iseq.c.

References INT2FIX, and rb_iseq_new_with_opt().

◆ rb_iseq_new_with_opt()

rb_iseq_t* rb_iseq_new_with_opt ( NODE node,
VALUE  name,
VALUE  path,
VALUE  realpath,
VALUE  first_lineno,
const rb_iseq_t parent,
enum iseq_type  type,
const rb_compile_option_t option 
)

Definition at line 495 of file iseq.c.

References iseq_alloc().

Referenced by rb_iseq_new(), rb_iseq_new_main(), and rb_iseq_new_top().

◆ rb_iseq_parameters()

VALUE rb_iseq_parameters ( const rb_iseq_t iseq,
int  is_proc 
)

◆ rb_iseq_path()

VALUE rb_iseq_path ( const rb_iseq_t iseq)

◆ rb_iseq_pathobj_new()

VALUE rb_iseq_pathobj_new ( VALUE  path,
VALUE  realpath 
)

◆ rb_iseq_pathobj_set()

void rb_iseq_pathobj_set ( const rb_iseq_t iseq,
VALUE  path,
VALUE  realpath 
)

◆ rb_iseq_realpath()

VALUE rb_iseq_realpath ( const rb_iseq_t iseq)

Definition at line 698 of file iseq.c.

Referenced by rb_iseq_absolute_path(), and rb_vm_set_progname().

◆ rb_iseqw_line_trace_all()

VALUE rb_iseqw_line_trace_all ( VALUE  iseqw)

Definition at line 2307 of file iseq.c.

◆ rb_iseqw_line_trace_each()

int rb_iseqw_line_trace_each ( VALUE  iseqw,
int(*)(int line, rb_event_flag_t *events_ptr, void *d)  func,
void *  data 
)

Definition at line 2255 of file iseq.c.

Referenced by rb_iseqw_line_trace_specify().

◆ rb_iseqw_line_trace_specify()

VALUE rb_iseqw_line_trace_specify ( VALUE  iseqval,
VALUE  pos,
VALUE  set 
)

◆ rb_iseqw_to_iseq()

const rb_iseq_t* rb_iseqw_to_iseq ( VALUE  iseqw)

Definition at line 958 of file iseq.c.

◆ ruby_node_name()

const char* ruby_node_name ( int  node)

Definition at line 1767 of file iseq.c.

References rb_bug().

Referenced by ruby_debug_print_node().

Variable Documentation

◆ rb_cISeq

VALUE rb_cISeq

Definition at line 29 of file iseq.c.

Referenced by Init_ISeq(), and rb_iseq_load_iseq().